scorm-local
SCORM API to test SCOs with localStorage. Not compliant yet.
Usage
scormLocal([scoId, options])
Returns an API object, containing all SCORM 1.2 methods:
LMSInitialize
, LMSFinish
, LMSGetValue
, LMSSetValue
, LMSCommit
,
LMSGetLastError
, LMSGetErrorString
and LMSGetDiagnostic
.
// this is the default scoIdvar scoId = 'default'; // and these are the default optionsvar options = // expire after 60 seconds from last commit. persistFor: 60 // persistFor: -1 - never expire. // persistFor: 0 - always expire. // an object with initial elements. model: null; // removes data from localStorage and mark it as flushedapi;
Examples
var api scormLocal = ; // creating an API for the SCO 'some-sco'api = ;api; // #=> trueapi; // #=> nullapi; // #=> trueapi; // #=> 100api; // #=> '' api = ;api;api; // #=> nullapi; // #=> trueapi; // #=> 50api; // #=> 'Changed initial model data.'api; // #=> true ; ; api = ;api;api; // #=> trueapi; // #=> 33 // flushing data removes it from localStorage and mark it as flushedapi;api; // #=> null // by marking it as flushed, it can be reset on next initialization// (in case it's committed after flushing, like on `window.onunload`)window { api; // #=> true api; // #=> 33 api; // #=> true api; // #=> true // data was committed, but it's marked as flushed. // on next initialization 'cmi.core.score.raw' will be null}; // import all LMS API methods to the `window` globalapi;;; // #=> 3.33
You can also use it with AMD:
;
Or just including it:
SCORM Local
License
MIT