Help with javascript - Passing score to LMS
Sep 12, 2013
HI
I have developed a course having 2 quiz and a result slide. One of the quiz is not developed with the built in storyline quiz template, so I cannot link it up to the result slide. So I have added a new slide wherein I am displaying the score. I want to pass this score to LMS based on which LMS will decide whether pass or fail.
Attached is the .story file. The total score is calculated in the 'hazards' variable. This variable is also used in my Result slide to show whether pass/fail. On the result slide, I have added this javascript to pass the score to LMS and mark pass/fail in LMS accordingly. This code is not working in ScormCloud. Please tell me if anything is wrong with the code.
Code:
var player = GetPlayer();
var lmsAPI = parent;
lmsAPI.SetScore(player.GetVar(“hazards”), 70, 0);
if(player.GetVar(“hazards”)>=60)
SetStatus = "Passed";
if(player.GetVar(“hazards”)<60)
SetStatus = "Failed";
11 Replies
Too bad no one helped you with this one, because I could use the answer.
Hi Bradley! Your response puts the thread back 'on the radar', so perhaps someone from the community will be able to assist you and Dipti with this issue. Have you sent her a PM, perhaps she was able to get this sorted already? JavaScript is not something that Articulate helps support.
Try this:
/*Get player to reference*/
var player = GetPlayer();
/*get LMS API*/
var lmsAPI = parent;
/*set score; the first number is the score*/
lmsAPI.SetScore(player.GetVar("hazards"), 100, 70);
/*set status; possible values:"completed","incomplete", "failed","passed"*/
if (player.GetVar("hazards")>=70)
SetStatus("passed");
else
SetStatus("failed");
Hi Dipti were you able to get a positive Response???? if yes then please share. i am facing the same situation
Hi Rehan,
I'm not sure that Dipti is still subscribed to this thread, but you may want to send her a private message as well.
I want to to show customized score in LMS using java script, but in LMS my Score showing "unknown" result. Please help.
Here is the JavaScript i used for that:
var player = GetPlayer();
var lmsAPI = parent;
var myScore= player.GetVar("LMS");
lmsAPI.SetScore(myScore, 100, 80);
SetStatus(“completed”);
Attached is the LMS screenshot.
Hi Mayur,
This discussion is quite a bit older and I don't know if folks are subscribed here. It's a bit outside my area of expertise, but you could try starting a new discussion to get some new eyes from the community on your Javascript!
Below script works perfectly:
Here, I am translating the points accumulated in the user variable "TotalScore". Below JavaScript is inserted in the "Results" slide in Articulate Storyline. Remove the default Submit results trigger, and then insert below JavaScript.
--------------------------------------------------------------
var myscore = 0;
var player = GetPlayer();
var ptScore = player.GetVar("TotalScore");
var maxPoints = 330;
myscore = 100*ptScore/maxPoints;
SCORM2004_SetScore(myscore, 100, 10);
SCORM2004_CommitData();
--------------------------------------------------------------
Thanks Vijay. It worked as expected.
Its not working for me. Vijay/Nandini can any one please share me storyline file please.
If any one have solution please share
Thanks,
Bhargav