test(journeys): real content types answered as a learner, with what they then do checked (#314)

AL
10h ago
+958-9

Part of #314: the harness, and the first five content types.

A journey builds a real package of a content type with h5p-author, plays it in the element and answers it in a browser as a learner does. Each case was written from the type's own script, read first: what it scores, what a wrong answer costs, when it offers Retry and Show solution, and what it saves.

What each type's cases hold

  • Multiple Choice 1.16 (8): radios when one answer is right, else boxes; a point for each right answer less one for each wrong, never below nothing; one point for the whole task where the author asked, from the pass mark up; Retry; Show solution; the answers come back by their place in the source.
  • True/False 1.8 (5): one point; the author's words for right and wrong, with @score and @total; Retry and Show solution only after a wrong answer; a check with nothing chosen; checking as the learner chooses.
  • Fill in the Blanks 1.14 (5): a point a blank; any of a blank's alternatives; compared as typed unless the author let case pass; one wrong letter in a word of more than three; the solution only once every blank is filled.
  • Drag the Words 1.10 (6): a point for each zone that holds a word with its text, so two words with the same text are either's; nothing off for a wrong word or an empty zone; the author's words for the score's range; each drop judged at once where asked.
  • Question Set 1.21 (9): reports once, on Finish, the sum of its questions' points, each of which says it is a part; passes from its pass mark up; offers Finish only once every question has an answer; Retry; no way back where the author closed it; no Check buttons; a pool; the order it shuffled its questions into kept when a learner comes back.
  • Each type has a case for resume: the state it saves, and what a learner sees on coming back.

What the scripts and the first runs showed

  • An Interactive Video built by h5p-author reports no result. It sends completed only from its submit screen, which exists only where the content lists one (assets.endscreens). H5P's editor gives a new video one at its end; a source does not. Measured on a video with two answered questions: no completed at the end, with or without reporting. Not fixed here.
  • In Firefox, a second word does not drag. The first drag leaves text selected, and a press on a word inside the selection starts the browser's own text drag, which takes the mouse. With the selection cleared the drag works. Whether a person's Firefox does the same is not known, so those 12 cases are not run there, and say why (dragsWords).
  • A click within 150 ms of a press was lost in Firefox, while a question rebuilds its buttons. The browser now acts at a learner's pace, 60 ms an action.

How it is built

  • apps/journeys, a test project of its own, as apps/skills is. tests/harness.ts reuses h5p-author's buildPackage and the verifier's server, serves the repository's copy of the pack, and reaches no network.
  • CI: a lane of its own on a pull request, in Chromium, when a package it plays changes, so the run takes no longer; Firefox and WebKit with the weekly run (pnpm test:engine).
  • design/testing.md: the rules. AGENTS.md, design/layout.md, docs/development.md: the third app.

Tests

  • 33 cases: Chromium 33 passed, five runs in a row and two under a load of three processes a core; WebKit 33 passed; Firefox 21 passed and 12 not run. On a Mac.
  • 45 s on a laptop, of which the resume cases wait about 5 s each for the content to save.
  • Type check and pnpm comments.
  • On CI: the pull request's run, with test (journeys) at 1m17s in Chromium; and the whole of CI run by hand on this branch, green, with the journeys in Firefox and WebKit on Linux.

Not done, and next under #314: Course Presentation and Interactive Video, each read first; both were played here while the harness was written.


Summary by cubic

Adds apps/journeys, a new test project that builds real H5P content packages with h5p-author, plays them in the element, and answers them in a browser as a learner does. Each case checks the score, the xAPI statements, and the saved state a reload with resume brings back.

  • Covers Multiple Choice 1.16, True/False 1.8, Fill in the Blanks 1.14, Drag the Words 1.10, and Question Set 1.21: 33 cases, written from each type's own script.
  • Runs in a lane of its own on pull requests, in Chromium; Firefox and WebKit join the weekly run. Nothing reaches a network.

Findings

  • An Interactive Video built by h5p-author reports no result: it sends completed only from a submit screen, which a source lacks (not fixed here).
  • In Firefox, a second drag fails because the first leaves text selected, starting the browser's own text drag; the 12 drag cases are not run there (dragsWords).
  • The browser acts at a learner's pace (60 ms an action), since a click within 150 ms of a press was lost in Firefox while a question rebuilds its buttons.