A simple SCORM interface written in ES6, heavily based on Pipwerks implementation.
npm install scormint --save
import SCORM from 'scormint';
const scorm = new SCORM();
// Initializing the connection with the API
scorm.initialize();
// Setting a field (suspend_data, in this case) in the API
scorm.set('cmi.suspend_data', 'Hello World!');
// Setting the lesson_status as complete
scorm.status('complete');
// Commiting the changes
scorm.save();
- constructor - Creates a SCORM object
- initialize - Connects and initialize the API
- terminate - Terminate the connection with the API
- status(status) - Gets or sets the lesson status
- get(key) - Gets a field from the API
- set(key, value) - Sets a field from the API
- save() - Persists/Commits the changes in the API
- lastErrorCode() - Gets the last error reported by the API
- errorString(code) - Gets the text representation of the error code
- version - The selected version of the SCORM API
- connected - The status of the connection
- updateStatusAfterInitialize - Update lesson/completion status after initialization
- updateStatusBeforeTerminate - Update exit status before terminate
- SCORM.VERSION_1_2 - Constant defining API version 1.2
- SCORM.VERSION_2004 - Constant defining API version 2004
const scorm = new SCORM('1.2');
Type: undefined
or String
The desired SCORM API version. Leave blank for autodetect (priorize SCORM 1.2).
Connects and initialize the API
Terminate the connection with the API
Gets or sets the lesson status
If status
is ommited, returns the lesson status. Sets the status otherwise.
Type: undefined
or String
The status of the lesson
Gets a field from the API
Type: String
The cmi key of the field
Sets a field in the API
Type: String
The cmi key of the field
Type: any
The value to persist. Any object passed here will be cast to string.
Persists/Commits the changes in the API
Gets the last error reported by the API
Gets the text representation of the error code
Type: String
The code returned by lastErrorCode()
The selected version of the SCORM API
The status of the connection
true
if connected to the SCORM API, false
otherwise
Determines if the lesson/completion status should be changed from 'not attempted' to 'incomplete' after initialization
Defaults to true
Determines if the exit status should be set as 'suspend' or 'logout' (depending on lesson/completion status) before terminate
Defaults to true
1.2
2004