MDL-63724 messaging: Prefix field with the table alias
[moodle.git] / grade / tests / behat / grade_category_validation.feature
blobb7da9640ed9a59fca3b7b87322b93c31e7152577
1 @core_grades
2 Feature: Editing a grade item
3   In order to ensure validation is provided to the teacher
4   As a teacher
5   I need to know why I can not add/edit values on the grade category form
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname | email |
10       | student1 | Student | 1 | student1@example.com |
11       | teacher1 | Teacher | 1 | teacher1@example.com |
12     And the following "courses" exist:
13       | fullname | shortname | category | groupmode |
14       | Course 1 | C1 | 0 | 1 |
15     And the following "course enrolments" exist:
16       | user | course | role |
17       | teacher1 | C1 | editingteacher |
18       | student1 | C1 | student |
19     And I log in as "admin"
20     And the "multilang" filter is "on"
21     And the "multilang" filter applies to "content and headings"
22     And I navigate to "Grades > Scales" in site administration
23     And I press "Add a new scale"
24     And I set the following fields to these values:
25       | Name  | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> ABCDEF |
26       | Scale | F,E,D,C,B,A                                                                                   |
27     And I press "Save changes"
28     And I press "Add a new scale"
29     And I set the following fields to these values:
30       | Name  | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Letter scale |
31       | Scale | Disappointing, Good, Very good, Excellent                                                           |
32     And I press "Save changes"
33     And I set the following administration settings values:
34       | grade_aggregations_visible | Mean of grades,Weighted mean of grades,Simple weighted mean of grades,Mean of grades (with extra credits),Median of grades,Lowest grade,Highest grade,Mode of grades,Natural |
35     And I log out
36     And I log in as "teacher1"
37     And I am on "Course 1" course homepage
38     And I navigate to "Setup > Gradebook setup" in the course gradebook
39     And I press "Add category"
40     And I set the following fields to these values:
41       | Category name | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Cat 1 |
42       | Aggregation   | Highest grade                                                                                |
43     And I press "Save changes"
44     And I press "Add grade item"
45     And I set the following fields to these values:
46       | Item name | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Item 1 |
47       | Grade category | EN Cat 1                                                                                 |
48     And I press "Save changes"
49     And I press "Add grade item"
50     And I set the following fields to these values:
51       | Item name | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Item 2 |
52       | Grade category | EN Cat 1                                                                                 |
53     And I press "Save changes"
55   Scenario: Being able to change the grade type, scale and maximum grade for a grade category when there are no overridden grades
56     When I click on "Edit settings" "link" in the "EN Cat 1" "table_row"
57     Then I should not see "This category has associated grade items which have been overridden. Therefore some grades have already been awarded"
58     And I set the field "Grade type" to "Scale"
59     And I press "Save changes"
60     And I should see "Scale must be selected"
61     And I set the field "Scale" to "EN ABCDEF"
62     And I press "Save changes"
63     And I should not see "You cannot change the type, as grades already exist for this item"
64     And I click on "Edit settings" "link" in the "EN Cat 1" "table_row"
65     And I should not see "This category has associated grade items which have been overridden. Therefore some grades have already been awarded"
66     And I set the field "Scale" to "EN Letter scale"
67     And I press "Save changes"
68     And I should not see "You cannot change the scale, as grades already exist for this item"
70   Scenario: Attempting to change a category item's grade type when overridden grades already exist
71     Given I navigate to "View > Grader report" in the course gradebook
72     And I turn editing mode on
73     And I give the grade "20.00" to the user "Student 1" for the grade item "EN Cat 1 total"
74     And I press "Save changes"
75     And I navigate to "Setup > Gradebook setup" in the course gradebook
76     When I click on "Edit settings" "link" in the "EN Cat 1" "table_row"
77     Then I should see "This category has associated grade items which have been overridden. Therefore some grades have already been awarded, so the grade type cannot be changed. If you wish to change the maximum grade, you must first choose whether or not to rescale existing grades."
78     And "//div[contains(concat(' ', normalize-space(@class), ' '), 'felement') and contains(text(), 'Value')]" "xpath_element" should exist
80   Scenario: Attempting to change a category item's scale when overridden grades already exist
81     Given I click on "Edit settings" "link" in the "EN Cat 1" "table_row"
82     And I set the field "Grade type" to "Scale"
83     And I set the field "Scale" to "ABCDEF"
84     And I press "Save changes"
85     And I navigate to "View > Grader report" in the course gradebook
86     And I turn editing mode on
87     And I give the grade "C" to the user "Student 1" for the grade item "EN Cat 1 total"
88     And I press "Save changes"
89     And I navigate to "Setup > Gradebook setup" in the course gradebook
90     When I click on "Edit settings" "link" in the "EN Cat 1" "table_row"
91     Then I should see "This category has associated grade items which have been overridden. Therefore some grades have already been awarded, so the grade type and scale cannot be changed."
92     And "//div[contains(concat(' ', normalize-space(@class), ' '), 'felement') and contains(text(), 'ABCDEF')]" "xpath_element" should exist
94   Scenario: Attempting to change a category item's maximum grade when no rescaling option has been chosen
95     Given I navigate to "View > Grader report" in the course gradebook
96     And I turn editing mode on
97     And I give the grade "20.00" to the user "Student 1" for the grade item "EN Cat 1 total"
98     And I press "Save changes"
99     And I navigate to "Setup > Gradebook setup" in the course gradebook
100     And I click on "Edit settings" "link" in the "EN Cat 1" "table_row"
101     And I set the field "Maximum grade" to "50"
102     When I press "Save changes"
103     Then I should see "You must choose whether to rescale existing grades or not."