RandyStewartMiller.com

Storyline 360 xAPI Statement Writing

To send an xAPI statement from Articulate Storyline to a Learning Record Store (LRS), you’ll need to follow these steps:

  1. Set Up Your LRS: First, you’ll need an LRS to store your xAPI statements. You can use a service like Veracity Learning LRS. Create an account and set up your LRS with a username, password, and access key1.
  2. Create the xAPI Statement: Write the xAPI statement in JSON format. Here’s a basic example:

{
“actor”: {
“name”: “John Doe”
},
“verb”: {
“id”: “http://adlnet.gov/expapi/verbs/completed”,
“display”: {“en-US”: “completed”}
},
“object”: {
“id”: “http://example.com/activity”,
“definition”: {
“name”: {“en-US”: “Sample Activity”}
}
},
“context”: {
“registration”: “12345”
}
}

3. Add JavaScript to Storyline: Open your Storyline project and add a trigger to call a JavaScript function when the desired action occurs (e.g., completing a quiz). Add the following JavaScript code to your project:

function sendXAPIStatement() {
    var statement = {
        "actor": {
            "name": "John Doe"
        },
        "verb": {
            "id": "http://adlnet.gov/expapi/verbs/completed",
            "display": {"en-US": "completed"}
        },
        "object": {
            "id": "http://example.com/activity",
            "definition": {
                "name": {"en-US": "Sample Activity"}
            }
        },
        "context": {
            "registration": "12345"
        }
    };

    var xhr = new XMLHttpRequest();
    xhr.open("POST", "https://your-lrs-url/xapi/statements", true);
    xhr.setRequestHeader("Content-Type", "application/json");
    xhr.setRequestHeader("Authorization", "Basic " + btoa("your-username:your-password"));
    xhr.send(JSON.stringify(statement));
}

4. Publish and Test: Publish your Storyline project and test it to ensure the xAPI statement is sent to the LRS