Skip to content

Warn authors when a QTI question has more than 5 options - #6356

Merged
AlexVelezLl merged 1 commit into
learningequality:unstablefrom
rtibblesbot:issue-6345-399c27
Nov 25, 2026
Merged

AlexVelezLl merged 1 commit into
learningequality:unstablefrom
rtibblesbot:issue-6345-399c27

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • QTI option-style lists warn (non-blocking) past 5 entries.
  • Each warning is announced politely once, as it appears.

References

Closes #6345. Related: #6316.

Reviewer guidance

Suggested review: Light-touch code review, then manual QA.

Engineer review

Engineer evidence

Not tested with a real screen reader.

QA review

  • Choice, multi select, ordering, associate pairs, match rows: with a screen reader, Add a 6th item; the warning is read once, and deleting back to 5 removes it.
  • Associate and match: save a 6th distractor with a screen reader; the warning is read, not cut off by focus returning to Add distractor.
  • Inline choice: Add option on a 5-option dropdown reads the warning politely after focus lands in the new field; opening a 6-option dropdown reads it as part of the panel's description.
  • Save a question of each type with 6+ items; it is not marked incomplete in the exercise's question list.
  • Warning banners above the choices, items, pairs, rows and distractors headers and in the inline choice panel lay out correctly at small and large widths, LTR and RTL.
Manual QA steps

QA team: the question editor warns when a list has more than 5 entries. Regressions are most probable in screen reader announcements and after a "Response type" change.

Open an exercise you can edit. Click "NEW QUESTION" in its "QUESTIONS" tab for each item.

  1. Choice and ordering. Set "Response type" to "Single Choice". Click "Add choice" until there are 6 options. A warning shows and is read once. Add a 7th option. The warning is not read again. Delete options back to 5. The warning goes and nothing is read. Save 6 options, click "CLOSE", then "Edit". The warning shows. Repeat for "Multiple Choice" and "Ordering".
  2. Associate and match. Set "Response type" to "Associate". Add 6 pairs. A pairs warning shows and is read once. Add 6 distractors, the 6th a copy of the 1st. A distractors warning and a duplicate error show, and both are read. Delete pair 6. Only the distractors warning stays. Repeat for "Match".
  3. Inline choice. Insert a dropdown and add 6 options. The panel shows a warning, read once as the option is added. Focus is in "Option 6". Delete option 6. The warning goes.
  4. Change question type. Change a 6-option "Single Choice" question to "Multiple Choice", then "Ordering". Change a "Match" question with 6 rows and 6 distractors to "Associate". The warnings show at once. Focus stays on "Response type". All entries stay after "CLOSE".
  5. Gap match. Add 7 gaps and 7 distractors. No warning shows.
Captures (13)

Associate and match

Step Screenshot
Associate: distractors warning with duplicate error Associate: distractors warning with duplicate error
Associate: pair 6 deleted, distractors warning stays Associate: pair 6 deleted, distractors warning stays
Match: rows and distractors warnings with duplicate error Match: rows and distractors warnings with duplicate error

Warning and duplicate error are each announced; neither replaces the other.

Choice and ordering

Step Screenshot
Single choice: 6 options warning Single choice: 6 options warning
Ordering: 6 items warning Ordering: 6 items warning
Single choice: reopened after reload, warning shows Single choice: reopened after reload, warning shows
multiple-select-add-6th-7th-remove.webm

Inline choice

Step Screenshot
6th option duplicates option 5: error and warning 6th option duplicates option 5: error and warning
Reopened with 6 options: warning in the panel Reopened with 6 options: warning in the panel
s3-inline-choice-add-6th-7th-remove.webm

Change question type

Step Screenshot
Multiple choice to ordering: change dialog Multiple choice to ordering: change dialog
s4-convert-single-to-multi-and-ordering.webm
s4-convert-match-to-associate-and-back.webm

AI usage

Claude Code wrote the code and tests; verified with Jest and screenshots.


Written by rtibblesbot, an LLM-based coding agent.

@rtibblesbot

🟡 Waiting for feedback

WAITING · for review
Last updated: 2026-11-25 00:37 UTC

