LmsGetLastError()

254 views
Skip to first unread message

craiga

unread,
Apr 14, 2009, 3:07:48 PM4/14/09
to eLearning Technology and Development
I am using the SCORM API wrapper for an eLearning project and I cannot
figure out how to get it to work with Saba's Centra One LMS. I have
successfully gotten it to work with Moodle and Test Track but not on
their system. So finally the Saba engineers took a look at it and
emailed me this:

--------------------------------------------------------------------------------------------------------------------------------------
Engineering has checked this SCORM content and has following
suggestions.

The reason this content is failing is because it has debugging code
that is calling LmsGetLastError(), expecting a String containing a
number, but the CKC SCORM API is returning an empty String “”.

A workaround is to modify the content’s SCORM_API_wrapper.js to deal
with the CKC returning an empty string. Specifically, function
debug.getCode() can be changed to guard against “” with the isNan()
function. We tried this and it works.

Can you ask your team to test this suggestion and let us know if your
content can be modified to work with the value that CKC API returns?
--------------------------------------------------------------------------------------------------------------------------------------

Does anyone have a suggestion what I should add to make to either the
Wrapper or my Flash file to get this to work?

Philip Hutchison

unread,
Apr 14, 2009, 5:50:30 PM4/14/09
to elearning-technolo...@googlegroups.com
ahh, great feedback. I've never tested in Saba, but I'll make the edit to the wrapper sometime tonight or tomorrow and post the revised version shortly thereafter.

thanks!
- philip

Philip Hutchison

unread,
Apr 14, 2009, 10:40:04 PM4/14/09
to elearning-technolo...@googlegroups.com
Here's a revised version of the debug.getCode snippet of the wrapper.  Please copy/paste into your copy of the wrapper (replacing the original getCode function) and let me know if it works for you.

/* -------------------------------------------------------------------------
   pipwerks.SCORM.debug.getCode
   Requests the error code for the current error state from the LMS

   Parameters: None
   Returns:    Integer (the last error code).
---------------------------------------------------------------------------- */

pipwerks.SCORM.debug.getCode = function(){
    
    var API = pipwerks.SCORM.API.getHandle(),
        scorm = pipwerks.SCORM,
        trace = pipwerks.UTILS.trace,
        code = 0;

    if(API){

        switch(scorm.version){
            case "1.2" : code = API.LMSGetLastError(); break;
            case "2004": code = API.GetLastError(); break;
        }
       
        //Fix for Saba returning empty string.
        //If empty string, assume everything's OK and change code to 0
        code = (code === "") ? 0 : parseInt(code, 10);
            
    } else {
    
        trace("SCORM.debug.getCode failed: API is null.");

    }
    
    return code;
   
};


FYI the SCORM documentation doesn't say anything about passing empty strings for error codes... I guess it technically isn't wrong, but the docs say the error code should be "strings that can be converted to integer numbers" (SCORM 1.2) or "a characterstring (convertible to an integer in the range from 0 to 65536 inclusive) representing the error code of the last error encountered" (SCORM 2004).

An empty string can't be converted to an integer.

 - philip
Reply all
Reply to author
Forward
0 new messages