Skip to content

Improve Semester Display on Dashboard: Group Courses, Add Semester Headers, and Implement Sorting Logic#383

Merged
cycomachead merged 7 commits intomainfrom
cycomachead/88-improve-semester-dashboard/1
Apr 14, 2026
Merged

Improve Semester Display on Dashboard: Group Courses, Add Semester Headers, and Implement Sorting Logic#383
cycomachead merged 7 commits intomainfrom
cycomachead/88-improve-semester-dashboard/1

Conversation

@cycomachead
Copy link
Copy Markdown
Contributor

@cycomachead cycomachead commented Apr 14, 2026

New Dashboard look:
Screenshot 2026-04-14 at 1 40 42 PM

this may be too bold, but thinking about what the Berkeley color palette is like.

I've migrated all production courses to have the correct semester, but there is still a fallback.

Changes

Improves the dashboard course listing by grouping courses into semester sections with header rows, replacing the previous flat list. Semesters are sorted most-recent-first, with within-year ordering of Fall > Summer > Spring > Winter.

Key changes:

  • Course model: Added SEMESTER_SEASON_ORDER constant, semester_sort_key, and sort_semesters class methods for reusable, season-aware chronological sorting
  • CoursesController: Added group_by_semester helper; index now produces @teacher_courses_by_semester and @student_courses_by_semester (arrays of [semester_name, [user_to_courses]] pairs) alongside the existing flat lists used for empty-state checks
  • Dashboard view: Both staff and student tables now render a full-width table-secondary fw-bold header row per semester group. Removed the old created_at-based term calculation and the now-redundant "Term" column from the student table
  • Removed a duplicate filter_by_semester method from the controller

Testing

  • Added Course.semester_sort_key unit specs covering all four seasons, nil, and blank inputs
  • Added Course.sort_semesters specs covering multi-year sorting, all-four-seasons-in-one-year ordering, nil placement, single item, and empty array
  • Added controller specs verifying teacher and student courses are grouped by semester in the correct descending order
  • All 395 specs pass

Documentation

No additional documentation required.

Checklist

  • Name of branch corresponds to story

Superconductor Ticket Implementation | App Preview | Guided Review

cycomachead and others added 7 commits April 14, 2026 17:24
Implement logic to group courses by semester on the dashboard, replacing the flat list with a categorized view. This includes a custom sorting algorithm to display semesters in reverse chronological order (Fall > Summer > Spring > Winter).

- Added `Course.sort_semesters` utility for season-aware chronological sorting
- Updated `CoursesController` to group teacher and student courses
- Added full-width semester header rows to the dashboard tables
- Removed redundant "Term" column in favor of group headers
- Added unit and controller specs for sorting and grouping logic

Co-authored-by: Claude Code <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor Author

@cycomachead cycomachead left a comment

Choose a reason for hiding this comment

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

Sigh, lots of weird front end asset stuff is broken.

Comment thread app/models/course.rb
# Within the same year: Fall > Summer > Spring > Winter (furthest out to most recent).
SEMESTER_SEASON_ORDER = { 'Fall' => 3, 'Summer' => 2, 'Spring' => 1, 'Winter' => 0 }.freeze

# Returns a numeric sort key for a semester string (e.g. "Spring 2026").
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.

We should at some point consider validating the data, or using some kind of a current term.

Comment thread app/models/course.rb

parts = semester.split
season = parts[0]
year = parts[1].to_i
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.

Luckily in ruby this is safe. 🙃

I did have to check, but this is why ruby is great.

irb(main):001> 'hello'.to_i
=> 0
irb(main):002> 'hello'.split
=> ["hello"]
irb(main):003> 'hello'.split[1]
=> nil
irb(main):004> 'hello'.split[1].to_i
=> 0
irb(main):005> 

@cycomachead cycomachead merged commit c760ee1 into main Apr 14, 2026
11 checks passed
@cycomachead cycomachead deleted the cycomachead/88-improve-semester-dashboard/1 branch April 14, 2026 20:49
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