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

214 Replies
James Bonney

Hi All,

In SL1, this code works for me on my Moodle LMS, but in SL2, it doesn't pull the name through. Can anyone tell me why it's no longer working?

var player = GetPlayer();

var myName = lmsAPI.GetStudentName();

var array = myName.split(',');

var newName = array[1];

player.SetVar("newName", newName);

 

Thanks

James

Steve Flowers

Hi, Julie - 

This one works fine for me in HTML5. The problem with the beginning of the thread was the use of a function that only worked in Flash. The example below is available to both Flash and HTML5:
https://community.articulate.com/discussions/articulate-storyline/retrieve-lms-user-name-as-variable?page=6#reply-388873

var player = GetPlayer();

lmsAPI=parent;

var myName = lmsAPI.GetStudentName();

var array = myName.split(',');

var newName = array[1];

player.SetVar("newName", newName);

 

Steve Flowers

JS *works* in Storyline. Because it's a great big topic and is an extension of Storyline (not a core function) Articulate support staff cannot *support* JS in Storyline. Falls outside the definition of support at the moment.

There is good news! The community is full of folks willing to help out and offer advice.