Retrieve LMS User Name as Variable

Jul 09, 2012

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

215 Replies
Matt Galbraith

Hello! I'm having some trouble getting a Student ID to display. I set an alert to get the Student ID and it pops up with the info displayed perfectly, but I can't seem to transfer that StudentID variable into my Storyline project. Here is my code:

var player = GetPlayer ();

var learnerID = lmsAPI.GetStudentID();

player.SetVar("learnerID", learnerID);

It might help to note that we use Cornerstone for our LMS. Any ideas?

Leslie McKerchie

Hi Matt! 

Hopefully someone will chime in to assist you here or you are welcome to reach out to users directly via the 'Contact Me' option on their user profile if needed.

I did want to pop in and let you know that we have a pretty extensive thread with our Cornerstone LMS users that I thought you might want to know about for sure :)

Matt Galbraith

I'm now trying to use the same script as my earlier post to grab the course ID (replacing StudentID with CourseID and learner with course in script), but can't seem to get it to return. I've tried to set up an alert like this:

alert(lmsAPI.GetCourseID());

But no pop-up message appears. I tried to add the var lmsAPI = parent line, but no luck. I double checked the variable name in the AICCFunctions.js file and there is a variable titled AICC_CourseID. Any idea why this isn't coming back for me, yet I get the StudentID with no problem?

Jay Dharap

Hey Jennifer!

You set up a variable called *newName* (you could call it anything you
want, just make sure the javascript I am about to share with you has the
same variable mentioned)

And then you set up a trigger to run at the start of the timeline, to
execute javascript.

And in the pace where the javascript is meant to go, you enter this:

var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var arrayName = myName.split(' ');
var newName = arrayName[0];
player.SetVar("newName", newName);

This works for my LMS. I'm no expert, but you can try this and ask around
if this doesn't work. There are versions of this floating around.