Public Method Author API


Set the widget JSON of the widget being edited in an Item. This only works with Question Editor v3.

setWidget accepts an object specifying a template_reference key for the template as a second argument. If this is set, the widget is displayed within the template specified by the argument. Use that approach if you have custom template (with hidden sections, fields, etc.) set up as reference of QuestionType inside question_types.

Returns true (boolean) if successful, or false (boolean) if unable to set the widget JSON (e.g. when not on Tile view or Widget edit view)


function setWidget (widgetJson, widgetTemplate) {
    return authorApp.setWidget(widgetJson, widgetTemplate);
    "options": [{
        "label": "[Choice A]",
        "value": "0"
    }, {
        "label": "[Choice B]",
        "value": "1"
    }, {
        "label": "[Choice C]",
        "value": "2"
    }, {
        "label": "[Choice D]",
        "value": "3"
    "stimulus": "<p>[This is the stem.]</p>",
    "type": "mcq",
    "ui_style": {},
    "validation": {
        "scoring_type": "exactMatch",
        "valid_response": {
            "score": 1,
            "value": [""]
    "template_reference": "908de244-5c71-4c09-b094-7fb49554f2f9"


  • widgetJson widgetJson
  • widgetTemplate widgetTemplate
    Widget template containing the template reference (case-sensitive)

Return value


Type definitions

widgetJson object

Properties of the Widget JSON vary depending on the Question type or Feature type. See Question Types and Features Types in Questions API for more information.

widgetTemplate object

  • template_reference string
    Widget template reference

See Widget template references Knowledge base for more information.