feat: Enhance session handling in timetable and UI

- Introduced session types (exams, credits, consultations, coursework defenses) with distinct icons and colors for better visibility in the UI.
- Updated PlansScreen, ScheduleScreen, and WeekGrid to display session information appropriately.
- Modified CalendarView and PlansView to include session indicators in the calendar and plans.
- Enhanced LessonCard and CompactLesson to show session details and adjust styling based on session presence.
- Added new SessionMark component for consistent session representation across Android and iOS.
- Updated server logic to handle session entries from external documents, ensuring accurate timetable representation.
- Improved date parsing to accommodate session-related dates in various formats.
- Added tests to verify session handling and date parsing functionality.
This commit is contained in:
2026-10-19 20:49:13 +03:00
parent db9a3f8243
commit 15851b26cd
21 changed files with 421 additions and 42 deletions

View File

@@ -83,3 +83,33 @@ test("Сессия с датами в Word не зависит от таблиц
const exam = t.days.find((d) => d.date === "2026-06-18").lessons.find((l) => l.type === "Экзамен");
assert.deepEqual([exam.start, exam.end, exam.pair], ["08:30", "09:55", 1]);
});
test("Зачёты из отдельного документа попадают в дни расписания группы", async () => {
const { buildIndex, sessionEntriesOf } = await import("../server/directory.js");
// The 26-АРХ credit schedule, readdressed to 23-БА, plus one exam after the semester's end.
const credits = parseDocx(fixture("isf-credits-26-arh"), { name: "Зачеты.docx" });
const readdress = (l) => ({ ...l, groups: ["23-БА"], subgroups: l.subgroups.map((s) => ({ ...s, group: "23-БА" })) });
const lessons = credits.lessons.map(readdress);
lessons.push({ ...lessons[1], id: "late", date: "2027-01-15", type: "Экзамен", subject: "Бизнес-анализ" });
const idx = buildIndex([
{ id: "fef", file, schedule },
{ id: "credits", file: { id: "credits", name: "Зачеты.docx" }, schedule: { ...credits, lessons, groups: ["23-БА"] } },
]);
const session = sessionEntriesOf(idx, "23-БА", null, "fef");
assert.equal(session.length, 10);
const t = timetable({ file, schedule, calendar, group: "23-БА", from: "2026-10-19", range: "semester", today: "2026-10-19", session });
const on = (date) =>
t.days.find((d) => d.date === date).lessons
.filter((l) => ["Зачёт", "Экзамен", "Консультация"].includes(l.type))
.map((l) => [l.start, l.type, l.subject, l.subgroup]);
// Both subgroups' credits, at their own time and with their subgroup.
assert.deepEqual(on("2026-12-22"), [
["17:00", "Зачёт", "Рисунок", "Подгруппа 1"],
["17:00", "Зачёт", "Рисунок", "Подгруппа 2"],
]);
assert.deepEqual(on("2026-10-27"), [["17:00", "Консультация", "Введение в архитектурное проектирование", null]]);
// The span runs past the semester (3 January) to the last exam.
assert.equal(t.days.at(-1).date, "2027-01-15");
assert.deepEqual(on("2027-01-15"), [[lessons.at(-1).start, "Экзамен", "Бизнес-анализ", null]]);
assert.ok(t.subgroups.includes("Подгруппа 2"));
});

View File

@@ -121,3 +121,18 @@ test("Парсер: 23-БА получает номера недель и дат
for (const n of [a, b ?? a])
assert.equal(n % 2, l.variant === "upper" ? 1 : 0, l.raw);
});
test("Даты числами: «10.09;15.10;19.11;17.12», но не время пары", () => {
// ИСФ пишет дни информирования списком дат, как в 23-АРХ.
assert.deepEqual(parseTextDates("Единый день информирования 10.09;15.10;19.11;17.12", 2026), [
"2026-09-10",
"2026-10-15",
"2026-11-19",
"2026-12-17",
]);
assert.deepEqual(parseTextDates("03.10, 17.10. Физика", 2026), ["2026-10-03", "2026-10-17"]);
assert.deepEqual(parseTextDates("12.01.2027; 19.01.2027 Экзамен", 2026), ["2027-01-12", "2027-01-19"]);
// One number pair alone or a time range is a time, not a date.
for (const time of ["10.05 Лекция", "10.05-11.30", "16.50 Информационный час", "09.11 по 06.12 практика"])
assert.deepEqual(parseTextDates(time, 2026), [], time);
});