Public Method Author API

setItemJson()

Sets the Item JSON for the current Item being edited.

You would want to use this method so that you can programatically set specific standard attributes, content, Questions or Features for new Items, for example.

Examples

var hasUpdatedJson = authorApp.setItemJson({
    "item": {
        "reference": "example-item-1",
        "title": "My Item title",
        "definition": {
            "widgets": [{
                "reference": "example-widget-ref1"
            }]
        }
    },
    "questions": [{
        "reference": "example-widget-ref1",
        "widget_type": "response",
        "data": {
            "stimulus": "This is the stimulus.",
            "type": "shorttext"
        },
        "type": "shorttext"
    }]
});
console.log(hasUpdatedJson);

Arguments

  • itemJson itemJson

    The Item JSON.

Return value

boolean

Returns true if the provided itemJson is valid and the Item editor view has started updating and rendering the Item's Questions and Features.

Returns false if unable to set the Item JSON. For example, if the Item reference in the JSON is invalid or if not in the Item editor view.

Type definitions

itemJson object

  • features array[widgetObject]
    Array of Widget objects for Features in the Item.
  • item object
    The settings and contents of the Item.
  • questions array[widgetObject]
    Array of Widget objects for Questions in the Item.

Related articles

  • The getItem() method, which allows you to get the current Item JSON.
Was this article helpful?