diff --git a/AGENTS.md b/AGENTS.md
index 167424d0..54b3d1ff 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -258,7 +258,7 @@ Read it before changing entry names, `untrusted`, the content check (`packages/r
- **The verifier** (`packages/verify/`): [`design/verify.md`](design/verify.md).
- **The author package** (`packages/author/`, `skills/h5p-author/`): [`design/author.md`](design/author.md).
- **The VS Code extension** (`packages/vscode/`): [`design/vscode.md`](design/vscode.md).
-- **The SCORM package** (`packages/embed/lib/scorm*.mjs`, `packages/embed/scorm/`, the SCORM page): [`design/scorm.md`](design/scorm.md).
+- **The SCORM package** (`packages/embed/lib/scorm*.mjs`, `packages/embed/scorm/`, the SCORM page, `skills/h5p-to-scorm/`): [`design/scorm.md`](design/scorm.md).
- **The embed site** (`packages/embed/` but its SCORM side, the demo's `/embed`): [`design/embed.md`](design/embed.md).
- **cmi5** (`packages/cmi5/`, the demo's cmi5 page, CATAPULT): [`design/cmi5.md`](design/cmi5.md).
- **The hosted demo and the app** (`apps/demo/`, `vercel.json`, `api/`): [`design/demo.md`](design/demo.md). It compiles the element from the player's source, not from `dist/`, as [`design/layout.md`](design/layout.md) explains.
diff --git a/README.md b/README.md
index 8abdb75b..54df0380 100644
--- a/README.md
+++ b/README.md
@@ -131,18 +131,21 @@ reads the `.h5p` itself, with nothing to unzip, and
[](https://skills.sh/missing-elements/h5p-offline-player)
-Four skills for Claude Code and other agents that can read files and run commands, installed
-with [skills](https://skills.sh/):
+Five skills for Claude Code and other agents that can read files and run commands, installed
+with [skills](https://skills.sh/); add `--skill ` for one of them. None needs a provider API
+key or an H5P server.
```bash
npx skills add missing-elements/h5p-offline-player
```
-[`h5p-author`](https://github.com/missing-elements/h5p-offline-player/tree/main/skills/h5p-author)
-turns a prompt or a lesson into H5P content of any of 28 types, chosen with you first, checks it
-in the real player and opens it for you to play. `h5p-player-setup` puts H5P on a site,
-`h5p-normalize` fixes video that will not stream, and `h5p-verify` checks that a package plays.
-None needs a provider API key or an H5P server.
+| Skill | What it does |
+|---|---|
+| [`h5p-author`](https://github.com/missing-elements/h5p-offline-player/tree/main/skills/h5p-author) | Turns a prompt or a lesson into H5P content of any of 28 types, chosen with you first, checks it in the real player and opens it for you to play |
+| [`h5p-verify`](https://github.com/missing-elements/h5p-offline-player/tree/main/skills/h5p-verify) | Checks that a package plays, and opens it in your browser for you to try |
+| [`h5p-to-scorm`](https://github.com/missing-elements/h5p-offline-player/tree/main/skills/h5p-to-scorm) | Turns a package into a SCORM zip that an LMS plays, grades and resumes, and says what to set in yours |
+| [`h5p-player-setup`](https://github.com/missing-elements/h5p-offline-player/tree/main/skills/h5p-player-setup) | Puts H5P on a website, from the player on the site itself or framed from a domain of your own |
+| [`h5p-normalize`](https://github.com/missing-elements/h5p-offline-player/tree/main/skills/h5p-normalize) | Rewrites a package whose video will not stream |
## Contributing
diff --git a/apps/demo/demo/scorm.html b/apps/demo/demo/scorm.html
index 2edfd784..d2cc75bc 100644
--- a/apps/demo/demo/scorm.html
+++ b/apps/demo/demo/scorm.html
@@ -76,7 +76,7 @@
3 Options
- For a gradebook that needs a number: a presentation without questions, finished, records 100. Content that never finishes, such as an Accordion, stays incomplete.
+ For a gradebook that needs a number: a questionnaire, submitted, records 100. Content that never finishes, such as an Accordion or a presentation without questions, stays incomplete.
diff --git a/apps/skills/package.json b/apps/skills/package.json
index dff52bb3..41f2a440 100644
--- a/apps/skills/package.json
+++ b/apps/skills/package.json
@@ -8,6 +8,7 @@
},
"devDependencies": {
"@missing-elements/h5p-author": "workspace:*",
+ "@missing-elements/h5p-embed": "workspace:*",
"@missing-elements/h5p-libraries": "workspace:*",
"@missing-elements/h5p-verify": "workspace:*",
"@types/node": "^26.6.6",
diff --git a/apps/skills/tests/to-scorm.test.ts b/apps/skills/tests/to-scorm.test.ts
new file mode 100644
index 00000000..51661f7f
--- /dev/null
+++ b/apps/skills/tests/to-scorm.test.ts
@@ -0,0 +1,449 @@
+import { execFile } from 'node:child_process'
+import { copyFile, mkdir, mkdtemp, readdir, readFile, rm, writeFile } from 'node:fs/promises'
+import { createServer, type Server } from 'node:http'
+import type { AddressInfo } from 'node:net'
+import { tmpdir } from 'node:os'
+import { dirname, extname, join, normalize, resolve } from 'node:path'
+import { promisify } from 'node:util'
+import { BlobReader, TextWriter, Uint8ArrayWriter, ZipReader, type Entry, type FileEntry } from '@zip.js/zip.js'
+import { buildPackage } from '@missing-elements/h5p-author'
+import { chromium, type Browser, type Frame, type Page } from 'playwright'
+import { afterAll, beforeAll, describe, expect, it } from 'vitest'
+
+/*
+ * The h5p-to-scorm skill as an agent follows it: its commands run as it writes them, on packages
+ * h5p-author builds, and the zips they write played by a learner under a stand-in for an LMS's
+ * player page, which puts the SCORM API in its window, frames the launch page and keeps what it is
+ * sent between launches, as Moodle's does. What the skill tells the user is held to what that LMS
+ * kept. The zip's behaviour in full, call by call, is the embed package's tests'; these hold the
+ * skill to it, with real content where those dispatch the element's events by hand.
+ */
+
+const run = promisify(execFile)
+const project = resolve(import.meta.dirname, '..')
+const skill = await readFile(resolve(project, '../../skills/h5p-to-scorm/SKILL.md'), 'utf8')
+const readme = await readFile(resolve(project, '../../packages/embed/README.md'), 'utf8')
+const types = resolve(project, '../../skills/h5p-author/references/types')
+const fixtures = resolve(project, '../../packages/author/tests/fixtures')
+// The commands, as installed here, which `npx` runs for the skill's user.
+const embed = resolve(project, 'node_modules/@missing-elements/h5p-embed/bin/h5p-embed.mjs')
+const verify = resolve(project, 'node_modules/@missing-elements/h5p-verify/bin/h5p-verify.mjs')
+// The pack this project installed, named to the check as `--libraries` names a copy of its parts,
+// so the check needs no network.
+const parts = resolve(project, 'node_modules/@missing-elements/h5p-libraries/parts')
+const META = { language: 'en', license: 'CC BY', authors: [{ name: 'Ann Author', role: 'Author' }] }
+
+/** The commands the skill gives, as it writes them: its indented lines that run one of ours. */
+const commands = [...skill.matchAll(/^ {4}npx @missing-elements\/(h5p-embed|h5p-verify)@latest (.+)$/gm)].map(([, tool, rest]) => ({ tool, args: rest.trim().split(/\s+/) }))
+
+/** The skill's command that writes a zip with these options and no others. */
+function embedCommand(...options: string[]) {
+ const named = (args: string[]) => args.filter((arg) => arg.startsWith('--') && arg !== '--scorm').sort()
+ const found = commands.find(({ tool, args }) => tool === 'h5p-embed' && JSON.stringify(named(args)) === JSON.stringify([...options].sort()))
+ if (!found) throw new Error(`the skill gives no command with ${options.join(' ') || 'no options'}`)
+ return found.args
+}
+
+/** A command run in a folder of its own holding the package as the skill names it, `course.h5p`. */
+async function runIn(name: string, h5p: string, bin: string, args: string[]) {
+ const cwd = join(dir, name)
+ await mkdir(cwd)
+ await copyFile(h5p, join(cwd, 'course.h5p'))
+ const { stdout } = await run(process.execPath, [bin, ...args], { cwd })
+ return { cwd, stdout }
+}
+
+/** A zip's entries, unpacked where an LMS would serve them, and its manifest. */
+async function unpack(zip: string, folder: string) {
+ const reader = new ZipReader(new BlobReader(new Blob([await readFile(zip)])))
+ for (const entry of await reader.getEntries()) {
+ if (entry.directory) continue
+ await mkdir(dirname(join(root, folder, entry.filename)), { recursive: true })
+ await writeFile(join(root, folder, entry.filename), await entry.getData(new Uint8ArrayWriter()))
+ }
+ await reader.close()
+ return readFile(join(root, folder, 'imsmanifest.xml'), 'utf8')
+}
+
+/** The source a type file of h5p-author gives as its example, the metadata a source carries added. */
+async function example(type: string, title: string) {
+ const text = await readFile(join(types, `${type}.md`), 'utf8')
+ const block = /## Example\s+```json\n([\s\S]*?)\n```/.exec(text)
+ if (!block) throw new Error(`${type} has no example`)
+ return { ...META, title, ...JSON.parse(block[1]) }
+}
+
+// The stand-in LMS: one page per version, its API in its window, the values it is sent kept
+// between launches, and a launch after a suspended session a resumed one. `cmi.interactions._count`
+// is one past the highest index written, as Moodle answers it.
+const LMS = {
+ '1.2': `
+ window.values = { 'cmi.core.lesson_status': 'not attempted', 'cmi.core.entry': 'ab-initio', 'cmi.suspend_data': '' }
+ window.finished = 0
+ const count = () => String(Math.max(-1, ...Object.keys(values).map((key) => Number(/^cmi\\.interactions\\.(\\d+)\\.id$/.exec(key)?.[1] ?? -1))) + 1)
+ window.API = {
+ LMSInitialize: () => 'true',
+ LMSFinish: () => { window.finished++; return 'true' },
+ LMSGetValue: (element) => (element === 'cmi.interactions._count' ? count() : values[element] ?? ''),
+ LMSSetValue: (element, value) => { values[element] = String(value); return 'true' },
+ LMSCommit: () => 'true',
+ LMSGetLastError: () => '0', LMSGetErrorString: () => '', LMSGetDiagnostic: () => ''
+ }
+ let launched = false
+ window.launch = (path) => {
+ values['cmi.core.entry'] = values['cmi.core.exit'] === 'suspend' ? 'resume' : launched ? '' : 'ab-initio'
+ launched = true
+ document.getElementById('sco')?.remove()
+ const frame = document.createElement('iframe')
+ frame.id = 'sco'
+ frame.src = path
+ frame.style.cssText = 'width: 100%; height: 700px; border: 0'
+ document.body.append(frame)
+ }`,
+ '2004': `
+ window.values = { 'cmi.completion_status': 'unknown', 'cmi.success_status': 'unknown', 'cmi.entry': 'ab-initio', 'cmi.suspend_data': '' }
+ window.finished = 0
+ const count = () => String(Math.max(-1, ...Object.keys(values).map((key) => Number(/^cmi\\.interactions\\.(\\d+)\\.id$/.exec(key)?.[1] ?? -1))) + 1)
+ window.API_1484_11 = {
+ Initialize: () => 'true',
+ Terminate: () => { window.finished++; return 'true' },
+ GetValue: (element) => (element === 'cmi.interactions._count' ? count() : values[element] ?? ''),
+ SetValue: (element, value) => { values[element] = String(value); return 'true' },
+ Commit: () => 'true',
+ GetLastError: () => '0', GetErrorString: () => '', GetDiagnostic: () => ''
+ }
+ let launched = false
+ window.launch = (path) => {
+ values['cmi.entry'] = values['cmi.exit'] === 'suspend' ? 'resume' : launched ? '' : 'ab-initio'
+ launched = true
+ document.getElementById('sco')?.remove()
+ const frame = document.createElement('iframe')
+ frame.id = 'sco'
+ frame.src = path
+ frame.style.cssText = 'width: 100%; height: 700px; border: 0'
+ document.body.append(frame)
+ }`
+}
+type Version = keyof typeof LMS
+type LmsWindow = Window & { values: Record; finished: number; launch: (path: string) => void }
+type Results = Window & { results: Array<{ success?: boolean; score?: { raw?: number; max?: number } } | null> }
+
+const MIME: Record = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript', '.css': 'text/css', '.json': 'application/json', '.woff2': 'font/woff2', '.h5p': 'application/zip' }
+let dir: string
+let root: string
+let server: Server
+let origin: string
+let browser: Browser
+const built: Record = {}
+
+beforeAll(async () => {
+ dir = await mkdtemp(join(tmpdir(), 'h5p-to-scorm-'))
+ root = join(dir, 'lms')
+ // The quiz example, with a pass percentage of its own that the learner's two of three points
+ // pass, so that a pass mark above it is seen to decide instead.
+ const quiz = JSON.parse(await readFile(join(fixtures, 'quiz.json'), 'utf8'))
+ const sources: Record = {
+ quiz: { ...quiz, passPercentage: 50 },
+ questionnaire: await example('H5P.Questionnaire', 'Rivers survey'),
+ scenario: await example('H5P.BranchingScenario', 'Crossing the river'),
+ presentation: {
+ ...META,
+ title: 'Rivers, three slides',
+ type: 'H5P.CoursePresentation',
+ params: { presentation: { slides: ['Sources', 'Courses', 'Mouths'].map((words) => ({ elements: [{ action: { library: 'H5P.AdvancedText', params: { text: `
${words}
` } } }] })) } }
+ }
+ }
+ for (const [name, source] of Object.entries(sources)) {
+ built[name] = join(dir, `${name}.h5p`)
+ await buildPackage(source, built[name])
+ }
+ server = createServer(async (request, response) => {
+ const path = decodeURIComponent(new URL(request.url ?? '/', 'http://x').pathname)
+ const version = /^\/lms-(1\.2|2004)\.html$/.exec(path)?.[1] as Version | undefined
+ if (version) {
+ response.writeHead(200, { 'Content-Type': MIME['.html'] }).end(``)
+ return
+ }
+ try {
+ const body = await readFile(join(root, normalize(path).replace(/^(\.\.[/\\])+/, '')))
+ response.writeHead(200, { 'Content-Type': MIME[extname(path)] ?? 'application/octet-stream', 'Content-Length': body.length, 'Cache-Control': 'no-store' }).end(body)
+ } catch {
+ response.writeHead(404).end()
+ }
+ })
+ await new Promise((done) => server.listen(0, '127.0.0.1', done))
+ origin = `http://127.0.0.1:${(server.address() as AddressInfo).port}`
+ browser = await chromium.launch()
+})
+
+afterAll(async () => {
+ await browser?.close()
+ await new Promise((done) => (server ? server.close(done) : done(undefined)))
+ if (dir) await rm(dir, { recursive: true, force: true })
+})
+
+/** A frame of the page, once one passes `test`. */
+async function frameWhere(page: Page, test: (frame: Frame) => boolean) {
+ for (const end = Date.now() + 60_000; Date.now() < end; await page.waitForTimeout(100)) {
+ const found = page.frames().find(test)
+ if (found) return found
+ }
+ throw new Error(`no such frame among ${page.frames().map((frame) => frame.url()).join(', ')}`)
+}
+
+/** The LMS's page for a version, with what it holds already, as from the manifest. */
+async function lms(version: Version, held: Record = {}) {
+ const context = await browser.newContext()
+ const page = await context.newPage()
+ await page.goto(`${origin}/lms-${version}.html`)
+ await page.evaluate((held) => Object.assign((window as unknown as LmsWindow).values, held), held)
+ return { context, page }
+}
+
+/**
+ * Launches a zip from the LMS's page and waits for its content: the launch page, with the results
+ * the element raises recorded, and the H5P frame in it.
+ */
+async function launch(page: Page, folder: string) {
+ const path = `/${folder}/index.html`
+ const before = new Set(page.frames())
+ await page.evaluate((path) => (window as unknown as LmsWindow).launch(path), path)
+ const sco = await frameWhere(page, (frame) => !before.has(frame) && frame.url().endsWith(path))
+ await sco.waitForFunction(() => (document.querySelector('h5p-player') as { state?: string } | null)?.state === 'ready', null, { timeout: 60_000 })
+ await sco.evaluate(() => {
+ const results: Results['results'] = ((window as unknown as Results).results = [])
+ document.querySelector('h5p-player')?.addEventListener('finished', (event) => results.push((event as CustomEvent).detail?.statement?.result ?? null))
+ })
+ return { sco, h5p: await frameWhere(page, (frame) => frame.parentFrame() === sco && frame.url().includes('/h5p/')) }
+}
+
+/** The learner leaves: the LMS takes the launch page down, which ends the session. */
+async function leave(page: Page) {
+ const finished = await page.evaluate(() => (window as unknown as LmsWindow).finished)
+ await page.evaluate(() => ((document.getElementById('sco') as HTMLIFrameElement).src = 'about:blank'))
+ await page.waitForFunction((before) => (window as unknown as LmsWindow).finished > before, finished)
+}
+
+const kept = (page: Page) => page.evaluate(() => ({ ...(window as unknown as LmsWindow).values }))
+/** Waits for the LMS to hold a value; if it never does, fails with all it holds. */
+async function holds(page: Page, element: string, value: string) {
+ try {
+ await page.waitForFunction(([element, value]) => (window as unknown as LmsWindow).values[element] === value, [element, value], { timeout: 30_000 })
+ } catch (error) {
+ throw new Error(`the LMS never held ${element} = ${value}; it holds ${JSON.stringify(await kept(page), null, 1)}`, { cause: error })
+ }
+}
+
+/**
+ * Clicks the visible button that begins with these words, once it is there, as a learner would:
+ * by its accessible name, which H5P often makes longer than its text ("Check the answers. …"), in
+ * any case, since some content types write their buttons in capitals. A button that does not come
+ * fails with what the frame offered instead.
+ */
+async function press(h5p: Frame, words: string) {
+ const button = h5p.getByRole('button', { name: new RegExp(`^${words}`, 'i') }).locator('visible=true').last()
+ try {
+ await button.waitFor({ timeout: 30_000 })
+ } catch (error) {
+ throw new Error(`no button "${words}" in the content:\n${await h5p.locator('body').ariaSnapshot().catch(() => '(none)')}`, { cause: error })
+ }
+ await button.click()
+}
+
+/**
+ * Presses a button until the words it leads to show: a branching scenario and a presentation slide
+ * each step in, and take no click until it has, so a learner presses again.
+ */
+async function pressFor(h5p: Frame, words: string, shown: string) {
+ const next = h5p.getByText(shown).locator('visible=true').first()
+ for (let tries = 0; tries < 5 && !(await next.isVisible()); tries++) {
+ await press(h5p, words)
+ await next.waitFor({ timeout: 3000 }).catch(() => undefined)
+ }
+ await next.waitFor({ timeout: 1000 })
+}
+
+describe('the h5p-to-scorm skill', () => {
+ it('checks a quiz and writes it as its commands say; in SCORM 1.2 the pass mark decides, and a learner who leaves continues', async () => {
+ // The check, as written, but for the pack named by its copy here.
+ const check = commands.find(({ tool }) => tool === 'h5p-verify')
+ expect(check?.args).toContain('pack')
+ const checked = await runIn('check', built.quiz, verify, check!.args.map((arg) => (arg === 'pack' ? parts : arg)))
+ expect(checked.stdout).toMatch(/^pass {2}course\.h5p {2}ready in /)
+
+ // The plain command: SCORM 1.2 in course.scorm.zip, graded by the content's own result.
+ const plain = await runIn('plain', built.quiz, embed, embedCommand())
+ expect(plain.stdout).toMatch(/^Wrote course\.scorm\.zip \([\d.]+ MB\): "Practice: recognizing phishing" as a SCORM 1\.2 package,\n/)
+ const plainManifest = await unpack(join(plain.cwd, 'course.scorm.zip'), 'plain')
+ expect(plainManifest).toContain('1.2')
+ expect(plainManifest).not.toContain('masteryscore')
+
+ // The pass mark's command: the zip it names, the mark in the manifest, where an LMS reads it.
+ const args = embedCommand('--pass-mark')
+ const mark = args[args.indexOf('--pass-mark') + 1]
+ const zip = args[args.indexOf('course.h5p') + 1]
+ expect(zip).toMatch(/\.zip$/)
+ const graded = await runIn('graded', built.quiz, embed, args)
+ expect(graded.stdout).toMatch(new RegExp(`^Wrote ${zip.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} \\([\\d.]+ MB\\): "Practice: recognizing phishing" as a SCORM 1\\.2 package \\(pass mark ${mark}\\),\\n`))
+ const manifest = await unpack(join(graded.cwd, zip), 'graded')
+ expect(manifest).toContain(`${mark}`)
+
+ // First session: the first question right, then the learner leaves.
+ const { context, page } = await lms('1.2', { 'cmi.student_data.mastery_score': mark })
+ let { h5p } = await launch(page, 'graded')
+ await h5p.getByRole('radio', { name: /known bookmark/ }).click()
+ await press(h5p, 'Check')
+ await holds(page, 'cmi.interactions.0.result', 'correct')
+ await press(h5p, 'Next')
+ await h5p.getByText('Which features of an unexpected email').waitFor()
+ await leave(page)
+ let values = await kept(page)
+ expect(values).toMatchObject({ 'cmi.core.lesson_status': 'incomplete', 'cmi.core.exit': 'suspend' })
+ expect(values['cmi.core.score.raw']).toBeUndefined()
+ // The saved state, compressed as base64: nothing an LMS's storage could mangle, and within 1.2's 4,096.
+ expect(values['cmi.suspend_data']).toMatch(/^[A-Za-z0-9+/]+=*$/)
+ expect(values['cmi.suspend_data'].length).toBeLessThan(4096)
+
+ // Second session: the quiz continues where it was, with the first answer kept.
+ let sco: Frame
+ ;({ sco, h5p } = await launch(page, 'graded'))
+ expect((await kept(page))['cmi.core.entry']).toBe('resume')
+ await h5p.getByText('Which features of an unexpected email').waitFor({ timeout: 30_000 })
+ // One of the two right answers: two of the quiz's three points, 66.67, which the quiz's own
+ // 50% passes and the mark of 80 fails.
+ await h5p.getByRole('checkbox', { name: /password by email/ }).click()
+ await press(h5p, 'Check')
+ await press(h5p, 'Finish')
+ await holds(page, 'cmi.core.lesson_status', Number(mark) <= 66.67 ? 'passed' : 'failed')
+ const results = await sco.evaluate(() => (window as unknown as Results).results)
+ expect(results.at(-1)).toMatchObject({ success: true, score: { raw: 2, max: 3 } })
+ values = await kept(page)
+ expect(values).toMatchObject({ 'cmi.core.score.raw': '66.67', 'cmi.core.score.min': '0', 'cmi.core.score.max': '100' })
+ expect(values['cmi.core.session_time']).toMatch(/^\d{2,4}:\d{2}:\d{2}(\.\d{1,2})?$/)
+ // Each question once, under an identifier 1.2 takes, the first from the first session.
+ const ids = Object.keys(values).filter((key) => /^cmi\.interactions\.\d+\.id$/.test(key)).map((key) => values[key])
+ expect(ids).toHaveLength(2)
+ expect(new Set(ids).size).toBe(2)
+ for (const id of ids) expect(id).toMatch(/^[\x21-\x7e]{1,255}$/)
+ expect(values).toMatchObject({ 'cmi.interactions.0.type': 'choice', 'cmi.interactions.0.result': 'correct', 'cmi.interactions.1.type': 'choice', 'cmi.interactions.1.result': 'wrong' })
+
+ // A finished 1.2 session ends with nothing to resume.
+ await leave(page)
+ expect((await kept(page))['cmi.core.exit']).toBe('')
+ await context.close()
+ })
+
+ it('in SCORM 2004 counts content that finishes without a score as 100, keeps it, and leaves what never finishes incomplete', async () => {
+ const args = embedCommand('--scorm-version', '--completion-score')
+ expect(args[args.indexOf('--scorm-version') + 1]).toBe('2004')
+ for (const name of ['questionnaire', 'scenario', 'presentation']) {
+ const { cwd, stdout } = await runIn(`s2004-${name}`, built[name], embed, args)
+ expect(stdout).toMatch(/^Wrote course\.scorm\.zip \([\d.]+ MB\): ".+" as a SCORM 2004 4th Edition package \(completion counts as 100\),\n/)
+ expect(await unpack(join(cwd, 'course.scorm.zip'), name)).toContain('2004 4th Edition')
+ }
+ const finishedAs100 = { 'cmi.completion_status': 'completed', 'cmi.success_status': 'unknown', 'cmi.score.raw': '100', 'cmi.score.scaled': '1' }
+
+ // A questionnaire, submitted: completed with no score of its own.
+ {
+ const { context, page } = await lms('2004')
+ let { sco, h5p } = await launch(page, 'questionnaire')
+ await h5p.getByRole('radio', { name: 'Sometimes' }).click()
+ await press(h5p, 'Continue')
+ await h5p.locator('textarea').locator('visible=true').fill('The Rhine: I grew up beside it.')
+ await press(h5p, 'Continue')
+ await press(h5p, 'Submit')
+ await holds(page, 'cmi.completion_status', 'completed')
+ // One result, the questionnaire's, and no score in it: the 100 is the option's.
+ const results = await sco.evaluate(() => (window as unknown as Results).results)
+ expect(results).toHaveLength(1)
+ expect(results[0]?.score?.max ?? 0).toBe(0)
+ expect(await kept(page)).toMatchObject(finishedAs100)
+ // Left and launched again: a 2004 session is suspended, and the result stays.
+ await leave(page)
+ expect((await kept(page))['cmi.exit']).toBe('suspend')
+ ;({ sco, h5p } = await launch(page, 'questionnaire'))
+ expect((await kept(page))['cmi.entry']).toBe('resume')
+ await page.waitForTimeout(1000)
+ expect(await kept(page)).toMatchObject(finishedAs100)
+ await context.close()
+ }
+
+ // A branching scenario without scoring, played to an ending: 0 of 0, so no score either.
+ {
+ const { context, page } = await lms('2004')
+ const { sco, h5p } = await launch(page, 'scenario')
+ await pressFor(h5p, 'Start the course', 'You reach a river after heavy rain')
+ await pressFor(h5p, 'Proceed', 'How do you cross?')
+ await pressFor(h5p, 'Walk to the bridge', 'The bridge takes longer')
+ await pressFor(h5p, 'Proceed', 'Safely across')
+ await holds(page, 'cmi.completion_status', 'completed')
+ const results = await sco.evaluate(() => (window as unknown as Results).results)
+ expect(results).toHaveLength(1)
+ expect(results[0]?.score).toMatchObject({ raw: 0, max: 0 })
+ expect(await kept(page)).toMatchObject(finishedAs100)
+ await context.close()
+ }
+
+ // A presentation without questions, every slide seen: it never finishes, so the option has
+ // nothing to count, and the activity stays incomplete, as the skill tells the user.
+ {
+ const { context, page } = await lms('2004')
+ const { sco, h5p } = await launch(page, 'presentation')
+ await pressFor(h5p, 'Next slide', 'Courses')
+ await pressFor(h5p, 'Next slide', 'Mouths')
+ await expect.poll(() => h5p.getByRole('button', { name: 'Next slide' }).locator('visible=true').isDisabled()).toBe(true)
+ await page.waitForTimeout(2000)
+ expect(await sco.evaluate(() => (window as unknown as Results).results)).toEqual([])
+ const values = await kept(page)
+ expect(values['cmi.completion_status']).toBe('incomplete')
+ expect(values['cmi.score.raw']).toBeUndefined()
+ await context.close()
+ }
+ })
+
+ it("names the content that keeps the learner's place, and the content that starts over, as the pack's libraries are", async () => {
+ // The player saves what a content type's getCurrentState() returns, and a type without it
+ // starts over (docs/resume.md). The skill names some of each; a pack refresh that changes one
+ // makes the skill wrong, and fails here.
+ const bullet = /^- The next launch continues where the learner was[\s\S]*?(?=\n- |\n\n)/m.exec(skill)?.[0]
+ expect(bullet).toBeTruthy()
+ const [keep, over] = bullet!.split(/(?<=\.) (?=An? )/)
+ const titles = { 'Question Set': 'H5P.QuestionSet', 'Course Presentation': 'H5P.CoursePresentation', 'Interactive Book': 'H5P.InteractiveBook', 'Interactive Video': 'H5P.InteractiveVideo', 'Branching Scenario': 'H5P.BranchingScenario', Accordion: 'H5P.Accordion', 'Image Hotspots': 'H5P.ImageHotspots', Flashcards: 'H5P.Flashcards', Timeline: 'H5P.Timeline' }
+ const named = (text: string) => Object.entries(titles).filter(([title]) => text.includes(title)).map(([, library]) => library)
+ expect(named(keep)).toHaveLength(5)
+ expect(named(over ?? '')).toHaveLength(4)
+ expect(over).toMatch(/starts over/)
+ /** Whether every version of a library the pack has saves its state. */
+ async function saves(library: string) {
+ const files = (await readdir(parts)).filter((name) => name.startsWith(`${library}-`) && name.endsWith('.h5p'))
+ expect(files.length, library).toBeGreaterThan(0)
+ const found = await Promise.all(files.map(async (name) => {
+ const reader = new ZipReader(new BlobReader(new Blob([await readFile(join(parts, name))])))
+ const scripts = (await reader.getEntries()).filter((entry: Entry): entry is FileEntry => !entry.directory && entry.filename.endsWith('.js'))
+ const texts = await Promise.all(scripts.map((entry) => entry.getData(new TextWriter())))
+ await reader.close()
+ return texts.some((text) => text.includes('getCurrentState'))
+ }))
+ return found.every(Boolean) ? true : found.some(Boolean) ? 'some versions' : false
+ }
+ for (const library of named(keep)) expect(await saves(library), library).toBe(true)
+ for (const library of named(over!)) expect(await saves(library), library).toBe(false)
+ })
+
+ it("names the embed README's supported LMSs, each added as it says and checked as far", () => {
+ /** A markdown table's rows under the heading that names it, by its header's columns. */
+ function table(text: string, heading: RegExp) {
+ const lines = text.slice(text.search(heading)).split('\n')
+ const start = lines.findIndex((line) => line.startsWith('|'))
+ const block = lines.slice(start, lines.findIndex((line, i) => i > start && !line.startsWith('|')))
+ const [header, , ...rows] = block.map((line) => line.split('|').slice(1, -1).map((cell) => cell.trim()))
+ return rows.map((row) => Object.fromEntries(header.map((name, i) => [name, row[i]])))
+ }
+ const listed = table(readme, /^### Supported LMSs$/m)
+ const named = table(skill, /^## 4\. Hand over$/m)
+ expect(listed.length).toBeGreaterThan(0)
+ const columns = ['LMS', 'Add the zip as', 'SCORM 2004 and the grading options']
+ const pick = (rows: Array>) => rows.map((row) => columns.map((column) => row[column]))
+ expect(pick(named)).toEqual(pick(listed))
+ })
+})
diff --git a/design/layout.md b/design/layout.md
index 23f62d25..d0f1ec19 100644
--- a/design/layout.md
+++ b/design/layout.md
@@ -347,8 +347,8 @@ apps/demo/ the demo app: the dev server for the whole repository,
site root -> dist-demo/
apps/skills/ the skills' test project, a project of the kind a skill's user runs it in:
- it installs the commands the skills run with npx, the author package and
- the verifier, and the library pack; nothing in it ships. Out of the demo
+ it installs the commands the skills run with npx, the author package,
+ the verifier and the embed command, and the library pack; nothing in it ships. Out of the demo
since 2026-10-23, by the owner's choice
tests/author-verify.test.ts every h5p-author type file's example built, with sample media, checked
as saved content against the libraries it carries with nothing reported
@@ -366,6 +366,14 @@ apps/skills/ the skills' test project, a project of the kind a skil
result's screen-reader announcement, since Question Set 1.21 draws
neither on its result page (h5p/h5p-question-set#183), and drawn
after Check on a question on its own; Chromium only
+ tests/to-scorm.test.ts the h5p-to-scorm skill's commands as it writes them, run on packages
+ h5p-author builds, and their zips played as a learner under a stand-in
+ LMS (#159): a quiz over two sessions in SCORM 1.2, which the skill's
+ pass mark fails where the quiz's own passes; a questionnaire, a
+ branching scenario without scoring and a presentation without questions
+ in 2004 with completion as 100; the content it names as keeping the
+ learner's place or starting over, held to whether the pack's library
+ has getCurrentState(); and its LMS table held to the embed README's
README.md what npm shows; ACCESSIBILITY.md, SECURITY.md, CONTRIBUTING.md, GLOSSARY.md,
CODE_OF_CONDUCT.md beside it
@@ -391,8 +399,10 @@ docs/ the README's longer sections, one file each: the eleme
skills/ agent skills, one directory per skill, at the root because that is where
`npx skills add ` looks: h5p-verify (when to run the verifier and how
to read its report), h5p-player-setup (putting the player on a site), h5p-normalize (when
- a package needs rewriting to stream, and how to read the dry run)
- and h5p-author (any of 28 content types from a prompt, since #100: the
+ a package needs rewriting to stream, and how to read the dry run),
+ h5p-to-scorm (a package as a SCORM zip for an LMS, since #159: what to ask,
+ the check, the command and its refusals, each LMS's setting; tested from
+ apps/skills) and h5p-author (any of 28 content types from a prompt, since #100: the
type chosen with the user first, a source of only what differs from the
defaults, written from references/types/.md — notes, a tested
example and the fields, their section generated from the pack — built
diff --git a/design/scorm.md b/design/scorm.md
index 67dd3392..5cd4743d 100644
--- a/design/scorm.md
+++ b/design/scorm.md
@@ -377,9 +377,14 @@ one row each; an LMS added here gets a row there.
written without a mark reads none, so an LMS's own mastery score never changes a default
zip's status.
- **Completion as 100.** A result with no score, neither `scaled` nor `raw` over a `max` above
- 0, as content without questions finishes, is reported as 100 (`scaled` 1) beside completed,
- and passes a mark. H5P invents no score, so this is off unless asked; content that never
- finishes, an Accordion or a Virtual Tour, stays incomplete.
+ 0, as a questionnaire or a branching scenario without scoring finishes, is reported as 100
+ (`scaled` 1) beside completed, and passes a mark. H5P invents no score, so this is off unless
+ asked; content that never finishes, an Accordion or a Virtual Tour, stays incomplete. So does a
+ presentation or book with no questions in it, which the README and the command's help gave as the
+ example until #160 (2026-11-08): Course Presentation 1.27 and Interactive Book 1.15 send their
+ `completed` from a summary page they show only when they hold tasks. Played to its last slide,
+ the presentation sent `progressed` alone; the book's chapters say `completed` as sub-content,
+ which is not the book's result.
- **Checked on 2026-11-05.** In Moodle 4.5.15 (Docker, `notes/scorm-spike`, the 2004 runs by
`drive-options.mjs`): Moodle took the 2004 zips as `SCORM_1.3`, kept the objective (0.8,
satisfied by measure) and the 1.2 mastery score (80). The quiz over two sessions resumed on
@@ -396,7 +401,8 @@ one row each; an LMS added here gets a row there.
as 100, completed, passed and 100; and 1.2 with a mark of 80 failed at 66.67, the
registration incomplete as for any failed 1.2 attempt there. The finishes with no score were
the element's `finished` dispatched in the SCO's frame, as the tests do, since no package here
- finishes without one. Completion as 100 without a mark ran in no LMS: it gives `completed`
+ finished without one; since #160 the h5p-to-scorm skill's test plays real ones under a stand-in
+ LMS. Completion as 100 without a mark ran in no LMS: it gives `completed`
and 100, and in 2004 leaves success `unknown`, which a test holds (#142).
`scorm-page.test.ts` drives the written site's page in Chromium: a chosen file read into its row
@@ -409,6 +415,21 @@ one row each; an LMS added here gets a row there.
for the manifest and the page, a title given to the page's builder to the command's `--title`,
entry for entry, and a title given to the plan to its writes, which hash the package once.
+- **`skills/h5p-to-scorm/SKILL.md` is the contract with an agent** (#159, 2026-11-08), as
+ `skills/h5p-verify/SKILL.md` is the verifier's: what to ask first (the LMS, then a pass mark,
+ completion as 100 and 2004 only where they matter), the check that plays a package as the zip
+ plays it (`--libraries pack --no-refresh-libraries --no-downgrade-libraries`), the command and
+ its refusals, the *Supported LMSs* table with the setting each LMS needs, and what to tell the
+ user. It names only options on npm, since a skill is installed from `main`.
+ `apps/skills/tests/to-scorm.test.ts` runs its commands as it writes them on packages h5p-author
+ builds, plays their zips under a stand-in LMS as a learner (a quiz over two sessions in 1.2,
+ where its mark of 80 fails the 66.67 the quiz's own 50% passes; a questionnaire, a branching
+ scenario without scoring and a presentation without questions in 2004 with completion as 100),
+ holds the content it names as keeping the learner's place or starting over to the pack's
+ libraries (the player saves what `getCurrentState()` returns, and a type without it starts
+ over, `docs/resume.md`), and holds its table to the README's, so an LMS checked later is added
+ to both.
+
`tests/scorm.test.ts` checks the zip, the parts it carries, its stored entries' local headers and
its refusals in Node. In Chromium it plays the unpacked zip under a page that holds the API and
frames the launch page, as Moodle's player does. It covers:
@@ -442,7 +463,8 @@ Not covered:
- any LMS but Moodle 4.5, Frappe LMS, SCORM Cloud, ILIAS 11, OpenOLAT 21.1 and Chamilo 3.0, and
SCORM 2004 and the grading options in any but Moodle 4.5 and SCORM Cloud;
-- content that finishes without a score, in an LMS: the finish was dispatched;
+- content that finishes without a score, in a real LMS: it has played to its end only under the
+ skill's stand-in;
- SCORM Cloud's launch in a frame of its player page, where it launched in its pop-up;
- Firefox and Safari;
- Moodle with `slasharguments` off, its popup window and its mobile app;
diff --git a/design/testing.md b/design/testing.md
index eb8d3f06..eec27f29 100644
--- a/design/testing.md
+++ b/design/testing.md
@@ -38,12 +38,15 @@ package's behaviour, the test moved into the package: the embed page asking befo
package that needs its own code, and `resizer.js` answering a frame that loaded before it, are in
`packages/embed/tests/site.test.ts`; the cmi5 page's were already in `packages/cmi5/tests/`.
The skills are source too, tested from `apps/skills`, a project of their own (2026-10-23, the
-owner's choice): what they tell an agent to write builds and plays. h5p-author's own code is the
-author package's since #100, tested with it. Its tests were first in the demo, which had the pack
-and zip.js installed, and in the verifier's tests, and the playback test played the quiz through
-the installable app. It plays it in the verifier's preview now, the page the skill hands a person to
-review it in, and in Chromium only, where in the demo the `engines` job ran it in Firefox and
-WebKit too; the player's own suite covers the engines.
+owner's choice): what they tell an agent to write builds and plays. For h5p-to-scorm (#159) that is
+its commands, run as it writes them, and their zips, played as a learner under a stand-in LMS with
+real content; that is how a presentation without questions, the example `--completion-score` gave,
+was found never to finish (#160). h5p-author's own code is the author package's since #100, tested
+with it. Its tests were first in the demo, which had the pack and zip.js installed, and in the
+verifier's tests, and the playback test played the quiz through the installable app. It plays it in
+the verifier's preview now, the page the skill hands a person to review it in, and in Chromium
+only, where in the demo the `engines` job ran it in Firefox and WebKit too; the player's own suite
+covers the engines.
The app's tests follow the same variable (`apps/demo/tests/engine.ts`; `tests/harness.ts`
starts the dev server and the second-origin package host and waits on the element for all of
diff --git a/docs/development.md b/docs/development.md
index acbbf094..7c10af02 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -4,7 +4,8 @@ A pnpm workspace: `packages/player`, `packages/runtime`, `packages/libraries`,
`packages/normalize`, `packages/verify`, `packages/author`, `packages/cmi5`, `packages/embed`,
`packages/vscode`, the demo site in `apps/demo`, and in `apps/skills` the tests of the agent
skills, run from a project the way a skill's user runs them: every h5p-author type file's example
-built and played.
+built and played, and the h5p-to-scorm skill's commands run and their zips played under a stand-in
+LMS.
```bash
pnpm install
diff --git a/packages/embed/README.md b/packages/embed/README.md
index ed99b671..8ed9d265 100644
--- a/packages/embed/README.md
+++ b/packages/embed/README.md
@@ -151,7 +151,9 @@ package, the player and the H5P runtime, and a launch page that reports to the L
never read them; the LMS's reports do;
- the time spent in each session;
- the learner's place: the content's saved state goes into `cmi.suspend_data`, compressed, and
- the next launch continues from it. SCORM 1.2 keeps 4,096 characters; compressed, a quiz's state
+ the next launch continues from it, for a content type that saves one, as Question Set, Course
+ Presentation, Interactive Book, Interactive Video and most single questions do. An Accordion,
+ Image Hotspots, Flashcards or a Timeline starts over, as on any H5P site. SCORM 1.2 keeps 4,096 characters; compressed, a quiz's state
takes about 200, a twelve-chapter Interactive Book about 1,000, and none of 23 real packages
measured passed 1,100. One that does not fit is not saved, the last that fitted stays, and
the page says so under the content, once. Moodle keeps 64,000 when its administrator turns
@@ -167,10 +169,15 @@ missing named.
The package plays trusted: its own code runs on the LMS's origin, as every SCORM package's does.
The LMS has to be served over https, since the player needs its Service Worker.
-Content that reports no result of its own, an Accordion or a Virtual Tour, stays `incomplete`:
-complete such an activity on viewing it instead. Replacing the zip with one written from another
-`.h5p`, or with other libraries from the pack, starts learners over, since their saved state
-belongs to what it was saved in.
+Content that reports no result of its own stays `incomplete`, such as an Accordion, a Virtual
+Tour, or a presentation or book with no questions in it: complete such an activity on viewing it
+instead.
+Replacing the zip with one written from another `.h5p`, or with other libraries from the pack,
+starts learners over, since their saved state belongs to what it was saved in.
+
+An [agent skill](https://github.com/missing-elements/h5p-offline-player/tree/main/skills/h5p-to-scorm)
+takes an agent through it, from checking the package to the setting each LMS needs:
+`npx skills add missing-elements/h5p-offline-player --skill h5p-to-scorm`.
### Options of the zip
@@ -186,8 +193,9 @@ Three, each off unless asked for; a zip written with none is the SCORM 1.2 zip d
a mark the LMS holds of its own wins. Content that reports no score gets no pass or fail from
it.
- **Completion as 100** (`--completion-score`): content that finishes without a score, such as a
- presentation without questions, is recorded as 100, for a gradebook that needs a number; with a
- pass mark, that passes. Content that never finishes still stays `incomplete`.
+ questionnaire or a branching scenario without scoring, is recorded as 100, for a gradebook that
+ needs a number; with a pass mark, that passes. Content that never finishes, such as a
+ presentation or book with no questions in it, still stays `incomplete`.
### In the browser
diff --git a/packages/embed/bin/h5p-embed.mjs b/packages/embed/bin/h5p-embed.mjs
index dce26b7c..665570f1 100755
--- a/packages/embed/bin/h5p-embed.mjs
+++ b/packages/embed/bin/h5p-embed.mjs
@@ -25,7 +25,7 @@ Options:
--pass-mark <0-100> with --scorm, the score out of 100 that passes, in place of the
content's own pass or fail; the LMS gets it as the mastery score
--completion-score with --scorm, count content that finishes without a score, such as a
- presentation with no questions, as 100
+ questionnaire, as 100
--packages play packages, and fetch library bundles, only from these origins
(comma or space separated; this site's own is always allowed). Add
any host a package URL redirects to, and https://cdn.jsdelivr.net for
diff --git a/packages/embed/site/scorm.html b/packages/embed/site/scorm.html
index 95d9c29f..6c41798e 100644
--- a/packages/embed/site/scorm.html
+++ b/packages/embed/site/scorm.html
@@ -55,7 +55,7 @@
3 Options
- For a gradebook that needs a number: a presentation without questions, finished, records 100. Content that never finishes, such as an Accordion, stays incomplete.
+ For a gradebook that needs a number: a questionnaire, submitted, records 100. Content that never finishes, such as an Accordion or a presentation without questions, stays incomplete.
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 357948ae..691f7626 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -63,6 +63,9 @@ importers:
'@missing-elements/h5p-author':
specifier: workspace:*
version: link:../../packages/author
+ '@missing-elements/h5p-embed':
+ specifier: workspace:*
+ version: link:../../packages/embed
'@missing-elements/h5p-libraries':
specifier: workspace:*
version: link:../../packages/libraries
diff --git a/skills/h5p-author/SKILL.md b/skills/h5p-author/SKILL.md
index 01aa9918..728f694b 100644
--- a/skills/h5p-author/SKILL.md
+++ b/skills/h5p-author/SKILL.md
@@ -110,4 +110,5 @@ or right for every LMS. The package carries the editor libraries an H5P site's u
for, so a Moodle with no library installed accepts it (the one site tried). It carries H5P's libraries, each under its own licence, most
MIT, listed in the pack's [`libraries.txt`](https://github.com/missing-elements/h5p-offline-player/blob/main/packages/libraries/libraries.txt):
tell the user, so they check those terms before they distribute it. The H5P Preview extension (`MissingElements.h5p-preview`) plays it in
-VS Code, Cursor or VSCodium; `h5p-player-setup` puts it on a website.
+VS Code, Cursor or VSCodium; `h5p-player-setup` puts it on a website, and `h5p-to-scorm` makes it a
+SCORM zip for an LMS.
diff --git a/skills/h5p-to-scorm/SKILL.md b/skills/h5p-to-scorm/SKILL.md
new file mode 100644
index 00000000..38062add
--- /dev/null
+++ b/skills/h5p-to-scorm/SKILL.md
@@ -0,0 +1,112 @@
+---
+name: h5p-to-scorm
+description: Turn an H5P package (.h5p) into a SCORM zip that an LMS plays, grades and resumes - Moodle, ILIAS, OpenOLAT, Chamilo, SCORM Cloud, Frappe LMS or another that takes SCORM 1.2 or 2004. Use when asked to convert H5P to SCORM, to put H5P content into an LMS as a SCORM package, or to get H5P scores into an LMS gradebook; and after h5p-author when the content is for an LMS. One command writes the zip, with the libraries an export from h5p.com or h5p.org leaves out. No H5P plugin, server or third-party service.
+license: MIT
+---
+
+# Turn an H5P package into a SCORM zip
+
+`h5p-embed --scorm` writes one `.h5p` as a SCORM zip: the package, the player, the H5P runtime
+and a launch page that reports to the LMS. It sends the score out of 100, passed or failed, each
+question's answer and the time spent, and saves the learner's place for the next launch where the
+content type keeps one (see *Hand over*). Every LMS below records the score, the result, the time
+and the place, except Frappe LMS, which records only a pass and the place. An export from h5p.com
+or h5p.org, which leaves the libraries out, works too: the zip takes the ones it needs from the
+library pack.
+
+The commands need Node 22 or later. Keep `@latest` in them: without it, npm on an older Node
+quietly installs the last version that supported it.
+
+## 1. Ask what the zip is for
+
+Ask which LMS it goes to, unless the user has said: it decides the settings to name at the end,
+and whether the options below were checked there. Each of these has a default:
+
+- **Pass or fail.** By default the content's own verdict counts, such as a Question Set's pass
+ percentage. `--pass-mark 80` makes 80 and above pass and anything below fail, whatever the
+ content says. Frappe LMS marks a lesson done only on a pass, so there a quiz needs one.
+- **Content that finishes without a score.** A questionnaire, or a branching scenario without
+ scoring, ends `completed` with no score; `--completion-score` records it as 100, for a
+ gradebook that needs a number, and with a pass mark it passes. An Accordion, a Virtual Tour, or a
+ presentation or book with no questions in it never finishes at all, and stays `incomplete` with
+ or without it: the LMS should complete such an activity on viewing.
+- **SCORM 2004** (`--scorm-version 2004`) only when the LMS asks for it, or a failed attempt
+ should still count as completed. Otherwise 1.2, the version checked in every LMS below.
+- **The title** the LMS lists it by is the package's own, unless `--title ""` gives another.
+
+For a plain quiz, the defaults fit: ask about nothing but the LMS.
+
+## 2. Check that the package plays
+
+ npx @missing-elements/h5p-verify@latest course.h5p --libraries pack --no-refresh-libraries --no-downgrade-libraries
+
+These options play it as the zip will: the libraries it carries as they are, the ones it lacks
+from the pack, and none older than the content was made for. Exit 0 is a pass. Exit 1 means
+the package does not play, and the summary says why: read it with the h5p-verify skill, if it is
+installed, and fix the package before going on. Exit 2 means the check could not run, for want of
+a browser or of a file at that path: fix that and run it again, or, where it cannot run, write
+the zip and tell the user the package is unchecked. Never change the package for an exit 2. A
+package h5p-author has just built and checked needs no second check.
+
+## 3. Write the zip
+
+ npx @missing-elements/h5p-embed@latest --scorm course.h5p
+ npx @missing-elements/h5p-embed@latest --scorm course.h5p course-80.zip --pass-mark 80
+ npx @missing-elements/h5p-embed@latest --scorm course.h5p --scorm-version 2004 --completion-score
+
+The first writes `course.scorm.zip` in the current folder; a name after the package writes that
+file instead, into a folder that already exists. It reads the whole package before it writes, and
+ends with what it wrote: the zip and its size, the title, the SCORM version, the options, and the
+libraries it took from the pack. If it refuses:
+
+| It says | What to do |
+|---|---|
+| `needs libraries that neither it nor the library pack carries: …` | The package was made with a library, or a version of one, that the pack does not have. Export it with its libraries from a tool that carries them, such as Lumi or the H5P plugin of Moodle, WordPress or Drupal, and write the zip from that |
+| `… exists. Pass --force to replace it.` | Give another name, or add `--force` once the user agrees to replace the file |
+| `No such file: …` | The path is wrong, or the command ran in another folder: check both before asking the user for the file |
+| `it is not an H5P package`, `could not be read as a zip archive`, `names no libraries` | Not a playable `.h5p`: ask the user for the file again |
+| `The pass mark is a number from 0 to 100` | Give a number, such as `--pass-mark 80` |
+
+## 4. Hand over
+
+Give the user the zip and the way into their LMS:
+
+| LMS | Add the zip as | Change from the defaults | SCORM 2004 and the grading options |
+|---|---|---|---|
+| Moodle 4.5 | a SCORM package activity | nothing; keep the maximum grade at 100 | checked |
+| ILIAS 11 | a SCORM learning module | turn Learning Progress on in Administration, then in the module's Learning Progress choose "Collection of SCORM Items" and tick the item; without it ILIAS drops every score | not yet |
+| OpenOLAT 21.1 | a "SCORM 1.2" course element | set "Score needed to pass" to the pass mark, or choose "Transfer passed value", since otherwise every result passes; in a learning path, choose "Passed" as the completion criterion | not yet |
+| Chamilo 3.0 | an imported learning path | publish the learning path | not yet |
+| SCORM Cloud | a course | nothing | checked |
+| Frappe LMS, `develop` | a SCORM chapter | nothing; the content needs a pass mark, and Frappe keeps no score | not yet |
+
+Each was checked at that version, as a learner in Chrome. Another LMS that takes SCORM 1.2 is
+likely to work but has not been tried: say so, and suggest a test course first.
+
+Tell the user, too:
+
+- The LMS must be served over https, since the player needs a Service Worker.
+- The package's own code runs on the LMS's site, as every SCORM package's does: make zips only
+ of packages the user trusts as much as any other SCORM package they upload.
+- How to try it: launch it as a student, answer one question wrong and the rest right, and check
+ the score and the status in the gradebook; then leave halfway through and launch it again.
+- The next launch continues where the learner was only for a content type that saves its place,
+ as Question Set, Course Presentation, Interactive Book, Interactive Video, Branching Scenario
+ and most single questions do. An Accordion, Image Hotspots, Flashcards or a Timeline starts over
+ at every launch, as on any H5P site.
+- SCORM 1.2 keeps 4,096 characters of saved state, of which a quiz takes about 200 and a
+ twelve-chapter Interactive Book about 1,000. A state that does not fit is not saved, and the
+ page says so under the content; SCORM 2004 keeps 64,000.
+- A zip written again from another `.h5p` starts learners over: their saved place belongs to
+ the package it was saved in.
+
+Someone who will convert files without a terminal, or many at once, can use the page that builds
+the same zips in the browser, with nothing uploaded:
+https://h5p-offline-player.vercel.app/demo/scorm.html
+
+## What a pass here does not prove
+
+You can check that the package plays and that the zip was written, not that the LMS records what
+it should: no LMS runs here. Say what was checked and no more. Where an LMS serves the zip whole
+rather than in ranges (ILIAS, Chamilo, Frappe LMS), a large video in it starts only once the
+download has reached it.