Skip to content

Normalize legacy multi-answer text-entry QTI items on publish - #6227

Closed
rtibblesbot wants to merge 1 commit into
learningequality:unstablefrom
rtibblesbot:issue-6223-6e656b
Closed

rtibblesbot wants to merge 1 commit into
learningequality:unstablefrom
rtibblesbot:issue-6223-6e656b

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Pre-QTI editor emits cardinality="multiple" and match_correct for multi-answer Numeric and Text entry questions #6187 multi-answer Numeric/Text entry items use cardinality="multiple" + match_correct, so Kolibri scores every response incorrect.
  • Publish rewrites them to cardinality="single", first answer in <qti-correct-response>, one <qti-map-entry> per answer, map_response.xml template.
  • Pure raw_data -> raw_data function (qti/normalize.py) called from _create_native_qti_item; stored raw_data is untouched.
  • Chosen over a data migration, which would miss later writes from stale clients or ricecooker.
  • Only declarations bound to qti-text-entry-interaction change.
  • Existing <qti-mapping> is kept, preserving per-answer case-sensitive.
  • Items with explicit response rules, several declarations, a DOCTYPE, or element content in qti-value are skipped with a warning.

References

Fixes #6223. Siblings under #6103: #6187, #6220.

Reviewer guidance

  • pytest contentcuration/contentcuration/tests/utils/qti contentcuration/contentcuration/tests/utils/test_exercise_creation.py
  • Perseus derivation still reads stored raw_data deliberately: the old shape lists every answer in <qti-correct-response>, which _derive_text needs.

AI usage

I used Claude Code to plan and implement this from the issue, with tests written alongside the code. I reviewed the diff and trimmed it for simplicity.

Deviations from the issue spec

Criterion Why not
A saved multi-answer text-entry item is answerable without re-saving Items with explicit response rules, several declarations, a DOCTYPE, or element content in qti-value are left as written (logged) and stay unscored; rewriting them safely needs per-item rule handling.

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Ran pre-flight CI checks (lint, format, tests) and verified all pass
  • Rebased onto the target branch and resolved any conflicts
  • Reorganized commit history into clean, logical commits
  • Audited the diff to ensure only issue-relevant files are changed
  • Built PR body from the repository's PR template with evidence blocks
@rtibblesbot

🟡 Waiting for feedback

Last updated: 2026-09-30 22:16 UTC

@rtibblesbot

Copy link
Copy Markdown
Contributor Author

Outside this PR's scope — tracked under #6103:


@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Ran pre-flight CI checks (lint, format, tests) and verified all pass
  • Rebased onto the target branch and resolved any conflicts
  • Reorganized commit history into clean, logical commits
  • Audited the diff to ensure only issue-relevant files are changed
  • Built PR body from the repository's PR template with evidence blocks

@rtibblesbot
rtibblesbot marked this pull request as ready for review September 30, 2026 16:46
@rtibblesbot
rtibblesbot requested review from a team and rtibbles September 30, 2026 16:46
@rtibblesbot
rtibblesbot force-pushed the issue-6223-6e656b branch 2 times, most recently from abe6ab2 to 329e9b9 Compare September 30, 2026 17:21
Rewrite legacy text-entry response declarations (multiple cardinality)
to single cardinality with the map_response template when building the
QTI archive.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@AlexVelezLl

Copy link
Copy Markdown
Member

The erroneous code has not yet reached production. So far, there are no QTI assessment items in the production DB. The only items potentially at risk are the QA items; in that case, we will ask our QA team to edit them again only after we have applied the fix for #6187.

@rtibblesbot
rtibblesbot deleted the issue-6223-6e656b branch September 30, 2026 22:37
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.

Multi-answer text-entry QTI items saved before

2 participants