Items API Methods
submit()
Saves the learner session responses into the Learnosity database, and flags them for grading.
You would want to use this method so that you can create your own submit button in your custom user interface, for example.
Calling submit
will make the session data available to Reports API and Data API.
The submitSettings
argument provides a way to define specific callbacks for events related to the submit operation. It is recommended to configure this argument to handle additional logic when the submit operation completes successfully and also allows you to gracefully handle any error states.
Examples
var submitSettings = {
show_submit_confirmation: true,
show_submit_ui: true
// Receives an array of response_ids (strings) of the saved session responses
success: function (response_ids) {
console.log("Submit was successful", response_ids);
},
// Allows you to immediately handle a submit error event
error: function (event) {
console.log("Submit has failed", event);
},
// Capture the progress of the current submit operation
progress: function (event) {
console.log("Current progress", event);
// The event object provides additional progress information, e.g.
/*
{
state: 'saving',
percentage: 50,
bytesTotal: 1234,
bytesUploaded: 567
}
*/
}
};
itemsApp.submit(submitSettings);
Arguments
-
submitSettings object
-
success function
Callback function triggered on a successful submission.
-
response_ids array[strings]
An array of response IDs (strings) of the successfully saved or submitted session responses.
-
-
error function
Callback function triggered when an error occurs while submitting.
-
event object
An object containing more information about the error.
-
-
progress function
Reports on the status of the submit operation while it is in progress.
-
event object
An object containing more information about the current progress of the save or submit operation. See code example for more information.
-
-
show_submit_confirmation boolean
Indicates whether a prompt should be shown to the learner for confirming whether they want to submit the Activity.
-
show_submit_ui boolean
Indicates whether the learner should be shown a dialog indicating the successful submission of the Activity.
If
true
, the dialog will be shown and they will no longer be able to work on the Activity.If
false
, the Activity will be submitted silently in the background and no dialog is shown. The learner can continue to interact with the Activity.
-
Return value
None (undefined
).
Caveats
Calling the submit
method while using the "local_practice"
session type is not supported. See Online Submission Versus Local Only for more information.
Related articles
- The
save()
method, the method used to save the current assessment. - The
safeToUnload()
method, the method used to check if the current session has been saved successfully.