pipwerks / scorm-api-wrapper

The pipwerks SCORM API Wrapper
http://pipwerks.com
362 stars 125 forks source link

JS wrapper data.get() fails if field value is "" and last error = 0 #1

Closed T0T4R4 closed 12 years ago

T0T4R4 commented 12 years ago

Javascript wrapper fails if API.GetValue returns an empty string value and API.GetLastError returns 0 , which is odd.

changing line 456 from if(value !== "" && errorCode === 0){ to if(value !== "" || errorCode === 0){

fixed the issue.

T0T4R4 commented 12 years ago

I checked your AS2 and AS3 wrappers, in which you implemented a different logic, and suggest you to fix the JS version as per the AS versions, which means replacing the whole IF block in line 456 by

        if(value == "" && errorCode != 0){

            trace(traceMsgPrefix +"failed. \nError code: " +errorCode +"\nError info: " +debug.getInfo(errorCode));

        } else {

            switch(parameter){

                case "cmi.core.lesson_status":
                case "cmi.completion_status" : scorm.data.completionStatus = value; break;

                case "cmi.core.exit":
                case "cmi.exit"     : scorm.data.exitStatus = value; break;

            }
        }
pipwerks commented 12 years ago

Patched per your first comment, thanks. RE: comment #2, thanks for the suggestion, but it would be inconsistent with my use of error messages throughout the rest of the JS wrapper. Functionally, the fix from comment 1 is all that's needed, the rest is style.

T0T4R4 commented 12 years ago

No worries.