Retrieving Data from LMS

Aug 24, 2022

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!

4 Replies
Math Notermans

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..

username

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
 

Robert Webbe

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.