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
Adam Trosper

Hi Alexa,

This sounds like it might be an issue with the LMS -- specifically, the way the user's first name and last name are being stored.  I would check those fields out in the LMS itself, and see if you see something obvious (like the first name being blank, and the last name being "John Smith"). 

If this isn't the case, I would check with your LMS provider to see if they are mapping the fields correctly. 

Typically, if something is working correctly in SCORM Cloud, but isn't working correctly in a specific LMS, it usually points to something being incorrect in the LMS itself. 

Derrick Thomas

Hi everyone,

I am trying to pull the username from Canvas for a storyline 360 certificate but I'm having a bunch of trouble.

I am using javascript but cannot seem to get it right. Here is what I have in my script:

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

then I print the name using 

%firstName”%
%lastName%

Any help will be appreciated.

 

Thanks

Joseph Francis

While the SCORM standard for cmi.core.student_name is last name, first name and middle initial  (last name and first name separated by a comma), I discovered the LMS I am working with (Absorb) is using FirstName LastName (with a space, no comma, between) to store the student's official name. So, trapping for the comma is throwing the function off. I adjusted my code accordingly, by trapping for the space and assigning index 0 to First Name (instead of Last Name):

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

var lmsStudent_Name = lmsAPI.GetStudentName();
     var nameArray = lmsStudent_Name.split(" ")

     player.SetVar("strFirstName",nameArray[0]);
     player.SetVar("strLastName",nameArray[1])

Adam Trosper

Hi Joseph - Good call on this.  The only thing you will want to be careful of/double-check, is how it will behave if someone does have a middle name/initial in there.   You should be safe if you change the last line to this:

player.SetVar("strLastName",nameArray[nameArray-1]);

This will make it pull the LAST item of the nameArray, no matter how long the array is.

Joseph Francis

That goes back to the rules your organization has in place for data, in this case, the user name. If the rule is a middle initial is required, it has to be across the board. It can't be there occasionally and absent occasionally. In many organizations, there's some integration going on in the LMS with the people system or mail system (Microsoft Exchange, for example) which enforces business rules for userName and other data points.

Otherwise, it ends up being Garbage in => Garbage Out.

Adam Trosper

Hi Derrick -  you can only get certain information from the LMS at runtime, and email address isn't one of those fields.  Some LMSes happen to use the email address at the Student ID, but most use a separate field for Student ID (login id) and Email Address.  You could try using the lmsAPI.GetStudentID(); function to see what you get back from the LMS.

For your question about the extra comma appearing after the last name, it's really hard to say what's going on without guessing.  It sounds like the .split() function is set up one way, but the student_name string returned from the LMS is formatted differently than what you were expecting.  I recommend looking at exactly what you are getting back from the LMS when you call lmsAPI.GetStudentName(); and then tweaking your JavaScript code from there.  

Joseph Francis

Unfortunately, neither SCORM 1.2 nor SCORM 2004 has an equivalent data element to the AICC Course.ID data element.

As for a Web Object loading a page with a studentID as a query string name/value pair, what you're after is something which is loaded dynamically at run-time, which isn't quite what a Web Object is. Whether it's an index.htm page on your local machine or an external URL, the location is fixed once you publish the course.

Hila Vauch

Thanks @Joseph for your quick reply! Yes, you described it well as this is exactly my problem - i'm trying to create a web object with dynamic parameters (the link I use inside the web object is to an external system and i'm trying to send it parameters related to the course the user came from).

Do you have any idea how I can achieve that? what is AICC Course.ID data element? i'm not familiar with it - would it be possible to convert my SCROM files to AICC? if it has dynamic parameters related to the LMS course maybe I should try it?


Adam Trosper

Hey Hila! 

It sounds to me like you are trying to do something that is better reserved for calls outside of the courseware itself (perhaps calls/reports that should be happening from the LMS instead).  Without knowing exactly what you are trying to accomplish, what data schema the external system is expecting, etc., etc., etc., it's hard to know where to even start.  

I think if I were in your shoes, I would contact someone at the external system and see what data/parameters they are even looking for, and in what format they need it sent.  I would recommend reaching out to them to get more info on what they are expecting, and maybe ask them if they have a preference between AICC, SCORM 1.2, SCORM 2004, or something else entirely.  They should be able to help you determine the best approach that you should take.

In terms of converting between SCORM 1.2, SCORM 2004, AICC... I'm assuming you are doing this in Storyline, since you are on a Storyline forum.  It should be a simple change in the Publish settings (LMS tab).

Hila Vauch

Thanks again for replying so fast :)
well- I am the external system! basically the whole flow is that the user starts inside the LMS, taking a course (currently built from SCORM files), then from within the SCORM I'm sending him to my system with a link - implemented inside a web object.
I've contacted my LMS provider and it's not possible sending parameters from within the LMS (I literally tried every learning material possible) so I was thinking maybe sending parameters as urlParams from inside the SCORM (for example course id, learning object id, user id and such) so I can recognise who the user is (on my external system) and which course he came from (the LMS).

Now, having said all that (hoping you're still here Adam) - I ran into your post noting AICC Course.ID - Is that referring to the LMS course? can the AICC hold parameters? 
hope my question makes more sense now... 

Adam Trosper

Hi Hila,

I think it's on an LMS-by-LMS basis exactly what information is provided to the course at runtime.  A lot of these fields are optional.

I think my advice would be to change the tracking type to AICC, export it and upload it to your LMS to test it out.  You should be able to turn on Debug Mode, and test what will and won't be possible.

There are 2 ways to turn debug mode on:

  1. In scormdriver.js, change:
    var SHOW_DEBUG_ON_LAUNCH = true;
  2. Using Dev Tools, you can call ShowDebugWindow()