MDL-47110 core_grades: Normalisation of grade weights.
[moodle.git] / grade / tests / behat / grade_natural_normalisation.feature
CommitLineData
519429b2
AG
1@core @core_grades
2Feature: We can use natural aggregation and weights will be normalised to a total of one hundred
3 In order to override weights
4 As a teacher
5 I need to add assessments to the gradebook.
6
7 Background:
8 Given the following "courses" exist:
9 | fullname | shortname | category | groupmode |
10 | Course 1 | C1 | 0 | 1 |
11 And the following "users" exist:
12 | username | firstname | lastname | email | idnumber |
13 | teacher1 | Teacher | 1 | teacher1@asd.com | t1 |
14 | student1 | Student | 1 | student1@asd.com | s1 |
15 And the following "course enrolments" exist:
16 | user | course | role |
17 | teacher1 | C1 | editingteacher |
18 | student1 | C1 | student |
19 And the following "grade categories" exist:
20 | fullname | course |
21 | Sub category 1 | C1 |
22 And the following "activities" exist:
23 | activity | course | idnumber | name | intro | grade |
24 | assign | C1 | a1 | Test assignment one | Submit something! | 300 |
25 | assign | C1 | a2 | Test assignment two | Submit something! | 100 |
26 | assign | C1 | a3 | Test assignment three | Submit something! | 150 |
27 | assign | C1 | a4 | Test assignment four | Submit nothing! | 150 |
28 And the following "activities" exist:
29 | activity | course | idnumber | name | intro | gradecategory | grade |
30 | assign | C1 | a5 | Test assignment five | Submit something! | Sub category 1 | 20 |
31 | assign | C1 | a6 | Test assignment six | Submit something! | Sub category 1 | 10 |
32 | assign | C1 | a7 | Test assignment seven | Submit nothing! | Sub category 1 | 15 |
33 And I log in as "teacher1"
34 And I follow "Course 1"
35 And I follow "Grades"
36 And I set the field "Grade report" to "Set up grades layout"
37 And I follow "Edit Course 1"
38 And I set the field "Aggregation" to "Natural"
39 And I press "Save changes"
40 And I follow "Edit Sub category 1"
41 And I set the field "Aggregation" to "Natural"
42 And I press "Save changes"
43
44 @javascript
45 Scenario: Setting all weights in a category to less than one hundred is normalised.
46
47 Given I set the field "Override weight of Test assignment five" to "1"
48 And I set the field "Override weight of Test assignment six" to "1"
49 And I set the field "Override weight of Test assignment seven" to "1"
50 And I set the field "Weight of Test assignment five" to "1"
51 And I set the field "Weight of Test assignment six" to "1"
52 And I set the field "Weight of Test assignment seven" to "2"
53 And I press "Save changes"
54
55 Then the field "Weight of Test assignment five" matches value "25.0"
56 And the field "Weight of Test assignment six" matches value "25.0"
57 And the field "Weight of Test assignment seven" matches value "50.0"
58
59 @javascript
60 Scenario: Set one of the grade item weights to a figure over one hundred.
61
62 Given I set the field "Override weight of Test assignment five" to "1"
63 And I set the field "Weight of Test assignment five" to "120"
64 And I press "Save changes"
65
66 Then the field "Weight of Test assignment five" matches value "68.355"
67 And the field "Weight of Test assignment six" matches value "12.658"
68 And the field "Weight of Test assignment seven" matches value "18.987"
69
70 @javascript
71 Scenario: Grade items weights are noramlised when all grade item weights are overridden. Extra credit is set to zero.
72
73 Given I follow "Edit assign Test assignment seven"
74 And I set the field "Extra credit" to "1"
75 And I press "Save changes"
76 And I set the field "Override weight of Test assignment five" to "1"
77 And I set the field "Override weight of Test assignment six" to "1"
78 And I set the field "Weight of Test assignment five" to "60"
79 And I set the field "Weight of Test assignment six" to "50"
80 And I press "Save changes"
81
82 Then the field "Weight of Test assignment five" matches value "54.545"
83 And the field "Weight of Test assignment six" matches value "45.455"
84 And the field "Weight of Test assignment seven" matches value "0.0"
85
86 @javascript
87 Scenario: The extra credit grade item weight is overridden to a figure over one hundred and then
88 the grade item is set to normal.
89
90 # And I follow "Reset weights of Sub category 1"
91 Given I follow "Edit assign Test assignment seven"
92 And I set the field "Extra credit" to "1"
93 And I press "Save changes"
94 And I set the field "Override weight of Test assignment seven" to "1"
95 And I set the field "Weight of Test assignment seven" to "105"
96 And I press "Save changes"
97 And I follow "Edit assign Test assignment seven"
98 And I set the field "Extra credit" to "0"
99 And I press "Save changes"
100
101 Then the field "Weight of Test assignment five" matches value "32.52"
102 And the field "Weight of Test assignment six" matches value "16.26"
103 And the field "Weight of Test assignment seven" matches value "51.22"
104
105 @javascript
106 Scenario: Two out of three grade items weights are overridden and one is not.
107 The overridden grade item weights total over one hundred.
108
109 Given I set the field "Override weight of Test assignment six" to "1"
110 And I set the field "Override weight of Test assignment seven" to "1"
111 And I set the field "Weight of Test assignment six" to "55"
112 And I set the field "Weight of Test assignment seven" to "65"
113 And I press "Save changes"
114
115 Then the field "Weight of Test assignment five" matches value "0.0"
116 And the field "Weight of Test assignment six" matches value "45.833"
117 And the field "Weight of Test assignment seven" matches value "54.167"