Skip to content

Trim QTI text entry answers and inline choice options on save - #6295

Merged
AlexVelezLl merged 2 commits into
learningequality:unstablefrom
rtibblesbot:issue-6264-cd7212
Oct 6, 2026
Merged

AlexVelezLl merged 2 commits into
learningequality:unstablefrom
rtibblesbot:issue-6264-cd7212

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Text entry answers and inline choice options are trimmed when item XML is built; input stays untouched while typing
  • Perseus derivation on publish strips stored values

References

Fixes #6264.

Reviewer guidance

  • Numeric answers are now trimmed too (their map-key kept typed spaces) — should numeric keep its typed value?
  • _correct_values stripping also affects choice items: <qti-value> choice_0 </qti-value> now derives as correct instead of matching nothing. Wanted beyond text entry?
  • No migration for stored padded values; trimmed on next save, stripped at publish meanwhile. Enough?

QA team: text entry and numeric answers now save without surrounding spaces. Regressions most likely in answer validation.

Sign in as a channel editor. Open "Sample Exercise" in "Published Channel" > "Topic 1".

  1. Text entry answers

    1. Click New question. Set Response type to "Text entry".
    2. Type " Paris ". Add the answer " london " and tick its Case-sensitive.
    3. Click Close. Reload and edit the question.

    Spaces stay while you type. After the reload, the answers are "Paris" and "london". Case-sensitive is ticked only on "london".

  2. Numeric answers

    1. Click New question. Set Response type to "Numeric".
    2. Type the answers " +5 ", " 5.0 " and " abc ".
    3. Delete "abc". Change "5.0" to " -7.5 ".
    4. Click Close. Reload and edit the question.

    Before step 3, "+5" and "5.0" show "Duplicate answers are not allowed". "abc" shows "Must be a valid number (e.g. 12, 0.5, -3.14)". After the reload, the answers are "+5" and "-7.5".

  3. Show answers

    1. In "Topic 1", click "Sample Exercise". Tick Show answers.

    The text entry answers are "Paris" and "london".

Look out for:

  • Add the text entry answers "Paris" and "Paris ". Look out for no duplicate error.
  • Add a text entry answer of only spaces. Look out for an empty answer that saves.

Skip inline choice: the editor cannot make it. Manual QA cannot reach questions that older versions saved with spaces.

Evidence

Text entry answers with spaces

Step Screenshot
While typing: " Paris " keeps its spaces While typing: "  Paris  " keeps its spaces
After save: answers "Paris" and "london" trimmed, Case-sensitive kept on "london" After save: answers "Paris" and "london" trimmed, Case-sensitive kept on "london"

Numeric answers with spaces

Step Screenshot
" +5 " and " 5.0 " flagged as duplicates, " abc " as not a number "  +5  " and " 5.0   " flagged as duplicates, " abc " as not a number
After reload: answers "+5" and "-7.5", no errors After reload: answers "+5" and "-7.5", no errors

Existing answer stored with spaces

Step Screenshot
Stored " Paris " shows as "Paris" in the editor Stored "  Paris  " shows as "Paris" in the editor
After editing only the question and reloading: answer still "Paris" After editing only the question and reloading: answer still "Paris"

Answers in the side panel

Step Screenshot
Show answers: "Paris" and "london" with no spaces Show answers: "Paris" and "london" with no spaces
More captures (3)
Step Screenshot
Question 5 editor: answers "Paris" and "london" Question 5 editor: answers "Paris" and "london"
Existing answer: question prompt edited, answer left alone Existing answer: question prompt edited, answer left alone
Inline choice item shows as "Unknown type", edit disabled Inline choice item shows as "Unknown type", edit disabled

AI usage

Used Claude Code to write the fix and its tests from the issue. Verified with the Jest and pytest suites for the changed modules and pre-commit.


Written by rtibblesbot, an LLM-based coding agent.

@rtibblesbot

🟡 Waiting for feedback

Last updated: 2026-10-06 08:10 UTC

rtibblesbot and others added 2 commits October 6, 2026 00:36
- Stored XML now matches what the editor validates and reloads.
- Trimmed at build time; editor state keeps typed whitespace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…items

Padded <qti-value> or map-key text no longer leaks into Perseus answers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rtibblesbot
rtibblesbot marked this pull request as ready for review October 6, 2026 08:10
@rtibblesbot
rtibblesbot requested review from a team and leq-bot October 6, 2026 08:10

@AlexVelezLl AlexVelezLl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look good and manual QA checks out! LGTM!

@AlexVelezLl
AlexVelezLl merged commit 3d8c455 into learningequality:unstable Oct 6, 2026
40 checks passed
@rtibblesbot

Copy link
Copy Markdown
Contributor Author

Quick check on rtibblesbot's work on this PR: react 👍 helpful · 😕 mixed · 👎 not helpful. Reply with anything specific.

@rtibblesbot
rtibblesbot deleted the issue-6264-cd7212 branch October 6, 2026 22:22
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.

[QTI] Editor saves leading and trailing whitespace in answer values

2 participants