Forum Discussion
lmsAPI Functionality in HTML5 Output
Hi Matthew,
I noticed you have helped a lot of people with this similar issue and I am hoping you can help me figure out what is wrong with my code:
......
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);
....
This originally worked when publishing to SCORM 1.2, but now that we are publishing to SCORM 2004 4th edition, the name populates with "undefined" in front of the name once the course is uploaded on the LMS.
One thing to note is this is not happening when testing on SCORM cloud site.
I've seen posts saying to change ' var myName = lmsAPI.GetStudentName (); ' to ' var myname = lmsAPI.SCORM2004_GetStudentName(); ' but I don't know if i need to keep the ' var newName = array[1] + ' ' + array[0]; ' line. I am assuming the [0] or [1] is reporting the undefined, but the client wants the full name (first and last) of the learner to be generated on the certificate.
I really appreciate any help with this! Thank you