feat: keep undergraduate exams independent of course terms
This commit is contained in:
@@ -28,8 +28,11 @@ class AppSnapshot {
|
||||
Map<String, String> calendarEventIds = const {},
|
||||
}) : settings = settings ?? AppSettings(),
|
||||
schoolTerm = schoolTerm ?? _legacyTerm(courses, examSchedule),
|
||||
selectedSchool = selectedSchool ?? schoolTerm?.school ??
|
||||
_legacyTerm(courses, examSchedule)?.school ?? examSchedule?.school,
|
||||
selectedSchool =
|
||||
selectedSchool ??
|
||||
schoolTerm?.school ??
|
||||
_legacyTerm(courses, examSchedule)?.school ??
|
||||
examSchedule?.school,
|
||||
courses = List.unmodifiable(courses),
|
||||
calendarEventIds = Map.unmodifiable(calendarEventIds);
|
||||
final AppSettings settings;
|
||||
@@ -75,13 +78,13 @@ class AppSnapshot {
|
||||
calendarEventIds: calendarEventIds ?? this.calendarEventIds,
|
||||
calendarCleanupPending:
|
||||
calendarCleanupPending ?? this.calendarCleanupPending,
|
||||
selectedSchool:selectedSchool ?? this.selectedSchool,
|
||||
selectedSchool: selectedSchool ?? this.selectedSchool,
|
||||
);
|
||||
Map<String, dynamic> toJson() => {
|
||||
'schemaVersion': 1,
|
||||
'examSchedule': examSchedule?.toJson(),
|
||||
'schoolTerm': schoolTerm?.toJson(),
|
||||
'selectedSchoolId':selectedSchool?.id,
|
||||
'selectedSchoolId': selectedSchool?.id,
|
||||
'courses': courses.map((c) => c.toJson()).toList(),
|
||||
'settings': {
|
||||
'semester': settings.semester == null
|
||||
@@ -153,7 +156,9 @@ class AppSnapshot {
|
||||
);
|
||||
final metadata = json['importMetadata'];
|
||||
final snapshot = AppSnapshot(
|
||||
selectedSchool:json['selectedSchoolId']==null ? null : SupportedSchool.fromId(json['selectedSchoolId'] as String),
|
||||
selectedSchool: json['selectedSchoolId'] == null
|
||||
? null
|
||||
: SupportedSchool.fromId(json['selectedSchoolId'] as String),
|
||||
schoolTerm: json['schoolTerm'] == null
|
||||
? null
|
||||
: SchoolTerm.fromJson(
|
||||
@@ -190,8 +195,9 @@ 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节需要本科课表来源');
|
||||
if (snapshot.schoolTerm?.school != SupportedSchool.uestcUndergraduate &&
|
||||
values.any((c) => c.endPeriod > 11))
|
||||
throw const FormatException('第12节需要本科课表来源');
|
||||
return snapshot;
|
||||
} catch (_) {
|
||||
throw const FormatException('保存文件内容无效,未覆盖已有数据');
|
||||
|
||||
Reference in New Issue
Block a user