Author API Methods
setActivity()
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.-
extend boolean
When
extend
istrue
, the supplied Activity JSON extends the existing JSON. This means that existing attributes will be overridden and new attributes will be added.When
extend
isfalse
, the supplied Activity JSON completely replaces the existing JSON.Default: true
Version 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.
-
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.