Pulling first name from LMS
Apr 19, 2017
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
44 Replies
"Test and celebrate" 😄Â
I'm definitely bookmarking this for future reference. Thanks for popping in to help, Matthew!
LEGEND!!! Thanks so much Matthew – it worked! J
Sally Milford
Online Learning Co-ordinator | Alzheimer's Australia Vic
155 Oak Street Parkville VIC 3052
p: +61 3 9816 5715 | f: +61 3 9816 5733 | e: Sally.Milford@alzheimers.org.au
w: www.fightdementia.org.au/vic
For more information or support call the National Dementia Helpline 1800 100 500
[cid:image04c0f7.PNG@782dabdf.49ab508b]
[cid:image9012aa.PNG@0405ee47.41b28567] [cid:image80933a.PNG@da38934d.448e8541] [cid:image507196.PNG@b0e1ed36.4aa4578f] [cid:image4299e8.PNG@5426a41f.4296c905] [cid:image3dd57a.PNG@7456ccc9.419c82c7] [cid:image3f6647.PNG@cd7a83fa.40bb3878] [cid:image2841d6.PNG@c259a276.4aa0b90b]
DEMENTIA IS A NATIONAL HEALTH PRIORITY
Alzheimer's Australia Vic would like to acknowledge the traditional owners of the land on which we meet and pay our respects to Elders both past & present.
PRIVACY STATEMENT: This email, and any attachments, contains confidential information intended only for the person/s named above and may be subject to legal privilege. If you are not the intended recipient, any use, disclosure, copying or distribution of this transmission is prohibited. If you have received this message in error, please notify the sender immediately by return email and delete the original email and any attachments.
Hey Sally! I wanted to mention that responding via email includes your email signature here. No worries on our end—just wanted to let you know in case you didn’t want to share it publicly. :)
Hi Mathew,
Thanks for your input!!
I'm just curious, is it necessary now to declare lmsAPI?
I guess it can't hurt to declare it as "parent" though I haven't been using that line in my cw with SL2, SCORM 1.2. I guess I'll integrate it in my process.
Thank you for the reply Mathew!!
Hi all - further to this, am I able to pull the following from the LMS?
- first initial of first name
- email address
Thanks in advance!
Sal
Mathew,
Wouldn't firstName.charAt(0) work better in this case?
Lucio
Â
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?
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.
Thanks for letting me know - that's good to know.
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).
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
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.
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?
This should provide the requested results:
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
Hi Sally,
Yes those are the variables required in SL.
Lucio
Â
Thanks Matthew and Lucio - this is working great :)
Except in one instance, when calling to display the last name, a random comma appears after it.
This is what I have used:
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);
This is how the reference appears on the slide:
Username: CORP\%first_name%.%last_name%
This is how it appears when published:
Username: CORP\Sal.Milford,
Surname is definitely just Milford in the LMS. Any ideas?
Thanks,
Sal
Ooops my bad, sorry! Good catch Matthew!!
Nothing works if publishing HTML5 only in Moodle.
Anyone found a fix yet?
Chris...
Ah.....so it is not just me having a problem!
I also have if html5/flash fallback when used in noodle.
Les
Perhaps a stupid question, but do you have javascript enabled on your browsers?
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.
Yes as Leslie says. JavaScript is enabled. It's a definite problem with the script, 360 and Moodle. In storyline 2 the same script works properly.
I'm still on SL2 and will be for a while. Sorry I can't help!!