setActivity - Methods - Author API

Author API Methods


Sets the Activity JSON of the Activity being edited.

You would want to use this method so that you can programatically set default values for various settings and content for the current Activity, for example.


var hasSetActivity = authorApp.setActivity({
    "items": [
            reference: "test1",
            organisation_id: 1
            reference: "test3",
            organisation_id: 1,
            item_pool_id: "pool_1"
    "rendering_type": "inline"


  • activityJson activityJson

    The new Activity JSON to set. See Type definitions for more information.

  • options object

    Options for customizing the behavior of the setActivity() method.

    • extend boolean

      When extend is true, the supplied Activity JSON extends the existing JSON. This means that existing attributes will be overridden and new attributes will be added.

      When extend is false, the supplied Activity JSON completely replaces the existing JSON.

      Default: true

Return value

Type boolean

Returns true if successful.

Returns false if unable to set the Activity JSON, for example, when not in the Activity editor view.

Type definitions

  • activityJson object

    Definition of the Activity JSON.

    • config object

      The Items API initialization options. See the Items API initialization options for more information.

    • items array[ItemObject]

      An array of ItemObject references to be used in the Activity.

    • rendering_type string

      The Items API rendering type for the assessment, which can be rendered inline or using the assessment player.

Related articles

  • The getActivity() method, which allows you to get the Activity JSON.
Was this article helpful?

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