Skip to content

[QTI] Convert answers or warn when changing question type in the QTI editor #6190

Description

@AlexVelezLl

❌ 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).

Implementation details are still open. Which conversions to support, how each type maps to the others, and the modal wording will be decided before work starts.

How to Get There

  1. Open an exercise's Questions tab and edit a question.
  2. Add a few answers, marking one or more as correct.
  3. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions