1@core @core_grades
2Feature: We can set the grade to pass value
3  In order to set the grade to pass value
4  As a teacher
5  I assign a grade to pass to an activity while editing the activity.
6  I need to ensure that the grade to pass is visible in the gradebook.
7
8  Background:
9    Given the following "users" exist:
10      | username | firstname | lastname | email |
11      | teacher1 | Teacher | 1 | teacher1@example.com |
12    And the following "courses" exist:
13      | fullname | shortname | format | numsections |
14      | Course 1 | C1 | weeks | 5 |
15    And the following "course enrolments" exist:
16      | user | course | role |
17      | teacher1 | C1 | editingteacher |
18    And the following "scales" exist:
19      | name | scale |
20      | Test Scale 1 | Disappointing, Good, Very good, Excellent |
21    And I log in as "teacher1"
22    And I am on "Course 1" course homepage
23
24  @javascript
25  Scenario: Validate that switching the type of grading used correctly disables grade to pass
26    When I turn editing mode on
27    And I add a "Assignment" to section "1"
28    And I expand all fieldsets
29    And I set the field "grade[modgrade_type]" to "Point"
30    Then the "Grade to pass" "field" should be enabled
31    And I set the field "grade[modgrade_type]" to "None"
32    And the "Grade to pass" "field" should be disabled
33    And I press "Save and return to course"
34
35  @javascript
36  Scenario: Create an activity with a Grade to pass value greater than the maximum grade
37    When I turn editing mode on
38    And I add a "Assignment" to section "1" and I fill the form with:
39      | Assignment name | Test Assignment 1 |
40      | Description | Submit your online text |
41      | assignsubmission_onlinetext_enabled | 1 |
42      | grade[modgrade_type] | Point |
43      | grade[modgrade_point] | 50 |
44      | Grade to pass | 100 |
45    Then I should see "The grade to pass can not be greater than the maximum possible grade 50"
46    And I press "Cancel"
47
48  Scenario: Set a valid grade to pass for an assignment activity using points
49    When I turn editing mode on
50    And I add a "Assignment" to section "1" and I fill the form with:
51      | Assignment name | Test Assignment 1 |
52      | Description | Submit your online text |
53      | assignsubmission_onlinetext_enabled | 1 |
54      | grade[modgrade_type] | Point |
55      | grade[modgrade_point] | 50 |
56      | Grade to pass | 25 |
57    And I navigate to "View > Grader report" in the course gradebook
58    And I turn editing mode on
59    And I click on "Edit  assign Test Assignment 1" "link"
60    Then the field "Grade to pass" matches value "25"
61    And I am on "Course 1" course homepage
62    And I follow "Test Assignment 1"
63    And I follow "Edit settings"
64    And I expand all fieldsets
65    And I set the field "Grade to pass" to "30"
66    And I press "Save and return to course"
67    And I navigate to "View > Grader report" in the course gradebook
68    And I click on "Edit  assign Test Assignment 1" "link"
69    And the field "Grade to pass" matches value "30"
70
71  Scenario: Set a valid grade to pass for an assignment activity using scales
72    When I turn editing mode on
73    And I add a "Assignment" to section "1" and I fill the form with:
74      | Assignment name | Test Assignment 1 |
75      | Description | Submit your online text |
76      | grade[modgrade_type] | Scale |
77      | grade[modgrade_scale] | Test Scale 1 |
78      | Grade to pass | 3 |
79    And I navigate to "View > Grader report" in the course gradebook
80    And I turn editing mode on
81    And I click on "Edit  assign Test Assignment 1" "link"
82    And I expand all fieldsets
83    Then the field "Grade to pass" matches value "3"
84    And I set the field "Grade to pass" to "4"
85    And I press "Save changes"
86    And I am on "Course 1" course homepage
87    And I follow "Test Assignment 1"
88    And I follow "Edit settings"
89    And the field "Grade to pass" matches value "4"
90
91  Scenario: Set a invalid grade to pass for an assignment activity using scales
92    When I turn editing mode on
93    And I add a "Assignment" to section "1" and I fill the form with:
94      | Assignment name | Test Assignment 1 |
95      | Description | Submit your online text |
96      | grade[modgrade_type] | Scale |
97      | grade[modgrade_scale] | Test Scale 1 |
98      | Grade to pass | 10 |
99    Then I should see "The grade to pass can not be greater than the maximum possible grade 4"
100
101  Scenario: Set a valid grade to pass for workshop activity
102    When I turn editing mode on
103    And I add a "Workshop" to section "1" and I fill the form with:
104      | Workshop name | Test Workshop 1 |
105      | Description | Test workshop |
106      | grade | 80 |
107      | Submission grade to pass | 40 |
108      | gradinggrade | 20 |
109      | Assessment grade to pass | 10 |
110    And I navigate to "View > Grader report" in the course gradebook
111    And I turn editing mode on
112    And I click on "Edit  workshop Test Workshop 1 (submission)" "link"
113    And I expand all fieldsets
114    Then the field "Grade to pass" matches value "40"
115    And I set the field "Grade to pass" to "45"
116    And I press "Save changes"
117    And I click on "Edit  workshop Test Workshop 1 (assessment)" "link"
118    And I expand all fieldsets
119    And the field "Grade to pass" matches value "10"
120    And I set the field "Grade to pass" to "15"
121    And I press "Save changes"
122    And I am on "Course 1" course homepage
123    And I follow "Test Workshop 1"
124    And I follow "Edit settings"
125    And the field "Submission grade to pass" matches value "45"
126    And the field "Assessment grade to pass" matches value "15"
127
128  Scenario: Set an invalid grade to pass for workshop activity
129    When I turn editing mode on
130    And I add a "Workshop" to section "1" and I fill the form with:
131      | Workshop name | Test Workshop 1 |
132      | Description | Test workshop |
133      | grade | 80 |
134      | Submission grade to pass | 90 |
135      | gradinggrade | 20 |
136      | Assessment grade to pass | 30 |
137    Then "The grade to pass can not be greater than the maximum possible grade 80" "text" should exist in the "Submission grade to pass" "form_row"
138    Then "The grade to pass can not be greater than the maximum possible grade 20" "text" should exist in the "Assessment grade to pass" "form_row"
139
140  Scenario: Set a valid grade to pass for quiz activity
141    When I turn editing mode on
142    And I add a "Quiz" to section "1" and I fill the form with:
143      | Name | Test Quiz 1 |
144      | Grade to pass | 9.5 |
145    And I navigate to "View > Grader report" in the course gradebook
146    And I turn editing mode on
147    And I click on "Edit  quiz Test Quiz 1" "link"
148    And I expand all fieldsets
149    Then the field "Grade to pass" matches value "9.5"
150    And I set the field "Grade to pass" to "8"
151    And I press "Save changes"
152    And I am on "Course 1" course homepage
153    And I follow "Test Quiz 1"
154    And I follow "Edit settings"
155    And the field "Grade to pass" matches value "8.00"
156
157  Scenario: Set a valid grade to pass for lesson activity
158    When I turn editing mode on
159    And I add a "Lesson" to section "1" and I fill the form with:
160      | Name          | Test Lesson 1 |
161      | Description   | Test          |
162      | Grade to pass | 90            |
163    And I navigate to "View > Grader report" in the course gradebook
164    And I turn editing mode on
165    And I click on "Edit  lesson Test Lesson 1" "link"
166    And I expand all fieldsets
167    Then the field "Grade to pass" matches value "90"
168    And I set the field "Grade to pass" to "80"
169    And I press "Save changes"
170    And I am on "Course 1" course homepage
171    And I follow "Test Lesson 1"
172    And I follow "Edit settings"
173    And the field "Grade to pass" matches value "80"
174
175  Scenario: Set a valid grade to pass for database activity
176    When I turn editing mode on
177    And I add a "Database" to section "1" and I fill the form with:
178      | Name           | Test Database 1    |
179      | Description    | Test               |
180      | Aggregate type | Average of ratings |
181      | Grade to pass  | 90                 |
182    And I navigate to "View > Grader report" in the course gradebook
183    And I turn editing mode on
184    And I click on "Edit  data Test Database 1" "link"
185    And I expand all fieldsets
186    Then the field "Grade to pass" matches value "90"
187    And I set the field "Grade to pass" to "80"
188    And I press "Save changes"
189    And I am on "Course 1" course homepage
190    And I click on "Edit settings" "link" in the "Test Database 1" activity
191    And the field "Grade to pass" matches value "80"
192
193  Scenario: Set an invalid grade to pass for forum activity
194    When I turn editing mode on
195    And I add a "Forum" to section "1" and I fill the form with:
196      | Forum name     | Test Forum 1    |
197      | Description    | Test               |
198      | Ratings > Aggregate type | Average of ratings |
199      | Ratings > Grade to pass  | 90                 |
200      | Ratings > scale[modgrade_point] | 60 |
201    Then I should see "The grade to pass can not be greater than the maximum possible grade 60"
202
203  Scenario: Set a valid grade to pass for forum activity
204    When I turn editing mode on
205    And I add a "Forum" to section "1" and I fill the form with:
206      | Forum name     | Test Forum 1    |
207      | Description    | Test               |
208      | Ratings > Aggregate type | Average of ratings |
209      | Ratings > Grade to pass  | 90                 |
210    And I navigate to "View > Grader report" in the course gradebook
211    And I turn editing mode on
212    And I click on "Edit  forum Test Forum 1 rating" "link"
213    And I expand all fieldsets
214    Then the field "Grade to pass" matches value "90"
215    And I set the field "Grade to pass" to "80"
216    And I press "Save changes"
217    And I am on "Course 1" course homepage
218    And I follow "Test Forum 1"
219    And I follow "Edit settings"
220    And the field "Ratings > Grade to pass" matches value "80"
221
222  Scenario: Set a valid grade to pass for glossary activity
223    When I turn editing mode on
224    And I add a "Glossary" to section "1" and I fill the form with:
225      | Name           | Test Glossary 1    |
226      | Description    | Test               |
227      | Aggregate type | Average of ratings |
228      | Grade to pass  | 90                 |
229    And I navigate to "View > Grader report" in the course gradebook
230    And I turn editing mode on
231    And I click on "Edit  glossary Test Glossary 1" "link"
232    And I expand all fieldsets
233    Then the field "Grade to pass" matches value "90"
234    And I set the field "Grade to pass" to "80"
235    And I press "Save changes"
236    And I am on "Course 1" course homepage
237    And I follow "Test Glossary 1"
238    And I follow "Edit settings"
239    And the field "Grade to pass" matches value "80"
240