lmsAPI Functionality in HTML5 Output

Apr 28, 2017

Hey all,

I've been searching through the forums and haven't been able to find anything solid.  I'm using Storyline 360, outputting to both HTML5 and Flash to cover my bases, since the audience doesn't have dedicated machines that they are taking this from.

I'm relying heavily on external Javascript that I wrote, which I have tested thoroughly in the Flash version, and it works fine.  But when it comes to the HTML5 version, it stops working.  I've proven that I'm able to get into the Javascript functions, like I would expect, but it appears that lmsAPI is no longer available to the course.

Are there any similar functions to those of the lmsAPI functions in the HTML5 output?  

Specifically, I'm looking for a way to do the following in HTML5:

  1. Get the StudentID from the LMS.
  2. Get the StudentName from the LMS.
  3. Manually call SetStatus("completed"); to pass a completion to the LMS on the last page of the course.
146 Replies
Adam Trosper

Hi Helene,

SetStatus("completed") only works with the Flash version because the HTML5 version doesn't end up using the lms.js file. So, you will have to bypass that function and directly call the function that the SetStatus function would have called... Try this:

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.SetReachedEnd();
Don Anthony Manuel

Hi guys... I am trying to create a certificate on a slide, following the assessment that will pull variables from SCORM (student name / today's date) and then allow me to print.

I've seen people mention to Print that you would need a flash object.  Our organization no longer supports Flash at all.

Any help?

Chris Pim

Try this:

---------------------------

if (document.location.href.indexOf('html5') < 0) {
GetPlayer().printSlide()
} else {
if(!window.hasPrintStyle){
window.hasPrintStyle = true;
var css = "@media print {div.controls.grid-row.inflexible,div.area-secondary.cs-left.inflexible,header.header-primary.centered-title.extended-height,div.presentation-wrapper:after {display:none !important; visibility:hidden !important;}}";
head = document.head || document.getElementsByTagName('head')[0];
style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
}
window.print();
}

Adam Trosper

If that doesn't work, the way that I've printed in the past was to use Execute Javascript to essentially create a new window with the certificate I wanted to print created on it using HTML.  The one piece of advice I have about printing is that different browsers handle printing just a little differently, and you will have to account for that.  Also, I always include a "print" button on the page that will disappear when clicked, in case they want to print a second copy, the cancel the print job, etc.

Ashley Terwilliger-Pollard

Hi Stephanie,

The issue with Javascript code no longer sending completion status to LMS in Storyline 360 and using HTML5 output, is still an open issue based on the changes made to the publishing engine in Storyline. Our team is looking at ways that we could incorporate these features for you and others to use in the future, but in the meantime you'd want to use the built in completion elements from the results slide or publishing properties. 

Stephanie Powner

Hi Ashley

Thanks for the information. There was an issue with the built in Scorm reporting for HTML5 courses, which is why I was trying to do down the javascript route. However, I have been contacted by your support team to say that this has been fixed in the update made available this evening. Hopefully that will sort the problem as I am very keen to move to HTML5 output asap due to the ever increasing restrictions on Flash player use.

Thanks again

 

Ashley Terwilliger-Pollard

Hi Matthew and Stephanie,

Just a quick clarification here - the issue fixed was Javascript triggers that would set Storyline variables based on using the LMS API. So that would be pulling data from the LMS such as the users' name, etc. This does not change the behavior for setting the completion using Javascript in Storyline 3/360. That is something our team is still looking at based on the changes made to our publishing engine, and ways it could be added as a new feature for Storyline.

Steve Galway
Adam Trosper

I actually ended up creating a function for myself to use, to error-check a little bit:

function findLMSAPI(win) {
// look in this window
if (win.hasOwnProperty("GetStudentID")) return win;
// all done if no parent
else if (win.parent == win) return null;
// climb up to parent window & look there
else return findLMSAPI(win.parent);
}

function someOtherFunc(){
var lmsAPI = findLMSAPI(this);
if(lmsAPI != null){
//do stuff
}
}

Just found this post and it helped me solve an issue I was having after stripping the Flash from a Storyline 2 published course. 

Many thanks

Shane Leonard
Adam Trosper

...this entire thread probably wouldn't be necessary if there was a trigger for "Mark Course Complete" within Storyline.  In that case, I would be able to simply say "Mark the course complete when the timeline starts on Page 4.4" or something to that effect.

Since this feature would be built into Storyline, it would presumably work in both Flash and HTML5, and wouldn't require external Javascript.

BUUUUMMMP!

Adam - much appreciated for your contribution to what is probably the Articulate Hack of the Year - which is a prestigious award considering how many hacks are required.

Speaking of hacks...
Articulate Staffers... has there been any progress on the above mentioned and extremely well articulated feature suggestions? Articulate 360 offers a few wonderful new features (closed captions!!), but to completely break the users' ability to effectively communicate with the LMS is simply madness! Madness I say!

You should add the above mentioned action triggers. It will take a few days for your skilled dev team to do, and will literally retain many paying customers. Ready? Go!

Meanwhile... I think I have the featured workaround working on my Moodle System thanks to Ad-rock's self-calling Javascript function, but I have yet one remaining thorn in my side.

I can't, for the life of me, change the cmi.core.lesson_status to anything other than Failed (SL360, HTML5, Moodle). I can set the score. I can get a li'l tick in the li'l "you did a thing" box in Moodle, but if I view the attempt details, it's cmi.core.lesson_status = failed.

I dunno.

My JS snippet is:

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("percentage"), 100, 0);
if (player.GetVar("percentage") >= 70)
{
lmsAPI.SetReachedEnd();
}

