Author API Methods
setActivity()
This feature has been deprecated.
From v2026.2.LTS, this method is deprecated and has been superseded by setActivityJson(), which can be used to set the Activity JSON for the Activity being edited. Please refer to and use setActivityJson().
Sets the Activity JSON of the Activity being edited.
You would want to use this method so that you can programmatically 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.The following properties are supported.
-
extend boolean
When
extendistrue, the supplied Activity JSON extends the existing JSON. This means that existing attributes will be overridden and new attributes will be added.When
extendisfalse, the supplied Activity JSON completely replaces the existing JSON.Default:
trueVersion added: v2021.3.LTS
-
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.
The following properties are supported.
-
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. See ItemObject in the
itemsInitialization article for property definitions. -
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. - The
setActivityJson()method is the recommended replacement for this deprecated method.