Forum Discussion
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:
- Get the StudentID from the LMS.
- Get the StudentName from the LMS.
- Manually call SetStatus("completed"); to pass a completion to the LMS on the last page of the course.
146 Replies
- AdamTrosperCommunity Member
Not a problem! I'm glad this has helped so many people!
I figured once I had a solution figured out, I should share with the community and also reach out to the Articulate team in hopes that they could fix the problem in future releases.
- TheJohnSmithCommunity Member
Thank you so much Matt!
- VinayakSawantCommunity Member
Thanks Matthew. for this help
- karunareddygariCommunity Member
Thanks Adam! you saved my day.
Happy to hear that Steve and thanks for the update!
- JoLamontagne-8fCommunity Member
Hi Matt, hope you're well!
I've been trying to use this when publishing html5 only via scorm2004.
I keep getting a message about blnstatuswasset = false.
Do I need to do anything different to this as I'm using scorm2004? Xxx
- AdamTrosperCommunity Member
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!
- ChrisPerez-f9f6Community Member
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?
- AdamTrosperCommunity Member
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('');- ChrisPerez-f9f6Community Member
Hi Adam - thanks for the reply. I will take a look on Monday. I wasn't able to get the array[1] to work at all, but I'll check and report back.
- MichaelMillikenCommunity Member
I just wanted to say thank you to Chris and Adam, This has helped me big time!
Related Content
- 4 months ago
- 4 months ago
- 10 months ago