Skip to content

fix: report a grown draw's own count, catch duplicate IDs in the bank - #18

Merged
wiseodd merged 2 commits into
mainfrom
bank-mistakes
Dec 1, 2026
Merged

wiseodd merged 2 commits into
mainfrom
bank-mistakes

Conversation

@wiseodd

@wiseodd wiseodd commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Two fixes from trying sortes as an instructor and as a TA.

  • A draw that grew past its section reports its own count. If #draw(<s>, 2) had already been built and was changed to #draw(<s>, 5) with only 3 questions in <s>, the error said "asks for 4". It also counted the draw's own questions as "elsewhere in this exam". It now says <s> has 3 unused questions; #draw(<s>, 5) asks for 5. Write 2 more, or draw fewer.
  • A duplicate question ID stops the bank preview. A question copied without renaming its ID used to compile fine in bank.typ. Only sortes build caught it, and that error had no fix. #q now fails as soon as an earlier question has the same ID, and both errors say "give one of them a new ID". The bank renders pixel-identical when there's no duplicate, and a 500-question bank still compiles in under half a second.

The duplicate-ID error can't point to the line in bank.typ, because Typst drops the call site for errors inside a context block. It names the ID, and searching for it finds both copies.

When a draw already held questions from an earlier build and asked for
more than the section has, the error gave the shortfall as the count
("#draw(<s>, 5) asks for 4") and counted the held questions as
elsewhere in the exam. It now counts them as available to the draw and
reports the count written in the exam.
Two questions with the same ID were only caught when an exam read the
bank, so a TA previewing bank.typ never saw it. #q now fails when an
earlier question has its ID, and both errors say to give one of them a
new ID.
@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Fixes the count shown when a saved draw grows beyond the available questions. Adds duplicate-ID checks to bank previews.

  • Draw shortage messages count the questions already held by the draw.
  • Duplicate question IDs stop bank previews and name the fix.

Reviews (1) · Last reviewed commit: "fix(typst): a duplicate question ID stop..." · Reviewed by Greptile

@wiseodd
wiseodd merged commit 6a26cea into main Dec 1, 2026
7 checks passed
@wiseodd
wiseodd deleted the bank-mistakes branch December 1, 2026 20:14
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.

1 participant