Skip to content

Respect the "Set Active?" checkbox when creating an exam - #182

Merged
pancakereport merged 2 commits into
mainfrom
fix-new-exam-active-checkbox
Nov 18, 2026
Merged

pancakereport merged 2 commits into
mainfrom
fix-new-exam-active-checkbox

Conversation

@pancakereport

@pancakereport pancakereport commented Nov 18, 2026 •

Copy link
Copy Markdown

Problem

The Set Active? checkbox on the Create New Exam form did nothing. new_exam ignored form.active and always created the exam with is_active=True, deactivating every other exam in the offering. Unchecking the box still swapped the active exam out from under staff.

Fix

  • Only deactivate the other exams when the box is checked.
  • Create the exam with is_active=form.active.data.
  • If that leaves the offering with no active exam, call ensure_one_exam_is_active() and flash the same message the edit form shows. Editing an exam already follows this rule.

Tests

  • test_new_exam now also checks that the seed exam, which starts active, gets deactivated.
  • test_new_exam_left_inactive: with the box unchecked, the new exam stays inactive and the current active exam stays active.
  • test_new_exam_left_inactive_with_no_active_exam: with the box unchecked and no active exam, the offering's first exam gets activated and the info message is shown.

Both new tests fail on main. The full unit suite passes (672 tests).

🤖 Generated with Claude Code

Creating an exam always made it the active one and deactivated the
others, whatever the checkbox said. Now an unchecked box leaves the new
exam inactive and the current active exam alone, falling back to the
first exam only when the offering would otherwise have none active, the
same rule editing an exam follows.

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

Copy link
Copy Markdown

🚀 Staging Preview Deployed!

URL: https://preview-seating-pr-182-137456085712.us-west1.run.app

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.35%. Comparing base (77d0a14) to head (d85ebe5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #182      +/-   ##
==========================================
+ Coverage   87.33%   87.35%   +0.01%     
==========================================
  Files          36       36              
  Lines        2709     2712       +3     
==========================================
+ Hits         2366     2369       +3     
  Misses        343      343              
Flag Coverage Δ
e2e 33.64% <0.00%> (-0.04%) ⬇️
unit 87.35% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The seed exam starts active, so the test never reached the fallback and
the flash it shows went uncovered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pancakereport
pancakereport merged commit e8be7a7 into main Nov 18, 2026
15 checks passed
@pancakereport
pancakereport deleted the fix-new-exam-active-checkbox branch November 18, 2026 19:13
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