Forum Discussion
Retrieve LMS User Name as Variable
Hello Kayode!
There is a more recent thread here about this, that starts with code that works with current Articulate 3 in HTML5 and Flash output.
Hello for your prompt response. I have read the thread. Where should I copy the JavaScript? I mean on which slide? Thanks Kayode
- KnutJackowski8 years agoCommunity Member
The JavaScript trigger has to be executed before you use the name, that you stored in a variable. Since variables in Articulate hold there value for the whole project, you can put the JavaScript trigger on the first slide.
- KayodeArowolo8 years agoCommunity Member
Hello, I'm not sure if I asked my question rightly. This is the scenario: Imagine a student logs in to his/her LMS and is going through this training course after which he/she will print out a certificate of completion that will include his/her registered name in d LMS. The module is created in Storyline 3. I have already created a certificate. How do I retrieve the name from the LMS to print on the certificate. Thanks for your help!
Kayode- EduardoRodri2358 years agoCommunity Member
Hello Kayode;
Sorry, my english it's not very well. But what you can do is get the var from moodle with java script. I can't give you an example in storyline because what you need is a connection between the lMS and the story.html file.
However I will tell you step by step the procedure that I do to validate the username of the platform:- The activity you have to create is a URL module in the LMS and in the option of parameters you have to add the name. This will encrypt the LMS name variable to the URL.
- In storyline you will create a variable named: %username%
- Insert a trigger that executes this javascript:
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\&]"+name+"=([^]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
var player = GetPlayer();
var sid = gup("username");
player.SetVar("username",sid);
- The value of the encrypted variable already has it in the file story.html and is now a variable of storyline.
- You can send that variable to a .html file where you have the certificate design. You can continue with this example for this step.
I hope this helps you
Regards.
Eduardo