push score with javascript

Nov 23, 2017

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
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();

This discussion is closed. You can start a new discussion or contact Articulate Support.