Skip to content

Stabilize timetable lesson ordering - #454

Open
nemkutya wants to merge 1 commit into
filcdev:mainfrom
nemkutya:main
Open

nemkutya wants to merge 1 commit into
filcdev:mainfrom
nemkutya:main

Conversation

@nemkutya

Copy link
Copy Markdown
Contributor

Summary

Make split-group lessons occupy the same horizontal position on every day and period. The timetable grid rendered lessons in raw API return order (getForCohort has no ORDER BY, and buildViewModel sorted nothing), so a group could appear in the left sub-column on Monday and the right sub-column on Tuesday. Every timetable view now orders the lessons of a (day × time) cell deterministically by group identifier before rendering, so group 1 is always the first sub-column, group 2 the second, and 3+ groups scale the same way.

No backend change was needed: lessons reference their groups through an array column (lesson.groupsIds), so the position cannot be expressed as a SQL ORDER BY, and the ordering is a presentation concern shared by three frontend views.

Closes #

Changes

Frontend

  • Shared split-group definition (components/timetable/helpers.ts): added isWholeClassGroup and getSplitGroups, so the lesson card label, the card group code and the slot ordering can no longer disagree about which group a lesson belongs to. Replaces two near-duplicate filters in lesson-card.tsx and secondary/helpers.ts.
  • Shared slot comparator (components/timetable/helpers.ts): added compareLessonsInSlot — trailing group ordinal first (mat1 before mat2, 3+ groups included), then natural localeCompare(..., { numeric: true }) for names without a number, then week type (A before B), then subject, then id as the final tiebreak. Grouped lessons sort before ungrouped ones, so a whole-class lesson never takes group 1's column. Subject is deliberately not part of the group key, so a group keeps its column when a different subject is taught to each group.
  • Grid and PDF (components/timetable/helpers.ts): buildViewModel now sorts each cell's lessons with compareLessonsInSlot. The PDF renders the same model, so it inherits the fix.
  • Card view (components/timetable/secondary/helpers.ts): removed the local week-then-id comparator and reused compareLessonsInSlot, so the card view and the grid agree.

Verification

  • bun run lint
  • bun run typecheck
  • bun run build — if bundler config, routers, or server entrypoints changed

Notes

  • Ordering was checked against mat1/mat2, 11.A angol1/angol2, mixed subjects (DiKu/Mat), three concurrent groups, a whole-class lesson sharing a cell, and A/B-week lessons of the same group.
  • Non-numeric group names (Kezdő/Haladó, Fiú/Lány) have no ordinal, so they fall back to natural alphabetical order.
  • Known follow-up, not part of this change: the PDF draws a single group-scoped lesson half-width on the left (pdf/document.tsx), so a lone mat2 still lands left.

Order lessons consistently by split-group position and week type across timetable views, and share whole-class group filtering between card labels and group codes.
@Dasa122 Dasa122 moved this from Backlog to In review in Filc Issue Tracker Nov 12, 2026
@Dasa122 Dasa122 moved this from In review to Ready in Filc Issue Tracker Nov 12, 2026
@Dasa122 Dasa122 moved this from Ready to In review in Filc Issue Tracker Nov 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

1 participant