Note: The following content is over a decade old and should be considered deprecated. I have left it up for historical purposes. SCORM has not been updated in nearly 20 years, so the wrapper itself is still running like a champ. It can be found on GitHub.

Current version: 1.1.7 (May 19, 2008)

  • Download: The wrapper and all example files have been moved to the downloads page.

Having a problem with the wrapper or example files? Visit the eLearning Technology and Development Google Group

Changes

Here’s a list of the changes I made to the ADL wrapper:

  1. Used object notation to faux-‘namespace’ the SCORM wrapper. This means there is only ONE global variable, the pipwerks object. Every other variable and function contained in the wrapper has been moved into the SCORM child object: pipwerks.SCORM.
  2. Cleaned up the code, simplifying where possible, formally declaring all variables, and making the code more consistent (trying to implement modern JavaScript ‘best practices’). The code has been vetted by Douglas Crockford’s notoriously finicky JSLint (with the ‘Assume a browser’ and ‘Tolerate sloppy line breaking’ options enabled).
  3. Renamed variables and functions to more understandable/obvious terms.
  4. Added consistent checks for valid server and API connection before performing most actions.
  5. Added clearly written debugging statements to every function (including just about every if/else clause).
  6. Converted all ‘boolean strings’ returned from the LMS (“true”, “false”) to actual booleans. This aids in error-checking and helps simplify the code.
  7. Converted the GetLastError integer ‘string’ to an actual integer. This aids in error-checking and helps simplify the code.
  8. Added support for both popular flavors of SCORM (1.2 and 2004). This single wrapper file wrapper works with both versions, with no extra configuration required. UPDATE: Some users find it helpful to specify the SCORM version manually. Just add the line pipwerks.SCORM.version = "1.2" (or 2004) before making the pipwerks.SCORM.init() call.
  9. Replaced the ADL’s FindAPI and GetAPI functions with a modified version of Mike Rustici’s FindAPI/GetAPI functions. I modified Mike’s code to be a little more legible, with no global variables, more error checking, debugging messages, and support for both SCORM 1.2 and 2004 in a single file.
  10. Added functionality that automatically handles the initial course status (sets to incomplete upon launch) and handles the course exit status (sets to suspend if course hasn’t been completed yet).

Relationships/Mapping

This table outlines the basic relationships of the SCORM API with the SCORM wrapper object.

Wrapper functionSCORM 1.2 EquivalentSCORM 2004 Equivalent
pipwerks.SCORM.init()API.LMSInitialize(“”)API.Initialize(“”)
pipwerks.SCORM.quit()API.LMSFinish(“”)API.Terminate(“”)
pipwerks.SCORM.get()API.LMSGetValue(parameter)API.GetValue(parameter)
pipwerks.SCORM.set()API.LMSSetValue(parameter, value)API.SetValue(parameter, value)
pipwerks.SCORM.save()API.LMSCommit(“”)API.Commit(“”)
pipwerks.SCORM.debug.getCode()API.LMSGetLastError()API.GetLastError()
pipwerks.SCORM.debug.getInfo(errorCode)API.LMSGetErrorString(errorCode)API.GetErrorString(errorCode)
pipwerks.SCORM.debug.getDiagnosticInfo (errorCode)API.LMSGetDiagnostic(errorCode)API.GetDiagnostic(errorCode)

Methods and properties

Here is a list of all of the methods(functions) and public properties (variables) contained in the wrapper.

Last updated May 25, 2008.

Wrapper method or propertyNotes
pipwerks.SCORM.versionString. Stores SCORM version. Is set automatically by wrapper based on API returned from LMS, but can also be set manually.
pipwerks.SCORM.handleCompletionStatusBoolean, defaults to true. Controls whether or not the wrapper will automatically set the initial completion status
pipwerks.SCORM.handleExitModeBoolean, defaults to true. Controls whether or not the wrapper will automatically set the exit mode upon course exit.
pipwerks.debug.isActiveBoolean, defaults to true. Controls whether or not the wrapper will use debug statements.
pipwerks.SCORM.init()Arguments: None.

 

Returns: Boolean indicating success.

Creates the SCORM API connection, initiating your SCORM course session.

Must be invoked by your course code, and must be invoked before calling any other SCORM functions.

pipwerks.SCORM.quit()Arguments: None.

 

Returns: Boolean indicating success.

Closes the SCORM API connection, terminating your SCORM course session.

Must be invoked by your course code. No other SCORM functions should be called after this.

pipwerks.SCORM.get(param)Arguments: Name of CMI element.

 

Returns: String (value of CMI element).

Gets the specific parameter from the LMS (returns a string).

Example (SCORM 1.2):

var bookmark = pipwerks.SCORM.get("cmi.core.lesson_location");

Example (SCORM 2004):

var bookmark = pipwerks.SCORM.get("cmi.location");

Must be invoked by your course code.

pipwerks.SCORM.set(param, value)Arguments: Name of CMI element, value to set in CMI element.

 

Returns: Boolean indicating success.

Sets the specific parameter in the LMS (returns a boolean indicating success).

Example (SCORM 1.2):

