feat: enhance lesson plan handling with new parser and color-coded room assignments

This commit is contained in:
2026-10-23 00:33:13 +03:00
parent c0487e4c2a
commit 02e6404731
11 changed files with 121 additions and 18 deletions

View File

@@ -95,6 +95,14 @@ export function personalFilter(lesson, group, prefs) {
if (prefs?.hidden?.includes(lessonKey(lesson, group))) return "hidden";
return "shown";
}
const inWeeks = (ranges, n) => !ranges || (n != null && ranges.some(([a, b]) => n >= a && (b === null || n <= b)));
/**
* A lesson's rooms and teachers by week ("1-9н. 502н", "бел.н.504н/зел.н.524н",
* "ауд.533н-б.н.,420н-з.н."): the plan entries for a week `{n, color}`, by its number, its colour
* or both. Shared by the server's timetable and the browser.
*/
export const planFor = (plan, week) =>
week && plan?.length ? plan.filter((p) => inWeeks(p.weeks, week.n) && (!p.color || p.color === week.color)) : [];
/** Subgroup labels present for a group, in column order. */
export function subgroupsOf(schedule, group) {
const labels = new Set();