fix(author): a Drag and Drop's task fits its boxes, or its picture's shape (#297)

Merged
AL
13h ago
+242-52

Closes #297.

A Drag and Drop's task size was left to the model: it wrote one too tall for its boxes, and on a background picture the task kept 620 × 310 whatever the picture's shape. The rules below come from H5P.DragQuestion 1.15's player, H5PEditor.DragQuestion 1.10 and the core's size widget, read and measured in the player.

What changes

  • The field list (schema --markdown): a group's default gives its fields theirs. Drag and Drop's size.width and size.height read = 620 and = 310, no longer "required". No other type file changes.
  • No picture: a task the build lays boxes out in is as tall as they need, shorter as well as taller than written. ChatGPT's 800 × 500 for six words and six zones is now about 350 px tall.
  • A picture:
    • A task with no height written takes the picture's shape. The player stretches the picture over the whole task, and the editor's size widget, meant to follow the picture, never does. A height written is kept, and one of another shape gets a note, so a package read back keeps the editor's size.
    • Elements with no place go in a band clear of the placed zones: the foot, the head, the right or the left. Where none is clear, each takes the lowest free spot. Before, they went below the zones, past the task's edge.
    • A zone's backgroundOpacity is 0 unless written. At the default 100 the zones hid what they name; the player still lights them up while a word is dragged. read writes a stored 100 back, so a package read back keeps it.
  • The generator: a group written in part takes the rest from its default, as H5P's editor fills one. read writes a stored height alone, and the build had then refused the missing width.
  • The type file: leave size out, and on a picture leave the elements out too. A zone is the box around its thing: x and y its top-left corner in percent of the picture, width and height in em by a given factor. Zones stay off each other, and showLabel stays off on a picture, since a label shown names the answer.

Content a 1.1.0 build gave differently

docs/compatibility.md promises the same content from a source that builds. This changes it in three places, all in Drag and Drop:

  • A task the build laid out without a picture changes height.
  • A task with a picture and no height written takes the picture's shape, and zones with no opacity written become clear.
  • Elements left without a place on a picture move.

Tested

  • Haiku, 9 runs: shown a house (4:3) or a plant (3:4) and asked for its parts, it put 46 of 46 zones on their parts, writing the em sizes by the factor: door zones 10–11 % wide for a 10 % door. Rebuilt with this branch, every task had the picture's shape, no word was over a zone, and no zone over another once the rule on overlapping things was added.
    • Most runs downloaded the live 1.1.0 tool from the org site, whose old placement put the words past the edge. Two of them then placed the words themselves, overlapping, as that note led them to; the run that left them out rebuilt clean.
  • New tests, each failing without its fix:
    • The field list shows the group's default.
    • A tall written task shrinks, and a small one is shorter than 310.
    • A picture's task gets its shape, with words at the foot, at the head when zones fill the foot, and in free spots around Haiku's six house zones; a written height is kept, with its note.
    • A Drag and Drop as the editor saves it, 620 × 310 over a 4:3 picture with an opaque zone, reads back with no note and builds again with its size and opacity.
  • Checks: author tests 312 passed, typecheck, pnpm comments, sync-skill --check.