This is a lower-level API. Lower-level APIs are not recommended for most projects, and may not be available on all plans. See our page on recommended deployment patterns for more information.
Initialization Option Question Editor API

question_types

Use this config option to modify the behaviour and appearance of Learnosity's question types. For example, if you wanted to change the name of the MCQ question type in the tile view, you can use this config option. Settings in question_types override or extend settings in base_question_type.

Values

Request object key question_types

Type object

This object has the following properties which can be configured.

Type definitions

QuestionType object

  • defaults object

    Change the default values that will be populated when you load the Question Types. (e.g. you could set the default Stimulus for MCQ using this config option). In order to set a default value for new array elements, keys with empty brackets "[]" can be used. Extends anything that is defined in base_question_type.defaults.

    • [key] *
  • dependency array

    Turns provided array items to become dependent items.

    To use, specify the "parent" as the first (odd) array value, then the "dependent" (child) as the next (even) array value. To set up multi-dependency, specify the parent again, with the second dependent after.

    For example: if we create an array like ["options", "metadata.distractor_rationale_response_level"] then "metadata.distractor_rationale_response_level" is now a dependant node of "options". So, if an "options" item is added or removed, a corresponding "metadata.distractor_rationale_response_level" item will be added or removed as well.

    Note The dependent array item should either have no default values set, or have the same number of array entries as the parent (use the defaults object to do this).

  • description string

    Overwrites the default description for the Question Type.

  • exclude_options object

    Combination of object key and array value to remove unwanted option(s) from dropdown input.

    The key is the attribute path of the property. See here on how to find attribute paths. If the path has an index in it (e.g. [0]) then just remove that to affect all indexes.

    The value must be the value stored in the JSON when selected, not the dropdown text. E.g. you could remove "xlarge", and "xxlarge" fontsizes from mcq question type - see example below) or Math question type's custom action group.

    Note: This overrides base_question_type.exclude_options.

    "question_types": {
        "mcq": {
            "exclude_options": {
                "ui_style.fontsize": ["xlarge", "xxlarge"]
            }
        }
    }
    • [optionKey] string
  • include_options object

    Combination of object key and array values to add option(s) to dropdown input.

    The key is the attribute path of the property. See here on how to find attribute paths. If the path has an index in it (e.g. [0]) then just remove that to affect all indexes.

    Note: in most cases the dropdowns show all of the specific values which the question renderer supports already, and so adding a new option wouldn't work. E.g. fontsize only supports "small", "normal", "large", "xlarge", and "xxlarge", so adding another entry for say "xxxlarge" wouldn't work as the renderer doesn't know that option.

    Note: exclude_options takes precedence, so an option will not be shown if it's included in exclude_options too.

    The main use-case for this is to add a custom keypad for symbols for Math question type (see example below), but it could also be used to add additional properties to custom fields (See example below for both).

    Example: Below example adds a new custom keypad for "symbols" option for clozeformulaV2 question type only, and which adds a new custom_metadata field with 2 options, then adds 1 extra different option for both mcq and clozetext.

    "question_types": {
        "mcq": {
            "include_options": {
                "metadata.my_custom_field": [{
                    "label": "MCQ Three",
                    "value": "3a"
                }]
            }
        },
        "clozetext": {
            "include_options": {
                "metadata.my_custom_field": [{
                    "label": "Cloze Three",
                    "value": "3b"
                }]
            }
        },
        "clozeformulaV2": {
            "include_options": {
                "symbols": [{
                    "label": "Custom keypad",
                    "value": {
                        "label": "Custom keypad",
                        "title": "Init option keys",
                        "value": ["M", "\\Lambda", "T", "H", "\\kappa", "\\in", "\\gamma", "\\$", "", "", "", "", "", "", "", "", "", "", "", ""]
                    }
                }]
            }
        }
    },
    "custom_metadata": {
        "my_custom_field": {
            "description": "My custom field",
            "name": "my_custom_field",
            "type": "select",
            "options": [
                {
                    "label": "One",
                    "value": "1"
                },
                {
                    "label": "Two",
                    "value": "2"
                }
            ]
        }
    }
    • [optionKey] string
  • group_reference string

    Changes the tile view group in which this question type will appear. E.g. if you created a new question type group (see the question_type_groups config option) called "Spoken", you could move the Audio question type to that group.

  • hidden array

    Define which attributes should be hidden in all question types.

    For array type fields like options, you can either define a selector for a specific entry, e.g. options[0], or you can specify a selector targeting the whole array, e.g. options[*]. Also use this for children of array type fields, e.g. validation.valid_response.value[*].aria_label

    Extends base_question_type.hidden.

  • hidden_search_terms array

    Additional terms which can be used to search for the template in the tile view.

    E.g. to get the hotspot question type to filter when searching for "map" or "world", set this to ["map","world"].

  • hidden_sections array

    This property will extend the setting from base_question_type in the specified widget type.

  • image string

    URI - Changes the image that will appear in the tile view for this question type. If no image is defined a default image for the according question_type will be displayed.

  • image_preview_placeholder string

    Define the URL of an image which is displayed as a placeholder in questions which show an image preview. The specified image is shown, if the image source of the question is empty or points to an incorrect url. Overrides base_question_type.image_preview_placeholder.

  • name string

    Changes the display name of the question type in the tile view

  • reference string

    A unique reference that identifies the Question Type Template. This attribute is only applicable to question_type_templates.

  • shown array

    Define which previously hidden attributes should be shown. This is useful, if you define hidden attributes in base_question_type.hidden, but want to show them for a certain question type only.

  • shown_sections array

    This property will extend the setting from base_question_type in the specified widget type.

Related articles

Was this article helpful?