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
- MattGalbraith1Community Member
Hello! I'm having some trouble getting a Student ID to display. I set an alert to get the Student ID and it pops up with the info displayed perfectly, but I can't seem to transfer that StudentID variable into my Storyline project. Here is my code:
var player = GetPlayer ();
var learnerID = lmsAPI.GetStudentID();
player.SetVar("learnerID", learnerID);
It might help to note that we use Cornerstone for our LMS. Any ideas?
Hi Matt!
Hopefully someone will chime in to assist you here or you are welcome to reach out to users directly via the 'Contact Me' option on their user profile if needed.
I did want to pop in and let you know that we have a pretty extensive thread with our Cornerstone LMS users that I thought you might want to know about for sure :)
- MattGalbraith1Community Member
Thanks, Leslie! Didn't know about the Cornerstone user thread.
- SteveFlowersCommunity Member
Try adding this before you call lmsAPI.GetStudentID():
lmsAPI=parent;
- MattGalbraith1Community Member
I must have had a typo in my code in the trigger I set up. I just recreated the trigger with the same code as above and was successful.
- BrianAllenCommunity Member
Sweet! Glad to hear you got it working. I love this thread...
- MattGalbraith1Community Member
Thanks for the reply, Steve! I had tried adding that line earlier, thinking that was the problem, but had no luck. I must have just messed up the code somehow because it's working now.
- MattGalbraith1Community Member
I'm now trying to use the same script as my earlier post to grab the course ID (replacing StudentID with CourseID and learner with course in script), but can't seem to get it to return. I've tried to set up an alert like this:
alert(lmsAPI.GetCourseID());
But no pop-up message appears. I tried to add the var lmsAPI = parent line, but no luck. I double checked the variable name in the AICCFunctions.js file and there is a variable titled AICC_CourseID. Any idea why this isn't coming back for me, yet I get the StudentID with no problem?
- EduardoRodri235Community Member
Hello!,
It works in SCORM 1.2 but if I want to know the User's ID. How can I get it? Hi Eduardo,
You'll need to click on the user's name to visit their profile. Then you'll see a "contact me" button to reach out to them specifically.
- EduardoRodri235Community Member
Thank you Ashley!