Repository navigation
feat(h5p-author): a check of saved content, which the build runs last (#107) - #113
Merged
Merged
Conversation
…#107) checkContent(libraries, { type, params }) checks content in the form H5P saves it, as the build checks what it writes: files and sub-content metadata as saved, held to what the platforms keep of them; each part's subContentId kept, a new one only for a part without one, with one H5P would not keep or with an earlier part's; a markup field's text not wrapped again. The layouts' after hooks, the empty titles and the unset fields moved into it, and the build runs it last on what it writes. Game Map's before keeps only the conversion of a source's numbers and labels; its checks run on the stored form. packageLibraries(files, pack) serves a package's own libraries where it carries a major, the pack's otherwise, by the player's ownLibraries. Where the content names another minor than the one checked against, a field only that minor has is noted and kept. A group that is sub-content now gets an id in a build, as the editor's initSubContent gives one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #107.
Stacked on #112 (#109): the base is
feat/embed-plan-imports, becausepackageLibrariestakes a package's own libraries by the player'sownLibraries, which #112 adds to./plan. Once #112 is merged I retarget this tomain.What it adds
checkContent(libraries, { type, params })checks content in the form H5P saves it, as the build checks what it writes, and returns{ params, problems, notes }. The libraries are loaded byloadLibraries, as for a build.typeis the content type with the version it was saved with, ash5p.jsonnames it (H5P.QuestionSet 1.20).subContentId. A part without one, with one H5P would not keep, or with an id an earlier part already has gets a new id, with a note. Copy and paste in the editor leaves such duplicates.after), each part without a title takes its content type's, and a hidden field nothing set is a problem.packageLibraries(files, pack)is a library source over a package's own library folders, with the pack behind it for what the package does not carry.filesis{ names, read }, so any zip reader serves. A folder counts as the package's own by the player's rule (ownLibraries).afterhooks, the empty titles and the unset fields moved out ofbuild.mjsinto the check. The build adds what the check finds, except where the source has that problem already, or where the generator refused what was written there and left a value missing. Every problem still comes at once.beforeis split as the issue proposed. It keeps the conversion of a source's numbers and labels into the stored text. The checks run on the stored form inafter: positions from 0 to 100, neighbours as indices of other stages, joined both ways.initSubContentgives one. Summary's statements and Single Choice Set's choices had none from a build, and Summary names each statement's statements by that id.The rule for which semantics (decided in #107)
The package's own libraries where it carries a major of one; the pack's where it does not. Where the content names another minor than the one it is checked against, as an export without its libraries does against the pack, a field only that minor has is noted and kept, not refused. The player upgrades older content as it plays it, which can move such a field: Question Set 1.21's upgrade step moves 1.20's
backgroundImageintooverride. That upgrade runs in the GPL runtime's frame, so h5p-author cannot run it. Content newer than the pack is played without the field.What saved content holds
Run over the 88 real packages in the local test corpus (not in git): 61 report nothing. Three things the editor saves for an author who never touched them are taken as such, all found on that corpus:
goto.type: "").The other 27 hold what their editor let an author save and the build does not:
dropZones[].type, Branching Scenario'scontentId);These are reported as problems. A tool that changes one part should keep only the problems under the paths it changed; the README and AGENTS.md say so.
Content written without its defaults comes back with them, as the editor saves it. The demo's hand-written packages are like that, so they come back changed but report nothing.
Checked
apps/skills' every-example test, which passes (73 tests).formulas.h5p, an export without its libraries, is checked against the pack, also with nothing reported.markup.h5preports exactly the markup it carries to be removed. All intests/check.test.ts.checkContent,packageLibrariesand the Game Map split against the real pack. I broke each saved-mode rule in turn, and each broken rule fails at least one test.mainfor Summary and Single Choice Set (nofinishedin either). CI runs it again, since it starts on any change togenerator.mjs.tests/package-types.ts.Not in this PR
check.mjsandmetadata.mjshave no Node import of their own, likelibraries.mjs;generator.mjsandtypes.mjsstill takerandomUUIDfromnode:crypto.null(one corpus package) are reported, though a layout could place them.🤖 Generated with Claude Code