Customizing Question Attributes and Templates

This page is an overview of how to hide or display attributes and sections in Question types via the init options.

There are three types of init options that determine whether an attribute or a section is shown or hidden in Question Editor:

  • base_question_type
  • question_types
  • question_type_templates
The options override each other, with base_question_type being the least specific, question_types being more specific and question_type_templates being most specific.

display_options_hierarchy.png
In order to know which attributes and attribute sections exist, you can load Question Editor API with global_template set to debug in the init options.
 
{
    "ui": {
        "layout": {
            "global_template": "debug"
        }
    },
    "base_question_type": {
        "hidden": [
            "stimulus",
            "penalty_score",
            "multiple_responses"
        ],
        "shown": [
            "stimulus"
        ],
        "hidden_sections": [
            "more_options.heading",
            "more_options.divider"
        ],
        "shown_sections": [
            "more_options.content"
        ],
        "image_preview_placeholder": "baseemptyimage.png"
    },
    "question_types": {
        "mcq": {
            "hidden": [
                "stimulus"
            ],
            "shown": [
                "penalty_score"
            ],
            "hidden_sections": [
                "layout",
                "more_options.heading",
                "more_options.divider"
            ],
            "shown_sections": [
                "more_options.divider"
            ]
        }
    },
    "question_type_templates": {
        "mcq": [
            {
                "name": "MCQ - Base Question",
                "reference": "e58f696f-4c70-4169-83b9-dfdeaa6e5cef"
            },
            {
                "name": "MCQ - New Template",,
                "reference": "f171f0dc-5703-41b4-beb1-430bb7bddf45",
                "hidden": [
                    "penalty_score"
                ],
                "shown": [
                    "stimulus"
                ],
                "hidden_sections": [
                    "more_options.divider"
                ]
            }
        ]
    }
}

base_question_type specifies settings which are applied to all Question types, unless they are overwritten/extended by question_types or question_type_templates. If you add the base_question_type option shown in the preview, the penalty_score and multiple_responses attributes would be hidden in all Question types. stimulus would not be hidden as it is specified in the shown array as well.
The hidden_sections specify that the more options heading and divider are hidden for all Questions, whereas the more options content is displayed as it is specified in shown_sections.

 

{
    "base_question_type": {
        "hidden": ["stimulus", "penalty_score", "multiple_responses"],
        "shown": ["stimulus"],
        "hidden_sections": ["more_options.heading", "more_options.divider"],
        "shown_sections": ["more_options.content"]
    }
}

question_types specify settings which are applied to certain Question types, unless they are overwritten/extended by question_type_templates. The settings in the preview would result in the following: multiple choice Questions would inherit penalty_score and multiple_responses as hidden attributes from base_question_type. This would be extended by stimulus. However, penalty_score would be removed as it is specified in the shown array. The end result would be that stimulus and multiple_responses are hidden for multiple choice Questions.
The hidden_sections array is merged with the array from the base Question type. When not specifying .heading,.content or .divider all these subsections of layout will be hidden. Sincemore_options.divider is specified in shown_sections, the dividing line will be visible.

 

{
    "base_question_type": {
        "hidden": ["stimulus", "penalty_score", "multiple_responses"],
        "shown": ["stimulus"]
    },
    "question_types": {
        "mcq": {
            "hidden": ["stimulus"],
            "shown": ["penalty_score"],
            "hidden_sections": ["layout"],
            "shown_sections": ["more_options.divider"]
        }
    }
}

question_type_templates specify variations on base Question types. The settings in the preview would result in the following: MCQ - Base Question would inherit the settings specified in the mcq section of question_types. MCQ - New Template would inherit stimulus and multiple_responses as hidden attributes from question_types. These are extended by penalty_scorestimulus is removed as it is specified in the shown array, resulting in multiple_response andpenalty_score being hidden.
Since more_options.divider is specified in hidden_sections the dividing line will not be shown for MCQ - New Template.

 

{
    "base_question_type": {
        "hidden": ["stimulus", "penalty_score", "multiple_responses"],
        "shown": ["stimulus"]
    },
    "question_types": {
        "mcq": {
            "hidden": ["stimulus"],
            "shown": ["penalty_score"],
            "hidden_sections": ["layout"],
            "shown_section": ["more_options.divider"]
        }
    },
    "question_type_templates": {
        "mcq": [
            {
                "name": "MCQ - Base Question",
                "reference": "e58f696f-4c70-4169-83b9-dfdeaa6e5cef"
            },
            {
                "name": "MCQ - New Template",
                "reference": "f171f0dc-5703-41b4-beb1-430bb7bddf45",
                "hidden": ["penalty_score"],
                "shown": ["stimulus"],
                "hidden_sections": ["more_options.divider"]
            }
        ]
    }
}
Was this article helpful?

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