@rtibblesbot
rtibblesbot marked this pull request as ready for review October 30, 2026 05:28
@rtibblesbot
rtibblesbot requested review from a team and leq-bot October 30, 2026 05:28
@rtibblesbot
rtibblesbot force-pushed the issue-6345-399c27 branch 2 times, most recently from 60479c4 to 1ea59fb Compare November 19, 2026 12:35
* it announces its messages itself.
*/
alert: {
announce: {

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.

Let's keep the alert prop and gate warnings on it (props.warning && props.alert), with its doc comment updated to cover warnings. Renaming it pulls the gap match, inline choice and EditableChipList callers into this PR when none of them need to change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done: alert is back, documented for warnings too, and announceWarning checks props.warning && props.alert. All 8 :announce callers (gap match ×2, inline choice editor ×2, InlineChoiceOptions ×3, EditableChipList ×1) are back to :alert, so gap match, inline choice Editor.vue and EditableChipList no longer appear in the diff.


Written by rtibblesbot, an LLM-based coding agent.

import { onBeforeUnmount } from 'vue';
import useKLiveRegion from 'kolibri-design-system/lib/composables/useKLiveRegion';

// KDS writes each message over the live region's text, so a message sent in the

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.

Could you please drop this composable and go back to calling sendPoliteMessage directly in ValidationMessage, EditableChipList and InlineChoiceOptions? Messages in the same tick overwriting each other is a KDS limitation that already exists and affects every caller, so let's open a KDS issue about queuing messages in useKLiveRegion rather than working around it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dropped useAnnouncePolitely; its 3 callers (ValidationMessage, EditableChipList, InlineChoiceOptions) call sendPoliteMessage directly again, and EditableChipList is back to its unstable version. Drafted a KDS issue asking useKLiveRegion to queue messages sent together.

Two changes remain that time a warning against focus, not against other messages:

  • InlineChoiceOptions: when Add option brings the 6th option, the warning is sent after addOption focuses the new field instead of before it.
  • New useWarningOnFocus, used by choice, ordering, associate and match: an Add that brings up the too-many warning sets :alert="false" on it and sends it on the section's next focusin, or after a frame if none lands. Tiptap focuses the new editor after a timeout and a frame, and a screen reader's focus announcement cuts off a message read before it.

Written by rtibblesbot, an LLM-based coding agent.

// KDS writes to `window.politeRegionEl`, clearing it 350ms later; a fresh one per test
// keeps an earlier test's clear from emptying it.
beforeEach(() => {
window.politeRegionEl = document.createElement('div');

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.

Without the queue, could you please mock useKLiveRegion here and in the match spec, as the other QTI specs do, rather than replacing window.politeRegionEl? The nextFrame() waits added to the existing specs and the batching tests in ValidationMessage.spec.js can go too. A test that a warning with alert set to false isn't announced would cover the new check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done: associate and match specs mock useKLiveRegion and assert on sendPoliteMessage, including which element has focus when the warning is sent. Removed every nextFrame() / requestAnimationFrame wait this PR added to the specs (choice, ordering, inline choice, EditableChipList, associate, match); the two that predate it stay. useWarningOnFocus.spec.js runs its frame fallback with Jest fake timers. ValidationMessage.spec.js now has only two tests: a warning is announced, and a warning with alert false isn't.


Written by rtibblesbot, an LLM-based coding agent.

* the `focus` command), and a screen reader's focus announcement cuts off a message read
* out before it.
*/
export function useWarningOnFocus(warning) {

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.

Could you please drop useWarningOnFocus and let these warnings announce on mount through ValidationMessage, the same way as the single-option warning? It relies on Tiptap's internal focus timing, and it spreads held state, focusin handlers and Add wrappers across four editors. If focus cutting off a warning turns out to be a problem with a real screen reader, it would affect every warning, so let's handle it in a separate issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dropped useWarningOnFocus; every too-many warning now announces on mount through ValidationMessage, like the single-option warning.

  • Searched the branch for announcements held until focus lands: 5 sites matched, all changed.
    • Choice, ordering, associate and match editors: focusin handlers, held state and Add wrappers removed.
    • InlineChoiceOptions: removed pendingAnnouncement, which held the panel's messages until the added option took focus; it announces straight away again, as on unstable.
  • The "read once it takes focus" tests now assert the warning shows and is announced on add.

Written by rtibblesbot, an LLM-based coding agent.

- Choice, ordering, associate, match and inline choice editors show a
  non-blocking warning past 5 options, pairs, rows or distractors
- ValidationMessage's `alert` prop now gates announcing warnings too

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

@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.

LGTM!

@AlexVelezLl
AlexVelezLl merged commit b296b45 into learningequality:unstable Nov 25, 2026
47 of 48 checks passed

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-6345-399c27 branch November 25, 2026 13:47
@AlexVelezLl

Copy link
Copy Markdown
Member

QA Steps

Lists with more than 5 entries now show a warning. It doesn't block saving.

  1. Choice and ordering. In Single Choice, add a 6th option, then delete it. Save with 6 and reopen. Repeat for Multiple Choice and Ordering. Expected: the warning shows at 6, goes at 5, and is back after reopening. The question isn't Incomplete.
  2. Associate and Match. Add 6 pairs (rows in Match) and 6 distractors. Expected: one warning above each list.
  3. Inline choice. Give a dropdown 6 options. Expected: the warning shows in its options panel, not on the chip.
  4. Type change. Switch a 6-option Single Choice to Ordering. Expected: the warning shows straight away.
  5. Gap match. Add 7 gaps and 7 distractors. Expected: no warning.
  6. Layout. Check the warnings at a narrow width and in Arabic. Expected: nothing overlaps.

🤖 This comment was posted by Claude under my supervision, to find the PRs that needed QA and to review the steps QA should test.

@pcenov

pcenov commented Nov 30, 2026

Copy link
Copy Markdown
Member

Implemented as specified.

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] Warn authors when a question has more than 5 options

3 participants