Forum Discussion
Retrieving Data from LMS
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-13 years agoCommunity Member
- MathNotermans-93 years agoCommunity 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.
- RobertWebbe-4042 years agoCommunity Member
Hi Math,
I'm also in need for a solution to retrieve the user's name in case of a xAPI export. Your story file works great in case I publish in SCORM but not in case of xAPI. You wrote that Storyline has the option to export a SCORM and xAPI in one package. Can you tell me how that's done? The only way I can think of is publish a SCORM en publish a xAPI and then manually merge it. I hope there is a faster and smarter way because this is a hassle for every publication.