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?
I know this is old but other than the student's name, is there any other information that could be retrieved from Moodle such as number of attempts? Is there a list of api commands, i.e.: "getstudentname()", available somewhere?
Hopefully there are some users still subscribed to this thread that will be able to pop in and assist you here. If not, feel free to reach out to a user directly via the 'Contact Me' option on the user profile.
Hi Julie - JavaScript coding is not something that is supported by Articulate, but there is a lot of information here and much more recent than when the thread was started. Hopefully you'll find something to best assist you or someone will be able to chime in and assist.
JS *works* in Storyline. Because it's a great big topic and is an extension of Storyline (not a core function) Articulate support staff cannot *support* JS in Storyline. Falls outside the definition of support at the moment.
There is good news! The community is full of folks willing to help out and offer advice.
Realizing that this post is 4 years old....I was unable to open your SL file as it was made with an older version. I am running Storyline 2 Update 11. Can you save and post with a later version?
Rick, we also use SumTotal. I've got a couple of working examples of this script in Storyline 2 that we've tested in SumTotal. Let me know if you have trouble getting things working.
213 Replies
Hey Jennifer! Welcome to the E-Learning Heroes community - assistance like you're getting above is the best welcome I could think of!
Thank you, everyone! What a great response! I got it to work! Yay!
Hi All,
In SL1, this code works for me on my Moodle LMS, but in SL2, it doesn't pull the name through. Can anyone tell me why it's no longer working?
var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1];
player.SetVar("newName", newName);
Thanks
James
Give this a shot:
var player = GetPlayer();
lmsAPI=parent;
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1];
player.SetVar("newName", newName);
Steve, I salute you. Once again helping me out on here.
Really appreciate, thank you!
Hi Phil,
I know this is old but other than the student's name, is there any other information that could be retrieved from Moodle such as number of attempts? Is there a list of api commands, i.e.: "getstudentname()", available somewhere?
Thanks
Hi Lucio!
Hopefully there are some users still subscribed to this thread that will be able to pop in and assist you here. If not, feel free to reach out to a user directly via the 'Contact Me' option on the user profile.
Hi Lucio,
The only one I know if is student name.
Sorry I couldn't be of more help.
Thank you both Leslie and Philip to get back to me.
In the meantime, I found this:
https://community.articulate.com/discussions/articulate-storyline/help-with-javascript-and-pulling-data-from-an-lms
Though I haven't tested any of it yet, it may help someone in the future.
Thanks for sharing Lucio :) There's a wealth of knowledge on the forums for sure.
This post is over four years old and I was wondering if there is an example for Storyline 2 and one that actually works with HTML5? Thanks!
Hi Julie - JavaScript coding is not something that is supported by Articulate, but there is a lot of information here and much more recent than when the thread was started. Hopefully you'll find something to best assist you or someone will be able to chime in and assist.
Hi, Julie -
This one works fine for me in HTML5. The problem with the beginning of the thread was the use of a function that only worked in Flash. The example below is available to both Flash and HTML5:
https://community.articulate.com/discussions/articulate-storyline/retrieve-lms-user-name-as-variable?page=6#reply-388873
var player = GetPlayer();
lmsAPI=parent;
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1];
player.SetVar("newName", newName);
I think I am confused regarding JS not supported in Storyline...we have JS codes for various things so how is it not supported?
Thank you
JS *works* in Storyline. Because it's a great big topic and is an extension of Storyline (not a core function) Articulate support staff cannot *support* JS in Storyline. Falls outside the definition of support at the moment.
There is good news! The community is full of folks willing to help out and offer advice.
Could not have said that better myself Steve :) Thanks!
Well that is good to know. I hope for SL3 or 360 JS gets support because many people tend to have questions.
Hi Phil,
Realizing that this post is 4 years old....I was unable to open your SL file as it was made with an older version. I am running Storyline 2 Update 11. Can you save and post with a later version?
Thanks Rick
Hi Rick
when you try to open the file it should give you the option to upgrade to SL2 - do you not see that pop up box?
Hey Rick - perhaps you're just having difficulty with the older file. Re-attaching here for you to try as Wendy's suggestion should assist :)
Hi Steve,
I am using your JS code above and am pointing to a text field object called "Name".
Can you offer some suggestions as to what I might be doing wrong. See attached.
I am using SL2 update 11 with SumTotal.
Thanks Rick
Hi Rick
what is in the ... code window and do you want the code to Execute when the timeline of the slide starts - you have it set on the variable 'name'.
Thanks Wendy and Leslie.
I was able to open the file. Will let you know how it goes.
Rick
Glad that was able to assist Rick :) Thanks for letting me know. Good luck with your project.
Rick, we also use SumTotal. I've got a couple of working examples of this script in Storyline 2 that we've tested in SumTotal. Let me know if you have trouble getting things working.