lmsAPI Functionality in HTML5 Output

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.
164 Replies
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!

Chris Perez

I've been following several threads on this topic after trying to get a student's first name to appear in a Storyline 360 course with Cornerstone LMS. I'm publishing in HTML Only using SCORM 2004.

The code I've culled from various threads that almost works is:

var player = GetPlayer();

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);
}

var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);

When I insert the variable onto a page, "undefined" is right before the user's name (first and last).

I've tried code almost identical to the above to get just the first name, but it yields nothing in the variable.

var player = GetPlayer();

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);
}

var lmsAPI = findLMSAPI(this);
var name = lmsAPI.GetStudentName();
var nameArray = name.split(", ");
var firstName = nameArray[1];
var lastName = nameArray[0];
var player = GetPlayer();
player.SetVar('first_name',firstName);
player.SetVar('last_name',lastName);

Anyone have any ideas why this woulnd't be working?

Adam Trosper

Hi Chris,

I wrote this original code to work with SCORM 1.2, not SCORM 2004.

I don't claim to know every difference between the two, but this might help.  My guess is that the Student Name is part of an multi-part object that is getting pulled in.

Have you considered using split/join to remove the "undefined"?  For example:

var firstName = nameArray[1].split('undefined').join('');

var lastName = nameArray[0].split('undefined').join('');
Chris Perez

Just wanted to report in - this is the working code for Cornerstone LMS using HTML5 and SCORM 2004 publishing in Storyline 360 if you just want the first name (variable in SL would be 'newName'):

var player = GetPlayer();

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);
}

var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();

// remove last name from array
var array = myName.split(' ');
var newName = array[0];

player.SetVar("newName", newName);
Jo Lamontagne

Following on from this thread, is there a way to call the student's line manager information from the LMS?  I want to set up an auto generated email to the line manager for users that fail an assessment 3 times. 

I'll be using the first set of coding to get the student information from the LMS.  Wondering if there's an obvious way of generating their line manager too?

 

xxx