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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user