Always Learning

API Group: 

The User Info content extension leverages the existing course context to provide details about the current user like their name, ID, etc.

For example, you could use this extension to retrieve the user's first name and display a custom welcome message. You can use this in combination with the Course Info content extension to create truly customized content for users.

The only practical way to implement content extensions is with "JSONP" or "JSON-with-Padding" approach. When you invoke the content extension, you'll include the name of a JavaScript function (which you create) that our code will invoke when it loads the data. The data is passed to that function as an object, and you can use it however you wish. The last section below shows how to do this.

Note: JQuery 1.6.2 is available in the Visual Editor, and you'll need to use this. If you aren't familiar with JQuery, you can view their documentation here.

Note: You will need to use the Visual Editor's HTML mode to enter your code. HTML mode is a button at the bottom of the editor, but is not the "Plain Text Editor." Don't use Plain Text Editor, because that strips out important HTML elements.

Data Source URL

In your JavaScript, you'll request the data via this URL (see example below):

Available Data

Payload Format

This is the object that will be passed to your JavaScript function.

    "status": "success",
    "userID": "8274388",
    "clientID": "37097",
    "firstName": "eCollege",
    "lastName": "Sample",
    "login": "ecollegesample",
    "email": "",
    "role": "STUD",
    "clientString": "sample",
          "name": "City",
          "value": "Denver"

Property Descriptions

Property Name Description
userID The LearningStudio numeric User ID. You could use this if you were building a unique SSO, such as an IFrame to import institution-specific content. If you are SSO-ing to a separate application entirely, you must use a proper LearningStudio Outbound SSO.
clientID The LearningStudio institution ID. This isn't used much anymore in favor of the client string (see below).
firstName The user's first name.
lastName The user's last name.
login The user's username or login ID used for signing into LearningStudio. This is generally set by the institution and is available even if the institution manages their own Identity Management system and SSO's to LearningStudio.
email The user's email address.
role The user's role in the course. This will typically be PROF (Professor), STUD (Student), or TAST (Teaching Assistant).
clientString The institution's client string, which identifies the campus instance in LearngnStudio.
userProperties An array of variables that are defined and populated by the institution.

Using the Content Extension

To use a content extension you will need to:

  • Write a JavaScript function that will accept the data object.
  • Invoke JQuery (built into the visual editor) and use its getJSON method to call the extension.

Here's some sample code:

<script src="/CurrentCourse/jquery-1.6.2.min.js"></script><script type="text/javascript">
<!--//--><![CDATA[// ><!--
<!--//--><![CDATA[// ><!--
function processContentExtension(userData){ 
	//process the data object with object notation. 
	//for example, to get the user's first name, reference the property with: 
	document.write("Hello, "+userData.userInfo.firstName+"! Welcome to class."); 
$(document).ready(function (){
1764 reads
Always Learning