Skip to content

Check if the active course reviews are completed instead of all course reviews #1188

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ PODS:
- FirebaseSharedSwift (~> 11.0)
- GoogleUtilities/Environment (~> 8.0)
- "GoogleUtilities/NSData+zlib (~> 8.0)"
- FirebaseRemoteConfigInterop (11.11.0)
- FirebaseRemoteConfigInterop (11.12.0)
- FirebaseSessions (11.10.0):
- FirebaseCore (~> 11.10.0)
- FirebaseCoreExtension (~> 11.10.0)
Expand All @@ -91,7 +91,7 @@ PODS:
- GoogleUtilities/UserDefaults (~> 8.0)
- nanopb (~> 3.30910.0)
- PromisesSwift (~> 2.1)
- FirebaseSharedSwift (11.11.0)
- FirebaseSharedSwift (11.12.0)
- Flutter (1.0.0)
- flutter_inappwebview_ios (0.0.1):
- Flutter
Expand Down Expand Up @@ -300,9 +300,9 @@ SPEC CHECKSUMS:
FirebaseCrashlytics: 84b073c997235740e6a951b7ee49608932877e5c
FirebaseInstallations: 9980995bdd06ec8081dfb6ab364162bdd64245c3
FirebaseRemoteConfig: 10695bc0ce3b103e3706a5578c43f2a9f69d5aaa
FirebaseRemoteConfigInterop: 85bdce8babed7814816496bb6f082bc05b0a45e1
FirebaseRemoteConfigInterop: 82b81fd06ee550cbeff40004e2c106daedf73e38
FirebaseSessions: 9b3b30947b97a15370e0902ee7a90f50ef60ead6
FirebaseSharedSwift: b1d32c3b29a911dc174bcf363f2f70bda9509d2f
FirebaseSharedSwift: d2475748a2d2a36242ed13baa34b2acda846c925
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_inappwebview_ios: 6f63631e2c62a7c350263b13fa5427aedefe81d4
flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12
Expand Down
7 changes: 6 additions & 1 deletion lib/data/services/signets-api/models/course.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ class Course {
if (reviews == null) {
return true;
}
return reviews!.every((review) => review.isCompleted);

final now = DateTime.now();
final activeReviews =
reviews!.where((review) => review.startAt.isBefore(now) && review.endAt.isAfter(now)).toList();

return activeReviews.isNotEmpty && activeReviews.every((review) => review.isCompleted);
}

Course(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,19 @@ void main() {
isCompleted: false,
);

final futureInactiveCourseReview = CourseReview(
acronym: 'GEN101',
group: '02',
teacherName: 'TEST',
startAt: DateTime.now().add(const Duration(days: 30)),
endAt: DateTime.now().add(const Duration(days: 60)),
type: 'Cours',
isCompleted: false,
);

final completedReviewList = <CourseReview>[completedCourseReview];
final nonCompletedReviewList = <CourseReview>[nonCompletedCourseReview];
final nonCompletedReviewList = <CourseReview>[nonCompletedCourseReview, futureInactiveCourseReview];
final semiCompletedReviewList = <CourseReview>[completedCourseReview, futureInactiveCourseReview];

final Course course = Course(
acronym: 'GEN101',
Expand All @@ -92,6 +103,16 @@ void main() {
title: 'Cours générique',
);

final Course courseWithEvaluationSemiCompleted = Course(
acronym: 'GEN101',
group: '02',
session: 'H2020',
programCode: '999',
numberOfCredits: 3,
title: 'Cours générique',
summary: courseSummary,
reviews: semiCompletedReviewList);

final Course courseWithEvaluationNotCompleted = Course(
acronym: 'GEN101',
group: '02',
Expand Down Expand Up @@ -204,6 +225,34 @@ void main() {

expect(find.byKey(const Key("EvaluationNotCompleted")), findsOneWidget);
});

testWidgets(
'display regular course content (evaluations, circular progress, etc) when in the evaluation period and the evaluation is completed with a future (inactive) review not completed',
(WidgetTester tester) async {
setupFlutterToastMock(tester);
CourseRepositoryMock.stubGetCourseSummary(courseRepositoryMock, courseWithEvaluationSemiCompleted,
toReturn: courseWithEvaluationSemiCompleted);
await tester.runAsync(() async {
await tester.pumpWidget(localizedWidget(child: GradesDetailsView(course: courseWithEvaluationSemiCompleted)));
await tester.pumpAndSettle(const Duration(seconds: 2));
}).then(
(value) {
expect(find.byType(RefreshIndicator), findsOneWidget);

// Find all the grade circular progress
expect(find.byKey(const Key("GradeCircularProgress_summary")), findsOneWidget);
for (final eval in courseSummary.evaluations) {
expect(find.byKey(Key("GradeCircularProgress_${eval.title}")), findsOneWidget);
}

expect(find.byType(Card), findsNWidgets(5));

for (final eval in courseSummary.evaluations) {
expect(find.byKey(Key("GradeEvaluationTile_${eval.title}")), findsOneWidget);
}
},
);
});
});
});
}
Loading