Moodle issue reporting the student name

Feb 15, 2022

Hi,
 
We have some courses created in Storyline 360, exported as SCORM packages and hosted in Moodle
 
We use the Javascript code below which ran on enter slide and always worked just fine..
 
Now, instead of the variable 'newName' referenced in a text field reporting 'Chris Pim" as it should, it reports "undefined Chris Pim"
 
I suspect a Moodle update has caused this bug but have no idea how to remedy it - can anyone help?
 
---------------------------------
 
var player = GetPlayer();
 
 
function findLMSAPI(win) {
// look in this window
  if (win.hasOwnProperty("GetStudentID")) return win;
 
// all done if no parent
  else if (win.parent == win) return null;
 
// climb up to parent window & look there
  else return findLMSAPI(win.parent);
}
 
 
var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();
var array  = myName.split(',');
var newName = array[1] + '  ' + array[0];
player.SetVar("newName", newName);

 

11 Replies
Joseph Francis

What is returned in Storyline if you populate the Storyline variable newName with the Javascript variable myName? I commented out lines 3 & 4.

var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();
//var array  = myName.split(',');
//var newName = array[1] + '  ' + array[0];

player.SetVar("newName", myName);

I'm curious that it wasn't returning "Pim Chris", as the correct SCORM format for cmi.core.student_name is last name, first name and middle initial, with last name and first name separated by a comma.