Skip to content

Keep QTI content an edit doesn't touch - #6486

Open
rtibblesbot wants to merge 2 commits into
learningequality:unstablefrom
rtibblesbot:issue-6309-cc75e3
Open

rtibblesbot wants to merge 2 commits into
learningequality:unstablefrom
rtibblesbot:issue-6309-cc75e3

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • An edit keeps QTI content it doesn't touch: interaction attributes, MathML, glossary spans, tables, media, some Text Entry answers.
  • Closing an unedited card saves nothing.
  • A question whose rich text TipTap's schema can't hold opens read-only; the Incomplete indicator and validateQtiItem agree on it.

References

Fixes #6309. Related: #6327, #6349.

Reviewer guidance

Suggested review: Full code review, then manual QA once the reviewer sets Needs QA.

Engineer review

  • Self-review stopped with blocking findings open: Decide whether an Inline Choice option carrying any attribute but identifier (e.g. fixed="false") should lock the item, as the branch does (inlineChoice/Descriptor.js:63), and whether a resize made before an image loads may save width alone when the image loads while its hint is minimized (ImageNodeView.vue:151).
  • Editing an imported formula's TeX saves a span that publishes without the formula until [QTI] - The formulas are not shown in Kolibri #6327 is fixed.
  • Retained MathML without a TeX annotation is omitted from the Perseus version.
  • Changing question type drops preserved interaction attributes without warning.
  • Passage edits drop extra attributes on rebuilt inline-choice dropdowns.
Engineer evidence

Saving drops unmodeled attributes on interaction children.
Unrelated edits regenerate imported presentation settings.
Unrelated edits regenerate imported scoring settings.
Unrelated edits can merge Text Entry keys that differ only in outer whitespace.
The first unrelated edit canonicalizes a parseable localized numeric answer.
Replacing an image with one stored dimension before its preview loads leaves Perseus without a size.
Redoing a resize before intrinsic dimensions are readable can leave Perseus without a size.
Saving an unchanged Edit image dialog can add permanentsrc when the caret is outside the image.
Decide whether <b>, <i>, or an inline image should lock a converted question (contentcuration/contentcuration/frontend/shared/views/QTIEditor/validateItem.js:237).
Decide how #6349's parser should handle preserved annotated MathML (contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/extensions/Math.js:32).
Decide whether image insertion or replacement must obtain dimensions before the preview loads (contentcuration/contentcuration/frontend/shared/views/TipTapEditor/TipTapEditor/composables/useImageHandling.js:65).

Open risks:

  • Changing an imported formula's LaTeX saves it as <span data-latex>, which publishes empty until the related PR merges.
  • The related PR saves annotated <math> as data-latex spans, where this branch keeps MathML; whichever merges second rebases Math.js and the math fixtures.
  • Converted <b>/<i> and inline images open read-only, since TipTap writes them back changed; should they stay editable?
  • A question-type change still drops interaction attributes the old builder kept, with no warning.

QA review

  • Exercise editor: check that a converted fraction stays legible beside prompt text at 320 CSS px.
  • Exercise editor at 320 CSS px: verify a wide unsized image fits in a hint and its resize handle is reachable in LTR and RTL.
  • Exercise editor: verify a screen reader conveys the read-only status of a question with a table.
  • Exercise editor: after editing beside prefixed MathML, reload the exercise to verify the synced formula.
  • Exercise editor, Questions tab: switch to Details while an unsized image loads; return and verify the first resize starts at its displayed width.
Manual QA steps

QA team: an edit keeps question content it does not change. Look most at formulas and images.

Requires: the development sample data. Open "Published Channel" > "Topic 1" > "Sample Exercise" > "QUESTIONS".

  1. Close without edits (issue step 3). On Question 2, click "Edit", then "CLOSE". Reload. The fraction still shows as a formula.
  2. Edit a formula. In edit mode, click the formula. "Special Characters" opens once. Add "+1", click "Insert", then reload. The formula shows "+1".
  3. Image. On Question 1, insert a PNG wider than 1200 pixels. It fits the editor. Resize it by drag and arrow key. It keeps its proportions.
  4. Replace and thin images. In "Edit image", replace the file and save. The same image changes. Insert a 4000×2 pixel PNG and press Left Arrow on its "Resize image" handle. The thin line stays visible.
  5. Keyboard. In edit mode, Tab to the formula and press Enter. Record what opens.

Look out for:

  • In "Imported Channel", change Question 2 of "Sample Exercise" to "Numeric". Look out for flat text in place of the formula.
Captures (10)

Insert, resize, replace and undo an image

Step Screenshot
Inserted image fits Inserted image fits
Replaced file Replaced file
Thin image after resize Thin image after resize
Undo, then save: thin image gone Undo, then save: thin image gone
image-resize-replace-undo.webm

Edit a formula in a question prompt

Step Screenshot
Closed card Closed card
Click opens menu Click opens menu
Changed in editor Changed in editor
After reload: changed formula After reload: changed formula
s2-formula-enter-edit-save-cancel.webm

AI usage

Claude Code planned, implemented and self-reviewed the change. Verified with the full Jest suite, pre-commit, and probes in headless Chromium.


Written by rtibblesbot, an LLM-based coding agent.

@rtibblesbot

🟡 Waiting for feedback

WAITING · for review
Last updated: 2026-11-30 07:18 UTC

@rtibblesbot
rtibblesbot marked this pull request as ready for review November 30, 2026 03:05
@rtibblesbot
rtibblesbot requested review from a team and leq-bot November 30, 2026 03:05
rtibblesbot and others added 2 commits November 30, 2026 06:04
- Math nodes keep stored MathML in a `mathml` attribute and restore it on save
- An editor whose content matches what it loaded reports the loaded value
- An image's size is saved only by the author's insert, replacement or resize
- Add `schemaKeepsContent` to check whether TipTap's schema keeps a field's markup
- Code blocks keep their newlines when content loads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Interactions keep the attributes their builder doesn't write
- Formulas stored as MathML are saved as MathML
- Text entry answers are read one per mapping entry
- An unedited card saves nothing, numeric items included
- Items the editor can't keep intact open read-only

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[QTI] Editing a question drops content the editor doesn't model

1 participant