The DEJS API is implemented in DataExchange.js, which you can download from DataExchange.zip. The package includes these files:
To use the DEJS API, follow these steps:
Create an activity of type Custom Activity in a course.
Pick Choose Web Site… and enter the URL to the activity on your web server:
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.
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.