That last command, I've also tried:
a) lmsAPI.SCORM_CallLMSSetValue("cmi.core.lesson_status", "completed");
b) SetStatus("complete");
c) lmsAPI.SCORM_SetCompleted();

Any ideas?

Adam Trosper

Hi Shane,

Thank you for the kind words!  My guess is that you might be using a "Passed/Failed" instead of a "Completed/Failed". 

I would recommend trying to call the following instead:

lmsAPI.SetPassed();

If you are looking for the different options you should be able to use with lmsAPI, here is the switch statement in the lms.js code, which I used as the basis of the code I wrote:

switch (strStatus){
case "complete":
case "completed":
lmsAPI.SetReachedEnd();
break;
case "incomplete":
lmsAPI.ResetStatus();
break;
case "not attempted":
break;
case "failed":
lmsAPI.SetFailed();
break;
case "passed":
lmsAPI.SetPassed();
break;
}

Good luck!

Simon Taghioff
Shane Leonard

...this entire thread probably wouldn't be necessary if there was a trigger for "Mark Course Complete" within Storyline.

Hi folks,

Thanks for your feedback here. I wanted to confirm that a new 'Complete Course' Trigger is currently in Beta and is on track to be released in an upcoming Storyline 360 update.

As you'd expect, the new trigger gives you the flexibility to specify all sorts of custom completion criteria from inside Storyline, and sits alongside the slides viewed and results slide as a third way of tracking course completion with an LMS.

We'll keep you posted and let you know once the update is available for download.

- Simon

Shane Leonard

That's awesome Simon. Apologies for my post being a tad terse. I was in the throes of troubleshooting frustrations.

I solved my problem by the way.

I was getting a persistent "Failed" status and couldn't work out why.

Turns out, even though my publish settings were tracking on Slide Views, an unused Results Slide was unwittingly setting a Mastery Score of 100. So even though the users couldn't navigate to this results slide, the mastery score was being set in imsmanifest.xml and my activity status was being overridden as failed.

As soon as I disabled all options on the results slide, the code mentioned in my post aboved worked as intended.

Looking forward to this SL360 update!