Quiz

When building a quiz you can add:

  • Quiz questions with answer explanations: SingleChoice, MultipleChoice, and TextEntry ("Type the answer")
  • Form fields
  • General blocks
  • Multiple result pages.

Single/multiple choice questions

To add a SingleChoice or MultipleChoice question to the build add an item to the blocks array. The item you add consists of:

PropertyRequiredTypeDescriptionDefault
titlestringtitle of the question
typestringset to SingleChoice or MultipleChoice
itemsobjectkey-value array, consisting of the question as the key and the value is a boolean value indicating if the answer is correct
itemsShuffledbooleanIf set to true, the order of the items/choices will be shuffledfalse
scoreintegerThe score the user gets for answering this question correctly1
explanationobjectAn explanation object for the correct answer; learn moreno default
wrongExplanationobjectAn explanation object for the incorrect answer; learn moreno default

Example:

{
    "title": "The best noodles?",
    "type": "SingleChoice",
    "items":  {
        "Spaghetti": true,
        "Fusilli": false
    }
}

In this example Spaghetti would be the correct choice.

Please note that only one answer option can be correct for SingleChoice questions. If you try to add more than one correct answer the API will return an error.

"Type the answer" questions

Properties

PropertyRequiredTypeDescriptionDefault
titlestringtitle of the block(no default)
typestringset to TextEntry(no default)
answersstring[]an array of possible answers(no default)
ignoreCasebooleanset to true to ignore the case of the answer (e.g. "hello" and "Hello" would be considered the same)false
ignoreSpacesbooleanset to true to ignore spaces in the answer (e.g. "hello" and "h e l l o" would be considered the same)false
livesintegerset to a number to give the user multiple attempts to answer the question1
unlimitedLivesbooleanset to true to give the user unlimited attempts to answer the questionfalse
scoreintegerThe score the user gets for answering this question correctly1
explanationobjectAn explanation object for the correct answer; learn moreno default
wrongExplanationobjectAn explanation object for the incorrect answer; learn moreno default

Example object

{
    "title": "Type 'hello' in either Italian, German, or French.",
    "type": "TextEntry",
    "answers": ["Ciao", "Hallo", "Bonjour"]
}

Optional properties

By default the user must type the exact answer to get the question correct and only has one life/attempt. To change this behavior you can set ignoreCase, ignoreSpaces, and lives:

{
    "title": "Type 'hello' in either Italian, German, or French.",
    "type": "TextEntry",
    "answers": ["Ciao", "Hallo", "Bonjour"],
    "ignoreCase": true,
    "ignoreSpaces": true,
    "lives": 3
}

Answer explanations

You can add an answer explanation to any quiz question. To do this add an explanation object to the respective quiz question, consisting of:

PropertyRequiredType
titlestring
descriptionstring

If you wish to have an incorrect answer explanation, you can add the wrongExplanation with the same properties as explanation to the block. If only explanation is provided, it will be shown as an explanation for both correct and incorrect answers.

Example:

{
    "title": "Type 'hello' in either Italian, German, or French.",
    "type": "TextEntry",
    "answers": ["Ciao", "Hallo", "Bonjour"],
    "explanation": {
        "title": "My correct explanation",
        "description": "My correct explanation description"
    },
    "wrongExplanation": {
        "title": "My wrong explanation",
        "description": "My wrong explanation description"
    }
}

Result pages

In a quiz you can specify multiple result pages to segment users based on their scores. For example users who score between 0-50% will see one result, users who score between 51-100% will see another result. Each result has a title, description, minPercentage, and maxPercentage property.

As there can be multiple results, we store the results in an array in build.results:

[
    {
        "title": "My result 0-30%",
        "description": "Description 1",
        "minPercentage": 0,
        "maxPercentage": 50
    },
    {
        "title": "My result 31-100%",
        "description": "Description 2",
        "minPercentage": 51,
        "maxPercentage": 100
    }
]

If you want to create complex result pages with texts, images, answered blocks, ... click here to learn how to build advanced result pages.

Full example

Example with all available blocks + options:

{
    "type": "Quiz",
    "build": {
        "title": "Germany quiz",
        "blocks": [{
                "title": "What's the capital of Germany?",
                "type": "SingleChoice",
                "items": {
                    "Berlin": true,
                    "Lissabon": false,
                    "Leipzig": false
                },
                "explanation": {
                    "title": "Correct!",
                    "description": "Berlin is the capital of Germany"
                },
                "wrongExplanation": {
                    "title": "Incorrect!",
                    "description": "Berlin is the capital of Germany"
                }
            },
            {
                "title": "What are valid colors in German?",
                "type": "MultipleChoice",
                "items": {
                    "rot": true,
                    "schwarz": true,
                    "nero": false
                },
                "explanation": {
                    "title": "Correct!",
                    "description": "Berlin is the capital of Germany"
                },
            }
            {
                "title": "Type 'hello' in either Italian, German, or French.",
                "type": "TextEntry",
                "answers": ["Ciao", "Hallo", "Bonjour"],
                "explanation": {
                    "title": "Correct!",
                    "description": "Ciao, Hallo, and Bonjour all mean 'hello'"
                },
                "wrongExplanation": {
                    "title": "Incorrect!",
                    "description": "Ciao, Hallo, and Bonjour all mean 'hello'"
                },
                "ignoreCase": true,
                "ignoreSpaces": true,
                "lives": 3
            }
        ],
        "results": [{
                "title": "Not so good...",
                "description": "There's room for improvement",
                "minPercentage": 0,
                "maxPercentage": 50
            },
            {
                "title": "Well done!",
                "description": "You're a winner",
                "minPercentage": 51,
                "maxPercentage": 100
            }
        ]
    }
}