From 5c1606e595ea5dd76f16ffa6e450f4a35d0d0d8b Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Thu, 15 Feb 2024 13:08:27 +0100 Subject: [PATCH] MOBILE-4350 quiz: Disable sequential navigation items --- .../navigation-modal/navigation-modal.html | 3 +- .../navigation-modal/navigation-modal.ts | 1 + src/addons/mod/quiz/pages/player/player.ts | 4 +- src/addons/mod/quiz/pages/review/review.ts | 1 + .../quiz/tests/behat/quiz_navigation.feature | 93 ++++++++++--------- 5 files changed, 53 insertions(+), 49 deletions(-) diff --git a/src/addons/mod/quiz/components/navigation-modal/navigation-modal.html b/src/addons/mod/quiz/components/navigation-modal/navigation-modal.html index 08856265c..3af0aef3f 100644 --- a/src/addons/mod/quiz/components/navigation-modal/navigation-modal.html +++ b/src/addons/mod/quiz/components/navigation-modal/navigation-modal.html @@ -15,7 +15,8 @@ + [disabled]="!isReview && isSequential && currentPage !== question.page" (click)="loadPage(question.page, question.slot)" + [detail]="false"> diff --git a/src/addons/mod/quiz/components/navigation-modal/navigation-modal.ts b/src/addons/mod/quiz/components/navigation-modal/navigation-modal.ts index 044d4d0e8..614572a59 100644 --- a/src/addons/mod/quiz/components/navigation-modal/navigation-modal.ts +++ b/src/addons/mod/quiz/components/navigation-modal/navigation-modal.ts @@ -30,6 +30,7 @@ export class AddonModQuizNavigationModalComponent { @Input() summaryShown?: boolean; // Whether summary is currently being shown. @Input() currentPage?: number; // Current page. @Input() isReview?: boolean; // Whether the user is reviewing the attempt. + @Input() isSequential?: boolean; // Whether quiz navigation is sequential. /** * Close modal. diff --git a/src/addons/mod/quiz/pages/player/player.ts b/src/addons/mod/quiz/pages/player/player.ts index 6d4aa1aa1..2fdc9e1b4 100644 --- a/src/addons/mod/quiz/pages/player/player.ts +++ b/src/addons/mod/quiz/pages/player/player.ts @@ -559,8 +559,6 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { return; } - // @todo MOBILE-4350: This is called before getting the attempt data in sequential quizzes as a workaround for a bug - // in the LMS. Once the bug has been fixed, this should be reverted. if (this.isSequential) { await this.logViewPage(page); } @@ -594,7 +592,6 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { // Mark the page as viewed. if (!this.isSequential) { - // @todo MOBILE-4350: Undo workaround. await this.logViewPage(page); } @@ -734,6 +731,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { summaryShown: this.showSummary, currentPage: this.attempt?.currentpage, isReview: false, + isSequential: this.isSequential, }, }); diff --git a/src/addons/mod/quiz/pages/review/review.ts b/src/addons/mod/quiz/pages/review/review.ts index d24d5068b..70f512c18 100644 --- a/src/addons/mod/quiz/pages/review/review.ts +++ b/src/addons/mod/quiz/pages/review/review.ts @@ -345,6 +345,7 @@ export class AddonModQuizReviewPage implements OnInit { summaryShown: false, currentPage: this.attempt?.currentpage, isReview: true, + isSequential: this.quiz && AddonModQuiz.isNavigationSequential(this.quiz), }, }); diff --git a/src/addons/mod/quiz/tests/behat/quiz_navigation.feature b/src/addons/mod/quiz/tests/behat/quiz_navigation.feature index 8107f7176..215885128 100644 --- a/src/addons/mod/quiz/tests/behat/quiz_navigation.feature +++ b/src/addons/mod/quiz/tests/behat/quiz_navigation.feature @@ -83,55 +83,58 @@ Feature: Navigate through a quiz in the app And I should find "Text of the first question" in the app And I should find "Text of the second question" in the app - # @todo MOBILE-4350 uncomment and update this test. -# Scenario: Sequential navigation -# Given I entered the quiz activity "Quiz 2" on course "Course 1" as "student1" in the app -# And I press "Attempt quiz now" in the app -# Then I should find "Text of the first question" in the app -# But I should not find "Text of the second question" in the app -# And I should not find "Text of the third question" in the app + Scenario: Sequential navigation + Given I entered the quiz activity "Quiz 2" on course "Course 1" as "student1" in the app + And I press "Attempt quiz now" in the app + Then I should find "Text of the first question" in the app + But I should not find "Text of the second question" in the app + And I should not find "Text of the third question" in the app -# When I press "Open navigation popover" in the app -# Then I should find "Question 1" in the app -# But I should not find "Question 2" in the app -# And I should not find "Question 3" in the app + When I press "Open navigation popover" in the app + Then I should find "Question 1" in the app + And I should find "Question 2" in the app + And I should find "Question 3" in the app + But I should not be able to press "Question 2" in the app + And I should not be able to press "Question 3" in the app -# When I press "Close" in the app -# And I press "Next" in the app -# Then I should find "Text of the second question" in the app -# But I should not find "Text of the first question" in the app -# And I should not find "Text of the third question" in the app -# And I should not find "Previous" in the app + When I press "Close" in the app + And I press "Next" in the app + Then I should find "Text of the second question" in the app + But I should not find "Text of the first question" in the app + And I should not find "Text of the third question" in the app + And I should not find "Previous" in the app -# When I press "Open navigation popover" in the app -# Then I should find "Question 2" in the app -# But I should not find "Question 1" in the app -# And I should not find "Question 3" in the app + When I press "Open navigation popover" in the app + Then I should find "Question 1" in the app + And I should find "Question 2" in the app + And I should find "Question 3" in the app + But I should not be able to press "Question 1" in the app + And I should not be able to press "Question 3" in the app -# When I press "Close" in the app -# And I press "Next" in the app -# Then I should find "Text of the third question" in the app -# But I should not find "Text of the first question" in the app -# And I should not find "Text of the second question" in the app -# And I should not find "Previous" in the app + When I press "Close" in the app + And I press "Next" in the app + Then I should find "Text of the third question" in the app + But I should not find "Text of the first question" in the app + And I should not find "Text of the second question" in the app + And I should not find "Previous" in the app -# When I press "Open navigation popover" in the app -# Then I should find "Question 3" in the app -# But I should not find "Question 1" in the app -# And I should not find "Question 2" in the app + When I press "Open navigation popover" in the app + Then I should find "Question 1" in the app + And I should find "Question 2" in the app + And I should find "Question 3" in the app + But I should not be able to press "Question 1" in the app + And I should not be able to press "Question 2" in the app -# When I press "Close" in the app -# And I press "Submit" in the app -# Then I should find "Summary of attempt" in the app -# # @todo MOBILE-4350: Uncomment these. -# # And I should find "Not yet answered" within "1" "ion-item" in the app -# # And I should find "Not yet answered" within "2" "ion-item" in the app -# # And I should find "Not yet answered" within "3" "ion-item" in the app + When I press "Close" in the app + And I press "Submit" in the app + Then I should find "Summary of attempt" in the app + And I should find "Not yet answered" within "1" "ion-item" in the app + And I should find "Not yet answered" within "2" "ion-item" in the app + And I should find "Not yet answered" within "3" "ion-item" in the app -# When I press "Submit all and finish" in the app -# And I press "Submit" near "Once you submit" in the app -# Then I should find "Review" in the app -# # @todo MOBILE-4350: Uncomment these. -# # And I should find "Text of the first question" in the app -# # And I should find "Text of the second question" in the app -# # And I should find "Text of the third question" in the app + When I press "Submit all and finish" in the app + And I press "Submit" near "Once you submit" in the app + Then I should find "Review" in the app + And I should find "Text of the first question" in the app + And I should find "Text of the second question" in the app + And I should find "Text of the third question" in the app