migrated timetable integration from WebUntis to the MarianumConnect API, implementing a Dio-based client with bearer token authentication, background session validation, and auto-refresh logic.

This commit is contained in:
2026-05-23 17:32:42 +02:00
parent 2858f910c9
commit 93b9929f8f
106 changed files with 2739 additions and 2624 deletions
@@ -1,32 +1,40 @@
import '../../../../api/webuntis/queries/get_timetable/get_timetable_response.dart';
import '../../../../api/marianumconnect/queries/timetable_get_week/timetable_get_week_response.dart';
enum LessonStatus {
cancelled,
event,
irregular,
teacherChanged,
duty,
past,
ongoing,
regular,
}
class LessonStatusClassifier {
/// Mirrors the legacy Webuntis classifier: cancelled trumps everything,
/// then event (subject-less lessons such as Wandertag), then irregular
/// (status from the backend or a slot without an assigned teacher), then
/// teacherChanged when the backend reports a substitution swap, then
/// duty (Aufsicht/Sprechstunde/…) so they stand out from regular
/// classroom lessons, then the time-based past/ongoing/regular states.
static LessonStatus classify(
GetTimetableResponseObject lesson,
McTimetableEntry entry,
DateTime startTime,
DateTime endTime,
DateTime now, {
bool isEvent = false,
bool isDuty = false,
}) {
if (lesson.code == 'cancelled') return LessonStatus.cancelled;
if (entry.status == 'CANCELLED') return LessonStatus.cancelled;
if (isEvent) return LessonStatus.event;
if (lesson.code == 'irregular' ||
(lesson.te.isNotEmpty && lesson.te.first.id == 0)) {
if (entry.status == 'IRREGULAR' || entry.teachers.isEmpty) {
return LessonStatus.irregular;
}
if (lesson.te.any((t) => t.orgname != null)) {
if (entry.teachers.any((t) => (t.originalShortName ?? '').isNotEmpty)) {
return LessonStatus.teacherChanged;
}
if (isDuty) return LessonStatus.duty;
if (endTime.isBefore(now)) return LessonStatus.past;
if (startTime.isBefore(now) && endTime.isAfter(now)) {
return LessonStatus.ongoing;