Forum Discussion

BrycePoole-1cf0's avatar
BrycePoole-1cf0
Community Member
8 months ago

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

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

  • 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

  • Thanks for the response!

    Seems it was the fact that I was viewing the scorm in the LMS and not viewing it as a learner. Once I did that the script worked perfectly.  

    Thanks again,

    Bryce