Forum Discussion
Retrieve LMS User Name as Variable
You’ll need a variable to hold the username; I choose “username”. I set the default value to “Guest” just in case anything went wrong.
Then set up a trigger to run the JavaScript that will fetch the name and stuff it in our variable. I am using a Slide Trigger set to run when the timeline starts.
And now put the following code in the Javascript section of your trigger.
//grab the LMS object
var lmsAPI = parent
//ask the LMS object to get the name
var rawName = lmsAPI.GetStudentName();
//the name comes very formal "Last, First"
//we will fix that by sticking the name into an array
var nameArray = rawName.split(",")
//then we save it the other way round "First Last"
var niceName = nameArray[1] +" "+nameArray[0];
//now we grab the Articulate player
var p = GetPlayer();
//finally we set our Articulate var to our username
p.SetVar("username",niceName);