Drag and Drop (H5P.DragQuestion 1.14) content can no longer be edited after library update – editor crashes, 1.15 content works
Environment
- Moodle 5.2.3, core H5P (not mod_hvp)
- H5PEditor.DragQuestion 1.10.27, H5PEditor.Wizard 1.2.17
- H5P.DragQuestion 1.14.23 (existing content) and 1.15.37 (new content, depends on H5P.Components 1.0)
Symptom
Existing Drag and Drop activities play correctly with all text elements and drop zones. When opened in the editor, the canvas is empty: no drop zones and no elements. Updating the libraries and purging caches did not fix it.
Console output when opening the editor:
H5PEditor.DragQuestion.js?ver=1.10.27:50 Uncaught TypeError: Cannot read properties of undefined (reading 'find')
at Array.<anonymous> (H5PEditor.DragQuestion.js:50:108)
at ns.processSemanticsChunk (h5peditor.js:515:24)
at ns.Form.processSemantics (h5peditor-form.js:445:6)
...
Wizard.js?ver=1.2.17:233 Uncaught TypeError: Cannot read properties of undefined (reading 'push')
at H5PEditor.Wizard.C.ready (Wizard.js:233:20)
at H5PEditor.DragQuestion.C.ready (H5PEditor.DragQuestion.js:1608:19)
...
What we tested
- Inspected the content of the affected activity. content.json is valid against the 1.14 semantics: 12 elements and 12 drop zones, all with x/y/width/height, valid subContentIds, a background image and size present, and consistent element/drop zone references. The only absent field is the optional behaviour.backgroundOpacity.
- Created a new Drag and Drop in the same Moodle. It is created as 1.15 and edits without problems.
- Uploaded the affected 1.14 file to h5p.test.schulcloud-thueringen.de. It could not be edited there either, so the problem does not appear to be specific to Moodle.
- The official h5p.test.schulcloud-thueringen.de Drag and Drop example (1.14) uploads and plays in Moodle but cannot be edited.
- Uploading the new 1.15 export to h5p.test.schulcloud-thueringen.de fails with "Missing main library H5P.DragQuestion 1.15" / "Missing required library H5P.Components 1.0".
Workaround that worked
We moved the content to 1.15 by hand. We took the working 1.15 export, replaced its content/ folder with the 1.14 content, and applied the 1.15 upgrade step from upgrades.js (behaviour.dragHandleVisibility = false). We also set the title and language in h5p.json. After re-uploading, the activity is fully editable.
Suspected root cause
Both the 1.14 and the 1.15 packages use the same editor version (H5PEditor.DragQuestion 1.10.27). The editor works with 1.15 content but fails with 1.14 content. Line 50 is:
H5PEditor.findField('../behaviour/backgroundOpacity', parent).$item.find('input')
The field is found, but its $item has not been rendered yet when the parent.ready() callback fires. The Wizard error that follows is a knock-on effect of the ready-callback order breaking. Our assumption is that editor 1.10.27 was updated together with DragQuestion 1.15 / H5P.Components and no longer handles 1.14 content. Either it relies on 1.15 behaviour, or the editor initialises before 1.14 content is upgraded. As a result, all 1.14 content on the site is uneditable.
Questions
- Is this a known regression in H5PEditor.DragQuestion 1.10.27?
- Is there a supported way to bulk-upgrade 1.14 content to 1.15 in Moodle core H5P?