A number of people have recently asked me about the scorm.save()
function in the pipwerks SCORM wrappers. What is it, and when should it be used?
The pipwerks scorm.save()
function is a shortcut for SCORM’s Commit
(SCORM 2004) and LMSCommit
(SCORM 1.2) methods. Invoking commit
in SCORM means you are explicitly instructing the LMS to persist the data you’ve sent. In other words, you’re telling the LMS to save your stuff!
When sending data from your course to the LMS, the data is traveling from the course window to the LMS via JavaScript and is stored in the browser. The SCORM spec gives LMSs the flexibility to decide when to transfer this data to the database. Some LMSs will not immediately write the data to the database because it can clog up the system; they prefer to queue up the data and send it in bunches. This explains why some courses will be successful in sending the data from the course to the LMS, but the LMS doesn’t seem to save the data. You didn’t tell it to! I know, I know, it seems daft, but it happens. So, to be safe, ensure your data gets saved by instructing the LMS to save the data.
Note that some LMSs will automatically commit at the end of a session, usually by detecting if the course window was closed (window.onunload
) or if a certain CMI call was invoked, such as setting the completion status. However, you should never take your chances, and should design your SCO to commit regularly. Just be careful not to overdo it.
The rule of thumb is to invoke a commit
(save()
) if you use the pipwerks wrapper) after a significant chunk of data has been sent to the LMS, but not after each and every call:
NO (committing too frequently):
scorm.set("cmi.location", "some string indicating location");
scorm.save();
scorm.set("cmi.suspend_data", "your custom suspend_data string");
scorm.save();
scorm.set("cmi.score.raw", 80);
scorm.save();
Code language: CSS (css)
NO (not committing enough):
scorm.set("cmi.location", "some string indicating location");
scorm.set("cmi.suspend_data", "your custom suspend_data string");
scorm.set("cmi.score.raw", 80);
Code language: CSS (css)
YES (one commit after a short series of ‘set’ calls):
scorm.set("cmi.location", "some string indicating location");
scorm.set("cmi.suspend_data", "your custom suspend_data string");
scorm.set("cmi.score.raw", 80);
scorm.save();
Code language: CSS (css)