Forum Discussion
Retrieve LMS User Name as Variable
I know you can have a user fill in a text box with their name and then later use that variable for personalization. What we would like to do is programmatically retrieve the user name from the LMS. Is there a way to set a variable with data from the LMS when the course is loaded instead of having the user enter their name?
Thx
- ChrisFCommunity Member
Does anyone have the Javascript that changes the first letter of username (pulled from lms) to a capital?
I have seen it on the forums somewhere, but cannot seem to find it.
Hi Chris! Hope you get some assistance from the community with this
- AlexYong1Community Member
Hello Folks!
Just wanted to re-post my question about this. Has anyone figured out how to get this to work with the HTML 5 output so the experience will be the same on a tablet?
- JørgenNielsenCommunity Member
Hello Chris
If the name is in a variable called stName, you can use this:
stName = stName.charAt(0).toUpperCase() + stName.slice(1);
- DanielIveyCommunity Member
I already have a storyline certificate which publishes the StudentName from the LMS and Date from the users computer, however I was hoping to add the Student ID. I don't know much javascript so apologies for the poor chopped code!
Here is what I have so far, I'm assuming Student ID from the LMS is just GetStudentID?? And employeeID is the variable I'm using in Storyline
var player = GetPlayer();
var employeeID = lmsAPI.GetStudentID();
player.SetVar("employeeID", employeeID);
- CaesarAycochoCommunity Member
thanks. this thread is really an eye opener. i like the fact that you can pull LMS data and use it in your Storyline course.
- OwenHoltSuper Hero
Can you use javascript to:
1) analyze the native string pulled from the LMS to detect if it ends with a space followed by a letter
2) if it does, remove the space and the letter
and then 3) perform the split string operation as described in this thread.
Would this work to get rid of those pesky middle initials in those cases where the name is listed as Last, First + Initial ????
- SteveFlowersCommunity Member
Yep. This should work. Looks for the last space. If the last space is the next to last character, strip it off. Otherwise, keep it.
var LMSName="flowers, steve t";
if(LMSName.lastIndexOf(" ")==LMSName.length-2){
//has an initial
LMSName=LMSName.substring(0,LMSName.length-2).split(",");
nameOut=LMSName[1]+" "+LMSName[0];
}else{
//no initial
LMSName=LMSName.split(",");
nameOut=LMSName[1]+" "+LMSName[0];
}
document.write(nameOut);
- OwenHoltSuper Hero
Thank you Steve; that works perfectly.
- DietmarGrasböckCommunity Member
Thanks a lot for all of your work
One question regarding the Name variable. Once it has been grabed from LMS, it can simply be displayed in the content slide with a code like %newName%.
My question: is there a way, to show the text variable in the player menu, for example in the upper left or right area of the player?
I tried a few things, but unfortunately without success...
maybe some tips from the experts here?
best regards, Didi