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!
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.
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, strFirstNameand strLastName.
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!
In your LMS, is Jane Doe's student_IDJane Doe and the student_nameBob? 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.
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.
10 Replies
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.
Hallelujah! It worked! Although the variable reference in Storyline needed to be set to lmsStudent_Name (not lmsStudentName) as mentioned above.
Thank you!
I actually just realized it is grabbing the username instead of the first name. Do you know what I need to change to get the first name?
Fixed (for the next reader).
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.
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!
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.
Good idea! But it returns the number of the order the user was created. For my ID it was "2" and for a fake student user we created it was "5".
The code obviously works I just can't figure out the actualy field for "Name." I wil try contacting Opigno.
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.
FYI--it was a setting in the LMS. We had to set the name as the actual name instead of the username. It works now!