kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

QTI prompts, choices and chips keep the space between inline elements

Open rtibblesbot opened this issue 1 week ago • 1 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

The QTI viewer joins two words when the only thing between their inline elements is a space: a prompt containing Which <strong>planet</strong> <em>orbits</em> closest to the Sun? reads "Which planetorbits closest to the Sun?". SafeHTML drops the space before the QTI components see it, and the components could not lay it out correctly if they did. Prompts, choices and match or associate chips should keep the space and read as authored.

Complexity: Medium Target branch: develop

Context

  • SafeHTML drops every text node that holds only whitespace (SafeHTML/index.js#L286).
  • PR #16010 (#15598) keeps that space in plain HTML, but leaves the children of a registered component such as qti-prompt as they are.
  • Prompt.vue wraps all its children in a <p> when one of them is text (Prompt.vue#L8-L15), so a kept space would nest an authored <p> inside another <p>.
  • Match and associate chips lay their children out as flex items, where a space between two elements has no width.
  • The same drop gives "Mercury(first)" for a qti-simple-choice containing <strong>Mercury</strong> <em>(first)</em>, and "Domesticcat" for a match or associate choice containing <strong>Domestic</strong> <em>cat</em>.

The Change

  • SafeHTML should keep whitespace-only text nodes for the children of registered components too, building on PR #16010.
  • Prompt.vue should wrap only runs of inline content in a <p>, leaving block children unwrapped.
  • Match and associate chips should lay out their content in an inline container, so a space between two elements keeps its width.

How to Get There

  1. Run the dev server and open /en/learn/#/qti_sandbox/.
  2. In "QTI XML editor", paste a choice item whose qti-prompt contains Which <strong>planet</strong> <em>orbits</em> closest to the Sun? and whose qti-simple-choice elements contain <strong>Mercury</strong> <em>(first)</em> and <strong>Venus</strong> <em>(second)</em>.
  3. Read the prompt and the choices under "Preview".

Acceptance Criteria

  • [ ] A qti-prompt whose only children are <strong>a</strong> <em>b</em> reads "a b", and gains no paragraph margin or width limit that it does not have on develop.
  • [ ] A qti-prompt with <strong>a</strong> <em>b</em><p>Details</p> keeps the space, and the authored <p> is not inside another <p>.
  • [ ] A qti-prompt with <strong>Use the figure</strong> <img src="/figure.png" alt="diagram"/> renders no <div> inside a <p>.
  • [ ] A qti-simple-choice, and a match or associate choice in the response pool, a filled slot and a match source row, each read "a b" for <strong>a</strong> <em>b</em>.
  • [ ] A match or associate choice with Figure <img src="/figure.png" alt="figure"/> keeps its label and image on one row, as on develop.
  • [ ] A match or associate choice with <strong>Given</strong> <math><mi>x</mi></math> <em>solve</em> keeps both spaces with native MathML and with the MathJax fallback.
  • [ ] Two block children of a QTI component that are separated by a newline or &nbsp; render as on develop.

AI usage

Claude Code found this while working on #15598, reproduced it in the QTI sandbox and drafted the report. I chose where the whitespace is kept and how Prompt and the chips lay it out, and Claude Code rewrote it as a task.

rtibblesbot avatar Nov 24 '26 13:11 rtibblesbot

Rewritten as a task: SafeHTML keeps whitespace-only text nodes for registered components' children too, building on #16010. Prompt.vue wraps only runs of inline content, and match and associate chips use an inline container.

rtibbles avatar Nov 24 '26 20:11 rtibbles