push score with javascript
Nov 23, 2017
By
hector teran
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
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);
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:
Try:
lmsAPI.SCORM_SetPassed();
lmsAPI.SCORM_SetFailed();
lmsAPI.SCORM_SetCompleted();
To set it to incomplete:
lmsAPI.SCORM_ResetStatus();
Thanks again for your Reply. i've tried to apply your suggestion but didn't seem to work.
this is how i put it in my code:
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
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.
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();
Hi,
I couldnt able to invoke the result to my lms from course stroyline. i couldnt able to intialise lmsapi from my lms page.kindly help me to intialize and fetch the result from story loaded in iframe
This discussion is closed. You can start a new discussion or contact Articulate Support.