push score with javascript

Hello everybody,

i'm trying to solve the following scenario:

i have a game where the student have 12 questions out of which s/he can answer only 5, so i'm accumulating the score in a variable and want to pass that score to the LMS, so far i have tried scorm cloud to test and i've read a lot of threats that talks about it but i don't seem to get how to get scorm cloud to read the value that i'm passing.

i've already created a result slide, added a javascript and setted the tracking to the number of slides viewed.

so far i've been able to set the status depending on the achieved score, but the score field remains as unknown.

This is the code that i've been using. can you help me to identify what i'm i doing wrong?

var player=GetPlayer();
var cScore=player.GetVar("Score1");
var lmsAPI = parent;
lmsAPI.SetScore(cScore, 1800, 0);
lmsAPI.CommitData();
if(cScore>1200)
{
SetStatus("completed");
SetStatus("passed");
}
8 Replies
Russell Killips

Looks like you are trying for a score between 0 and 1800. Unfortunately according to SCORM data model a score can only be between 0 and 100.

Take your cScore Value and divide it by 1800 and multiply by 100 to send a percent value instead.

var PercentScore = cScore / 1800 * 100;

lmsAPI.SetScore(PercentScore, 100, 0);

hector teran

Thanks for your replay Russell! that was a quick and accurate response. i've modified my code and is working fine. i'm able to set the completion status but not yet able to set the success status. is there any other line i can add to set the course as passed/failed?

Btw, this is the new code that i'm using in case anyone else wants to try it:

var player=GetPlayer();
var cScore=(player.GetVar("Score1")/1800)*100;
lmsAPI.SetScore(cScore, 100, 0);
lmsAPI.CommitData();
if(cScore>65){
SetStatus("completed");
} else {
SetStatus("incomplete");
}

 

Russell Killips

Which version of storyline are you using and which version of SCORM are you exporting to?

You also cannot set the status to passed and completed at the same time. It's only one field. I don't know why the scorm cloud shows two fields.

For SCORM 1.2 the actual field is called: cmi.core.lesson_status and can be set to:
passed, completed, failed, incomplete, browsed, not attempted

 

hector teran

i'm using storyline 2 and i think that the problem might be that i'm exporting to scorm 1.2 (client requirement)...

when i use the prebuild reporting system of storyline it mark both fields (completion and success) in scorm cloud but anyways, i think that i'll stick with the completion status and the score for the reporting. if anything changes on the way i'll let you know.

thank you very much for your time and effort you've been very helpful.

Russell Killips

Passed / Failed:

var player = GetPlayer();
var cScore = player.GetVar("Score1")/1800*100;
var lmsAPI = parent;

lmsAPI.SetScore(cScore,100,0);

if(cScore>65){
lmsAPI.SCORM_SetPassed();
} else {
lmsAPI.SCORM_SetFailed();
}

lmsAPI.CommitData();

 

Completed / Incomplete

var player = GetPlayer();
var cScore = player.GetVar("Score1")/1800*100;
var lmsAPI = parent;

lmsAPI.SetScore(cScore,100,0);

if(cScore>65){
lmsAPI.SCORM_SetCompleted();
} else {
lmsAPI.SCORM_ResetStatus();
}

lmsAPI.CommitData();