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.

48 Replies
Scott Wiley

I also just now seeing that some of the original JavaScript I posted was stripped out.

Maybe there is a particular way to format programming code that I'm not privy to?

****************

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.
Of course there are other options… "completed", "incomplete", "failed" and "passed"

But, 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:

//get LMS API
 var lmsAPI = parent;
 //set score; the first number is the score
 lmsAPI.SetScore(90, 100, 0);
 //set status; possible values: "completed","incomplete", "failed", "passed"
 SetStatus("completed")

Scott Wiley

Exactly. That is how I did it in the past.

Before the learner can possibly view all slides, the course is set to "complete" by landing on a particular slide, one of multiple slides, or some other action that you apply the script to.

As a proof of concept exercise a few years back I backwards engineered a course called "Connect with Haji Kamal" in Articulate Presenter and used this same method. It was designed by Cathy Moore and if you look at her flowchart graphic you can see where there are multiple slide locations that can be considered "acceptable" or "good" that could implement the JavaScript trigger when the learner reaches that timeline.

I guess there could be other scenarios where a complex multi-branching course could have varying levels of mastery attained by reaching different slide locations. But I believe using the slide count selection for publishing and still using JavaScript to set an actual score in the LMS instead of "completion" would make the most sense, since you wouldn't really have a "quiz" to point to for capturing a score in the normal sense.

Steve Flowers

When using this method, you might want to make sure you create a condition that cannot be reached using built-in methods. Either by adding a results slide that will never be reached and setting track by result, or by adding a slide that will never be reached and setting track by slide count. 

If not, there's a chance that Storyline might overwrite your custom set score.

Ravi Kumar

Hi Scott

Many thanks for this. I just want to know if i remove the bold lines from the below code will it run fine, i don't want to show the score.

//get LMS API
var lmsAPI = parent;
//set score; the first number is the score
lmsAPI.SetScore(90, 100, 0);
//set status; possible values: "completed","incomplete", "failed", "passed"
SetStatus("completed")

Thanks.

Tim Milke

Hi Rich.

 

You'd probably use Results.ScorePercent from a normal results slide, but I've found this is not always reliable with the javascript.  I created my own variable, and set that to be equal to Results.Score.  Suddenly everything worked.

 

Here's how my script looks:

var player=GetPlayer();
var currentscore=player.GetVar("currentscore");
var lmsAPI = parent;
lmsAPI.SetScore(currentscore,100,0);