Build an H5P package
build_h5pValidate H5P content against deployment and content-type rules, then write a content-only .h5p package plus an optional HTML preview for review before upload.
Instructions
Build a content-only .h5p package (h5p.json and content/content.json, no libraries) from content written for one of list_h5p_types' types, in the shape its fields give. The content is checked first, with the rules a site applies when it deploys the package (required fields, kinds, limits, the HTML tags each text allows) and the type's own (a multiple choice with a right answer, a blank with its answer…); if anything is wrong nothing is written and the error lists what to fix. Plain text is escaped; where a field takes HTML, simple HTML with its allowed tags may be used. Buttons and messages are filled in the package's language. Writes /.h5p and, unless preview is false, .preview.html next to it: the content as a page to review before uploading. Confirm with the person before overwriting. The package plays only on a site with that type installed at that version; uploading it is another tool's job.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | The file name without .h5p; by default made from the title | |
| type | Yes | The content type, such as H5P.MultiChoice (from list_h5p_types) | |
| title | Yes | The package's title, as the site will show it | |
| content | Yes | The content, in the shape list_h5p_types gives for the type | |
| destDir | Yes | An existing folder to write the package in (absolute path) | |
| preview | No | Write the HTML preview next to the package (default true) | |
| language | Yes | The content's language code, such as es or en: its buttons and messages come in it | |
| overwrite | No | Replace the package and preview if they exist; only once the person agrees |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The package written | |
| type | Yes | ||
| title | Yes | ||
| preview | No | The HTML preview written next to it | |
| version | Yes | The type's version the site must have | |
| language | Yes | ||
| warnings | Yes | What the person should know, such as texts left in English |