Retrieve LMS User Name as Variable

I know you can have a user fill in a text box with their name and then later use that variable for personalization. What we would like to do is programmatically retrieve the user name from the LMS. Is there a way to set a variable with data from the LMS when the course is loaded instead of having the user enter their name?

Thx

213 Replies
Knut Jackowski

There is more then one way to do what you want.

The easiest way does not involve Storyline or JavaScript: some LMSs (OLAT for example) provide functionality to generate certificates based on PDFs. If this is possible (and how) for you depends on the LMS, that is going to be used.

A little more complicated is the way for which you need the JavaScript, that I linked before or the solution from Eduardo. But:

The JavaScript thread I mentioned solves one part of what you want to do: it is a way to get the name of the user from the LMS to use it in your Storyline module. You can use it there like any other variable in Storyline. With that, you will still have to choose/find a way to generate the certificate.

I use the method from this thread at work. I think it might be worth your while to have a look at it and see if it is something you want to use. This generates a PDF certificate in the browser that the user can download or print.

Steve Flowers

Have been using the methods listed in the thread for years to get this to work with HTML5.

//this might not be required depending on how your LMS nests the API. Try with then comment out if it does not work in a test publish.

lmsAPI=parent;

//This splits the username sent by the LMS by the comma and creates a string Firstname Lastname.

var userName=lmsAPI.GetStudentName().split(',')[1]+" "+lmsAPI.GetStudentName().split(',')[0];

//get storyline's player

var player=GetPlayer();

//set a player variable in your storyline file to the string created above. Make sure the variable exists in Storyline.

player.SetVar("storylineNameVariable",userName);

Works every time for me in HTML5.

Steve Flowers

Matthew's find-the-api-automatically method should work as well:

https://community.articulate.com/discussions/articulate-storyline/getting-student-name-from-the-lms-and-using-it-in-articulate#reply-453410

As with all, test it first. I tend to stick with my test and revise method. The approach illustrated at Matthew's link did fail for me once but I didn't take the time to figure out why.

Steve Flowers

Hi Bruce - 

Sort of... AO doesn't use SCORM, so the same method can't be used. What I was successful with was picking up the email address / username from the launching window. This only works when the user logs into AO first. If logging in using a guest link, it will fail. This also only picks up the account email and won't be able to access the first / last name since there isn't a way to get to that as far as I've found using any kind of API. 

Doesn't mean that it doesn't exist:) You might try hitting up the team with a support request. I'd imagine this could be a popular ask. 

Bruce Roberts

Hi Steve,

I got an out-of-character unhelpful response from support simply saying the API is not supported and pointing me to two discussion forums that were not really appropriate to the issue.  I'd love to know how you picked up the email as potential users would log into AO with email and randomly generated password. 

For this particular project, the client, (on a tight budget as this is for a major one-off event supported by volunteers), likes the option of AO as it is good value and delivers content efficiently.  All output data is going to an external database so interaction reporting is not required, but if we can't pull out learner identifiers (email would be perfect) we'll need to opt for a more expensive SCORM compliant solution.

Bruce Roberts

After a bit of poking about in Articulate Online, and in this instance, as I want to capture user entered variables and not just show the name in the lesson, I have hit upon the "Guestbook" feature in AO.  Any lesson can be preceded with a form/questionnaire prior to launching.  As we plan to create learner logins in AO using a list of email addresses and system generated passwords, the Guestbook Automatically captures the email address as the unique identifier. It is possible to add multiple custom questions.  Any field has options as to whether the question is mandatory or optional.  This will give us all the variables we need and then we can subsequently deliver the training package.


Just a couple of points to note:
1. if you test the Guestbook as Admin and then log in as a second user to test, do this on a different PC else the Guestbook considers you have already completed it. (Clearing cookies does not resolve this).
2. If you delete the lesson and recreate the lesson with the same name, the Guestbook is not deleted and old data fields are included in any new report.

Nathan Leavitt

The lmsAPI.GetStudentName(); method no longer works for me when I publish to HTML5 only. Here's the code that I use for HTML5:

//This trigger is set to execute when the timeline starts. In order for it to work, this slide requires a variable "newName".
//Get User Name embedded into file from LMS
var myName = SCORM_GetStudentName();

//SCORM has last name, first and we are switching it around to first last.
var array = myName.split(',');
var newName = array[1] + ' ' + array[0]; 

//Set the variable
var player = GetPlayer();
player.SetVar("newName", newName);

FYI, we’ve found that although the lms.js file is still included in the published HTML5 zip package, it’s not actually used and all its functions and variables aren’t used in our LMS. I’m not sure if that has something to do with our LMS (Saba Cloud) or something else. Regardless, that’s why the lmsAPI variable is undefined in our LMS. Instead I used the SCORM_GetStudentName(); function from SCORMFunctions.js.

Angela Kim

Hi,

We are trying to retrieve two identifiers (numerical IDs) from the LMS to appear at the top of our course. Is there a way to do this with javascript and to appear in HTML5 output of the course when launched from our LMS? Our LMS is CECity. Any help would be appreciated...I don't know a lot about javascript, but this string seems to indicate that this is possible with names from the LMS, so I'm assuming other information can be pulled into the course as well. Thanks!

Matthew Bibby
Angela Kim

Hi,

We are trying to retrieve two identifiers (numerical IDs) from the LMS to appear at the top of our course. Is there a way to do this with javascript and to appear in HTML5 output of the course when launched from our LMS? Our LMS is CECity. Any help would be appreciated...I don't know a lot about javascript, but this string seems to indicate that this is possible with names from the LMS, so I'm assuming other information can be pulled into the course as well. Thanks!

What are the identifiers that you want to grab? While it is possible to grab some info from the LMS, there are limits around what data can be accessed.

Angela Kim

We're trying to create a seamless flow from a platform that will authenticate a user with two identifying numbers ("#######" and "#######") that will manually be entered by the user. Our IS team says that they can create an API call with these numbers...and I assume this API call would be sent to our LMS that will host the course. Once the course is launched from our LMS, we would like those identifying numbers to appear at the top of each slide. We are trying to avoid requiring them to enter that information again within the course in order to accomplish those numbers appearing at the top of each slide for the course.