Forum Discussion
What other information can be accessed from the LMS API using JavaScript
Hoping the community can help me figure this out. I am currently using this JavaScript to retrieve the learner's name from the LMS:
var lmsAPI = parent;
var name = lmsAPI.GetStudentName();
var nameArray = name.split(",");
var firstName = nameArray[1];
var lastName = nameArray[0];
var player = GetPlayer();
player.SetVar('first_name',firstName)
player.SetVar('last_name',lastName)
Wondering what other information we might be able to retrieve from the LMS API, such as course name or completion information. Our overall intent is to make a custom completion certificate where all of the learner's detail is system generated.
Any insight or suggestions for different approaches would be greatly appreciated.
Thanks
Mark
- JamesMartin-49fCommunity Member
All I've found you can pull (assuming you publish to some version of SCORM) is student name, as you've demonstrated. I'd really, like to be able to pull course title and student email address. But I haven't found a way to do it.
Here's my more verbose way of doing student first name and last name:
// Only works if published via SCORM
if (typeof lmsAPI != "undefined") {
var LMSName = lmsAPI.GetStudentName();
var nameArray = LMSName.split(',');
var lastName = nameArray[0];
var firstName = nameArray[1].trim();
var fullName = firstName + ' ' + lastName;
console.log('Published via SCORM: lmsAPI is available');
console.log('fullName: ' + fullName);
console.log('learnerEmail: ' + learnerEmail);
} else {
console.log('lmsAPI does not exist. Did you publish as xAPI?')
} - MarkSetlock-b41Community Member
Hi James.
Thanks for the response. You are correct in assuming we are using SCROM (2004 1.4 to be exact). I have been working with some colleagues on the data side of things and it doesn't appear that there is a realistic way to obtain that information on the path that I am on. That said, there are some options built into our LMS (Workday learning) that may solve for this.
If I get any further information relevant to this, I will be sure to post!
- JamesMartin-49fCommunity Member
I appreciate that, Mark. I'll do the same.