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
Steve Flowers

Hi, Vince - 

You can try a couple of things to troubleshoot the issue.

1)
alert(lmsAPI.GetStudentName());

If your student name returns in the alert, the method is working and there's another problem. If it doesn't, try this:

2) 
var lmsAPI = parent;

alert(lmsAPI.GetStudentName());

It could be that your LMSAPI is nested in a parent. This jacks up the reference. If #2 returns your student name, let us know and we'll recommend a change to the original script.

Vince Pileggi

Does anyone have more sugesstions to try? The fact that it is returning a blank( ie. " , ") it seems the code is working fine, but it is not grabbing the name properly from the LMS. Is it possible that the LMSAPI is nested in more than 1 parent? I initially felt good about this code:

var lmsAPI = parent;

alert(lmsAPI.GetStudentName());

But when that didn't work, I thought maybe the idea of nested parents could be taken further. Stop me if I don't know what I'm talking about here, just trying to get this to work somehow.

Phillip Barefoot

I am doing the same thing trying to get the Users ID or Email from the LMS.   I am trying to have a promotion in the course that will give the Users ID or Email over to a website that will randomly select a winner for a prize.  I want to use something more than just the users name because there maybe people with the same name.  I need help getting this info and then giving it to a website to see if they can win.  thanks for any help you can give.

Alex Y

Did some searching and stumbled across this forum.  Just a couple questions about this and hoping someone might have an answer.

1) Has anyone figured out a way to get this working with HTML 5 yet?

2) Has anyone gotten this to work on the Skillport LMS?  

Thank you in advanced to anyone who might have an answer!

Chris Freebairn

I am trying to pull the users "business area" from the LMS so I can bespoke parts of the learning to meet their specific roles/needs, however, I have tried amending the above script but no joy so far.

Any ideas?  The data is stored in the LMS as Division

Has anyone had any success in pulling division/dept from the LMS?  If so, could you possibly share the code?

Thanks

Israel Rodriguez

I'm trying to generate a certificate that contains the name of the student. I created a button that opens an html file with the certificate design, and the code I'm using is:

var player=window.opener.GetPlayer();
var learnerName=player.GetVar("newName");


document.write("

" +learnerName+ "
");

Yet, I'm getting undefined as a result. What am I doing wrong?

Ashley Terwilliger-Pollard

Hi Israel, and welcome to Heroes! 

Although we don't support the creation of certificates, I wanted to point you to this KB article with a few methods described. Additionally, this thread with an example from Steve Flowers is a popular one, and a great place to discuss customizing the certificate further. 

Israel Rodriguez

Hi Ashley, thanks for your answer.

I actually did base my certificate on Steve Flowers' example and following some of the posts on that thread.

However, I'm still getting "undefined". Moreover, using firebug to debug js I found out that lmsAPI.js functions are not working as if the .js file was not being loaded.

Daniel Ivey

I already have a storyline certificate which publishes the StudentName from the LMS and Date from the users computer, however I was hoping to add the Student ID. I don't know much javascript so apologies for the poor chopped code!

Here is what I have so far, I'm assuming Student ID from the LMS is just GetStudentID?? And employeeID is the variable I'm using in Storyline

var player = GetPlayer();

var employeeID  = lmsAPI.GetStudentID();

player.SetVar("employeeID", employeeID);