简体   繁体   中英

SCORM 2004 Get and Set Values

I am trying to get and set the completion status of various objectives. I am trying to do these;

str = scorm.GetValue("cmi.objectives." + i.toString() + ".completion_status");

GetValue('cmi.objectives.0.completion_status') returned '' in 0 seconds
[13:50:23.469] Checking for GetValue Error
[13:50:23.469] SCORM ERROR FOUND - Set Error State: 301 - 
The Objectives collection does not have an element at index 0, the current element count is 0.

This is the log of SCORM Cloud. I think it might be related to giving IDs to objectives.

My objectives are not set ID in manifest and I don't know I have to do it. So the question is do I need to give an ID to each objective (manifest or javascript)?

If you think/guess/know the problem is completely different, any help will be appreciated.

So typically you could check - scorm.GetValue('cmi.objectives._count') to know if you had any objectives to poll.

If it came back with 2, you would then have two objectives to loop thru to look for the cmi.objective.x.id you needed to update. Or, if your adding a new objective, that _count would give you the next available index in the packed array.

If you had a _count of 1 it would be worth trying to check for completion_status etc ... Otherwise you'll generate SCORM Errors like the one you described.

Hope that helps.

It's a requirement to set the id first before setting (or getting) other values - see REQ_72.4.2.6 in the SCORM Conformance Requirements (around page 50).

It is quite ok to set the id within javascript, so you could quite easily use "objective_1" for the first etc (though for more future proof it should be some form of URN instead - even if that's "urn:x-local:objective_1" ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM