feat: integrate undergraduate school workflows and period twelve

This commit is contained in:
Codex
2026-10-15 00:28:04 +08:00
parent 7939bd4c3c
commit b28f333720
15 changed files with 573 additions and 26 deletions
+21 -3
View File
@@ -43,6 +43,26 @@ class AppSnapshot {
final Map<String, String> calendarEventIds;
final bool calendarCleanupPending;
final SupportedSchool? selectedSchool;
static void validateCourseSource(List<Course> courses, SchoolTerm? term) {
if (term?.school != SupportedSchool.uestcUndergraduate &&
courses.any((c) => c.endPeriod > 11)) {
throw const FormatException('第12节需要本科课表来源');
}
for (final course in courses) {
final under = RegExp(r'^uestc-undergraduate-(\d+)-')
.firstMatch(course.id);
if (under != null &&
(term?.school != SupportedSchool.uestcUndergraduate ||
under[1] != term?.id.toString())) {
throw const FormatException('本科课程学校或学期不一致');
}
if (term?.school == SupportedSchool.uestcUndergraduate &&
RegExp(r'^uestc-\d+-').hasMatch(course.id)) {
throw const FormatException('本科课表包含研究生课程标识');
}
}
}
static SchoolTerm? _legacyTerm(List<Course> courses, ExamSchedule? exams) {
final ids = courses
.map(
@@ -195,9 +215,7 @@ class AppSnapshot {
(k, v) => MapEntry(k as String, v as String),
),
);
if (snapshot.schoolTerm?.school != SupportedSchool.uestcUndergraduate &&
values.any((c) => c.endPeriod > 11))
throw const FormatException('第12节需要本科课表来源');
validateCourseSource(values, snapshot.schoolTerm);
return snapshot;
} catch (_) {
throw const FormatException('保存文件内容无效,未覆盖已有数据');
+1
View File
@@ -15,6 +15,7 @@ const lessonSlots = [
LessonSlot(9, 1170, 1215),
LessonSlot(10, 1220, 1265),
LessonSlot(11, 1270, 1315),
LessonSlot(12, 1320, 1365),
];
String minuteLabel(int minute) =>
'${(minute ~/ 60).toString().padLeft(2, '0')}:${(minute % 60).toString().padLeft(2, '0')}';