Forum Discussion
LauraMillion
11 days agoCommunity Member
Java Script pulls name from Blackboard Grade Center
I created a certificate in Storyline for compliance training. The Storyline file is published as a SCORM package and uploaded to Blackboard. Within the Storyline is a Java Script code that pulls the ...
JoeFrancis
11 days agoCommunity Member
I see a couple of potential issues. JavaScript executes code line-by-line, starting at the top. "lmsAPI" isn't defined, because what it refers to hasn't yet been defined. And "name" hasn't been defined because the function it refers to hasn't yet been defined.
GetStudentName() and GetStudentID() are functions built into Storyline, which refer to the SCORM data elements cmi.core.student_name and cmi.core.student_id respectively.
This is the code I've been using to retrieve the learner's name and then parse it, along with his/her UserID.
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_ID = lmsAPI.GetStudentID();
player.SetVar("lmsStudent_ID", lmsStudent_ID);
var lmsStudent_Name = lmsAPI.GetStudentName();
var nameArray = lmsStudent_Name.split(", ")
var niceName = nameArray[1] +" "+nameArray[0];
player.SetVar("txtStudentName", niceName);
var txtFirstName = nameArray[1];
var txtLastName = nameArray[0];
player.SetVar("txtFirstName",txtFirstName);
player.SetVar("txtLastName",txtLastName);
With the following variables declared in Storyline:
- lmsStudent_ID
- txtFirstName
- txtLastName
- txtStudentName
Related Content
- 6 months ago
- 3 months ago
- 6 months ago
- 30 days ago