Get User ID SCORM 2004, CSOD, JS

Oct 25, 2022

Hello everyone,

We are experiencing an issue with accessing the Learner's ID from our customers LMS Cornerstone on demand. With SCORM 1.2 our Javascript was working without any issue. However, when updating to SCORM 2004 3rd Edition, we no longer receive the correct Learner's ID but another number. It is alwas the same number, but it is not the correct one.

Our old JS for SCORM 1.2 looks like this:

function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}

var lmsAPI = findLMSAPI(this);

var student_id = lmsAPI.GetStudentID();
var p = GetPlayer();
p.SetVar("user_id",student_id);

And this is how we modified it for SCORM 2004:

function findLMSAPI(win) {
if (win.hasOwnProperty("SCORM2004_GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}

var lmsAPI = findLMSAPI(this);

var student_id = lmsAPI.SCORM2004_GetStudentID();
var p = GetPlayer();
p.SetVar("user_id",student_id);

Can anybody help by finding the cause of this issue and a possible solution?

Thanks :)

1 Reply
Hannes Kleefeld

In case anybody else is having this problem. It seems the code on our side was corret. However, on the LMS side there had to be made some changes.

While the code for SCORM 1.2 grabbed the cmi.core.student_id which was the value we required.

For SCORM 2004 the code grabs the cmi.learner_id which was filled by the lms with a diffrent ID we did not require.

By adjusting the settings in the LMS this could be solved.