Binary challenge {…}0 … or {…}1 …

A binary challenge is a special kind of option that consists of a pre-formulated phrase and a checkbox to select that option. It gives readers a binary choice, since the checkbox can be either checked or not checked.

Unlike regular options, binary challenges always have an expected choice. Whether a particular binary challenge should be checked or not checked is configured by the author. That configuration is not shown to readers. It is hence a challenge for readers to figure the expected answer out.

Binary challenges can be used for automatically assessed multiple response tests for example. They can also be added to questionnaires with otherwise regular options to sieve out submissions where respondents – whether humans or bots – just chose random answers without reading and understanding the questions first.

How submissions that fail to meet the binary challenges are dealt with depends entirely on the Aneamal module that is chosen to handle the submission. Modules can discard wrong submissions; they can give readers feedback about which questions they failed; they can accept wrong submissions and just mark the errors for further analysis.

How to

Mark each binary challenge with curly brackets {…} at the beginning of a new line. Add the digit zero 0 immediately after the right curly bracket for a binary challenge that should not be checked. Add the digit one 1 directly after the right curly bracket for a binary challenge that should be checked.

The zero or one is followed by a space character and the option’s text then.

Each binary challenge can have a key between its curly brackets { and } as in the examples below. The key identifies a selected binary challenge when the form is submitted. Avoid words like true and false which give the solution to the challenge away. While the keys are not displayed on the webpage, they can still be found in the HTML code of the webpage.

You can write a question or task directly in the line above the binary challenges like in the first example below.

Examples

The first example asks users to find all the options with animals in them. There is a 50% chance to answer a single binary challenge correctly by guessing, but the combination of four binary challenges reduces the chance to pass this test by selecting options randomly to 6.25%.

Please check *all* answers which have an *animal* in them:
{bedroom}1 🐭 ⏰
{kitchen}0 🍊 🥒
{forest}1 🌳 🕊️
{playground}1 ⚽ 🐶
Please check all answers which have an animal in them:


Imagine the challenges from the next example as part of a poll for a coming election. To get most accurate results, you may not want to count participants who are too young to be eligible to vote in the actual election. You also do not want people to skew the results of the poll by participating repeatedly. The following challenges would sieve such invalid votes out, if answered correctly.

{adult}1 I am 16 years old or older.
{again}0 I have submitted this questionnaire before.

Mind that such challenges do not prevent people from lying. It may be worth to try to identify repeated participations in a poll with other technical means. It may also be advisable to enforce age checks differently, for example to restrict access to content that would be harmful for children.

For developers

When Aneamal is translated to HTML, binary challenges are handled identical to regular options: each binary challenge is turned into an HTML input element whose type is checkbox and whose value attribute contains the challenge’s key. The input is followed by a label element that contains the challenge’s text. Multiple challenges are separated by br elements.

A block with binary challenges is wrapped in an HTML fieldset element. The optional question or task at the start of the block is translated to a HTML legend element inside the fieldset. So the examples become:

<fieldset>
<legend>Please check <b>all</b> answers which have an <b>animal</b> in them:</legend>
<input id='_1' name='_1' form='_f1' type='checkbox' value='bedroom'> <label for='_1'>🐭 ⏰</label><br>
<input id='_2' name='_2' form='_f1' type='checkbox' value='kitchen'> <label for='_2'>🍊 🥒</label><br>
<input id='_3' name='_3' form='_f1' type='checkbox' value='forest'> <label for='_3'>🌳 🕊️</label><br>
<input id='_4' name='_4' form='_f1' type='checkbox' value='playground'> <label for='_4'>⚽ 🐶</label>
</fieldset>
<fieldset>
<input id='_5' name='_1' form='_f2' type='checkbox' value='adult'> <label for='_5'>I am 16 years old or older.</label><br>
<input id='_6' name='_2' form='_f2' type='checkbox' value='again'> <label for='_6'>I have submitted this questionnaire before.</label>
</fieldset>

The HTML attributes id, name, form and for automatically take different values depending on where the challenges occur in the webpage.

In the form API

The Aneamal Translator supplies modules that use the form API with posted data when a form is submitted. There is a PHP array in the $_['post'] array for every block with form fields such as binary challenges.

The array for a block with binary challenges will always have the indices block and match. The value for block is an array that contains information on the selected binary challenges. It can be empty. The value for match is boolean and true, if all the binary challenges have been checked as expected. Otherwise it is false. The index topic is only available, if the corresponding block in the Aneamal file starts with a question or task.

Imagine a user selects the options which are labeled 🐭 ⏰ and ⚽ 🐶 in the first example and submits the form. That would not pass the challenge, since he failed to select the expected option 🌳 🕊️ as well. The data provided to modules would be this:

$_['post'] => [
    [
        'topic' => 'Please check *all* answers which have an *animal* in them:',
        'block' => [
            [
                'input' => 'bedroom',
                'label' => '🐭 ⏰',
            ],
            [
                'input' => 'playground',
                'label' => '⚽ 🐶',
            ],
        ],
        'match' => false,
    ],
];

If the challenge from the second example was answered as expected, the data provided to modules processing the form submission would be this:

$_['post'] => [
    [
        'block' => [
            [
                'input' => 'adult',
                'label' => 'I am 16 years old or older.',
            ],
        ],
        'match' => true,
    ],
];