Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: timetable week problem #218

Merged
merged 3 commits into from
Mar 5, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/model/time_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class TimeTable {

factory TimeTable.mergeManuallyAddedCourses(
TimeTable? formerTimeTable, List<Course?> newCourses) {
if(formerTimeTable == null){
if (formerTimeTable == null) {
return TimeTable();
}
if (newCourses.isEmpty) {
Expand Down Expand Up @@ -239,7 +239,16 @@ class TimeTable {
table[i] = [];
}
for (var course in courses!) {
// if the course is available in this week
if (course.availableWeeks!.contains(week)) {
for (var courseTime in course.times!) {
if (courseTime.weekDay != 6) {
table[courseTime.weekDay]!.add(Event(course, courseTime));
}
}
// or the course is available in the next week and the course is on Sunday
} else if ((course.availableWeeks!.contains(week + 1) &&
course.times!.any((element) => element.weekDay == 6))) {
for (var courseTime in course.times!) {
table[courseTime.weekDay]!.add(Event(course, courseTime));
}
Expand Down