Search code examples
scormscorm1.2

Registering and retrieving 'interactions' with SCORM 1.2


We've been using SCORM in our previous e-learning 'engine' but we want to change the elements our Managed Learning Environment (MLE) tracks, namely each completable component in an e-learning module.

At runtime, we run the following code to set up our SCORM connection:

var vault = {};                             //vault 'namespace' helps ensure no conflicts with possible other "SCORM" variables
vault.UTILS = {};                           //For holding UTILS functions
vault.debug = { isActive: true };                   //Enable (true) or disable (false) for debug mode

vault.SCORM = {                             //Define the SCORM object
    version:    null,                               //Store SCORM version.
    handleCompletionStatus: true,               //Whether or not the wrapper should automatically handle the initial completion status
    handleExitMode: true,                       //Whether or not the wrapper should automatically handle the exit mode
    API:{handle: null, isFound: false},             //Create API child object
    connection: { isActive: false },                //Create connection child object
    data: { completionStatus: null, exitStatus: null},  //Create data child object
    debug:{}                                        //Create debug child object
};

vault.SCORM.API.find('win'); 
            vault.SCORM.connection.initialize();
            if (vault.SCORM.data.get("cmi.core.lesson_status")=="not attempted") {

                vault.SCORM.data.set("cmi.core.lesson_status" , "incomplete");

                vault.SCORM.data.save();

            }

There are many more functions in the SCORM.js file, but the point is this all works; When the module is loaded into our MLE, the following code triggers course completion:

vault.SCORM.data.set("cmi.core.lesson_status" , "completed");

So how would we register a completable component with SCORM? (Components in our 'engine' are jQuery objects usually called 'element'). Would something like the following work, or are custom calls in SCORM not possible?

vault.SCORM.data.set("cmi.interactions.n."+element.componentId() , "incomplete");

But then if I registered an interaction by specifying an id, as follows...

 vault.SCORM.data.set("cmi.interactions.n.id", element.componentId());

...how do I then set or access 'completion' on that component?

I've been reading posts and pdf specs from various sites, but the explanations are sparse at best.

I know there aren't a lot of SCORM followers here, but if you have any info, I'd be keen to hear it.


Solution

  • FWIW, that's my pipwerks SCORM wrapper, but with the variable pipwerks changed to ncalt.

    There is documentation on how to use my wrapper at http://pipwerks.com (search for "scorm wrapper" in the search field). The original source code can be found at https://github.com/pipwerks/scorm-api-wrapper.

    Note your sample code is not using the wrapper the way it was intended to be used. For example, this:

    ncalt.SCORM.data.set("cmi.core.lesson_status" , "completed");
    

    should be this (data is an internal helper and not necessary):

    ncalt.SCORM.set("cmi.core.lesson_status" , "completed");
    

    You can shorten it even further via a reference variable, like so:

    var scorm = ncalt.SCORM;
    scorm.set("cmi.core.lesson_status" , "completed");
    scorm.save();
    scorm.get("cmi.core.lesson_status"); //returns "completed"
    

    As for your 'components', if you'd like to use SCORM's cmi.interactions model, be sure you're using the correct syntax. The "n" in the SCORM documentation (cmi.interactions.n.id) is meant to represent a number, it's not a literal "n".

    scorm.set("cmi.interactions.0.id", "myfirstinteraction");
    scorm.save();
    

    To retrieve data from that interaction, you need to specify the number in place of the n:

    scorm.get("cmi.interactions.0.id"); //returns "myfirstinteraction"
    

    Note the CMI data model doesn't provide a 'status' field for cmi.interactions. You'd need to use cmi.objectives.

    scorm.set("cmi.objectives.0.status", "completed");
    scorm.save();
    scorm.get("cmi.objectives.0.status"); // returns "completed"
    

    The CMI data model (as available in SCORM) is spelled out here: http://scorm.com/scorm-explained/technical-scorm/run-time/run-time-reference/