Forum Discussion
Retrieving Data from LMS
Hello all,
Hoping to get pointed to the right resources. I'm trying to retrieve 'firstName' data from LMS into Storyline file. I've exported an xAPI package and published in LMS trying some JS I found in this forum, but have had no luck.
I've scoured through this forum for similar conversations and only see threads from 8+ years ago. Would anyone be able to point me in the right direction or share any recent sample files that demonstrate JavaScript in a current version of Storyline?
Also, if there is a list of current javascript functions available for other types of data collection that would be helpful. Thank you!
- MathNotermans-9Community Member
You need to access the LMSAPI for that.
I written a function i reuse over and over to get the users name. In my code i have a if/then wrapped around it to check whether the url is run from a LMS or plain Webpage. The difference is that when testing as plain HTML5 you donot have access to a usersname and thus will return nothing. Removed that for ease for now..
This is how it looks then on the LMS, Instructure Canvas in my case..
This is the code used on start of the slide:// when published as Scorm on a LMS
let player = GetPlayer();
let lmsAPI = findLMSAPI(this);
let myName = lmsAPI.GetStudentName();
let array = myName.split(',');
let newName = array[1] + ' ' + array[0];
player.SetVar("newUser", newName);
console.log("newUser: "+myName);
//Function to connect with LMSAPI
function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) {
return win;
}else if (win.parent == win) {
return null;
}else {
return findLMSAPI(win.parent);
}
}
And for ease, the Storyline attached.
Kind regards,
Math
- RickyRatcliff-1Community Member
- MathNotermans-9Community Member
Probably , but that depends on your LMS. As Storyline has the option to export a Scorm and xApi in one package and you can use LMSApi functionality next to your xApi statements, you probably ( you have to test this ) get your LMSApi data as before.