How to modify LMS StudentName Script to Capture another LMS Variable?

Hi all

I use the following script (see below) to capture the student name from my LMS.

I obtained the code from this forum and the neat thing about it is that:

  1. It works!
  2. It "hunts" for the parent frame to find the LMS value
  3. It parses the Student Name (in my case to a new VAR called "newName")

I'd like to modify the code to capture another VAR (studentID) stored in my LMS. 

When I contacted the LMS vendor (and shared the code below) this was their response:

"...we store the student ID in the property: cmi.core.student_id. In a SCORM frame (not the popup) this property can be retrieved via:

window.parent.API.LMSGetValue( "cmi.core.student_id")

 He assumed you will be able to retrieve the student ID via:

var studentId = lmsAPI.LMSGetValue("cmi.core. student_id") at the end of the provided source code..."

I've done what they've suggested - and it doesn't work :(

Can anyone else suggest the edits I need to make to the script below to retrieve the studentId?

(Here is the script that DOES work to pull out StudentName)

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


Be the first to reply