MDL-53966 lesson: Allow maximum number of attempts to be unlimited
[moodle.git] / mod / lesson / tests / behat / lesson_navigation.feature
CommitLineData
550d842e 1@mod @mod_lesson
9fb5894e
DM
2Feature: In a lesson activity, students can navigate through a series of pages in various ways depending upon their answers to questions
3 In order to create a lesson with conditional paths
4 As a teacher
5 I need to add pages and questions with links between them
6
22cd6b3c 7 Background:
759b323e 8 Given the following "users" exist:
9fb5894e 9 | username | firstname | lastname | email |
0fe86bbd
RT
10 | teacher1 | Teacher | 1 | teacher1@example.com |
11 | student1 | Student | 1 | student1@example.com |
759b323e 12 And the following "courses" exist:
9fb5894e
DM
13 | fullname | shortname | category |
14 | Course 1 | C1 | 0 |
759b323e 15 And the following "course enrolments" exist:
9fb5894e
DM
16 | user | course | role |
17 | teacher1 | C1 | editingteacher |
18 | student1 | C1 | student |
19 And I log in as "teacher1"
fdeeaff9 20 And I am on "Course 1" course homepage with editing mode on
22cd6b3c 21
22cd6b3c
DC
22 Scenario: Student navigation with pages and questions
23 Given I add a "Lesson" to section "1" and I fill the form with:
9fb5894e 24 | Name | Test lesson name |
5b17d81d 25 | Description | Test lesson description |
9fb5894e
DM
26 And I follow "Test lesson name"
27 And I follow "Add a content page"
f083d614 28 And I set the following fields to these values:
9fb5894e
DM
29 | Page title | First page name |
30 | Page contents | First page contents |
31 | id_answer_editor_0 | Next page |
32 | id_jumpto_0 | Next page |
33 And I press "Save page"
beaf0da9 34 And I select "Add a content page" from the "qtype" singleselect
f083d614 35 And I set the following fields to these values:
9fb5894e
DM
36 | Page title | Second page name |
37 | Page contents | Second page contents |
38 | id_answer_editor_0 | Previous page |
39 | id_jumpto_0 | Previous page |
40 | id_answer_editor_1 | Next page |
41 | id_jumpto_1 | Next page |
42 And I press "Save page"
43 And I follow "Expanded"
38976081 44 And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
f083d614 45 And I set the field "Select a question type" to "Numerical"
9fb5894e 46 And I press "Add a question page"
f083d614 47 And I set the following fields to these values:
9fb5894e
DM
48 | Page title | Hardest question ever |
49 | Page contents | 1 + 1? |
50 | id_answer_editor_0 | 2 |
51 | id_response_editor_0 | Correct answer |
52 | id_jumpto_0 | End of lesson |
53 | id_score_0 | 1 |
54 | id_answer_editor_1 | 1 |
55 | id_response_editor_1 | Incorrect answer |
56 | id_jumpto_1 | Second page name |
57 | id_score_1 | 0 |
58 And I press "Save page"
9fb5894e
DM
59 And I log out
60 And I log in as "student1"
fdeeaff9 61 And I am on "Course 1" course homepage
9fb5894e
DM
62 When I follow "Test lesson name"
63 Then I should see "First page contents"
64 And I press "Next page"
65 And I should see "Second page contents"
66 And I should not see "First page contents"
67 And I press "Previous page"
68 And I should see "First page contents"
69 And I should not see "Second page contents"
70 And I press "Next page"
71 And I should see "Second page contents"
72 And I press "Next page"
73 And I should see "1 + 1?"
f083d614 74 And I set the following fields to these values:
9fb5894e
DM
75 | Your answer | 1 |
76 And I press "Submit"
77 And I should see "Incorrect answer"
78 And I press "Continue"
79 And I should see "Second page name"
80 And I press "Next page"
81 And I should see "1 + 1?"
f083d614 82 And I set the following fields to these values:
9fb5894e
DM
83 | Your answer | 2 |
84 And I press "Submit"
ab2d8946 85 And I should see "Maximum number of attempts reached - Moving to next page"
9fb5894e
DM
86 And I press "Continue"
87 And I should see "Congratulations - end of lesson reached"
88 And I should see "Your score is 0 (out of 1)."
22cd6b3c 89
22cd6b3c
DC
90 Scenario: Student reattempts a question until out of attempts
91 Given I add a "Lesson" to section "1" and I fill the form with:
92 | Name | Test lesson name |
93 | Description | Test lesson description |
94 | id_review | Yes |
95 | id_maxattempts | 3 |
96 And I follow "Test lesson name"
97 And I follow "Add a question page"
98 And I set the following fields to these values:
99 | id_qtype | True/false |
100 And I press "Add a question page"
101 And I set the following fields to these values:
102 | Page title | Test question |
103 | Page contents | Test content |
104 | id_answer_editor_0 | right |
105 | id_answer_editor_1 | wrong |
106 And I press "Save page"
107 And I log out
108 And I log in as "student1"
fdeeaff9 109 And I am on "Course 1" course homepage
22cd6b3c
DC
110 When I follow "Test lesson name"
111 Then I should see "Test content"
112 And I set the following fields to these values:
113 | wrong | 1 |
114 And I press "Submit"
115 And I should see "You have 2 attempt(s) remaining"
116 And I press "Yes, I'd like to try again"
117 And I should see "Test content"
118 And I set the following fields to these values:
119 | wrong | 1 |
120 And I press "Submit"
121 And I should see "You have 1 attempt(s) remaining"
122 And I press "Yes, I'd like to try again"
123 And I should see "Test content"
124 And I set the following fields to these values:
125 | wrong | 1 |
126 And I press "Submit"
ab2d8946 127 And I should not see "Yes, I'd like to try again"
22cd6b3c
DC
128 And I press "Continue"
129 And I should see "Congratulations - end of lesson reached"
252e85be
MG
130
131 Scenario: Student should not see remaining attempts notification if maximum number of attempts is set to unlimited
132 Given I add a "Lesson" to section "1" and I fill the form with:
133 | Name | Test lesson name |
134 | Description | Test lesson description |
135 | id_review | Yes |
136 | id_maxattempts | 0 |
137 And I follow "Test lesson name"
138 And I follow "Add a question page"
139 And I set the following fields to these values:
140 | id_qtype | True/false |
141 And I press "Add a question page"
142 And I set the following fields to these values:
143 | Page title | Test question |
144 | Page contents | Test content |
145 | id_answer_editor_0 | right |
146 | id_answer_editor_1 | wrong |
147 And I press "Save page"
148 And I log out
149 And I log in as "student1"
150 And I am on "Course 1" course homepage
151 When I follow "Test lesson name"
152 Then I should see "Test content"
153 And I set the following fields to these values:
154 | wrong | 1 |
155 And I press "Submit"
156 And I should not see "attempt(s) remaining"
157 And I press "Yes, I'd like to try again"
158 And I should see "Test content"
159 And I set the following fields to these values:
160 | right | 1 |
161 And I press "Submit"
162 And I should not see "Yes, I'd like to try again"
163 And I should see "Congratulations - end of lesson reached"