Repository navigation
Keep text after a formula when reopening a QTI question - #6297
Conversation
7ca76d1 to
6866536
Compare
AlexVelezLl
left a comment
There was a problem hiding this comment.
Code changes look good, this is the correct fix. Could you also add a very small README in the QTIEditor folder, similar to the TipTapEditor, describing the high-level details of the Editor? It doesnt have to be thorough but it'd be great to have this now, and then add a flag saying that we should use the getContentHTML on parse for fields that will be treated as HTML in the TipTapEditor.
| expect(errorIds).not.toContain('e'); | ||
| }); | ||
|
|
||
| it('flags a stored formula option and the same formula typed in again', () => { |
There was a problem hiding this comment.
suggestion (pre-existing, follow-up): This makes a formula-only option match its retyped twin, which is right. The opposite case is still broken: richTextComparisonKey uses only the text whenever there is any, and formulas contribute no text. So <p>Solve <span data-latex="x^2"></span> for x</p> and <p>Solve <span data-latex="y^3"></span> for x</p> both key to "Solve for x". I confirmed that buildMatchInteractionXML then merges two rows' answers x² is it / y³ is it into a single choice (m1, match-max="2"), and the y³ content is lost. Choice/ordering validation will also report them as duplicates. Now that formula text survives reopening, authors are more likely to hit this. Could we file an issue to include data-latex (and maybe img src) in the key? Not for this PR.
There was a problem hiding this comment.
Outside this PR's scope — tracked as #6301 under #6103.
Written by rtibblesbot, an LLM-based coding agent.
| const IMG_TAG = /<img\b[^>]*>/gi; | ||
| // Quoted values are skipped whole: the HTML serializer leaves `>` unescaped in them. | ||
| const IMG_TAG = /<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi; | ||
| const SRC_ATTRIBUTE = /\bsrc\s*=\s*(["'])(.*?)\1/i; |
There was a problem hiding this comment.
nitpick: IMG_TAG now skips quoted values, but SRC_ATTRIBUTE still searches the whole tag. So alt='see src="a.png"' (or any data-src) matches before the real src. That's rare enough to leave alone, but the comment on line 17 reads as if quoted values are safe throughout.
There was a problem hiding this comment.
Fixed in 5fdf2a781: src is now read by walking the tag's attributes, so src= inside a quoted value or data-src is skipped, and the first real src wins. Test added with both cases.
Searched the frontend for other regexes that pull an attribute out of a tag: SRC_ATTRIBUTE was the only one.
|
Added |
…AsHtml - Drop noscript, script and style, as TipTap does. - Turn iframe, noembed, noframes, plaintext and xmp into their text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Prompts, options and hints were read back with XML innerHTML, which self-closes the empty formula span; TipTap then nested the trailing text inside it and dropped it. Read them with serializeAsHtml instead, via a shared getContentHTML. Fixes learningequality#6269 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6866536 to
651615f
Compare
AlexVelezLl
left a comment
There was a problem hiding this comment.
Code changes look good, manual QA checks out, follow-up issue filled. LGTM!
|
Quick check on rtibblesbot's work on this PR: react 👍 helpful · 😕 mixed · 👎 not helpful. Reply with anything specific. |
Summary
script/styleare dropped; raw-text elements likeiframereduce to text.srcresolution skips quoted attributes (alt text with>).<br></br>reads as two breaks,<br/>as one, matching the HTML parser.QTIEditor/README.md(new work, not a fold): parse/build flow and thegetContentHTMLrule.References
Fixes #6269.
Reviewer guidance
Stored XML that loads differently:
<p>a <strong/> b</p>→a b;<a href="u"/>tailkeepstailoutside the link.<p><![CDATA[a < b]]></p>→a < b, notPROMPT_REQUIRED.DUPLICATE_CHOICE_CONTENT; match/associate merge answers.Open question:
<noscript>text now shows and saves. Drop it likescript?QA team: text and line breaks after a formula now stay on reopen. Regressions are most probable beside a dropdown or an image.
Use a new exercise. "Formula text": type "Solve ", insert the "Math formula"
x^2, type " for x". "Reopen": save, close and open the exercise.Look out for:
Evidence
Single choice question with a formula mid-sentence
Multiple choice with formulas in several choices
Hint with a formula mid-sentence
Ordering question
Match question
Associate question
Image with alt text "a > b" beside a formula
No file storage on the QA stack: images show as placeholders.
Formulas in several fields: opening each field in turn
s2-reopen-cycle-fields.webm
More captures (24)
x^2AI usage
Claude Code wrote the fix and tests; verified with the QTIEditor and TipTapEditor Jest suites and pre-commit.
Written by rtibblesbot, an LLM-based coding agent.
🟡 Waiting for feedback
Last updated: 2026-10-07 18:10 UTC