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
- JørgenNielsenCommunity Member
Sorry, that I'm repeating my question, but I never got an answer:
lmsAPI.GetStudentName() is working for me, but SCORM_GetStudentName() is not - why?
I'm looking for a way to read/write values to lesson_location in SCORM 1.2, but lmsAPI does not offer a method for that. SCORM_CallLMSGetValue and SCORM_CallLMSSetValue in SCORMFunctions.js would be perfect, but how do I call them from my javascript?
- PhilMayorSuper Hero
I dont know, I avoid writing to scorm because I expect that the course would overwrite what you are attempting
- BrettRockwoodCommunity Member
Can I revisit this topic again? Using Phil's JavaScript I can get the student's full name from the LMS no problem. But I'd like to just get the first name to put a little personalization into the training, e.g. "Hi Erika, welcome to today's session...". How would I need to modify the script to pull just the first name?
Here is the full name script:
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);
//myName = player.GetVar('myName');
//player.SetVar("newName", newName);
Thanks as always.
- anoyatisCommunity Member
Hi Brett,
You should be good to go this to capture only first name :
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[0];
player.SetVar("newName", newName);
- rathnakumaran-fCommunity Member
Thanks a ton! Alex for sharing this script to capture only first name from LMS.
- BrettRockwoodCommunity Member
Hi Alexandros,
Thanks for the speedy reply, the Articulate forums are amazing!
This script almost does it... On our LMS though it pulls down the last name rather than the first. Any thoughts?
- BrettRockwoodCommunity Member
Andrew, that does it. Figured it was something simple like that. Now the only problem is the way names have been entered in our LMS. It looks like some people (me, for example) have their middle initial as part of their first name... [sigh]. Still, it is working and it's better than the whole name.
Thanks to you both.
- JennyAndersonCommunity Member
Brett,
We're both running across the same situation (LMS pulling the middle initial). Did you find a solution?
- BrettRockwoodCommunity Member
Hi Jenny,
Unfortunately, no. I don't know how you could separate out an initial if it was entered as part of a first name. My first thought was to see if there was some kind of script that could limit the name to just one word but quickly realized that, even if were possible, it would mess up a lot of people who have first names like Ellie May and Billie Jean...
- PhilMayorSuper Hero
Have you set a text variable in Storyline called newName?
- tomwatsonCommunity Member
hey can you tell me about this LMS...