Data Exchange Javascript API

Standard browser cross-site scripting security prevents externally hosted activities from accessing the SCORM+ Javascript API object. However, using the Data Exchange Javascript (DEJS) API, you can still host your activity on an external web server and update the gradebook with learner results and store learner-specific activity data in the gradebook.

Downloading the Data Exchange Javascript API

The DEJS API is implemented in DataExchange.js, which you can download from The package includes these files:

Creating the Activity

To use the DEJS API, follow these steps:

Custom activity

Create an activity of type Custom Activity in a course.

Choose web site

Pick Choose Web Site… and enter the URL to the activity on your web server:

SCO dropbox

Check the Completion and grade set by content (SCO) checkbox:

When a student or teacher launches your activity in the course viewer, the course viewer automatically appends query parameters to your URL that enable DEJS to store and retrieve data for the current learner. The course viewer also sets an expiring cookie that the DEJS API relies on for authentication. The DEJS_API object regularly pings the server to prevent the cookie from expiring.

Using Data Exchange Javascript API

The DataExchange.js file defines an object named DEJS_API, which contains the API methods. Include the DataExchange.js file in your web pages to use the DEJS_API object.

The DEJS API communicates with the application web server asynchronously. This means most calls return immediately before the work has completed, and you process results in a callback function. This lets your activity remain responsive to the end-user while the server communication occurs.

A typical activity calls initialize to start the activity. It calls getData to retrieve any previously stored SCORM variables for the activity. Upon learner completion, the activity calls putData to store SCORM data for the end-user and to update the gradebook. Note: The putData call overwrites any previously existing variables, so the activity should include in the putData call all data retrieved during getData.