jcputney / scorm-again

A modern SCORM JavaScript runtime library.
https://jcputney.github.io/scorm-again/
MIT License
218 stars 53 forks source link

storeData(terminateCommit: boolean) has different / wrong return type #712

Open drahkrub opened 3 months ago

drahkrub commented 3 months ago

(but I'm not sure if this is perhaps intentional)

storeData(...) (https://github.com/jcputney/scorm-again/blob/master/src/Scorm12API.js#L269 and also in Scorm2004API.js) returns an object like

{
    result: global_constants.SCORM_TRUE,
    errorCode: 0,
}

received as return value from processHttpRequest(...) if lmsCommitUrl is set in settings.

If lmsCommitUrl is not set then global_constants.SCORM_TRUE is returned.

The latter leads to problems in terminate(...) and commit(...) where storeData(...) is called, because in

      returnValue = (typeof result !== 'undefined' && result.result) ?
      result.result : global_constants.SCORM_FALSE;

(from https://github.com/jcputney/scorm-again/blob/master/src/BaseAPI.js#L321C1-L322C54)

returnValue is always evaluated to global_constants.SCORM_FALSE, which means that terminate(...) and commit(...) return global_constants.SCORM_FALSE although there is no error.

In that case a scorm package can call LMSGetLastError() to get the error code and realize that there was no error - but we have scorm packages from one supplier that simply stop working and only display an error window "0: No error".

I had to patch scorm-again.js to make this scorm packages work.

One could say that the scorm packages from this provider do not behave correctly - but I think also scorm-again.js can do a better job in the case mentioned.

drahkrub commented 3 months ago

just discovered #679 - essentially the same

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

jcputney commented 3 weeks ago

@drahkrub I believe this should be resolved/no longer an issue in 2.0.0