Commit SCORM data, lazily, to avoid data loss

Commit SCORM data, lazily, to avoid data loss

by Ray Morris -
Number of replies: 2

I'd like to get your opinions about something.  We have some code we're using locally which may be of use to others.

It seems to us it is good for data sent from a SCORM package, via SetValue(), to eventually be stored in the database so that student progress data isn't lost.  Preserving data is good, we think, even if the network connection is lost, the browser crashes, etc. a few minutes later.

Some SCORM packages don't explicitly call Commit() regularly for whatever reason.  Moodle currently doesn't commit data itself unless the SCORM package explicitly calls Commit(), so data can be lost.  We wrote some code for local use which will Commit() the data 60 seconds afer the values are set, unless the package Commit()s sooner.  

As written, it's a lot like how most OSes write data to disk, to be efficient. It calls commit only if the client (SCO) hasn't already done so explicitly, and calls it only once per 60 seconds even if many values are pending, and doesn't call it at all if no values are pending.

 

Would this be ueful to other people?  If so, I can re-arrange our new code in the form of a patch to scorm/datamodels/scorm_13.js.php.  The patch would basically consist of adding to SetValue():

 setAutoCommit.timeout = window.setTimeout(API_1484_11.Commit,30000, "");

 

But canceling that if Commit() is called explicitly:
window.clearTimeout(setAutoCommit.timeout);

Let me know what you think about adding this to the master Moodle. Currently our does some magic subclassing to alter the functionallity of the stock code without modifying the files, so I'll reformat it as a patch only if it sound slike the patch would be committed.

 

 

Average of ratings: -
In reply to Ray Morris

Re: Commit SCORM data, lazily, to avoid data loss

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

sounds like a nice idea. I think if we were to accept it for inclusion in core we'd probably need an admin setting included that has it off by default to start with - also as it would be classed as an improvement it would only be approved to go into the master branch - feel free to create a bug and attach your patch and I'll take a look.