Getting name from opigno LMS

Jan 26, 2022

I have read so many threads about getting names from LMS  and using them as a reference in storyline but none are working for me. They are all several years old, too. I am a javascript novice so I am not sure how to do this. I know that the variable I need in the LMS is "field_first_name"

I am exporting as SCORM 1.2 to Opigno and using storyline 360. Thank you!

10 Replies
Joseph Francis

If the LMS is SCORM-conformant, then it will respond to a request for the data element cmi.core.student_name (the field name in the LMS' database is irrelevant) with the student's name, formatted as last name, first name and middle initial (note, middle initial may or may not be populated). Last name and first name are separated by a comma. Spaces in the name must be honored.

The basic Javascript you would use is:

var player = GetPlayer();

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 lmsStudent_Name = lmsAPI.GetStudentName();
     player.SetVar("lmsStudent_Name", lmsStudent_Name);

Create a new variable in Storyline called lmsStudent_Name and insert it as a Reference into a Text Box.

Joseph Francis

Now that you have the raw student's name, you can convert lmsStudent_Name into an array, using the comma + space as the separator (if there isn't a space between the last name and first name, then remove the space from the split parameter below).

In Javascript, add this below what you already have:

var nameArray = lmsStudent_Name.split(", ")
player.SetVar("strFirstName",nameArray[1]);
player.SetVar("strLastName",nameArray[0]);

In Storyline, create two new variables, strFirstName and strLastName.

 

Julia Beck

It is still giving me the username versus the real name. For example we have a student whose name is Jane Doe but her user name is bob, it is showing "bob". I don't need to split the username, I just need to pull the actualy name instead of the username. Is that possible? Thsi is the first script that has actually worked at all so thank you for that!

Joseph Francis

In your LMS, is Jane Doe's student_ID Jane Doe and the student_name Bob? Let's find out. Insert the following into the above code and see what is returned:

var lmsStudent_ID = lmsAPI.GetStudentID();
     player.SetVar("lmsStudent_ID", lmsStudent_ID);

Create a new variable in Storyline, titled lmsStudent_ID, and insert it as a Reference into a Text Box.

Joseph Francis

Not entirely unexpected. Depending on an organization's implementation, an LMS' student_ID field may contain the learner's Employee ID (ideal, since then it would have an easier time integrating with other enterprise applications like HRIS), a unique numeric which is auto-generated when the learner is created in the LMS and then populated into the learner's ID field in the database, or something else entirely. I wanted to see if perhaps your implementation had the data in the 2 fields transposed.