Forum Discussion
Pulling first name from LMS
Hi all - I'm wondering if anyone might be able to put together a step-by-step guide as to how to set up a variable / javascript function for this? (i.e. pulling a user's first name from the LMS).
I've read through this discussion (https://community.articulate.com/discussions/articulate-storyline/retrieve-lms-user-name-as-variable) but I'm very green and have had no experience with javascript functions (and only basic variables).
Any help for dummies would be amazing.
Thanks,
Sal
- LeslieFosterCommunity Member
I am having some problems with this. If I use the technique to pull usernames etc, it only works if I publish as flash/html5 fallback. If I publish in Storyline 3 as html5 only....it does not work.
Any suggestions?
- LeslieFosterCommunity Member
Thanks for the offer. File contains 3 slides, each trying to extract the username or email. Works fine in flash, but not html5.
I use moodle as an lms.
- SallyMilfordCommunity Member
Hi Matthew,
Probably a dumb question, but I have various screens which need various combos of first/last/email/first initial etc. Can I set the screens up with the necessary references, then add this full code to 1 trigger on each screen (regardless of whether I need to call all references?)
Will this break the page as it might be calling for references that aren't on this screen? Just trying to see if I can stream line..
Thanks for your continued help with this,
Sal
(FYI I'm building an induction module which needs to display usernames, Outlook logins, etc so this is really useful).
- SallyMilfordCommunity Member
Hi again Matthew - curly one for you. Any way to remove any punctuation from a last name?
i.e. O'Bryan > obyran
Taylor-Smith > taylorsmith
(I'm looking to arrive at a reference(s) which creates a username which is <firstinitial><surname>
i.e.
Carrie O'Bryan > cobryan
Thanks,
Sal
- LeslieFosterCommunity Member
Matthew
Can I confirm what settings you had when you published it. I have been on this all day and if i set it to publish with flash or flash as fallback...it works. If I set to html5 only...it fails.
I have tested on scormcloud and in moodle.
- LeslieFosterCommunity Member
Further testing make it more bizarre (using ScormCloud):
Publish with HTML5 or HTML5+flash fallback - does not work
Publish with Flash or Flash+HTML5 fallback - works if you publish to scorm, but not if you publish to tincan
As I am using scormcloud, can I therefore assume that it is a Storyline bug?
- LucioCommunity Member
This should provide the requested results:
var lmsAPI = parent;
var name = lmsAPI.GetStudentName();
var id = lmsAPI.GetStudentID();
var nameArray = str.split(" ");
var firstName = nameArray[1];
var firstInitial = firstName.charAt(0);
var lastName = nameArray[0];
var cleanLastName = lastName.replace(/[^a-zA-Z]/g, "");
var userName = firstInitial + cleanLastName;
var userName = userName.toLowerCase();
var player = GetPlayer();
player.SetVar('first_name', firstName);
player.SetVar('last_name', lastName);
player.SetVar('first_initial', firstInitial);
player.SetVar('email', id);
player.SetVar('username', userName);- SallyMilfordCommunity Member
Thanks Lucio - you're a star :)
Just confirming, I will need the following text variables in Storyline for this to work:
first_name
last_name
first_initial
email
username
?
Thanks,
Sal
- LucioCommunity Member
Hi Sally,
Yes those are the variables required in SL.
Lucio
- LucioCommunity Member
Ooops my bad, sorry! Good catch Matthew!!
- ChrisPimCommunity Member
Nothing works if publishing HTML5 only in Moodle.
Anyone found a fix yet?
- LeslieFosterCommunity Member
Chris...
Ah.....so it is not just me having a problem!
I also have if html5/flash fallback when used in noodle.
Les
- LucioCommunity Member
Perhaps a stupid question, but do you have javascript enabled on your browsers?
- LeslieFosterCommunity Member
If I publish courses in flash or flash +html5 fallback...then everything works. If I publish in html5 only or html5 + flash fallback....nothing works, no data is pulled from Moodle. Given it works in flash with the same browser configuration, then I assume javascript is working in the browser. I have tested in Chrome, Edge and Firefox and always get the same result in all browsers.