JavaScript returning with "Preview" when trying to pull user names from LMS

Mar 27, 2024

Hi everyone,

I have run across this before but don't recall what I did to correct it, I am trying to pull the learners first and last name from the LMS and when I test in the LMS the system shows Preview rather than my name, I will share the JavaScript below. 

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

 

Any assistance that can be offered will be greatly appreciated.

 

Bryce

2 Replies
Sam Hill

Hi Bryce,

Your script looks fine. The LMS must returning preview as the name. Is this because you are just "previewing" the content and it's not using actual student data? Are you accessing the content as learner would?

I suspect this is some king of preview/test mode for testing content and it uses dummy SCORM data.

To confirm you could use the cloud.scorm.com test service to see if the name is returned correctly.

Which LMS do you use?

Cheers,

Sam