Public Method Author API

setActivity()

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.

Examples

var hasSetActivity = authorApp.setActivity({
    "items": [
        {
            reference: "test1",
            organisation_id: 1
        },
        {
            reference: "test3",
            organisation_id: 1,
            item_pool_id: "pool_1"
        }
    ],
    "rendering_type": "inline"
});
console.log(hasSetActivity);

Arguments

  • 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

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.

Related articles

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