Grading API Methods
once()
Set up a one-time event listener for a specified event that will execute the callback function once and then stop listening to the event.
You would want to use this method so that you can execute some custom logic the first time an event is fired, such as displaying a message the first time the learner unfocuses the grading session, for example.
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.');
}
// The callback function that will be executed when the event is fired.
gradingApp.once('attachitem:start', attachItemStartHandler);
Arguments
-
eventName string
Name of the event that you want to listen to.
-
eventCallback function
Callback function that will be triggered when the event is fired.
-
context object
Execution context that will be used for
this
when the callback function is triggered.
Return value
None (undefined
).
Related articles
- List of all Grading API Events
- The
on()
method, the method used to add custom event listeners to the grading events. - The
off()
method, the method used to remove custom event listeners from the grading events.