Retrieve name variable from Cornerstone and display it in a Storyline course

Hi,

I am having trouble with retrieving a user's name from the LMS and inserting it into a Storyline 2 course.  I am using Cornerstone LMS and building courses in SCORM 1.2 (I would use SCORM 2004 but Cornerstone have issues with that...)

Below is the JS I've tried, any ideas?

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

var player = GetPlayer(); 
var myName = SCORM_GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);

I've got a variable in Storyline called newName and the JS triggers when the timeline starts, or failing that, when the user presses a button on screen.

10 Replies
Christie Pollick

Hi, Nick -- You may already be aware of this, but I just wanted to chime in and mention that although we don't provide support for JavaScript coding, it may be helpful to take a look at this document on JavaScript Best Practices. Hopefully, some of our JS experts in the community can share their suggestions! 

Kamil Nowek

Nick, please check if something is getting from your LMS using function alert:

var player = GetPlayer();
var lmsAPI = parent;
var myName = lmsAPI.SCORM_GetStudentName();
alert("my name "+myName);

Now you're able to see if LMS let you get something. And please check your course using other LMS f.e. cloud.scorm.