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?
Should be able to grab the value through a JavaScript function. This won't work in HTML5 at the moment but should be fine in the Flash based version. Try this in a JavaScript trigger:
This'll grab the Student Name using the built in function in SCORMFunctions.js and push it into a variable called sLearnerName. If you need to arrange it differently you may need to split to an array and arrange the First / Last as separate parts before pushing in.
Haha, that's what I get for multi-tasking. Phil's example demonstrates it the rearrangement. lmsAPI.GetStudentName() and SCORM_GetStudentName() should return identical values.
You're correct, Steve. Works great in Flash, but epic failure in HTML5. Bummer...HTML5 is a deal breaker for my organization. Thanks to both for your quick replies.
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? Do I need a src-statement?
Slightly off topic but I was wondering if you could use something similar to pull down a student's business unit or cost center. This would be really great in that you could then have the course automatically present the material that is applicable to a particular team.
I pretty limited in my LMS/SCORM knowledge; are there standard names like that that can be pulled down?
I agree with you, though. There are many pieces of information that I think could be carried forward from the LMS to customize / adapt to the needs of the user. I think things like accessibility preferences would be VERY useful.
Thanks Steve. Yes, accessibility would be excellent. I'm going to do some research and find out just what is available in the LMS we're using. I could imagine having language based on location and many other customizations.
An option if you have the ability to customize your LMS. We had our vendor code a second API that is initialized with the SCORM API that allows us to call a custom data set for exactly what you are looking for.
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?
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?
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.
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...
I am trying to pull information from the LMS and save into Storyline variables. To start off, I'm trying to grab the user's name. I used the Javascript code shown in this thread but it doesn't work for me.
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);
Do I have to change something based on the particular LMS I'm using? What could be the problem?
I placed your script on a button and showed the variable in a text field. It works OK in SCORM Cloud LMS. When you click the button, your student name shows up in the text field. I attach my example.
I tried the file attached from Jorgen and I still cannot get it to work. When I click the button that should get the student name, the text reference field goes blank. The LMS I am using is called LearnFlex and I am publishing to SCORM 1.2 if that makes any difference as well.
213 Replies
There is a slide in this that does just that
Winner, winner, chicken dinner...Thanks, Phil! Very much appreciated.
Hey, Andrew -
Should be able to grab the value through a JavaScript function. This won't work in HTML5 at the moment but should be fine in the Flash based version. Try this in a JavaScript trigger:
var player=GetPlayer();
player.SetVar("sLearnerName", SCORM_GetStudentName());
This'll grab the Student Name using the built in function in SCORMFunctions.js and push it into a variable called sLearnerName. If you need to arrange it differently you may need to split to an array and arrange the First / Last as separate parts before pushing in.
Haha, that's what I get for multi-tasking. Phil's example demonstrates it the rearrangement. lmsAPI.GetStudentName() and SCORM_GetStudentName() should return identical values.
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);
You're correct, Steve. Works great in Flash, but epic failure in HTML5. Bummer...HTML5 is a deal breaker for my organization. Thanks to both for your quick replies.
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? Do I need a src-statement?
Slightly off topic but I was wondering if you could use something similar to pull down a student's business unit or cost center. This would be really great in that you could then have the course automatically present the material that is applicable to a particular team.
I pretty limited in my LMS/SCORM knowledge; are there standard names like that that can be pulled down?
Hey, Brett -
Unless someone's storing a value in the data model to bend in that type of info, this usually isn't exposed.
http://scorm.com/wp-content/assets/scorm_ref_poster/RusticiSCORMPoster.pdf
I agree with you, though. There are many pieces of information that I think could be carried forward from the LMS to customize / adapt to the needs of the user. I think things like accessibility preferences would be VERY useful.
Thanks Steve. Yes, accessibility would be excellent. I'm going to do some research and find out just what is available in the LMS we're using. I could imagine having language based on location and many other customizations.
An option if you have the ability to customize your LMS. We had our vendor code a second API that is initialized with the SCORM API that allows us to call a custom data set for exactly what you are looking for.
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?
I dont know, I avoid writing to scorm because I expect that the course would overwrite what you are attempting
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.
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);
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?
That's because the student name is stored as first name last. Set the array[1] to get the first name.
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.
Brett,
We're both running across the same situation (LMS pulling the middle initial). Did you find a solution?
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...
Hi all,
I am trying to pull information from the LMS and save into Storyline variables. To start off, I'm trying to grab the user's name. I used the Javascript code shown in this thread but it doesn't work for me.
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);
Do I have to change something based on the particular LMS I'm using? What could be the problem?
Hi Vince,
I placed your script on a button and showed the variable in a text field. It works OK in SCORM Cloud LMS. When you click the button, your student name shows up in the text field. I attach my example.
Have you set a text variable in Storyline called newName?
hey can you tell me about this LMS...
I tried the file attached from Jorgen and I still cannot get it to work. When I click the button that should get the student name, the text reference field goes blank. The LMS I am using is called LearnFlex and I am publishing to SCORM 1.2 if that makes any difference as well.
I appreciate the help everyone.
Sorry I only checked it with Moodle it may be that your LMS does not support this