Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCORM 1.2 - bug in function getCMIValue #17

Open
muksyd opened this issue Sep 26, 2018 · 4 comments
Open

SCORM 1.2 - bug in function getCMIValue #17

muksyd opened this issue Sep 26, 2018 · 4 comments
Assignees
Labels

Comments

@muksyd
Copy link

muksyd commented Sep 26, 2018

Hi @gabrieldoty,

First off, cheers for this amazing package. You are genius!!

I wanted to point out a bug I have been getting from some SCORM packages that are running this code.

The following line in scormAPI.js

if (!refObject.hasOwnProperty(structure[i])) {

I get cannot read hasOwnPropery of undefined. Turns out, some SCORM packages would request to get value of random objective or interactions if there is no value with that ID.

I suggest the following fixes:
Change L295 to:
if (typeof refObject === 'object' && !refObject.hasOwnProperty(structure[i])) {

and change L300 -

refObject = refObject[structure[i]];
to:
refObject = typeof refObject === 'object' ? refObject[structure[i]] : undefined;

This seems to work for nearly all the 50+ packages I have tested so far.

Again, awesome work on this and cheers!!!!

@xob
Copy link
Collaborator

xob commented Sep 26, 2018

Good find!

While investigating this, I found that there is an ever bigger underlying problem that affects both 1.2 and 2004 APIs, where it is impossible to get the value of an interaction (or anything else that has a childArray). For example, window.API.LMSGetValue("cmi.interactions.0.type") will always return an error, even when there is data there.

I will look into this.

@xob xob self-assigned this Sep 26, 2018
@xob xob added the bug label Sep 26, 2018
@syaiful6
Copy link

I pretty sure cmi.interactions.n.id and others are write only. Only the cmi.interactions._count is RO. So this is not bug, i guess..

@paulo2nd
Copy link

paulo2nd commented Sep 2, 2020

cmi.interactions.n.type (“true-false”, “choice”, “fill-in”, “matching”, “performance”, “sequencing”, “likert”, “numeric”, WO) Which type of interaction is recorded

If you want to recover the interaction you need to use: cmi.interactions._children (id,objectives,time,type,correct_responses,weighting,student_response,result,latency, RO) Listing of supported data model elements

@herasymchuk
Copy link

herasymchuk commented Aug 13, 2022

@xob any suggestions on how to quickly fix that? I have the same problem while executing window.API.LMSGetValue("cmi.objectives.0.id")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants