Javascript for Learner name

May 15, 2015

Hi,

 

I am building a course and would like a way to pull the username from their single sign on or from saba.

 

does anyone know if this is possible? I want to try to avoid having the learner type in their name.

9 Replies
sandie coco

It is possible. I did this a few years back with Saba. Here's the Javascript I used to pull the username. Note that the name comes Last Name, First Name so my script puts the name in an array so we can switch it to First Name Last Name. I used username as my variable name.

//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);

This discussion is closed. You can start a new discussion or contact Articulate Support.