Events

This article describes the Events that Items API provides details how the to bind function callbacks to these events.

Supported Events

Items API provides methods which provide the ability to bind callback functions to particular events, usually triggered by user actions, or specific events occurring in the Assessment wrapper or Question element.

Assessment

Assessment events are events raised during the course of a user interacting with the assessment player. These are events concerning navigation, interaction with assessment level tools or options, start and end of test, etc.

To learn more about how to bind to these events, please see the on(), once() and off() methods on our Methods section.

Example

itemsApp.on("item:changed", function(itemIndex) {
    console.log("The current item index is: " + itemIndex);
});
        
Event name Description Event data
button:[name]:clicked

Triggered whenever a custom region button or custom dialog button is clicked.

The name in the event is the name/id given to the custom button, e.g. a button referenced as 'myCustomButton' will have an event called 'button:myCustomButton:clicked'.

focused
Triggered whenever the student has the browser tab and window with the test focused.
item:changed
Triggered before navigating to an item.
  • itemIndex - integer
    The zero-based index of the item that has been navigated to and is now visible.
item:changing
Triggered upon navigating to an item.
  • itemIndex - integer
    The zero-based index of the item that is being navigated to and is yet to be made visible.
item:goto

Triggered when navigating between items in the activity.

Please note that this event won't be triggered when the initial item has been made visible. Please use the item:changed or item:changing events to track navigation to the initial item.

Please use item:load to track when an intro item is made visible.

  • itemIndex - integer
    The zero-based index of the item that is being navigated to.
item:load
Triggered when an item (including an intro item) is active.
item:setAttemptedResponse
Triggered when a question in an item is attempted.
item:unload
Triggered when an item (including an intro item) is no longer active.
item:warningOnChange
If the warning_on_change option is enabled in the items region, this event triggers when a user attempts to leave an item that is unattempted or only partially attempted.
items:fetch

Triggered when the data for a new batch of items is being fetched when using the addItems method.

Useful when dynamic items are being fetched when using adaptive and dynamic assessments.

items:fetch:done

Triggered when the data for a new batch of items has been fetched when using the addItems method.

Useful when dynamic items are being fetched when using adaptive and dynamic assessments.

section:changed
Triggered when a new section has loaded and has been navigated to.
test:finished:discard
Triggered when a test has been exited and discarded, e.g. by an administrator.
test:finished:save
Triggered when a test is finished and has successfully been saved.
test:finished:submit
Triggered when a test is finished and has successfully been submitted.
test:pause
Triggered when a test has been paused by the student.
test:reading:end
Triggered when reading time has ended.
test:reading:start
Triggered when reading time has started.
test:ready
Triggered once a test is ready to be started.
test:resume
Triggered when a test has been resumed by the student.
test:save
Triggered when a test has a pending save.
test:save:error
Triggered when there is an error saving a test.
test:save:success
Triggered when saving a test is successful.
test:start
Triggered once a test has been started.
  • appInstance - object
    The instance of the Assess API.
test:submit
Triggered when test submission begins.
test:submit:error
Triggered when there is an error submitting a test.
test:submit:success
Triggered when a test is successfully submitted.
time:change
Triggered whenever the timer ticks.
  • timeElapsed - integer
    The time elapsed in seconds.
test:proctor:exitAndSubmit
Triggered when a test is exited and submitted by a proctor.
test:proctor:goto
Triggered when a proctor navigates the test to a different item.
test:proctor:paused
Triggered when a proctor pauses a test.
test:proctor:resumed
Triggered when a proctor resumes a test.
test:proctor:save
Triggered when a proctor saves a test.
test:proctor:terminated
Triggered when a proctor terminates a test.
unfocused
Triggered whenever the student has the browser tab and window with the test unfocused/blurred.

Questions

Question events are events raised during the course of a user interacting with a specific question, such as whether they have changed the question model (i.e. attempted the question) or clicked the "check answer" button.

To learn more about how to bind to these events, please see the on(), once() and off() methods for the Question Object on our Methods section.

Example

var questions = itemsApp.questions();

Object.values(questions).forEach(function(question) {
    question.on("changed", function() {
        console.log("student has attempted a question");
    });
});
        
Event name Description Event data
changed
Fired when model value has changed.
beforeValidate

Fired before the question is validated by clicking Check Answer button or via public method validate.

If this event is listened to, developer can prevent the validation from happening by calling event.preventDefault

  • event - object
    Calling event.preventDefault() to prevent the validation from happening.
validated
Fired when validation of question response has completed.
masked
Fired when masking for the corresponding question is enabled.
  • response_id - string
playback:assetLoaded

Important Audio question type only.

Fired when the playback asset within audio question type is loaded.
playback:complete

Important Audio question type only.

Fired when the playback within audio question type has ended.
playback:paused

Important Audio question type only.

Fired when the playback within audio question type has been paused.
playback:resumed

Important Audio question type only.

Fired when the playback asset within audio question type has been resumed.
playback:started

Important Audio question type only.

Fired when the playback asset within audio question type has started.
playback:stopped

Important Audio question type only.

Fired when the playback within audio question type has stopped.
recording:paused

Important Audio question type only.

Fired when the recording within audio question type has been paused.
recording:resumed

Important Audio question type only.

Fired when the recording within audio question type has been resumed.
recording:started

Important Audio question type only.

Fired when the recording within audio question type has started.
recording:stopped

Important Audio question type only.

Fired when the recording within audio question type has stopped.

Features

Feature events are events raised during the course of a user interacting with a specific feature, such as playing audio or video features.

To learn more about how to bind to these events, please see the on(), once() and off() methods for the Feature Object on our Methods section.

Example

var features = itemsApp.features();

Object.values(features).forEach(function(feature) {
    question.on("playback:started", function() {
        console.log("student has started playing an audio or video feature");
    });
});
        
Event name Description Event data
begin
Fired when the Feature begins.
complete
Fired when the Feature completes.
playback:started

Important Audio and video feature types only.

Fired when the playback within audio or video features has started.
playback:assetLoaded

Important Audio and video feature types only.

Fired when the playback asset within audio or video features is loaded.
playback:complete

Important Audio and video feature types only.

Fired when the playback within audio or video features has ended.
playback:paused

Important Audio and video feature types only.

Fired when the playback within audio or video features has been paused.
playback:resumed

Important Audio and video feature types only.

Fired when the playback asset within audio or video features has been resumed.
playback:stopped

Important Audio and video feature types only.

Fired when the playback within audio or video features has stopped.