Repository navigation
[QTI] Formulas using a LaTeX matrix, alignment or \boxed construct don't publish as MathML #6347
Copy link
Copy link
Open
Labels
Description
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Target branch: unstable
Observed behavior
- Publishing converts every legacy exercise to a QTI package (
QTIExerciseGenerator). The conversion parses each formula's MathML into the pydantic MathML models. - Those models reject MathML that latex2mathml produces for common LaTeX:
\begin{matrix},\begin{pmatrix},\begin{cases},\begin{array},\boxed,\substack. - The error reaches
recurse_nodesuncaught, so the whole channel publish fails, not just the one item. - One cause:
Mtableis not a presentation element, soMrowrefuses it.menclosehas no model at all. - The same MathML in the MathML namespace passes
validate_qti_item. - Same rule broken as [QTI] A QTI item containing an XML comment fails the channel publish #6229 and [QTI] A QTI item with a DOCTYPE entity reference fails the channel publish #6234 (native items): one item's error fails the publish instead of skipping that item. Their fixes don't reach the legacy conversion.
- latex2mathml 3.78.1 writes the alignment
&ofaligned,align,alignat,gathered,eqnarray,rcases,dcasesunescaped (<mi>&</mi>), so_convert'sET.fromstringraisesParseError. Onunstablethis aborts the publish too; with the [QTI] - The formulas are not shown in Kolibri #6327 fix the formula publishes as$$…$$text instead, in legacy and QTI editor (<span data-latex>) items alike.
Errors and logs
pydantic_core._pydantic_core.ValidationError: 2 validation errors for Mrow
ValueError: No registered class found for tag: menclose
xml.etree.ElementTree.ParseError: not well-formed (invalid token)
User-facing consequences
- A channel with one legacy question holding a matrix, a piecewise function or a boxed answer cannot be published at all.
- With the [QTI] - The formulas are not shown in Kolibri #6327 fix, learners see the raw LaTeX source in place of a formula using an alignment environment.
Steps to reproduce
- On
unstable(3857a5e), create an exercise with a single-choice question whose text is$$\begin{pmatrix}1\\2\end{pmatrix}$$. - Publish the channel.
- The publish fails with the
ValidationErrorabove;$$\boxed{x}$$fails with theValueError;$$\begin{aligned}a&=b\\c&=d\end{aligned}$$fails with theParseError.
Acceptance Criteria
- A legacy question containing each of
\begin{matrix},\begin{pmatrix},\begin{cases},\begin{array}{cc},\boxed{x},\substack{a\\b}publishes, and its QTI item passesvalidate_qti_item. - A formula using each of
aligned,align,alignat,gathered,eqnarray,rcases,dcaseswith&publishes as MathML in the MathML namespace with itsapplication/x-texannotation, from legacy and QTI editor items, and the item passesvalidate_qti_item. - A formula the QTI item cannot carry costs at most that item, never the channel publish.
AI usage
Found by Claude Code while planning #6327: it probed latex2mathml output against the MathML models and the item XSD on unstable, and drafted this issue.

Activity
[-][QTI] A legacy exercise with a matrix or \boxed formula aborts the channel publish[/-][+][QTI] Formulas using a LaTeX matrix, alignment or \boxed construct don't publish as MathML[/+]rtibblesbot commentedon Oct 27, 2026
Alignment environments fail the same way:
aligned,align,alignat,gathered,eqnarray,rcases,dcases.&unescaped, so_convert'sET.fromstringraisesParseError:unstablethe error aborts the publish, like the matrix cases.$$…$$text instead, in legacy and QTI editor (<span data-latex>) items alike; it logsCould not convert LaTeX to MathML.matrix,pmatrix,cases,array,splitwith&parse fine.Reproduce: publish a question holding
$$\begin{aligned}a&=b\\c&=d\end{aligned}$$.Written by rtibblesbot, an LLM-based coding agent.