gabrieldoty / simplify-scorm

Scorm 1.2 Javascript API
MIT License
230 stars 77 forks source link

GetLastError function does not return the right error code #48

Open mbabayev-coursera opened 9 months ago

mbabayev-coursera commented 9 months ago

Hi, I noticed a couple issues with GetLastError implementation when I was playing around with this library. Although, let me know if this is intentional and I misunderstood the SCORM spec in some way.


First issue is specific to SCORM 1.2:

  1. Call Initialize()
  2. Call SetValue("cmi.core.student_name", "asd") (or any other read only value) -> 403 error as expected
  3. Call GetLastError() -> error code 0 returned

I believe this is because there is a check missing for lastErrorCode != 0, which 2004 implementation has, here: https://github.com/gabrieldoty/simplify-scorm/blob/master/src/scormAPI.js#L223C16-L223C16


Second issue happens in both 1.2 and 2004:

  1. Do NOT call Initialize()
  2. Call SetValue("cmi.core.student_name", "asd") (or any other value, it doesn't matter) -> 301 error as expected
  3. Call GetLastError() -> error code 0 returned

I haven't dug around in the code as to why this happens.