Sub topic 15
Platform Integration and E-Learning Standards
What this chapter assumes
You should know how to build a quiz and set its pass mark and attempt limit. The earlier chapters on scoring rules and on delivering files cover this. You should also be comfortable reading JSON and short JavaScript. You don't need to have used SCORM or xAPI before.
Why standards exist
A quiz built inside one platform works fine there. Problems start when you want to move content to another platform, or report results to a system the quiz doesn't live in. An e-learning standard is an agreed format for packaging content and for reporting what a learner did. With a standard, one piece of content can run on many platforms, and each platform can read the results.
Four names come up most often:
- SCORM (Sharable Content Object Reference Model) packages content as a zip file that runs inside a learning management system (LMS).
- xAPI (Experience API, also called Tin Can) sends small activity records to a separate store.
- cmi5 is a profile of xAPI that adds the launch and completion rules SCORM had.
- LTI (Learning Tools Interoperability) lets an LMS launch an outside tool and receive a grade back.
Most small course creators only need to know which one their platform accepts. This chapter covers SCORM and xAPI in enough detail to make that choice.
SCORM: a package plus a runtime API
A SCORM package is a zip file. At its root is imsmanifest.xml, which lists the content files and how they are organized. The LMS reads that manifest, unpacks the files, and launches the content in a frame or a pop-up window.
Once launched, your content talks to the LMS through a JavaScript object that the LMS provides. In SCORM 1.2 the object is named API. In SCORM 2004 it is named API_1484_11. Your code must search upward through the parent windows to find it. The LMS doesn't hand it to you directly.
The two versions differ in how they report results:
| Item | SCORM 1.2 | SCORM 2004 |
|---|---|---|
| API object | `API` | `API_1484_11` |
| Start and end calls | `LMSInitialize`, `LMSFinish` | `Initialize`, `Terminate` |
| Pass or fail | `cmi.core.lesson_status` (one combined field) | `cmi.success_status` and `cmi.completion_status` (two fields) |
| Score | `cmi.core.score.raw` (0 to 100 by convention) | `cmi.score.scaled` (-1 to 1), plus raw, min, and max |
| Saved progress | `cmi.suspend_data`, 4,096 characters | `cmi.suspend_data`, 64,000 characters |
SCORM 1.2 is older and has the widest support. Its single status field mixes completion and success, which causes the errors described later in this chapter.
The sequence below shows a normal launch and result report.
Reporting a quiz result with SCORM 1.2
This code uses the scoreQuiz result from the scoring chapter. It finds the API, then reports the score and a pass or fail status. SCORM 1.2 methods return the strings "true" and "false", not booleans, so compare against the string.
function findApi(win) {
let tries = 0;
while (!win.API && win.parent && win.parent !== win && tries < 10) {
win = win.parent;
tries += 1;
}
return win.API || null;
}
function reportResult(result) {
const api = findApi(window);
if (!api) return false; // Not running inside an LMS.
if (api.LMSInitialize("") !== "true") return false;
api.LMSSetValue("cmi.core.score.min", "0");
api.LMSSetValue("cmi.core.score.max", "100");
api.LMSSetValue("cmi.core.score.raw", String(Math.round(result.ratio * 100)));
api.LMSSetValue("cmi.core.lesson_status", result.passed ? "passed" : "failed");
api.LMSCommit("");
return api.LMSFinish("") === "true";
}In a real quiz you would call LMSInitialize once when the page loads and LMSFinish once when the learner leaves. Calling both inside one function keeps this example short.
The pass mark exists in two places. Your code decides passed using your own threshold. Many LMSs also read a mastery score from the manifest and may override your status. Keep both values the same.
xAPI: statements sent to a store
xAPI doesn't need a package or a frame. Any app can send a statement, a JSON record in the form "actor did verb to object". Statements go to a Learning Record Store (LRS) over HTTP. Because statements are plain web requests, they can come from a mobile app, a simulation, or a video player. SCORM can't track those.
{
"actor": { "name": "Ada Lovelace", "mbox": "mailto:[email protected]" },
"verb": {
"id": "http://adlnet.gov/expapi/verbs/passed",
"display": { "en-US": "passed" }
},
"object": {
"id": "https://example.com/courses/design/module-2/quiz-1",
"definition": { "name": { "en-US": "Module 2 quiz" } }
},
"result": {
"score": { "scaled": 0.8, "raw": 8, "min": 0, "max": 10 },
"success": true,
"completion": true
}
}Sending it takes one authenticated POST. This script runs on Node 18 or later, which includes fetch. Replace the endpoint and credentials with the values from your LRS.
const statement = {
actor: { name: "Ada Lovelace", mbox: "mailto:[email protected]" },
verb: { id: "http://adlnet.gov/expapi/verbs/passed", display: { "en-US": "passed" } },
object: { id: "https://example.com/courses/design/module-2/quiz-1" },
result: { score: { scaled: 0.8 }, success: true }
};
async function send(endpoint, key, secret) {
const auth = Buffer.from(`${key}:${secret}`).toString("base64");
const response = await fetch(`${endpoint}/statements`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Experience-API-Version": "1.0.3",
Authorization: `Basic ${auth}`
},
body: JSON.stringify(statement)
});
if (!response.ok) throw new Error(`LRS returned ${response.status}`);
return response.json(); // The LRS replies with an array of statement IDs.
}
send("https://lrs.example.com/xapi", "my-key", "my-secret").then(console.log);Choosing between them
Start with what your platform accepts, because you can't use a format it doesn't support. Then apply these criteria:
- If the platform imports only SCORM, use SCORM 1.2 for the widest support, or 2004 if you need separate completion and success fields.
- If you need to track activity outside the LMS, such as a simulation or a mobile app, use xAPI.
- If you want an LMS-launched xAPI course with defined completion rules, check whether the platform supports cmi5.
- If the platform is a hosted course site and you only need quizzes and files, its built-in quiz tool is often enough. Standards add testing work and give no benefit if you never move the content.
A built-in quiz also gives you all the features covered earlier, such as feedback, attempt limits, and question banks. A SCORM package gives you whatever features its authoring tool provides.
Common errors
- Status stays "incomplete". The content never sent a status, or the learner closed the window before
LMSFinish. Send the status as soon as the score is known, and commit before any step that might not run. - Score appears as 0.8 in a field that expects 80. SCORM 1.2 uses a 0 to 100 raw score, and 2004 uses a -1 to 1 scaled score. Convert for the version you target.
API not found. The content was opened outside an LMS, such as from a local file. Make your code handle a missing API without crashing, asreportResultdoes above.- Pass mark mismatch. The LMS shows "failed" while your quiz shows "passed". The mastery score in the manifest differs from your quiz's threshold.
- Progress lost on resume. Data in
cmi.suspend_datawent over the 4,096-character limit in SCORM 1.2. Store a compact state, not the full question text. - Attempts don't match. The LMS may count attempts each time the package launches, while your quiz counts submissions. Decide which side enforces the limit, and test that it does.
Exercise
A learner scores 8 of 10 on a quiz packaged as SCORM 1.2, with a pass mark of 70%. What values would your code send for cmi.core.score.raw and cmi.core.lesson_status? What would the 2004 equivalent of the score be?
Show answer
Send "80" for cmi.core.score.raw (with min "0" and max "100") and "passed" for cmi.core.lesson_status, because 0.8 is at least 0.7. In SCORM 2004 the score goes in cmi.score.scaled as 0.8, with cmi.success_status set to passed and cmi.completion_status set to completed.
Exercise
Your course includes a mobile app drill that must report results to the same record as the LMS quizzes. Which standard fits, and why can't SCORM do it alone?
Show answer
xAPI fits. SCORM content runs only inside an LMS-provided frame or window, where it can reach the API object. A mobile app has no such object, but it can send an xAPI statement to the LRS with an ordinary HTTP request.