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.
166 Replies
Adam Trosper

Hi Astutis,

One thing I noticed in your code is that you have quotes around the "14" when you are declaring the passingScore variable.  This is most likely forcing that variable to be used as a String.  So, when you do your '>=' comparison later on, it would be comparing a number to a string (which wouldn't be reliable).  Otherwise, I think your code looked good.

The other thing I would double-check is that these variables that you are pulling in are exactly what you are expecting them to be.  For example, I'm assuming that you have a trigger on your results slide somewhere to set "finalscore" equal to "Results.PassPoints" or something like that, right?

If you try these things, it may or may not work.  If it doesn't work, perhaps you could upload a .story file and I could take a look?

Tom W

Hi Karuna.

I have tried this, but when I track the results using a complete course trigger I lose the answers to the questions - they only send to the LMS when the results are tracked by the quiz results slide.

I may look at reporting the answers via hidden survey slides, rather than using the built-in quiz functionality, although I'm not sure this is going to be possible when using a randomised question bank.

Tom W

Hi Adam.

I removed the quotations from the "14", but it's still setting a 'Passed' status when the score is 13.

I have a variable in my project titled 'finalscore', but I don't have a trigger on my results slide involving it. Should I? The only triggers I have are a 'Submit results' one to get the question answers sent to the LMS, and the one executing the Javascript code.

I do have a trigger on the previous hidden 'How many' survey slide which is setting finalscore to the typed value in the numeric entry box. 

I've got the variables being displayed on the results slide so that I can check they're working okay, and they are displaying correctly. It's just the passed/failed status that's not working.

Adam Trosper

So, I believe the way that it works is that as soon as you call the Submit Results trigger, it is going to set Passed/Failed and send a score to the LMS based on the actual results of your quiz. 

I would put an alert into each portion of your if/else statement to see which one it's calling.  If it's calling the "Failed" one, but you are still getting a "Passed" in the LMS, it's most likely because the Submit Results trigger is overriding your code (or something to that effect).

You *might* be able to swap the order of your triggers so that your JS trigger comes before the Submit Results trigger, but I don't know that it would help or not.  You might not be able to accomplish exactly what you are going for without digging further into the Storyline engine code to understand exactly what's happening.

Adam Trosper

Technically, every variable gets tracked to the LMS, but it's just a matter of whether or not the LMS can report on it in a readable fashion.  Assuming you are using SCORM, everything gets stored in SuspendData, but quiz elements get stored as Interactions, which is why the LMS can report on the data more robustly.  I would try Googling "Storyline Submit Interactions" and see what you can find as far as that goes.  You might be able to restructure the questions to all be submitted as interactions, but then use the Complete Course method that Karuna suggested for the results.

Tom W

I think the questions are currently being submitted as interactions, as they're using the built in quiz functionality. However, for them to work I need to track using quiz results, which overrides any complete course trigger or JavaScript code.

I may just have to sacrifice the success criteria, as everything else is working fine.

Thanks everyone for the suggestions and help though.

Adam Trosper

What I was suggesting was to switch the tracking to "Complete Course Trigger" and then remove the quiz functionality but keep the questions (submitting each as interactions).  Without actually testing this myself, I would think this would store the questions themselves in the LMS, but not require a results slide to submit the score.  Then, you could keep your JS code to try to submit a passed/failed.  Again, just thoughts, but I would think it could work.

If you do manage to get this to work, this thread could benefit from knowing your solution!  Best of luck!  

Tom W

Ah okay. This sounds promising. I shall investigate this approach and let you know how I get on.

EDIT: It seems there's no way to submit an interaction without using the built-in quiz functionality. And they only get reported to the LMS when the results are submitted on a results slide. Is there something I'm missing?

Adam Bayliss

Hi Adam – thanks for replying – but ha! I’m not giving up that easily, that data is stored by the LMS – there must be a way to get to it? – If I can open an LMS page that shows it, it is there…

We are using Ilias LMS – I’ll try the user forums there, will let you know if I find anything..
Cheers
Adam

amit yunger

Hi Matthew,
Thank you so much for the code you wrote, the LMS gets the score (after hours of searching...).
However, the success status remains unknown, instead of passed or failed.

I tired to make the slide a question slide, tried different tracking settings...
What am I doing wrong?

Many thanks,
Amit

Maria Erin Anne Domingo

Hi Adam,

I used a combination of your suggested codes:

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("Results_ScorePoints"), 27, 0);

var passingScore = "23";
if (player.GetVar("Results_ScorePoints") >= passingScore)
{
lmsAPI.SetPassed();
} else {
lmsAPI.SetFailed();
}

Our LMS (Workday) reads this perfectly if the learner has passed the quiz which is set at 23 points (85%). The completion status is reflecting as Completed and the lesson grade as Pass. 

On the other hand, if the learner gets below 23 points, the lesson grade is properly reflecting as Fail but the completion status is showing up as In Progress.

If I add this code: 

lmsAPI.SCORM_CallLMSSetValue("cmi.core.lesson_status", "completed");

the completion status is properly showing as Completed, but the lesson grade does not reflect the Fail status.

 

