Convert H5P to SCORM in your browser — h5p-offline-player
-
+
-
+
@@ -19,7 +19,7 @@
-
+
@@ -33,7 +33,7 @@
H5P to SCORM
Drop .h5p files here, or choose them, check what each zip will hold, and
- download them as SCORM 1.2 packages for your LMS. They are built in your browser with the
+ download them as SCORM packages for your LMS. They are built in your browser with the
player this site serves, and nothing is uploaded: the packages never leave your computer.
@@ -57,8 +57,32 @@
2 Review
+
+
3 Options
+
+ For every zip. Left as they are, a zip is SCORM 1.2 and takes the content's own result, as
+ this page has always written it.
+
+
+
+
+
+
+ A score at or above it passes, whatever the content says, and the LMS gets it as the mastery score. Content with no score gets no pass or fail from it.
+
+
+
+ For a gradebook that needs a number: a presentation without questions, finished, records 100. Content that never finishes, such as an Accordion, stays incomplete.
+
+
+
+
-
3 Download
+
4 Download
@@ -87,23 +111,24 @@
In the LMS
-
Checked in
Add the zip as
Change from the defaults
+
Checked in
Add the zip as
Change from the defaults
SCORM 2004 and the options
-
Moodle 4.5
a SCORM package activity
nothing; keep the maximum grade at 100
-
ILIAS 11
a SCORM learning module
turn Learning Progress on
-
OpenOLAT 21.1
a "SCORM 1.2" course element
the pass mark; in a learning path, the completion criterion
-
Chamilo 3.0
an imported learning path
publish the learning path
-
SCORM Cloud
a course
nothing
-
Frappe LMS
a SCORM chapter
nothing; the content needs a pass mark
+
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
not yet
+
OpenOLAT 21.1
a "SCORM 1.2" course element
the pass mark; in a learning path, 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
a SCORM chapter
nothing; the content needs a pass mark
not yet
Another LMS that takes SCORM 1.2 may work as well; these are the ones checked, as a learner
in Chrome. The LMS has to be served over https, since the player needs its Service Worker.
- SCORM 1.2 keeps 4,096 characters of saved state; the zip writes it compressed, so a quiz
- takes about 200 and a twelve-chapter Interactive Book about 1,000. One that does not fit is
- not saved, and the learner is told under the content.
+ SCORM 1.2 keeps 4,096 characters of saved state, and 2004 64,000; the zip writes it
+ compressed, so a quiz takes about 200 and a twelve-chapter Interactive Book about 1,000.
+ One that does not fit is not saved, and the learner is told under the content. SCORM 2004
+ and the grading options are checked in Moodle and SCORM Cloud so far.
What goes in the zip
@@ -123,7 +148,8 @@
From the command line
written by h5p-embed for a player domain of your own carries this page too, at
/scorm.html.
-
+ For every zip. Left as they are, a zip is SCORM 1.2 and takes the content's own result, as
+ this page has always written it.
+
+
+
+
+
+ A score at or above it passes, whatever the content says, and the LMS gets it as the mastery score. Content with no score gets no pass or fail from it.
+
+
+
+ For a gradebook that needs a number: a presentation without questions, finished, records 100. Content that never finishes, such as an Accordion, stays incomplete.
+
+
+
-
3 Download
+
4 Download
@@ -57,20 +79,21 @@
In the LMS
-
Checked in
Add the zip as
Change from the defaults
+
Checked in
Add the zip as
Change from the defaults
SCORM 2004 and the options
-
Moodle 4.5
a SCORM package activity
nothing; keep the maximum grade at 100
-
ILIAS 11
a SCORM learning module
turn Learning Progress on
-
OpenOLAT 21.1
a "SCORM 1.2" course element
the pass mark; in a learning path, the completion criterion
-
Chamilo 3.0
an imported learning path
publish the learning path
-
SCORM Cloud
a course
nothing
-
Frappe LMS
a SCORM chapter
nothing; the content needs a pass mark
+
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
not yet
+
OpenOLAT 21.1
a "SCORM 1.2" course element
the pass mark; in a learning path, 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
a SCORM chapter
nothing; the content needs a pass mark
not yet
- Another LMS that takes SCORM 1.2 may work as well; these are the ones checked. The LMS has
- to be served over https.
+ Another LMS that takes SCORM 1.2 may work as well; these are the ones checked. SCORM 2004
+ and the grading options are checked in Moodle and SCORM Cloud so far. The LMS has to be
+ served over https.
What goes in the zip
diff --git a/packages/embed/tests/package-types.ts b/packages/embed/tests/package-types.ts
index 12f7718a..9663bf71 100644
--- a/packages/embed/tests/package-types.ts
+++ b/packages/embed/tests/package-types.ts
@@ -24,7 +24,10 @@ export async function asACallerWould(): Promise {
await buildSite({ folder: 'public/player' })
// One package as a SCORM zip, for an LMS.
- const zip: BuiltScorm = await buildScorm({ h5p: 'course.h5p', out: 'course.scorm.zip', force: true, title: 'Week 3' })
+ const zip: BuiltScorm = await buildScorm({ h5p: 'course.h5p', out: 'course.scorm.zip', force: true, title: 'Week 3', scormVersion: '2004', passMark: 80, completionScore: true })
+ const scorm: '1.2' | '2004' = zip.scormVersion
+ // @ts-expect-error the version is 1.2 or 2004
+ await buildScorm({ h5p: 'course.h5p', out: 'course.scorm.zip', scormVersion: '1.3' })
const build: string = zip.build
const fromPack: string[] = zip.libraries
// @ts-expect-error the package is named `h5p`
@@ -36,13 +39,13 @@ export async function asACallerWould(): Promise {
// Read first, so that a page can say what the zip will hold, and written after, under a title.
const plan: PlannedScorm = await planScormInPage({ file: new Blob([]), name: 'course.h5p', pack })
const main: string | undefined = plan.mainLibrary?.machineName
- const retitled: PageScorm = await plan.write({ title: 'Week 3', onProgress: ({ step }) => step })
+ const retitled: PageScorm = await plan.write({ title: 'Week 3', scormVersion: '2004', passMark: null, completionScore: false, onProgress: ({ step }) => step })
// @ts-expect-error a title is text
await plan.write({ title: 3 })
startScormPage({ pack, version: '1.4.0', packVersion: '1.0.1' })
// @ts-expect-error the package is a `file`, not a path
await buildScormInPage({ h5p: 'course.h5p' })
- void [hosts, build, fromPack, blob, main, retitled, parseOrigin, new EmbedError('refused') instanceof Error]
+ void [hosts, build, fromPack, blob, main, retitled, scorm, parseOrigin, new EmbedError('refused') instanceof Error]
return site.csp
}
diff --git a/packages/embed/tests/scorm-browser.test.ts b/packages/embed/tests/scorm-browser.test.ts
index 54829855..dba22adf 100644
--- a/packages/embed/tests/scorm-browser.test.ts
+++ b/packages/embed/tests/scorm-browser.test.ts
@@ -140,6 +140,29 @@ describe('built in a page', () => {
await expect(buildScormInPage({ file: await picked(quiz, 'quiz.h5p'), ...onSite(site), title: ' \t ' })).resolves.toMatchObject({ title: 'Do you know what just happened?' })
})
+ it("writes the command's zip with the command's options, and refuses them with a launch page from before them", async () => {
+ const options = { scormVersion: '2004' as const, passMark: 80, completionScore: true }
+ const built = await buildScormInPage({ file: await picked(formulas, 'formulas.h5p'), ...onSite(site), ...options })
+ const out = join(dir, 'formulas.2004.page.zip')
+ await writeFile(out, new Uint8Array(await built.blob.arrayBuffer()))
+ const command = await buildScorm({ h5p: formulas, out: join(dir, 'formulas.2004.cli.zip'), ...options })
+ expect(built).toMatchObject({ scormVersion: '2004', build: command.build })
+ await expectSameZip(out, command.out)
+
+ // A plan written under other options, as the page's options step changes them.
+ const plan = await planScormInPage({ file: await picked(quiz, 'quiz.h5p'), ...onSite(site) })
+ expect((await plan.write()).scormVersion).toBe('1.2')
+ expect((await plan.write({ scormVersion: '2004' })).scormVersion).toBe('2004')
+ await expect(plan.write({ passMark: 120 })).rejects.toThrow(/The pass mark is a number from 0 to 100, not 120\./)
+ await expect(planScormInPage({ file: await picked(quiz, 'quiz.h5p'), ...onSite(site), scormVersion: '3' as never })).rejects.toThrow(/The SCORM version is 1\.2 or 2004/)
+
+ // A page that bundles the launch page as embed 1.5 shipped it has no place for the options.
+ const launch = (await readFile(join(import.meta.dirname, '../scorm/index.html'), 'utf8')).replace('%SCORM%', '')
+ const older = { ...onSite(site), assets: { launch } }
+ await expect(buildScormInPage({ file: await picked(quiz, 'quiz.h5p'), ...older, scormVersion: '2004' })).rejects.toThrow(/The launch page's template is older than the SCORM options/)
+ await expect(buildScormInPage({ file: await picked(quiz, 'quiz.h5p'), ...older })).resolves.toMatchObject({ scormVersion: '1.2' })
+ })
+
it("takes the pack as its package exports it, with the same result", async () => {
const index = JSON.parse(await readFile(join(dir, 'site', 'libraries', 'index.json'), 'utf8')) as { libraries: Array<{ folder: string }> }
const pack = { libraries: index.libraries.map((entry) => ({ ...entry, url: `${site.origin}/libraries/${entry.folder}.h5p` })) }
diff --git a/packages/embed/tests/scorm-page.test.ts b/packages/embed/tests/scorm-page.test.ts
index 7fb746d8..a69e9226 100644
--- a/packages/embed/tests/scorm-page.test.ts
+++ b/packages/embed/tests/scorm-page.test.ts
@@ -210,6 +210,47 @@ describe('the SCORM page', () => {
await context.close()
})
+ it('writes every zip with the options chosen, takes the zips back when one changes, and refuses a pass mark that is not one', async () => {
+ const context = await browser.newContext()
+ const page = await context.newPage()
+ await page.goto(`${site.origin}/scorm.html`)
+ expect(await page.locator('[data-step="options"]').isHidden()).toBe(true)
+ await page.setInputFiles('#file', [quiz, formulas])
+ await read(page, 2)
+ expect(await page.locator('[data-step="options"]').isVisible()).toBe(true)
+ // As they come: SCORM 1.2, no mark, no score for content without one.
+ expect(await page.locator('input[name="scorm-version"][value="1.2"]').isChecked()).toBe(true)
+ expect(await page.locator('#pass-mark').inputValue()).toBe('')
+ expect(await page.locator('#completion-score').isChecked()).toBe(false)
+
+ await page.locator('input[name="scorm-version"][value="2004"]').check()
+ await page.locator('#pass-mark').fill('120')
+ expect(await page.locator('#build').isDisabled()).toBe(true)
+ expect(await page.locator('#pass-mark').getAttribute('aria-invalid')).toBe('true')
+ expect(await page.locator('#status').textContent()).toMatch(/^The pass mark is a number from 0 to 100/)
+ await page.locator('#pass-mark').fill('80')
+ await page.locator('#completion-score').check()
+ expect(await page.locator('#build').isDisabled()).toBe(false)
+ await page.locator('#build').click()
+ await page.locator('#download').waitFor({ state: 'visible', timeout: 120_000 })
+ expect(await page.locator('#status').textContent()).toBe('2 SCORM 2004 packages, each with its link above.')
+
+ const own = await saved(page, rowOf(page, 'quiz.h5p').locator('.scorm-row-download'), 'quiz.options.zip')
+ const zip = await entriesOf(own.path)
+ expect(await zip.text('imsmanifest.xml')).toContain('0.8')
+ const launchPage = await zip.text('index.html')
+ expect(launchPage).toContain('')
+ expect(launchPage).toContain('')
+ await zip.close()
+
+ // Back to 1.2: every zip written before is taken back, to be built again.
+ await page.locator('input[name="scorm-version"][value="1.2"]').check()
+ expect(await page.locator('#download').isHidden()).toBe(true)
+ expect(await page.locator('#files > li[data-state="built"]').count()).toBe(0)
+ expect(await page.locator('#build').textContent()).toBe('Build 2 SCORM packages')
+ await context.close()
+ })
+
it('takes files dropped on the page, and the same file only once', async () => {
const context = await browser.newContext()
const page = await context.newPage()
diff --git a/packages/embed/tests/scorm.test.ts b/packages/embed/tests/scorm.test.ts
index ac141833..5c27685e 100644
--- a/packages/embed/tests/scorm.test.ts
+++ b/packages/embed/tests/scorm.test.ts
@@ -165,6 +165,56 @@ describe('the package', () => {
expect(existsSync(out)).toBe(false)
})
+ it('writes none of the options unless asked: SCORM 1.2, the content\'s own result, and nothing in the page', async () => {
+ const out = join(dir, 'plain-options.zip')
+ expect(await buildScorm({ h5p: quiz, out })).toMatchObject({ scormVersion: '1.2' })
+ const zip = await entriesOf(out)
+ const xml = await zip.text('imsmanifest.xml')
+ expect(xml).toContain('1.2')
+ expect(xml).not.toContain('masteryscore')
+ expect(await zip.text('index.html')).not.toContain('h5p-scorm')
+ expect(await zip.text('NOTICE.txt')).toMatch(/^This is a SCORM 1\.2 package/)
+ await zip.close()
+ })
+
+ it('writes a pass mark as SCORM 1.2\'s mastery score, and SCORM 2004\'s manifest with the mark as its objective', async () => {
+ const graded = join(dir, 'graded.zip')
+ await buildScorm({ h5p: quiz, out: graded, passMark: 80, completionScore: true })
+ const one = await entriesOf(graded)
+ expect(await one.text('imsmanifest.xml')).toContain('Do you know what just happened?\n 80\n ')
+ const page = await one.text('index.html')
+ expect(page).toContain('')
+ expect(page).toContain('')
+ expect(page).not.toContain('h5p-scorm-version')
+ await one.close()
+
+ const out = join(dir, 'quiz-2004.zip')
+ // A mark kept to the hundredth, as the score is, and to the ten-thousandth as a measure.
+ expect(await buildScorm({ h5p: quiz, out, scormVersion: '2004', passMark: 66.666 })).toMatchObject({ scormVersion: '2004' })
+ const zip = await entriesOf(out)
+ const xml = await zip.text('imsmanifest.xml')
+ expect(xml).toContain('xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"')
+ expect(xml).toContain('xmlns:adlcp="http://www.adlnet.org/xsd/adlcp_v1p3"')
+ expect(xml).toContain('2004 4th Edition')
+ expect(xml).toContain('')
+ expect(xml).toContain('0.6667')
+ expect(xml).toContain('adlcp:scormType="sco"')
+ const listed = [...xml.matchAll(//g)].map((match) => match[1])
+ expect(listed.sort()).toEqual([...zip.names].sort())
+ expect(await zip.text('index.html')).toContain('\n ')
+ expect(await zip.text('NOTICE.txt')).toMatch(/^This is a SCORM 2004 4th Edition package/)
+ await zip.close()
+ })
+
+ it('refuses an option it does not know, before writing anything', async () => {
+ const out = join(dir, 'unknown-option.zip')
+ await expect(buildScorm({ h5p: quiz, out, scormVersion: '1.3' as never })).rejects.toThrow(/The SCORM version is 1\.2 or 2004, not "1\.3"\./)
+ for (const passMark of [101, -1, Number.NaN, '80' as never]) {
+ await expect(buildScorm({ h5p: quiz, out, passMark })).rejects.toThrow(/The pass mark is a number from 0 to 100/)
+ }
+ expect(existsSync(out)).toBe(false)
+ })
+
it('refuses what is not a package, and a zip already there unless forced', async () => {
const notZip = join(dir, 'not.h5p')
await writeFile(notZip, 'not a zip')
@@ -214,6 +264,31 @@ describe('the command', () => {
expect(existsSync(join(dir, 'titled-site'))).toBe(false)
})
+ it('writes SCORM 2004 with a pass mark and completion as 100 as the flags say, and refuses what is not one', async () => {
+ const cwd = join(dir, 'cli-options')
+ await mkdir(cwd)
+ const { stdout } = await run(process.execPath, [bin, '--scorm', quiz, '--scorm-version', '2004', '--pass-mark', '80', '--completion-score'], { cwd })
+ expect(stdout).toContain('"Do you know what just happened?" as a SCORM 2004 4th Edition package (pass mark 80, completion counts as 100)')
+ const zip = await entriesOf(join(cwd, 'quiz.scorm.zip'))
+ expect(await zip.text('imsmanifest.xml')).toContain('0.8')
+ await zip.close()
+
+ for (const [flags, said] of [
+ [['--pass-mark', 'eighty'], 'The pass mark is a number from 0 to 100, not "eighty".'],
+ [['--pass-mark', ''], 'The pass mark is a number from 0 to 100, not "".'],
+ [['--pass-mark', '120'], 'The pass mark is a number from 0 to 100, not 120.'],
+ [['--scorm-version', '1.3'], 'The SCORM version is 1.2 or 2004, not "1.3".']
+ ] as const) {
+ const failure = await run(process.execPath, [bin, '--scorm', quiz, 'refused.zip', ...flags], { cwd }).catch((error) => error)
+ expect(failure.code, flags.join(' ')).toBe(1)
+ expect(failure.stderr).toContain(said)
+ }
+ expect(existsSync(join(cwd, 'refused.zip'))).toBe(false)
+ const site = await run(process.execPath, [bin, 'site', '--pass-mark', '80', '--completion-score'], { cwd }).catch((error) => error)
+ expect(site.code).toBe(2)
+ expect(site.stderr).toContain('--pass-mark, --completion-score only with --scorm')
+ })
+
it('refuses the site\'s options beside --scorm', async () => {
const failure = await run(process.execPath, [bin, '--scorm', quiz, '--packages', 'https://cdn.example.org'], { cwd: dir }).catch((error) => error)
expect(failure.code).toBe(2)
@@ -306,6 +381,51 @@ const LMS_PAGE = `