You may have seen this latest product over at eLearningEnhanced.com It lets you display the students name (from the LMS) in your course content. Check out the screenr to see it in action.

You may have seen this latest product over at eLearningEnhanced.com It lets you display the students name (from the LMS) in your course content. Check out the screenr to see it in action.

I thought some of you might like to see how I did it.
There are two pieces to this widget.
1. A small change to Articulate’s lms.js file.
2. The Flash file which will ‘talk’ to the lms.js file.

Let’s take a look at the code in both…

The lms.js is Articulate’s JavaScript that allows it to talk with almost any LMS (nice job Rustici). We need to extend it just a bit with a new function which will tap into it’s built in functions. Here is my code (it’s very simple):

function FindStudentName(){
	return lmsAPI.GetStudentName()
}

I just stuck that at the end of the file.

Next is our Flash file… again very simple. Just has one frame, a dynamic text field and some AS2.

import flash.external.ExternalInterface;
var userName:String;
var rtnData:Object;
if (ExternalInterface.available) {
	rtnData = ExternalInterface.call("FindStudentName");
	if (rtnData != null) {
		userName = rtnData.toString() 
	} else {
		userName = "Guest";
	}
}
name_txt.text = userName;

First I set up the communication with JavaScript.
Then I create a string to hold the name and an object to hold the data returned from the JavaScript.
I put the actual JS call to our new function in an IF statement just in case we can’t make the call… in that case we set the user name to “Guest”.
Now… most LMSes will return the username backwards Last, First. I don’t think that is very friendly so added a function to turn things around. Here is all my code together:

import flash.external.ExternalInterface;
var userName:String;
var rtnData:Object;
if (ExternalInterface.available) {
	rtnData = ExternalInterface.call("FindStudentName");
	if (rtnData != null) {
		userName =  rearrangeName(rtnData.toString());
	} else {
		userName = "Guest";
	}
}
name_txt.text = userName;

function rearrangeName(lastNameFirst:String):String {
	var tmpArray:Array = lastNameFirst.split(",");
	return tmpArray[1]+" "+tmpArray[0];
}

I hope this helps!
And remember for more widgets and/or custom eleaning solutions please visit www.eLearningEnhanced.com

8 Comments. Leave new

  • Grab Name and Course Name
    I wonder if this could be modified and combined with some code that would allow me to create a custom “Course Completion” certificate.

    Here is what I wish I had.

    The ability to grab the users name from the LMS.
    The ability to grab the course name from the LMS.
    The ability to grab the date from the LMS.

    Then place the flash file on an Articulate (ppt) slide that was a certificate that I design around the insert.

  • This would be possible.
    But

    This would be possible.
    But it wouldn’t be formatted very nicely for printing… The slide size and shape won’t fit cleanly on a page.
    Let me think on it some….

  • Thanks James, worked first
    Thanks James, worked first time, thank you for sharing

    Phil

  • First Name Only
    I like this widget, but I wish I could grab the user’s first name only… Like “Hello Jim” Not “Hello Jim Smith”

    • First name only?
      That was my reaction, too – is there a way to do this? I think it would look more friendly than using the learner’s full name.

    • I know I am a little late to
      I know I am a little late to the party, but…

      You should be able to get the First Name by modifying the last line of the rearrange function:
      return tmpArray[0];
      (Assuming your LMS username comes out like “Last Name”,”First Name”).

      Hope that helps.

  • Annette Grazulis
    April 10, 2012 3:33 pm

    Not working
    We built this and it is not working with our lms (Success Factors) anyone know why? It is just saying undefined.

Menu