fix(author): a Drag and Drop's boxes are laid out by the build (#295)
Merged
AL
2d ago+420+420+012345678901234567890123456789-15-15-01234567890123456789
Closes #295.
A Drag and Drop built in a chat played with its words stacked over each other and over the zones. Its boxes are placed by x and y in percent of the task and sized by width and height in em, and a model wrote all four as percent. Now the build lays the boxes out itself, and a model is told to leave the four out.
What changes
- The build lays out a Drag and Drop's boxes that have no place (
dragQuestioninlib/types.mjs). Words go in centred rows, shared evenly (3 and 2, not 4 and 1), each as wide as its text. Zones go below, as wide as their labels and tall enough for the words right in them. The task grows as tall as they need. Boxes placed by hand keep their places, and the rest go below them. The sizes come from the player: per-character text widths, a draggable's 1.55 by 0.75 em of handle and padding, and a zone's label drawn 1.25 em above its box, all measured in H5P.DragQuestion 1.15. - A zone the build lays out shows its label when no background picture is under it, since nothing else tells it apart. A
showLabelthe source writes is kept. - One note when written boxes run past the task or over each other: it names them and gives the units. Zones on a background picture get the "placed by numbers" note that hotspots get.
- The field list leaves out the four layout fields, as it does for Course Presentation. A new type file,
H5P.DragQuestion.md, says to leave them out, and when to write them: zones on a picture. The skill's table lists the type. - A group's default keeps only its fields. The build wrote
size.field: "background", the dimensions widget's own setting, which the content check removes. Every Drag and Drop with no size written carried it.
Tested
- Unit tests: author's 305 pass, 4 of them new. They check that laid-out boxes stay inside the task and never overlap, words above zones; that placed boxes are kept and a written
showLabel: falsestays; that the reported content gets one note; and the picture note. Typecheck andpnpm commentspass, andsync:skill --checkfinds every type file current. - The type file's example builds, checks as saved content unchanged, and plays trusted and untrusted without warnings (
apps/skills). - Played: the reported content with its places left out lays out as words above zones. A word dragged into a zone fits with room around it.
- Haiku, route 1, a build archive from this branch: asked for "an H5P Drag & Drop with 5 random questions about English vocabulary". It left the places out in 5 of 5 runs, and the 3 played had no box over another and every label whole.
Summary by cubic
Fixes Drag and Drop layout so generated boxes no longer stack on each other or the task's zones. The build now places unplaced words and zones itself in rows, growing the task to fit, instead of relying on the model's percent-based coordinates.
- Words go in centred rows above zones, sized by their text; zones are wide enough for their labels and the words right in them.
- Boxes placed by hand keep their places, and laid-out rows go below them; a
ywritten in percent stays in the written pixels, not the grown task's height. - Boxes without a written size get sized even when already placed.
- Zones on a background picture keep the "placed by numbers" note; all laid-out boxes are checked for running past the task or overlapping, with one note naming offenders.
- Models are told to leave
x,y,width, andheightout unless placing zones on a picture, via the newH5P.DragQuestion.mdtype file. - Group defaults now keep only the group's own fields, dropping widget-driven values like
size.field.