Using JavaScript to get variable from LMS
Nov 14, 2019
I found a JavaScript that allows me to pull the learner's name from the LMS and appear as a text variable within the Storyline project. This is particularly useful where I have some examples of documents where the learner's name needs to appear. What I would also like to do is display the learner's manager's name; also pulled from the LMS. I am using Bridge LMS and have seen that the manager's name is there. Below is the JavaScript that display's the learner's name. Can anyone help with the manager's name?
// Display learners lastName
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 newName = "Guest";
if (lmsAPI)
{
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
if (array.length>2)
{
newName = array[2];
}
else
{
newName = array[0];
}
}
player.SetVar("lastName", newName);
2 Replies
Matthew,
hat's a bummer. Since i was able to get the learner's name from the LMS i really thought i could pull in other variables.
Matthew,
i am teaching the learners how to handle a special document. In real life the document will already have the learner's name and their manager's name.
I thought it would be cool to have the real info in the lesson rather than "John Doe" and "Susan Smith" appear on the document.
Knowing that i can pull the learner's email address from the LMS and display in a Storyline project may be of help in a future lesson. Thanks.
This discussion is closed. You can start a new discussion or contact Articulate Support.