📘 How to Add xAPI to Your HTML Interactives (for SLS Integration)
In this post, I’ll walk you through how to integrate xAPI (Experience API) into your HTML-based interactive so you can track user responses and send data to the Student Learning Space (SLS). This guide is especially useful for those creating custom learning tools and simulations using HTML and JavaScript. Screenshots will be attached along the way to help illustrate each step.
✅ Step 1: Set Up Your Project Folder
Start by creating a folder named lib inside your project directory. This folder will store your xAPI dependencies.
Inside the lib folder, upload the xapiminwrapper.js file. This is the wrapper library provided by SLS that enables your HTML simulation to communicate with the SLS xAPI endpoint.
✅ Step 2: Add the xAPI Utility Code
Still inside the lib folder, create a new JavaScript file — you can name it something like xapi-utils.js. This file will house the utility functions required to send and retrieve xAPI state data.
Paste the following code into your new file:
This script handles:
-
Fetching required xAPI parameters from the URL
-
Setting the xAPI configuration
-
Sending and retrieving xAPI state using wrapper methods
✅ Step 3: Use the storeState() Function to Send User Activity
To send user activity data to SLS, you’ll make use of the storeState() function defined earlier. This function takes in an object containing two keys:
-
score: A number representing the user's score for the activity -
feedback: A string containing activity feedback, which can include HTML for richer presentation
Here’s an example of how to use it inside your simulation when the user completes an interaction:
You can customize the feedback section however you like—include explanations, responses, or even visuals. This feedback will be visible to teachers within SLS.
✅ Step 4: Upload Your Interactive to SLS
Once everything is wired up, export or zip your simulation package and upload it to SLS as a Custom HTML interactive. After uploading:
-
View the activity as a student.
-
Complete the task inside your simulation.
-
Verify that the data is captured and visible on the teacher dashboard or in SLS reports.
🎯 Final Thoughts
By following these steps, you’ve enabled your HTML interactive to communicate with the SLS backend via xAPI. This opens up powerful possibilities for tracking student learning, capturing custom feedback, and enhancing formative assessment.
In future posts, I’ll explore how to expand this integration with additional xAPI features, like progress tracking, deeper analytics, and interoperability across multiple platforms.
Let me know if you’d like help troubleshooting or refining your xAPI integration — happy to support fellow developers and educators!
No comments:
Post a Comment