Storyline - Set LMS Status with JavaScript
Jun 26, 2014
As known with previous Articulate products and versions, there are traditionally only two ways to set the LMS status to "complete".
- Number of slides viewed
- 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:
SetStatus("completed")
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:
//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")
Now you can set the course status whenever/wherever you want.
72 Replies
hi Scott,
where can I find the file AS2 "setStatus.swf"?
I do not see it in the attachments
Thank you
Sorry about that. I'm new to this community and wasn't sure how to attach files.
I'm attempting to attach the SWF and FLA.
Well, it only allowed one file at a time, so here is the SWF file compiled from the above FLA.
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")
It keeps removing the simplest line of JavaScript code from the post. Here it is again. Keeping fingers crossed.
SetStatus("completed")
So if I wanted to use the javascript method and call the SetStatus function on a particular slide, would I choose the slide count method in the Storyline LMS options and set it to all slides?
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.
Thanks for the info! I will definitely try this out soon, as I am currently using a hidden one-question quiz and result slide at the end of my projects to trigger completion (like this).
Your method will be much cleaner if I can make it work.
I'm sure you will have no trouble.
I have a sample file you can check out. See slide 4 and the slide trigger.
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.
Thank you
Hi Scott,
Thanks for sharing this information.
However, when I try to download [setstatus.swf] , it's showing a blank page. Could you please share the file again?
Thanks.
Hi Shyam! I'm not sure if Scott is still subscribed to this thread. You are welcome to utilize the 'Contact Me' option on his profile if needed.
Hi Leslie,
Thanks for noticing this.
However I could generate the SWF file from the FLA file.
Sharing this here, if anyone requires it at any point of time.
Thanks Shyam :)
This post was removed by the author
Many thanks for the tips !
Hi Ravi !
Yes, if you just want to set the status, usually, I use that :
SetStatus("completed")
Just that and it works.
You have just to set the status that you choose.
Cédric
Thank you Scott, so in that JavaScript, what is the variable that represents the score? is it "lmsAPI"? Right now, I want to do this in a course, and the variable I'm using (that I want reported as a score to the LMS) is "Results"? where would that fit into this code?
Hi, Rich -- Thanks for your question, and in case Scott or other participants are no longer subscribed, you are welcome to use the 'Contact Me' link on an individual's profile page to reach out directly. ")
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);
Thanks for popping in to share Tim :) It may not assist Rich at this time, but could certainly assist users that run across this thread in the future.
Hi i am trying to force a completion using JS code but for some reason it's failing everytime I upload it on LMS or SCORM cloud
can some please tell me what did I miss?
here is my code
var lmsAPI = parent;
lmsAPI.SetScore(70, 100, 0);
SetStatus(“completed”)
alert("you just clicked the button");
Hi HT.
I don't see a semicolon at the end of SetStatus.
Also, how does your course report completion in the publish setting. via a results slide, or number of slides visited?
I have attached the test file, it's suppose to trigger the JS code when the user enters "slide#2", but so far nothing happens.
The completion status is set to Completed / incomplete with the measureable set to the number of slides visited
This discussion is closed. You can start a new discussion or contact Articulate Support.