How to Add xAPI to Your EJS Interactive
In this guide, I’ll walk you through how to add xAPI tracking to your EJS (Easy Java Simulations) interactive so that you can send user activity data directly to the SLS platform. This allows you to record learning analytics like scores and user interactions. Let’s get started!
webejs_model_xAPI_kangRui/ webejs_model_xAPI_kangRui.zip |
webejs_model_xAPI_kangRui/ webejs_model_xAPI_kangRui.zip |
Step 1: Upload the xAPI Wrapper File
Create a folder named lib
within your EJS project directory. This is where you’ll store the xapiminwrapper.js
file, which is the JavaScript wrapper that enables communication between your simulation and xAPI endpoints.
To do this:
-
Go to the Files tab in your EJS simulation editor.
-
Create a new folder called
lib
. -
Upload the
xapiminwrapper.js
file into this folder.
Step 2: Add the Wrapper to Run Options
Now that you’ve uploaded the xAPI wrapper file, you need to include it in the simulation’s runtime.
-
Go to the Simulation Options panel.
-
Under the Run Options section, look for User Files.
-
Add the path to
lib/xapiminwrapper.js
.
This ensures that the wrapper loads when the simulation runs.
Step 3: Create an xAPI Function Page
Next, create a new function page that will handle your xAPI statements.
-
Go to the Custom tab in EJS.
-
Add a new function page and name it
xApi
. -
Paste in the required xAPI-related JavaScript code that includes functions such as
sendState()
.
🧠 Tip: This page acts as your communication bridge between the simulation’s internal events and the external xAPI calls.
Step 4: Send xAPI Statements with sendState()
To push activity data to the SLS platform, you’ll use the sendState()
function. This function accepts an object with two key parameters:
-
score: A number indicating the score the student achieved for a particular task.
-
feedback: A string of HTML content that provides a detailed breakdown of the student’s activity.
Here’s an example of how to use it:
This flexible feedback
field lets you format the message however you want using HTML tags—perfect for detailed, visual, and student-friendly feedback.
Step 5: Upload and Test on SLS
Once your xAPI integration is complete:
-
Download the interactive
-
Upload it to the Student Learning Space (SLS).
-
Test the interactive in Student View to confirm if scores and feedback are sent and displayed correctly in the learning analytics section.
Make sure to trigger actions within your interactive that call sendState()
so the system registers them.
Final Thoughts
Adding xAPI support to your EJS interactives is a great way to track learning, personalize feedback, and generate meaningful analytics. It does take some setup, but once configured, it opens up a powerful layer of insight into student behavior and performance.
https://weelookang.blogspot.com/2025/07/how-to-add-xapi-to-ejs-interactives.html