var success = pipwerks.SCORM.set("cmi.core.lesson_location", "page2");

Example (SCORM 2004):

var success = pipwerks.SCORM.set("cmi.location", "page2");

Must be invoked by your course code.

pipwerks.SCORM.save()Arguments: None.

 

Returns: Boolean indicating success.

Instructs the LMS to “persist” the data you’ve sent it.

Some LMSs cache data and don’t immediately write it to the database. It’s a good idea to invoke pipwerks.SCORM.save() whenever you send important data to the LMS; this ensures the LMS has written the data to the database.

For instance, if you send a bookmark via lesson_location, then close your browser window, you can’t be sure if the LMS has written the bookmark data to the database.

If you send the bookmark, then call pipwerks.SCORM.save() before closing the window, you can be reasonably sure your data has been saved to the DB.

pipwerks.SCORM.status(action, status)Internal function that can either retrieve or set the course status stored in the LMS. Can also be used by course developers. Examples:

 

var status =
pipwerks.SCORM.status(“get”);

var success = pipwerks.SCORM.status(“set”, “completed”);

Is compatible with SCORM 1.2 & SCORM 2004.

pipwerks.SCORM.isAvailable()Returns boolean true.

 

Used by the pipwerks SCORM ActionScript classes (via ExternalInterface) to verify presence of the wrapper.

pipwerks.SCORM.API.find(window)Used internally to locate the SCORM API exposed by the LMS. You will never need to use this function yourself.
pipwerks.SCORM.API.get()Used internally to locate the SCORM API exposed by the LMS. You will never need to use this function yourself.
pipwerks.SCORM.API.getHandle()Used internally to locate the SCORM API exposed by the LMS. You will never need to use this function yourself.
pipwerks.SCORM.debug.getCode()Gets the last error code from the LMS, indicating success or failure of the the last action.

 

The wrapper uses this function internally to ensure successful communication between the LMS and course.

You may also invoke this function yourself if you’d like to add an extra layer of error-checking.

pipwerks.SCORM.debug.getInfo(errorCode)Gets a text-based description of a particular error code.

 

The wrapper uses this function internally to ensure successful communication between the LMS and course.

You may also invoke this function yourself if you’d like to add an extra layer of error-checking.

pipwerks.SCORM.debug.getDiagnosticInfo (errorCode)If an LMS vendor has supplied additional error messages, you would use getDiagnosticInfo the same way you’d use getInfo() to retrieve the message.

 

The wrapper uses this function internally to ensure successful communication between the LMS and course.

You may also invoke this function yourself if you’d like to add an extra layer of error-checking.

pipwerks.UTILS.trace(msg)Sends debugging messages to the Firebug console.

 

Used internally throughout the wrapper, but may also be used by your own code. Feel free to edit this portion of the wrapper to handle the messages differently, such as writing them to the HTML page or using the ‘alert’ function.

pipwerks.UTILS.StringToBoolean(string)Used internally to convert ‘boolean strings’ returned by the LMS to actual booleans, such as converting "false" to false.

Naming shortcuts

You may find it easier to work with a ‘shortcut’ name such as scorm or sco instead of the full pipwerks.SCORM. Here’s an example:

//Using pipwerks namespace, SCORM 1.2

var success = pipwerks.SCORM.init();

if(success){
  var status = pipwerks.SCORM.get("cmi.core.lesson_status");
  if(status != "completed"){
    success = pipwerks.SCORM.set("cmi.core.lesson_status", "completed");
    if(success){
       pipwerks.SCORM.quit();
    }
  }
}Code language: JavaScript (javascript)
//Using shortcut instead of pipwerks namespace, SCORM 1.2

var sco = pipwerks.SCORM;
var success = sco.init();

if(success){
  var status = sco.get("cmi.core.lesson_status");
  if(status != "completed"){
    success = sco.set("cmi.core.lesson_status", "completed");
    if(success){
       sco.quit();
    }
  }
}Code language: JavaScript (javascript)

Just remember that if you stick to the pipwerks namespace you can be reasonably sure you won’t have any naming conflicts. If you decide to use a naming shortcut, be sure to use something that won’t conflict with any of your other scripts.

LMS compatibility

The example files have been successfully tested on a variety of LMSs. If you’ve tested the files on an LMS not listed here, please let me know!

LMSSCORM 1.2 ExampleSCORM 2004 ExampleNotes
ADL Test SuitesWorks as intended (v1.1.5)Works as intended (v1.1.5)SCORM 1.2 Conformance Test Suite v1.2.7

 

SCORM 2004 3rd Ed. Conformance Test Suite v1.0.2

SumTotal TotalLMS 7.6Works as intended (v1.1.4)Works as intended (v1.1.4) 
Moodle 1.8Works as intended (v1.1.4)Works as intended (v1.1.4) 
Ilias 3.9.3Works as intended (v1.1.4)Works as intended (v1.1.4)Ilias loads SCORM 1.2 courses using the SCORM 2004 RTE and the ADL SCORM 1.2-2004 wrapper.
Pathlore 6.5Works as intended* (v1.1.4)Works as intended* (v1.1.4)As reported by email. Have not verified.