question_types - Initialization - Question Editor API

Question Editor API Initialization

question_types

Modify the default behavior and appearance of Learnosity's Question types.

For example, you can change the name of the multiple choice Question type in the tile view.

Settings in this option will override or extend settings in base_question_type initialization option.

Values

Attribute path question_types

Type object

Properties

  • anyQuestionTypeName object

    Controls the default values that populate when you load a specific Question type.

    Each entry in this object uses the Question type reference as its key. The corresponding value is a definition object that specifies the following configuration options.

    See the Question type reference for more information.

    The "anyQuestionTypeName" is a placeholder for a real Question type reference. You must replace "anyQuestionTypeName" with the actual type, for example, "mcq" for multiple choice.

    // example with mcq Question type.
    "question_types": {
        "mcq": {
            "exclude_options": {
                "ui_style.fontsize": ["xlarge", "xxlarge"]
            }
        }
    }
    

    The following properties are supported.

    • defaults object

      Change the default values that will be populated when you load the Question Types. For example, 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.

      The following properties are supported.

      • anyKeyToOverride *

    • dependency array[string]

      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" font sizes 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"]
              }
          }
      }
      

      The following properties are supported.

      • anyKeyToExclude 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 The exclude_options value 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).

      For example, the below 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"
                  }
              ]
          }
      }
      

      The following properties are supported.

      • anyKeyToInclude string

    • group_reference string

      Changes the tile view group in which this Question type will appear. For example, 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[string]

      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[string]

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

      For example, to get the hotspot Question type to filter when searching for "map" or "world", set this to ["map","world"].

    • hidden_sections array[string]

      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[string]

      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[string]

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

Related articles

Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.