learningequality / learningequality/studio
[QTI] Cannot publish QTI packages with formulas in answer choices
@AlexVelezLl is already working on this.
Since Aug 25, 2026.
- Dominant language
- Python
- Stars
- 191
- Forks
- 307
- Avg merge
- 5d 6h
- Merged PRs (30d)
- 10
Description
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Observed behavior
Formulas can be added to the question prompt in a QTI assessment without issue, but adding a formula to an answer choice (simple choice / choiceInteraction) causes the backend to fail at publish time with a pydantic validation error.
The error indicates that Math elements are not recognized as valid children of SimpleChoice — only FlowContentElement or TextNode are accepted — so any answer choice containing a formula cannot be exported to a QTI package.
Errors and logs
2 validation errors for SimpleChoice
children.0.FlowContentElement
Input should be a valid dictionary or instance of FlowContentElement [type=model_type, input_value=Math(id_=None, class_=Non...Node(text='a^{b}')])])]), input_type=Math]
For further information visit https://errors.pydantic.dev/2.12/v/model_type
children.0.`function-before[functools.partial(<function coerce_str_to_model at 0x11740beb0>, <class 'contentcuration.utils.assessment.qti.base.TextNode'>)(), TextNode]`
Input should be a valid dictionary or instance of TextNode [type=model_type, input_value=Math(id_=None, class_=Non...Node(text='a^{b}')])])]), input_type=Math]
For further information visit https://errors.pydantic.dev/2.12/v/model_type
Expected behavior
Formulas should be supported in answer choices (simple choices) as well as in question prompts. A QTI package containing formulas in any field should publish successfully.
User-facing consequences
- Users cannot publish QTI packages if any answer choice contains a formula, blocking the export workflow entirely.
- Formulas work in question prompts but not in answer choices, creating an inconsistent and confusing authoring experience.
Steps to reproduce
- Create an exercise in Studio. Set completion to Survey and add a free response question.
- Add a single-choice question and insert a formula into one of its answer choices using the formula editor in the RTE.
- Attempt to publish the exercise as a QTI package.
- Observe that the publish fails with a pydantic validation error on
SimpleChoice.
Context
- The failure occurs in the QTI export backend, in the pydantic model for
SimpleChoice. - The
Mathelement type is not included as a valid child type ofSimpleChoice, unlike the question prompt which correctly supports it. - Relevant code:
contentcuration/utils/assessment/qti/andcontentcuration/utils/publish.py.
Acceptance Criteria
- Formulas can be added to answer choices (simple choices) in a QTI assessment without causing a publish error.
- A QTI package containing formulas in both question prompts and answer choices publishes successfully.
- The
Mathelement is recognized as a valid child ofSimpleChoicein the QTI pydantic model.
AI usage
Drafted with Claude Code. Reproduction steps and acceptance criteria were reviewed and confirmed manually.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.