The LMS Reporting is set to Completed/Failed, and the output option is SCORM 1.2.

Thank you so much!

Anne

phil Mek

Hello everybody,

I read every single message in this thread , also here :(https://community.articulate.com/discussions/retrieve-lms-user-name-as-variable) , and in some others (https://community.articulate.com/discussions/getting-the-student-name-from-the-lms).... (https://community.articulate.com/discussions/getting-student-name-from-the-lms-and-using-it-in-articulate)

But couldn't find what I am looking for :

My client LMS (Talentsoft) in SCORM 2004, can display cmi.learner_name as a variable.

I tried many many many syntaxes to grab this data, but I guess the only working one wasn't in my scope !

Can anymone help me ? what is the syntax to grab this value ?

thank you for the help

Philippe

Matthew Bibby

@ Philippe, try this code:

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);
var name = lmsAPI.SCORM2004_GetStudentName();
var nameArray = name.split(', ');
var firstName = nameArray[1];
var lastName = nameArray[0];
var fullName = firstName + ' ' + lastName;
var player = GetPlayer();
player.SetVar("Name",fullName);

You'll need a text variable in Storyline called Name for it to work.

phil Mek

Bravo Matthew !

it works !

Thank you very much.

I changed a few things, as I only need (at this time) the firstname.

Also, my LMS return no space after the comma in studentname().

Here is your code with small modificaitons :

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);
var name = lmsAPI.SCORM2004_GetStudentName();
var nameArray = name.split(',');
var firstName = nameArray[1];
// var lastName = nameArray[0];
// var fullName = firstName + ' ' + lastName;
var player = GetPlayer();
player.SetVar("Name",firstName);


Do you know why in specification it is said : "cmi.learner_name", and in getting the value : GetStudentName()  ?

I am not dying for the answer, just curiosity.

Anyway, you saved me, Talensoft support was unable to answer.

Have a nice day

Philippe

 

 

Steven Pascoe

Hi, can anyone help me?

This code works for Scorm 1.2.

How do I convert this to Tin Can?

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

 

Appreciated!

jeff barclay

I know this is old but I’ve searched everywhere to try and find how to get the same variables already stored in player() (flash version) while I’m only using story_html5.html

I have random quiz questions and need to capture the wrong answers selected as well as the randomizes question asked?

the g_quizzes produced all this in flash player, now how can I gat the same in html5...

Alexa Yacteen

Hi Matthew,

I noticed you have helped a lot of people with this similar issue and I am hoping you can help me figure out what is wrong with my code:

......

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

....

This originally worked when publishing to SCORM 1.2, but now that we are publishing to SCORM 2004 4th edition, the name populates with "undefined" in front of the name once the course is uploaded on the LMS.

One thing to note is this is not happening when testing on SCORM cloud site.

I've seen posts saying to change ' var myName = lmsAPI.GetStudentName (); ' to '   var myname = lmsAPI.SCORM2004_GetStudentName(); ' but I don't know if i need to keep the ' var newName = array[1] + ' ' + array[0]; ' line. I am assuming the [0] or [1] is reporting the undefined, but the client wants the full name (first and last) of the learner to be generated on the certificate.

I really appreciate any help with this! Thank you

Adam Trosper

To clarify your question, when you use the lmsAPI.SCORM2004_GetStudentName(), you are getting something like "undefinedJohn Smith"?

What GetStudentName (and the 2004 version) both send back is a string of the student/learner's name but in this form: "Smith, John".  The part of the code that's splitting string, and the resulting array, is to swap the order into FirstName LastName order (John Smith). 

So, array[1] should be "John"... and array[0] should be "Smith".  One of these might be coming back as undefined.

All of this is to say that it's possible that it's just the user in question simply doesn't have a first name or last name in the LMS.  But other users in the system still might, so you will need to account for both cases, if possible.

Some code you could use to possibly fix it is:

var newName = "";
if(array[1] != "undefined"){ newName += array[1]; }
if(array[0] != "undefined"){ newName += " " + array[0]; }

I hope this helps!

Alexa Yacteen

Hi Adam, I am getting "undefined John Smith"

When this code was used in the SCORM 1.2 output, the name was correct and there was no "undefined" for the certificate.  

To clarify, I haven't sent an updated version of the course for upload to the LMS yet. In that next version, I replaced this line of code: var myName = lmsAPI.GetStudentName(); with var myName = lmsAPI.SCORM2004_GetStudentName()

I was hoping to gain some insight into whether or not any other parts of the code need to be adjusted. Unfortunately, I'm unable to test the course myself on the LMS, so I am hoping to get the code right before sending in my next version before course deployment. SCORM cloud is not having any issues with the original code in the published SCORM 2004 output. 

I wonder if the code mentioned in a post above would work? :

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);
var name = lmsAPI.SCORM2004_GetStudentName();
var nameArray = name.split(', ');
var firstName = nameArray[1];
var lastName = nameArray[0];
var fullName = firstName + ' ' + lastName;
var player = GetPlayer();
player.SetVar("Name",fullName);