Warning Warning! This is a lower-level API. Lower-level APIs are not recommended for most projects, and may not be available on all plans. See our page on recommended deployment patterns for more information.

Events

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

Supported Events

Questions API provides methods which provide the ability to bind callback functions to particular events, usually triggered by user actions, or specific events occurring in questions or features.

Question events

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 = questionsApp.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.

Feature Events

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 = questionsApp.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.