Storyline 3 | Javascript to Set Success Status to Passed

I know this has been discussed before for past version, but I haven't been able to find an elegant solution to this. I have two branching stories with two Results Slides. Obviously upon Publish, you can only choose it to report one slide, hence the need for a javascript solution. I actually don't even need to check it against the quiz questions because we allow them unlimited guesses till they get each question right. I'm hoping to be able to change this status via just a trigger button.

I've managed to figure out how to get the LMS API, Set the Score and change Completion Status to complete

//get LMS API
var lmsAPI = parent;
//set score; the first number is the score
lmsAPI.SetScore(100, 100, 0);
//set Completion to "complete"
lmsAPI.SetReachedEnd();

But I'm absolutely stuck on how to get the Success Status to change to Passed.  Does anyone have a clue how to achieve this?

19 Replies
Matthew Bibby

Try this:

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(100, 100, 0);
lmsAPI.SetStatus("passed");

For more, see this discussion.

Matthew Bibby
Alex Selamat

This doesn't seem to work on the Storyline 3 version. I read somewhere that they had re-written the program to be more HTML5 compliant and as such the command SetStatus("passed"); doesn't seem to work anymore

I don't think it's that SetStatus doesn't work anymore, it's just that the lmsAPI isn't available without doing something like this first:

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);
Matthew Bibby

I've just updated the code, see if this works instead:

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(100, 100, 0);
lmsAPI.SetStatus("passed");
Matthew Bibby

Ok, then maybe try this:

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(100, 100, 0);
lmsAPI.SetPassed();

Or, if that doesn't work, this:

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(100, 100, 0);
lmsAPI.SCORM_CallLMSSetValue("cmi.core.lesson_status", "passed");

 

Matthew Bibby

I just tested this in SCORM Cloud and both solutions shared in this comment work when publishing to SCORM 1.2.

If using SCORM 2004, then this should do the trick:

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(100, 100, 0);
SCORM2004_CallSetValue("cmi.completion_status", SCORM2004_COMPLETED);
SCORM2004_CallSetValue("cmi.success_status", SCORM2004_PASSED);
Cecile Pham

I'm on SCORM 1.2... I'm also Alex. LOL Well, he's my Art Director on which the serial number is registered to so I must have logged in to update the program and forgot I left it on his account. Gonna test those two options again. They were weren't yielding completes and passes in SCORM cloud yesterday but I'll also post a paired down test file. Maybe you can see where might be entering something wrong.

Cecile Pham

So I woke up this morning and realized that I could eschew all this convoluted Javascript hacking and came to a more elegant solution. (not to diminish all your incredible trouble shooting which I'm so grateful for the counsel). I realized I had created a variable lang to indicate whether the user chose to proceed in english 'en' or spanish 'es' and that variable needed to be reported to the LMS. Either way, I needed the result slide to send a report regardless of which branch of the story we were on. Which lead me to wondering why i didn't just have the two branches converge to one result slide that passed on 50% of the quizzes being finished (half being english, half being the spanish side) and reported the language variable.

I guess, sometimes, one just needs some sleep to find the easiest path.

Matt Walsh

Hey Matthew,

Different but somewhat related topic: Any idea how you can manually get Storyline to automatically save the current state to the LMS? I tried different iterations similar to this, but have not gotten it to work:
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.SCORM_CommitData();

There are certain points in my course I want to save the current state in case the user exits without advancing to another slide (ex: opening an external document, completed viewing a video). I'm trying to avoid using the lightbox workaround and thought since you've had success with marking completion/success, you might also have a solution for this. Thanks.

Matt Walsh

Thanks for the quick reply. I had looked at that thread previously, and unless I'm missing something, I didn't find anything there that worked in SL3. Going through the LMS debug logs, it seems like you might need to call "SetDataChunk" first, so I'm currently trying to call a "ForceCommit", but cannot get it to access that function at all (have debug lines before and after the call and never gets to the 2nd debug line). Anyways, thanks for the info and trying to help out. Very much appreciated. I'll keep trying.