Skip to content

fix: end classes at the end-of-term finals block, whatever its titles - #1056

Merged
jaspermayone merged 2 commits into
mainfrom
fix-finals-periods-by-category
Nov 17, 2026
Merged

jaspermayone merged 2 commits into
mainfrom
fix-finals-periods-by-category

Conversation

@jaspermayone

Copy link
Copy Markdown
Member

What

Classes now end at the term's end-of-term finals block, whatever the titles of its events.

  • UniversityCalendarEvent.finals_periods selects every study_day and finals event. Before, it also needed "Final Exam Period" or "Study Day" in the title, so "Final Exams (...)" and "Finals Week" did not end classes.
  • UniversityCalendarEvent.end_of_term_finals_starts gives the first day of each term's last finals block: the earliest finals period that starts no more than 14 days before the term's last one. A finals period for the first 7-week classes in October cancels classes on its own dates only. It does not end the 15-week classes.
  • CourseCalendars::RecurrenceBuilder uses it in the per-term path and in the preload path.
  • UniversityCalendar::TermDates.detect takes the latest finals event as the term end. UniversityCalendar::Category already gives finals only to exam-period titles.
  • UniversityCalendar::Category.finals_period? is false for a title with "Midterm". Classes meet in a midterm exam period.
flowchart TD
  A[study_day and finals events of the term] --> B[latest start]
  B --> C[events that start no more than 14 days before it]
  C --> D[earliest start of those]
  D --> E[classes end the day before]
Loading

Why it is safe now

The announcements that the feed stored as finals ("Final Exam Schedule Available to Students") would have ended terms early. #1052 moved new ones to academic, and the recategorize task moved the 3 stored rows in production today. manual: rows keep the category that an admin gave them.

After deploy

Run bin/rails university_calendar:recategorize (dry run) once. It shows any stored "Midterm ..." row that now leaves finals. Apply it with DRY_RUN=0 if it lists one.

Checks

  • Full suite with CI=1, twice: 6665 examples. The first run had 1 failure in next_term_courses_spec.rb:656, an order-dependent query-count spec that does not touch this code. It passed alone with 3 seeds, and the second full run had 0 failures. Line coverage 96.18%, branch 86.29%.
  • New specs: a term with first 7-week finals in October and the real finals block in December (both the per-term and the preload path), end_of_term_finals_starts for two terms and a term with no finals, and a midterm exam period title.

@jaspermayone
jaspermayone added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 9d04c13 Nov 17, 2026
6 checks passed
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