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?
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...
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);
I have this working from the SCORM cloud and the same code does not work in the ArticulateOnline environment. Thoughts?
Articulate Online uses xAPI not SCORM. Getting the username through the AO implementation is a little more challenging. You can grab a username from AO using DOM in JavaScript to grab the username displayed on the screen. However, this is rarely usable in a Firstname Lastname format. Depending on what you're trying to do, you may be out of luck.
Consider engaging support with a request. Maybe there's something in AO that you can employ that I'm not aware of.
Are the only options lmsAPI.GetStudentName(); and lmsAPI.GetStudentID(); . Is it possible to pull any other fields from Moodle like if you had a custom company field set-up. Has anyone managed to pull any other data from an LMS?
You’ll need a variable to hold the username; I choose “username”. I set the default value to “Guest” just in case anything went wrong.
Then set up a trigger to run the JavaScript that will fetch the name and stuff it in our variable. I am using a Slide Trigger set to run when the timeline starts.
And now put the following code in the Javascript section of your trigger.
//grab the LMS object var lmsAPI = parent //ask the LMS object to get the name var rawName = lmsAPI.GetStudentName(); //the name comes very formal "Last, First" //we will fix that by sticking the name into an array var nameArray = rawName.split(",") //then we save it the other way round "First Last" var niceName = nameArray[1] +" "+nameArray[0]; //now we grab the Articulate player var p = GetPlayer(); //finally we set our Articulate var to our username p.SetVar("username",niceName);
Has anyone tried using this code to get the student's name from SumTotal LMS? I used it for one of my clients that works with SumTotal, but they are telling me they are not getting the name in the certificates.
I've tried searching info on google, but no success.
Seriously guys you really are the heros - I got the elearn to read the students name into the feedback for their results using the lmsAPI functions, brilliant !
I used the javascript code given in this forum and it works fine for me.
The problem is I also got bookmark feature "Prompt to resume on presentation restart'' which gets stop as soon as I use this javascript code to get the Learner's name.
Is there any way that I can have both features in my course?
I'm trying to display student name and date in the certificate, that appears on the Result slide. I have used the "Execute Javascript" trigger with code written like:
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var date1 = new Date();
player.SetVar("displayDate", date1);
player.SetVar("studName", myName);
Now the problem is it is not working in iOS device, as HTML5 output is running there.
Is there any way to execute javascript in HTML5 output also?
If not, then how can I fetch Student name and Current date in Articulate Storyline 2, so that they can be displayed in the Certificate.
Has anyone figured out how to achieve the ability to pull a student name from the LMS which is supported in HTML5? I've been watching this thread for quite some time hoping for a solution. Is it just not possible?
I have been actually able to do that now in HTML5 too. I have used the same javascript code to fetch student name from LMS and current date.
The only difference is I have not used the code in the result slide where the certificate will appear. I have used the code at the very first slide of my course and stored them in Storyline variables. In the certificate popup in result slide, I have just used those 2 Storyline variables.
I have been actually able to do that now in HTML5 too. I have used the same javascript code to fetch student name from LMS and current date.
The only difference is I have not used the code in the result slide where the certificate will appear. I have used the code at the very first slide of my course and stored them in Storyline variables. In the certificate popup in result slide, I have just used those 2 Storyline variables.
It worked in IOS 7 that I'm testing!
Hi Tanmay,
That's a pretty cool workaround, would you be willing to share a sample file of how you did that? Thanks a ton!
Looks like you resolved this below. There isn't a good reason why the code you've shown here wouldn't work in HTML5. I am not sure if iOS will like the Date() object pushed into a variable.
I've used the same code for both Flash based and HTML5 output for quite awhile and it's worked consistently in all cases.
When testing, use a modern browser's console to show where the script is being stopped.
213 Replies
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 ????
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);
Thank you Steve; that works perfectly.
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
I have this working from the SCORM cloud and the same code does not work in the ArticulateOnline environment. Thoughts?
Articulate Online uses xAPI not SCORM. Getting the username through the AO implementation is a little more challenging. You can grab a username from AO using DOM in JavaScript to grab the username displayed on the screen. However, this is rarely usable in a Firstname Lastname format. Depending on what you're trying to do, you may be out of luck.
Consider engaging support with a request. Maybe there's something in AO that you can employ that I'm not aware of.
Are the only options lmsAPI.GetStudentName(); and lmsAPI.GetStudentID(); . Is it possible to pull any other fields from Moodle like if you had a custom company field set-up. Has anyone managed to pull any other data from an LMS?
You’ll need a variable to hold the username; I choose “username”. I set the default value to “Guest” just in case anything went wrong.
Then set up a trigger to run the JavaScript that will fetch the name and stuff it in our variable. I am using a Slide Trigger set to run when the timeline starts.
And now put the following code in the Javascript section of your trigger.
//grab the LMS object
var lmsAPI = parent
//ask the LMS object to get the name
var rawName = lmsAPI.GetStudentName();
//the name comes very formal "Last, First"
//we will fix that by sticking the name into an array
var nameArray = rawName.split(",")
//then we save it the other way round "First Last"
var niceName = nameArray[1] +" "+nameArray[0];
//now we grab the Articulate player
var p = GetPlayer();
//finally we set our Articulate var to our username
p.SetVar("username",niceName);
Hi all,
Has anyone tried using this code to get the student's name from SumTotal LMS? I used it for one of my clients that works with SumTotal, but they are telling me they are not getting the name in the certificates.
I've tried searching info on google, but no success.
Thanks!
Julio, we use SumTotal LMS and the code is working great for us. PM me with your email address and I'll forward you a sample .story file we've tested.
Seriously guys you really are the heros - I got the elearn to read the students name into the feedback for their results using the lmsAPI functions, brilliant !
Thanks
Orla, I agree, I absolutely love all of the creative and helpful ideas in this community. Learn something new just about every day here!
Hi guys,
I used the javascript code given in this forum and it works fine for me.
The problem is I also got bookmark feature "Prompt to resume on presentation restart'' which gets stop as soon as I use this javascript code to get the Learner's name.
Is there any way that I can have both features in my course?
I used following code for user name:
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);
I love this community - we were just discussing this morning whether this would be possible - and here it is, demo and all.
Thank you so much :)
Glad that this thread helped you out Miranda!
Hi,
I'm trying to display student name and date in the certificate, that appears on the Result slide. I have used the "Execute Javascript" trigger with code written like:
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var date1 = new Date();
player.SetVar("displayDate", date1);
player.SetVar("studName", myName);
Now the problem is it is not working in iOS device, as HTML5 output is running there.
Is there any way to execute javascript in HTML5 output also?
If not, then how can I fetch Student name and Current date in Articulate Storyline 2, so that they can be displayed in the Certificate.
Tanmay
Hi Tanmay,
Javascript is not something we offer support for, but I did want to point you to the information in regards to our Javascript best practices and examples.
Has anyone figured out how to achieve the ability to pull a student name from the LMS which is supported in HTML5? I've been watching this thread for quite some time hoping for a solution. Is it just not possible?
Hi,
I have been actually able to do that now in HTML5 too. I have used the same javascript code to fetch student name from LMS and current date.
The only difference is I have not used the code in the result slide where the certificate will appear. I have used the code at the very first slide of my course and stored them in Storyline variables. In the certificate popup in result slide, I have just used those 2 Storyline variables.
It worked in IOS 7 that I'm testing!
Hi Tanmay,
That's a pretty cool workaround, would you be willing to share a sample file of how you did that? Thanks a ton!
Hi Alex,
I have attached the Story file with that workaround.
Thanks, Tanmay
Thanks Tanmay for coming back to share the file here!
Thanks for sharing Tanmay!
Looks like you resolved this below. There isn't a good reason why the code you've shown here wouldn't work in HTML5. I am not sure if iOS will like the Date() object pushed into a variable.
I've used the same code for both Flash based and HTML5 output for quite awhile and it's worked consistently in all cases.
When testing, use a modern browser's console to show where the script is being stopped.