SharezoneApp / sharezone-app

Sharezone is a collaborative school organization app for iOS, Android, macOS and web with +500,000 downloads. Built with Flutter & Firebase.
https://sharezone.net
European Union Public License 1.2
280 stars 50 forks source link

The due date isn't autofilled anymore, if the lesson is not in the timetable #1135

Closed nilsreichardt closed 1 year ago

nilsreichardt commented 1 year ago

Describe the bug

If a course is not present in the timetable, the autofill for the due date of the homework doesn't work anymore.

Steps to reproduce the bug

  1. Go to the homework tab
  2. Click "Create homework"
  3. Select a course that is not in the timetable

Current broken behavior

No due date is autofilled.

Expected behavior

In previous versions, if the course is not present in the timetable, we just used the next day as a due date.

Screenshots, videos or logs

https://github.com/SharezoneApp/sharezone-app/assets/24459435/2fe5307c-dfc6-4f3c-aabe-9954d6eb5839

Tested device

Additional context

cc: @Jonas-Sander

Possible solution

Jonas-Sander commented 1 year ago

In previous versions, if the course is not present in the timetable, we just used the next day as a due date.

Was it the next day (tomorrow) or the next school day? (So if tomorrow is the weekend or the next days are holidays they are skipped)

Jonas-Sander commented 1 year ago

https://github.com/SharezoneApp/sharezone-app/blob/3ae53ff39e3021c031e60aa9661ee3d76a313690/app/lib/blocs/homework/homework_dialog_bloc.dart#L175C1-L187C4

  static DateTime _getSeedTodoUntilDate() {
    DateTime now =
        DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day);
    if (DateTime.now().weekday == DateTime.friday ||
        DateTime.now().weekday == DateTime.saturday) {
      DateTime monday = now.add(
          Duration(days: DateTime.now().weekday == DateTime.friday ? 3 : 2));
      return monday;
    } else {
      DateTime tomorrow = now.add(const Duration(days: 1));
      return tomorrow;
    }
  }

This seems to be the algorithm