Setting LMS status with Javascript when using SCORM 2004, 4th edition
Oct 19, 2018
Hello there,
I am using SL3 and publishing a quiz to HTML5. I don't use storyline's inbuilt result slide (due to the design) but uses the following javascript to pass the score and status to LMS at the end.
var player = GetPlayer();
function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
lmsAPI.SetScore(player.GetVar("FinalScore"), 100, 0);
var passingScore = "80";
if (player.GetVar("FinalScore") >= passingScore)
{
lmsAPI.SCORM_CallLMSSetValue("cmi.core.lesson_status", "passed");
} else {
lmsAPI.SCORM_CallLMSSetValue("cmi.core.lesson_status", "failed");
}
This is working fine for SCORM 1.2
However due to 'suspended data' limit in SCORM 1.2, the quiz did not resume after a particular slide, then I need to change the output option to SCORM 2004 4th edition. Now the quiz resumes as expected.
But the completion status is not working even though the score is passed to LMS correctly. LMS status is shown as completed/passed even for 30% of the score. Reporting status to LMS is set as "Passed/ Incompleted".
How to correct the above javascript when using SCORM 2004, 4th edition?
4 Replies
Not an answer to your question (apologies) but have you considered customising the design of the results slide to enable you to use Storyline's native features without the need to rely on JS?
Hello Fernando, could you adapt the code to Scorm 2014 -4?
I am having difficulties with sending the variable and changing the state in the LMS and I would appreciate knowing the changes that you had to apply in code.
Thank you
Hi Fon Alejandro.
Noticed the original thread is quite old, so I thought I would attempt to assist.
In SCORM 2004 we have a few functions that we can leverage to set the Passed / Failed parameters instead of the lmsAPI.SCORM_CallLMSSetValue("cmi.core.lesson_status", "passed"); used in Sanduni's example.
Maybe try the following code and see how it behaves:
var player = GetPlayer();
function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
lmsAPI.SetScore(player.GetVar("FinalScore"), 100, 0);
//Replace FinalScore with the variable you are using in your course
var passingScore = "80";
if (player.GetVar("FinalScore") >= passingScore)
{
lmsAPI.SetPassed();
} else {
lmsAPI.SetFailed();
}
In SCORM 2004, cmi.completion_status (“completed”, “incomplete”, “not attempted”, “unknown”) and cmi.success_status (“passed”, “failed”, “unknown”) are two separate data elements that must both typically be updated correctly in order for your completion to be recorded.
For a pass, completion_status = completed and success_status = passed.
For a fail, completion_status = completed and success_status = failed.
Experiment with other combinations to see how your LMS reacts.
This discussion is closed. You can start a new discussion or contact Articulate Support.