Retrieve LMS User Name as Variable

Jul 09, 2012

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?

Thx

214 Replies
James Bonney

Hi Steve,

Cheers for that, I'll give that one a go.

I was using the most recent code you posted previously (to me) on page 6 of this thread.

With 360 giving us the option for a preferred HTML5/Flash priority, how is this going to affect the choice of code we use? Could we encounter certain code not working depending on the format the course launches in?

Or would we need two triggers for the two different types of JS code? 1 for HTML5 and 1 for flash?

 

Sally Milford

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 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

Kayode Arowolo

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  

Eduardo Rodriguez

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:

  1. 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.
  2. In storyline you will create a variable named: %username%
  3. 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);

  4. The value of the encrypted variable already has it in the file story.html and is now a variable of storyline.
  5. 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