Items API Events
items:fetch:done
Fires when a batch of Items has been successfully fetched using the addItems public method.
You would want to be notified about this event firing so that you can know when dynamic Items have been successfully fetched using adaptive and dynamic assessments so that you can keep track of the navigation state in your own application, for example.
Additionally, this event is particularly useful in Item adaptive assessments that use termination_criteria. You can use the testEnd property in the callback arguments to determine whether the end of the assessment has been reached.
Examples
itemsApp.on('items:fetch:done', function (args) {
console.log('This code executes when a batch of Items has been successfully fetched.');
// Check if end of itemadaptive assessment (with termination criteria) reached
if (args.testEnd) {
console.log('End of the assessment reached.');
// Custom assessment submission logic
var submitSettings = {
show_submit_confirmation: false,
show_submit_ui: false,
success: function (response_ids) {
console.log('Submit was successful', response_ids);
},
error: function (event) {
console.log('Submit has failed', event);
}
};
console.log('Submitting the assessment...');
itemsApp.submit(submitSettings);
}
});
Callback arguments
-
args object
An object containing metadata about the assessment and its current state.
The following properties are supported.
-
testEnd boolean
Controls whether the end of the assessment has been reached.
You would want to use this so that you can execute custom logic after the assessment has ended, such as triggering a custom assessment submission.
When set to
true, this property indicates that the end of the assessment has been reached. When set tofalse, it indicates that the assessment has not yet ended.Default:
false
-
Related articles
- The
items:fetchevent, the event that occurs when a batch of Items is being fetched. - The
items:fetch:errorevent, the event that occurs when a fetch action for a batch of Items has failed. - The Building Item Branching Assessments article for more information on dynamic assessments.