Skip to content

Commit cbb33b0

Browse files
authored
Merge pull request #3699 from NoelDeMartin/MOBILE-4345
MOBILE-4345 quiz: Fix sequential navigation
2 parents 737c2c2 + 50cf8e0 commit cbb33b0

File tree

2 files changed

+85
-6
lines changed

2 files changed

+85
-6
lines changed

src/addons/mod/quiz/pages/player/player.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,14 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
531531
return;
532532
}
533533

534+
// @todo MOBILE-4350: This is called before getting the attempt data in sequential quizzes as a workaround for a bug
535+
// in the LMS. Once the bug has been fixed, this should be reverted.
536+
if (this.isSequential) {
537+
await CoreUtils.ignoreErrors(
538+
AddonModQuiz.logViewAttempt(this.attempt.id, page, this.preflightData, this.offline, this.quiz),
539+
);
540+
}
541+
534542
const data = await AddonModQuiz.getAttemptData(this.attempt.id, page, this.preflightData, {
535543
cmId: this.quiz.coursemodule,
536544
readingStrategy: this.offline ? CoreSitesReadingStrategy.PREFER_CACHE : CoreSitesReadingStrategy.ONLY_NETWORK,
@@ -559,9 +567,12 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
559567
});
560568

561569
// Mark the page as viewed.
562-
CoreUtils.ignoreErrors(
563-
AddonModQuiz.logViewAttempt(this.attempt.id, page, this.preflightData, this.offline, this.quiz),
564-
);
570+
if (!this.isSequential) {
571+
// @todo MOBILE-4350: Undo workaround.
572+
CoreUtils.ignoreErrors(
573+
AddonModQuiz.logViewAttempt(this.attempt.id, page, this.preflightData, this.offline, this.quiz),
574+
);
575+
}
565576

566577
// Start looking for changes.
567578
this.autoSave.startCheckChangesProcess(this.quiz, this.attempt, this.preflightData, this.offline);

src/addons/mod/quiz/tests/behat/quiz_navigation.feature

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,39 @@ Feature: Attempt a quiz in app
1515
| user | course | role |
1616
| student1 | C1 | student |
1717
And the following "activities" exist:
18-
| activity | name | intro | course | idnumber |
19-
| quiz | Quiz 1 | Quiz 1 description | C1 | quiz1 |
18+
| activity | name | intro | course | idnumber | navmethod |
19+
| quiz | Quiz 1 | Quiz 1 description | C1 | quiz1 | free |
20+
| quiz | Quiz 2 | Quiz 2 description | C1 | quiz2 | sequential |
2021
And the following "question categories" exist:
2122
| contextlevel | reference | name |
2223
| Course | C1 | Test questions |
2324
And the following "questions" exist:
2425
| questioncategory | qtype | name | questiontext |
2526
| Test questions | truefalse | TF1 | Text of the first question |
2627
| Test questions | truefalse | TF2 | Text of the second question |
28+
| Test questions | truefalse | TF3 | Text of the third question |
2729
And quiz "Quiz 1" contains the following questions:
2830
| question | page |
2931
| TF1 | 1 |
3032
| TF2 | 2 |
33+
And quiz "Quiz 2" contains the following questions:
34+
| question | page |
35+
| TF1 | 1 |
36+
| TF2 | 2 |
37+
| TF3 | 3 |
3138

3239
Scenario: Next and previous navigation
3340
Given I entered the quiz activity "Quiz 1" on course "Course 1" as "student1" in the app
3441
And I press "Attempt quiz now" in the app
3542
Then I should find "Text of the first question" in the app
3643
But I should not find "Text of the second question" in the app
3744

38-
When I press "Next" in the app
45+
When I press "Open navigation popover" in the app
46+
Then I should find "Question 1" in the app
47+
And I should find "Question 2" in the app
48+
49+
When I press "Close" in the app
50+
And I press "Next" in the app
3951
Then I should find "Text of the second question" in the app
4052
But I should not find "Text of the first question" in the app
4153

@@ -54,6 +66,8 @@ Feature: Attempt a quiz in app
5466
When I press "Next" in the app
5567
And I press "Submit" in the app
5668
Then I should find "Summary of attempt" in the app
69+
And I should find "Not yet answered" within "1" "ion-item" in the app
70+
And I should find "Not yet answered" within "2" "ion-item" in the app
5771

5872
When I press "Not yet answered" within "2" "ion-item" in the app
5973
Then I should find "Text of the second question" in the app
@@ -69,3 +83,57 @@ Feature: Attempt a quiz in app
6983
When I press "Submit all and finish" in the app
7084
And I press "OK" near "Once you submit" in the app
7185
Then I should find "Review" in the app
86+
And I should find "Text of the first question" in the app
87+
And I should find "Text of the second question" in the app
88+
89+
Scenario: Sequential navigation
90+
Given I entered the quiz activity "Quiz 2" on course "Course 1" as "student1" in the app
91+
And I press "Attempt quiz now" in the app
92+
Then I should find "Text of the first question" in the app
93+
But I should not find "Text of the second question" in the app
94+
And I should not find "Text of the third question" in the app
95+
96+
When I press "Open navigation popover" in the app
97+
Then I should find "Question 1" in the app
98+
But I should not find "Question 2" in the app
99+
And I should not find "Question 3" in the app
100+
101+
When I press "Close" in the app
102+
And I press "Next" in the app
103+
Then I should find "Text of the second question" in the app
104+
But I should not find "Text of the first question" in the app
105+
And I should not find "Text of the third question" in the app
106+
And I should not find "Previous" in the app
107+
108+
When I press "Open navigation popover" in the app
109+
Then I should find "Question 2" in the app
110+
But I should not find "Question 1" in the app
111+
And I should not find "Question 3" in the app
112+
113+
When I press "Close" in the app
114+
And I press "Next" in the app
115+
Then I should find "Text of the third question" in the app
116+
But I should not find "Text of the first question" in the app
117+
And I should not find "Text of the second question" in the app
118+
And I should not find "Previous" in the app
119+
120+
When I press "Open navigation popover" in the app
121+
Then I should find "Question 3" in the app
122+
But I should not find "Question 1" in the app
123+
And I should not find "Question 2" in the app
124+
125+
When I press "Close" in the app
126+
And I press "Submit" in the app
127+
Then I should find "Summary of attempt" in the app
128+
# @todo MOBILE-4350: Uncomment these.
129+
# And I should find "Not yet answered" within "1" "ion-item" in the app
130+
# And I should find "Not yet answered" within "2" "ion-item" in the app
131+
# And I should find "Not yet answered" within "3" "ion-item" in the app
132+
133+
When I press "Submit all and finish" in the app
134+
And I press "OK" near "Once you submit" in the app
135+
Then I should find "Review" in the app
136+
# @todo MOBILE-4350: Uncomment these.
137+
# And I should find "Text of the first question" in the app
138+
# And I should find "Text of the second question" in the app
139+
# And I should find "Text of the third question" in the app

0 commit comments

Comments
 (0)