Storyline - Set LMS Status with JavaScript

As known with previous Articulate products and versions, there are traditionally only two ways to set the LMS status to "complete".

  1. Number of slides viewed
  2. Score on quiz/test


A third "custom" way to set completion in the LMS:

  • Slide location


This third way would be more appropriate with multi-branching courses where the test is really landing on a particular screen or one of multiple screens.

Publishing

When publishing, choose the slide count method set to all slides. In a multi-branching course the learner would not see all slides but the course will be set to complete before the learner views all slides.

Flash method

In the past, this was accomplished with an imported flash file that would call a JavaScript function. That is still possible using the AS2 "setStatus.swf" file found attached to this post.

However, in Storyline, you can call JavaScript functions from any trigger, including a slide trigger.

JavaScript method

So here is the least bit of JS you need on a trigger to mark a course complete:


Run that little bit of code in a JavaScript trigger on any slide, object, button, etc. and Storyline will tell the LMS that the course is done.

Other options… "completed", "incomplete", "failed" and "passed"

Some LMSes want a bit more info. And you may want more yourself; like a score. That only takes a few more lines of code be added before we call SetStatus:


Now you can set the course status whenever/wherever you want.

65 Replies
Curtis Wiens

Hey Guys, I realize this is an old thread but I am having some trouble getting this to work when I publish for html5 only. I tried Scotts sample file on our LMS, because I thought I was doing something wrong, but it does not work either when I publish for only HTML5. If I publish for HTML5 and Flash SetStatus("completed") marks the course complete on Cornerstone. Any ideas?

Mateusz Szuter
Curtis Wiens

Hey Guys, I realize this is an old thread but I am having some trouble getting this to work when I publish for html5 only. I tried Scotts sample file on our LMS, because I thought I was doing something wrong, but it does not work either when I publish for only HTML5. If I publish for HTML5 and Flash SetStatus("completed") marks the course complete on Cornerstone. Any ideas?

Hey Curtis,

code for html5 is a bit different:

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("Your_Score_Variable"), 100, 0);

Here's the optional code for setting passing threshold and thus completion status:

var passingScore = "75"; 
if (player.GetVar("Your_Score_Variable") >= passingScore)
{
SetStatus("passed");
} else {
SetStatus("failed");
}

However, I've seen some approachesu using different 'commands' for SetStatus, because sometimes it won't work. I've made a fast search and found this:

lmsAPI.SCORM_CallLMSSetValue("cmi.core.lesson_status", "completed");
You can change completed to passed or failed, depending on your needs.

lmsAPI.SetReachedEnd();
can do the trick also.

You must of course change "Your_Score_Variable" to name of your variable containing score :)

Sanduni Fernando

Hi Mateusz, 

Thanks a lot for looking into this. I am publishing for SCORM 1.2, HTML5 only. May be I am doing it in a wrong manner.

I am offering points based on question number. Questions are presented randomly. In order to remove the complexity I have prepared the attached file to show how I used the javascript. The published file (zip file) is also attached here. I want to pass some points to LMS without using the results slide.

I have uploaded this to SCORM could and tested but score does not reported there.

Do I have to add something to "GetStudentID" in the javascript?

 

Mateusz Szuter

Hey Sanduni,

Reported points must be in range from 0 to 100, or simplier - passed in percents.

So when you have 2500 to achieve, that's not correct value for scorm :) you must calcuate it to the percents and then send it to the scorm.

Just change your points from 1000 to 10 and it will work in attached case.

Laurel Thomas

Hi, I'm trying to follow along with the JavaScript code, but I admit I'm not a programmer like that.

I'm using Storyline 3 and need to publish using AICC. I'm confused, though: am I still including a quiz slide and results slide, or does the JavaScript replace all that? 

I want to set a numeric variable in the course to equal the results score/points. The "Score" variable is already out of 100 -- it starts as 100% and the learners' selections take away points from the percentage. I need to send the score they end with and if it passed or failed. Anything below 96% is failing.

This is what I have so far:

var player=GetPlayer();
var customScore=player.GetVar("Score");

//get LMS API
var lmsAPI = parent;
//set score; the first number is the score
lmsAPI.SetScore(customScore, 100, 0);

Glen Savory

Hi all,  Been reading through this thread and still not clear what I need any help would be appreciated.

What i need is to have 2 buttons  One when clicked will place the course as Incomplete and One as complete

I dont need scores etc all im looking for is what Javascript i need to attach to a button. Im guessing this would do the job

SetStatus("Complete")

or SetStatus("Incomplete")

Or do i need more Javascript?   

Thanks