on - Methods - Grading API

Grading API Methods

on()

Sets up an event listener for the Grading API. This method binds a callback function that will be invoked whenever the specified eventName is fired.

You would want to use this method so that you can take custom actions in your application when certain defined events occur in the grading session.

The full list of available event names are listed on the Grading API Events page.

Examples

function attachItemStartHandler() {
    console.log('The callback which executes when an event is fired.');
}

// Sets up a recurring event listener for the 'attachitem:string' event.
gradingApp.on('attachitem:start', attachItemStartHandler);

Arguments

  • eventName string

    Name of the event that you want to listen to.

  • eventCallback function

    Callback function that will be triggered whenever the event is fired.

Return value

None (undefined).

Related articles

  • List of all Grading API Events
  • The off() method, the method used to remove custom event listeners from the grading events.
  • The once() method, the method used to add custom event listeners to the grading events that will only execute once.
Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.