Repository navigation
[QTI] Convert answers or warn when changing question type in the QTI editor #6190
Description
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
When an author changes a question's type in the QTI editor, their existing answers should carry over to the new type wherever that makes sense. If a change would drop content, the author should be warned in a modal and asked to confirm first. The old editor worked this way, and we should keep that behaviour so authors don't lose work silently.
Complexity: Medium
Target branch: unstable
Context
- QTI editor now: changing to a question type that uses a different interaction (e.g. single choice → numeric input) keeps only the prompt. Answers are dropped without any warning.
- Old editor, removed in d4b7026, converted the answers on a type change:
- To single choice: kept only one correct answer.
- To numeric input: kept only the numeric answers and marked them all correct.
- To true/false: replaced the answers with True/False.
- To free response: removed all answers.
- Old editor warning: when answers would change or be lost, it first opened a "Changing question type" confirmation dialog (e.g. "Switching to 'true or false' will remove all current answers. Continue?").
The Change
- Changing question type should keep as much of the author's content as the new type can hold: the prompt, answer text, and which answers are correct.
- If the change would drop or alter content (answers removed, correct answers reduced, non-numeric answers discarded), the editor should show a confirmation modal before switching. The modal says what will be lost, and the author can cancel.
- If nothing would be lost, the type should switch straight away with no modal.
- This covers all question types the QTI editor now offers, including the ones the old editor didn't have (text entry, ordering, matching).
Conversion rules
Decisions:
- Answers carry over within three families. Across families, only the question carries over.
- Answer lists (single choice, multi select, numeric input, text entry, free response, ordering): answers, which ones are correct, shuffle, fixed answers, orientation and expected length.
- Pairs (associate ↔ match): pairs and distractors. Going to match, pairs that share a source become one row with several matches.
- Passages (inline choice, and gap match once it exists): going to a type with no passage, the passage is added to the question with each dropdown shown as
_____. An inline choice with one dropdown gets no special conversion to single choice.
- Anything the new type can show is kept, even if it isn't valid there, and validation points it out. For example, answers that aren't numbers are kept when switching to numeric input.
- Nothing is marked correct that the author didn't mark, except going from numeric input or text entry, where every answer is already correct, to a choice type.
- Single choice keeps only the first correct answer marked, since it can't show more than one.
- Wrong choices are removed going to numeric input or text entry, because they would otherwise become accepted answers.
- Numeric answers going to another type are written as the exercise language shows them (
3,5in a German exercise). - The modal lists one sentence per change, and only the ones that apply to the question's content. A change that loses nothing switches straight away.
Each cell lists what the modal says when converting a filled question from the row's type to the column's type. "—" means nothing is lost, so there's no modal.
| From \ To | Single | Multi | Numeric | Text entry | Free resp. | Ordering | Associate | Match | Inline choice |
|---|---|---|---|---|---|---|---|---|---|
| Single | — | I | I | A | C, O | A | A | A | |
| Multi | R | I, E | I, E | A | C, O | A | A | A | |
| Numeric | R | — | — | A | O | A | A | A | |
| Text entry | R | — | — | A | O | A | A | A | |
| Free response | — | — | — | — | — | — | — | — | |
| Ordering | N | N | A | A | A | A | A | A | |
| Associate | A | A | A | A | A | A | — | A | |
| Match | A | A | A | A | A | A | — | A | |
| Inline choice | P | P | P | P | P | P | P | P |
- A: All answers will be removed.
- I: Answers not marked as correct will be removed.
- E: Learners will only need to give one of the correct answers. (With more than one correct answer: a choice question needs all of them, numeric input and text entry accept any one.)
- R: Only the first correct answer will stay marked as correct. (With more than one correct answer.)
- C: Answers will no longer be marked as correct.
- O: The current order will become the correct order. (With more than one answer.)
- N: The correct order won't be kept. (With more than one answer.)
- P: The passage will be added to the question, with each blank shown as "_____". Its answers will be removed.
- F: Formatting, images and formulas in answers will be removed. Answers with only an image or formula will be removed entirely. (Not in the table: added whenever rich answers from single choice, multi select or ordering go into numeric input or text entry and lose something.)
How to Get There
- Open an exercise's Questions tab and edit a question.
- Add a few answers, marking one or more as correct.
- Change the question type from the type selector to one that uses a different interaction (e.g. single choice → numeric input).
Acceptance Criteria
General
- The conversion rules for every pair of question types, and the cases that show the modal, are decided and written down in this issue before work starts
- Changing question type keeps the prompt and any answers the new type can hold, following those rules
- A change that would drop or alter content shows a confirmation modal first; cancelling leaves the question unchanged
- A change that loses nothing switches straight away, with no modal
Accessibility and i18n
- The modal can be used with the keyboard only and focus goes back to the type selector when it closes
- All modal text is translatable
Testing
- Tests cover the conversion for each supported type pair, plus confirming and cancelling the modal
References
- d4b7026, which removed the old editor; its parent commit has the old conversion logic and dialog strings
AI usage
I used Claude Code to find the old editor's type-change behaviour in git history, check what the QTI editor does today, and draft this issue. I reviewed and edited each section.

Activity
[-]Convert answers or warn when changing question type in the QTI editor[/-][+][QTI] Convert answers or warn when changing question type in the QTI editor[/+]rtibblesbot commentedon Sep 30, 2026
@AlexVelezLl this is blocked on the conversion rules. The issue says they are decided before work starts, but they aren't written down yet. Could you specify:
Once these are in the issue I can implement it.
AlexVelezLl commentedon Oct 1, 2026
You shouldn't have assigned this to yourself yet @rtibblesbot.
Convert answers when the question type changes
Convert answers when the question type changes
Convert answers when the question type changes
Convert answers when the question type changes
Convert answers when the question type changes
Convert answers when the question type changes
Convert answers when the question type changes