MDL-47064 Grades: Make the contribution to total column work
authorDamyon Wiese <damyon@moodle.com>
Tue, 23 Sep 2014 07:38:54 +0000 (15:38 +0800)
committerAdrian Greeve <adrian@moodle.com>
Fri, 3 Oct 2014 05:55:23 +0000 (13:55 +0800)
Part of: MDL-46576

grade/report/user/lib.php
grade/tests/behat/grade_aggregation.feature
grade/tests/behat/grade_calculated_weights.feature [deleted file]

index cc0bc28..7a14694 100644 (file)
@@ -350,7 +350,7 @@ class grade_report_user extends grade_report {
         return true;
     }
 
-    private function fill_table_recursive(&$element) {
+    private function fill_table_recursive(&$element, &$aggregationhints = array()) {
         global $DB, $CFG;
 
         $type = $element['type'];
@@ -620,52 +620,16 @@ class grade_report_user extends grade_report {
                     $data['contributiontocoursetotal']['class'] = $class;
                     $data['contributiontocoursetotal']['content'] = '-';
                     $data['contributiontocoursetotal']['headers'] = "$header_cat $header_row contributiontocoursetotal";
-                    /**
-                    if (($type != 'categoryitem') && ($type != 'courseitem')) {
-                        $weight = $grade_grade->get_aggregation_weight($grade_object);
-                        if (is_numeric($weight)) {
-                            $me = $grade_grade->grade_item;
-                            $percentoftotal = $hint;
-                            $validpercent = true;
-                            $parent = null;
-                            while ((!$me->is_course_item()) && ($validpercent)) {
-                                // The parent of a category grade item is itself (yes - how odd).
-                                // This means we need to use the parent of the grade_category if it exists.
-                                if (!empty($parent)) {
-                                    $parent = $parent->get_parent_category();
-                                } else {
-                                    $parent = $me->get_parent_category();
-                                }
-                                $parentgradeitem = $parent->load_grade_item();
-                                $parentgradegrade = grade_grade::fetch(array('itemid'=>$parentgradeitem->id, 'userid'=>$this->user->id));
-                                if (!$parentgradegrade) {
-                                    $validpercent = false;
-                                    continue;
-                                }
-                                $hint = $parentgradegrade->get_aggregation_hint($parentgradeitem);
-                                $me = $parentgradeitem;
-                                if (!is_numeric($hint)) {
-                                    // It's OK for the course grade item to not have a usedinaggregation value.
-                                    $validpercent = $parentgradeitem->is_course_item();
-                                    continue;
-                                }
-                                $thispercent = $hint;
-                                $percentoftotal *= $thispercent;
-                            }
-                            if ($validpercent) {
-                                $grademin = $grade_grade->grade_item->grademin;
-                                $grademax = $grade_grade->grade_item->grademax;
-                                $finalgrade = $grade_grade->finalgrade;
-                                $contribution = format_float(((($finalgrade-$grademin)/($grademax-$grademin)*($percentoftotal * 100.0))),2);
-                                $data['contributiontocoursetotal']['content'] = $contribution;
-                            }
-                        }
-                    } **/
-                    $hint = $grade_grade->get_aggregation_hint($grade_object);
-                    if ($hint && is_numeric($hint)) {
-                        $data['contributiontocoursetotal']['content'] = $hint;
-                        $data['contributiontocoursetotal']['content'] .= ' ' . $grade_grade->finalgrade . ' ' . $grade_grade->rawgrademin . ' ' . $grade_grade->rawgrademax;
+
+                    $hint['grademax'] = $grade_grade->grade_item->grademax;
+                    $hint['grademin'] = $grade_grade->grade_item->grademin;
+                    $hint['grade'] = $gradeval;
+                    $parent = $grade_object->load_parent_category();
+                    if ($grade_object->is_category_item()) {
+                        $parent = $parent->load_parent_category();
                     }
+                    $hint['parent'] = $parent->load_grade_item()->id;
+                    $aggregationhints[$grade_grade->itemid] = $hint;
                 }
             }
         }
@@ -692,7 +656,57 @@ class grade_report_user extends grade_report {
         /// Recursively iterate through all child elements
         if (isset($element['children'])) {
             foreach ($element['children'] as $key=>$child) {
-                $this->fill_table_recursive($element['children'][$key]);
+                $this->fill_table_recursive($element['children'][$key], $aggregationhints);
+            }
+        }
+
+        if ($this->showcontributiontocoursetotal && ($type == 'category' && $depth == 1)) {
+            // We should have collected all the hints by now - walk the tree again and build the contributions column.
+
+            $this->fill_contributions_column($element, $aggregationhints);
+        }
+    }
+
+    public function fill_contributions_column($element, $aggregationhints) {
+
+        /// Recursively iterate through all child elements
+        if (isset($element['children'])) {
+            foreach ($element['children'] as $key=>$child) {
+                $this->fill_contributions_column($element['children'][$key], $aggregationhints);
+            }
+        } else if ($element['type'] == 'item') {
+            $grade_object = $element['object'];
+            $itemid = $grade_object->id;
+            if (isset($aggregationhints[$itemid])) {
+
+                $graderange = $aggregationhints[$itemid]['grademax'] - $aggregationhints[$itemid]['grademin'];
+                $gradeval = ($aggregationhints[$itemid]['grade'] - $aggregationhints[$itemid]['grademin']) / $graderange;
+
+                $parent = $aggregationhints[$itemid]['parent'];
+                do {
+                    if (!is_null($aggregationhints[$itemid]['weight'])) {
+                        $gradeval *= $aggregationhints[$itemid]['weight'];
+                    }
+
+                    if (isset($aggregationhints[$itemid]['parent']) &&
+                        $aggregationhints[$itemid]['parent'] != $itemid) {
+                        $parent = $aggregationhints[$itemid]['parent'];
+                        $itemid = $parent;
+                    } else {
+                        $parent = false;
+                    }
+                } while ($parent);
+                $gradeval *= $aggregationhints[$itemid]['grademax'];
+
+                $header_row = "row_{$grade_object->id}_{$this->user->id}";
+                foreach ($this->tabledata as $key => $row) {
+                    if (isset($row['itemname']) &&
+                        ($row['itemname']['id'] == $header_row)) {
+                        $decimals = $grade_object->get_decimals();
+                        $this->tabledata[$key]['contributiontocoursetotal']['content'] = format_float($gradeval, $decimals, true);
+                        break;
+                    }
+                }
             }
         }
     }
index 33a18c8..22e248d 100644 (file)
@@ -265,14 +265,40 @@ Feature: We can use calculated grade totals
     And I turn editing mode off
     Then I should see "152.68 (24.43 %)" in the ".course" "css_element"
     And I navigate to "Course grade settings" node in "Grade administration > Settings"
-    And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
+    And I set the field "report_overview_showtotalsifcontainhidden" to "Show totals excluding hidden items"
+    And I set the field "report_user_showtotalsifcontainhidden" to "Show totals excluding hidden items"
+    And I set the field "Show contribution to course total" to "Show"
+    And I set the field "Show weightings" to "Show"
     And I press "Save changes"
+    And I set the field "Grade report" to "User report"
+    And the following should exist in the "user-grade" table:
+      | Grade item | Calculated weight | Grade | Range |
+      | Test assignment five | 28.57 % | 10.00 (50.00 %) | 0–20 |
+      | Test assignment six | 50.00 % | 5.00 (50.00 %) | 0–10 |
+      | Test assignment seven | 21.43 % | - | 0–15 |
+      | Test assignment eight | 66.67 % | 10.00 (50.00 %) | 0–20 |
+      | Test assignment nine | 33.33 % | 5.00 (50.00 %) | 0–10 |
+      | Test assignment ten | -( Empty ) | - | 0–15 |
+      | Test assignment one | 48.00 % | 60.00 (20.00 %) | 0–300 |
+      | Test assignment two | 16.00 % | 20.00 (20.00 %) | 0–100 |
+      | Test assignment three | 24.00 %( Extra credit ) | 40.00 (26.67 %) | 0–150 |
+      | Test assignment four | 24.00 % | - | 0–150 |
     And I log out
     And I log in as "student1"
     And I follow "Course 1"
     And I follow "Grades"
     And I set the field "Grade report" to "Overview report"
     And I should see "113.75 (23.45 %)" in the "overview-grade" "table"
+    And I set the field "Grade report" to "User report"
+    And the following should exist in the "user-grade" table:
+      | Grade item | Calculated weight | Grade | Range |
+      | Test assignment six | 70.00 % | 5.00 (50.00 %) | 0–10 |
+      | Test assignment seven | 30.00 % | - | 0–15 |
+      | Test assignment nine | 100.00 % | 5.00 (50.00 %) | 0–10 |
+      | Test assignment ten | -( Empty ) | - | 0–15 |
+      | Test assignment one | 61.86 % | 60.00 (20.00 %) | 0–300 |
+      | Test assignment three | 30.93 %( Extra credit ) | 40.00 (26.67 %) | 0–150 |
+      | Test assignment four | 30.93 % | - | 0–150 |
 
   @javascript
   Scenario: Natural aggregation with drop lowest
diff --git a/grade/tests/behat/grade_calculated_weights.feature b/grade/tests/behat/grade_calculated_weights.feature
deleted file mode 100644 (file)
index 5cd1ebc..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-@core @core_grades
-Feature: We can understand the gradebook user report
-  In order to understand the gradebook user report
-  As an teacher
-  I need to see the calculated weights for each type of aggregation
-
-  Background:
-    Given the following "courses" exist:
-      | fullname | shortname | category | groupmode |
-      | Course 1 | C1 | 0 | 1 |
-    And the following "users" exist:
-      | username | firstname | lastname | email | idnumber |
-      | teacher1 | Teacher | 1 | teacher1@asd.com | t1 |
-      | student1 | Student | 1 | student1@asd.com | s1 |
-    And the following "course enrolments" exist:
-      | user | course | role |
-      | teacher1 | C1 | editingteacher |
-      | student1 | C1 | student |
-    And the following "activities" exist:
-      | activity | course | idnumber | name | intro |
-      | assign | C1 | a1 | Test assignment one | Submit something! |
-      | assign | C1 | a2 | Test assignment two | Submit something! |
-      | assign | C1 | a3 | Test assignment three | Submit something! |
-      | assign | C1 | a4 | Test assignment four | Submit something! |
-      | assign | C1 | a5 | Test assignment five | Submit something! |
-      | assign | C1 | a6 | Test assignment six | Submit something! |
-    And I log in as "admin"
-    And I set the following administration settings values:
-      | 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 |
-    And I log out
-    And I log in as "teacher1"
-    And I follow "Course 1"
-    And I follow "Grades"
-    And I turn editing mode on
-    And I give the grade "60.00" to the user "Student 1" for the grade item "Test assignment one"
-    And I give the grade "20.00" to the user "Student 1" for the grade item "Test assignment two"
-    And I give the grade "40.00" to the user "Student 1" for the grade item "Test assignment three"
-    And I give the grade "10.00" to the user "Student 1" for the grade item "Test assignment four"
-    And I give the grade "70.00" to the user "Student 1" for the grade item "Test assignment five"
-    And I give the grade "30.00" to the user "Student 1" for the grade item "Test assignment six"
-    And I press "Save changes"
-    And I navigate to "Course grade settings" node in "Grade administration > Settings"
-    And I set the field "Show weightings" to "Show"
-    And I set the field "Show contribution to course total" to "Show"
-    And I press "Save changes"
-    And I set the field "Grade report" to "Set up grades layout"
-    And I press "Add category"
-    And I set the field "Category name" to "Sub category"
-    And I press "Save changes"
-    And I click on "Move" "link" in the "Test assignment six" "table_row"
-    # This xpath finds the forth last row in the table.
-    And I click on "Move to here" "link" in the "//tbody//tr[position()=last()-3]" "xpath_element"
-    And I click on "Move" "link" in the "Test assignment five" "table_row"
-    And I click on "Move to here" "link" in the "//tbody//tr[position()=last()-3]" "xpath_element"
-    And I click on "Move" "link" in the "Test assignment four" "table_row"
-    And I click on "Move to here" "link" in the "//tbody//tr[position()=last()-3]" "xpath_element"
-
-  @javascript
-  Scenario: Mean of grades aggregation
-    And I set the following settings for grade item "Course 1":
-      | Aggregation | Mean of grades |
-    And I set the field "Grade report" to "User report"
-    And I set the field "Select all or one user" to "Student 1"
-
-    # Check the values in the weights column.
-    Then "//td[contains(@headers,'weight') and contains(., '25.00 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '25.00 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '25.00 %')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-    # Check the values in the contributions column.
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '25.00 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '25.00 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '25.00 %')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '8.33 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '8.33 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '8.33 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-
-  @javascript
-  Scenario: Weighted mean of grades aggregation
-    And I set the following settings for grade item "Course 1":
-      | Aggregation | Weighted mean of grades |
-    And I set the following settings for grade item "Test assignment one":
-      | Item weight | 2.0 |
-    And I set the following settings for grade item "Test assignment two":
-      | Item weight | 1.0 |
-    And I set the following settings for grade item "Test assignment three":
-      | Item weight | 1.0 |
-    And I set the following settings for grade item "Sub category":
-      | Item weight | 1.0 |
-    And I set the field "Grade report" to "User report"
-    And I set the field "Select all or one user" to "Student 1"
-
-    # Check the values in the weights column.
-    Then "//td[contains(@headers,'weight') and contains(., '40.00 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '20.00 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '20.00 %')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-    # Check the values in the contributions column.
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '40.00 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '20.00 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '20.00 %')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '6.67 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '6.67 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '6.67 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-
-  @javascript
-  Scenario: Simple weighted mean of grades aggregation
-    And I set the following settings for grade item "Course 1":
-      | Aggregation | Simple weighted mean of grades |
-    And I set the following settings for grade item "Test assignment three":
-      | Extra credit | 1 |
-    And I set the field "Grade report" to "User report"
-    And I set the field "Select all or one user" to "Student 1"
-
-    # Check the values in the weights column.
-    Then "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., 'Extra credit')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-    # Check the values in the contributions column.
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '-')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '11.11 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '11.11 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '11.11 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-
-  @javascript
-  Scenario: Mean of grades (with extra credits) aggregation
-    And I set the following settings for grade item "Course 1":
-      | Aggregation | Mean of grades (with extra credits) |
-    And I set the following settings for grade item "Test assignment three":
-      | Extra credit weight | 1.0 |
-    And I set the field "Grade report" to "User report"
-    And I set the field "Select all or one user" to "Student 1"
-
-    # Check the values in the weights column.
-    Then "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., 'Extra credit')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-    # Check the values in the contributions column.
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '-')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '11.11 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '11.11 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '11.11 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-
-  @javascript
-  Scenario: Median of grades aggregation
-    And I set the following settings for grade item "Course 1":
-      | Aggregation | Median of grades |
-    And I set the field "Grade report" to "User report"
-    And I set the field "Select all or one user" to "Student 1"
-
-    # Check the values in the weights column.
-    Then "//td[contains(@headers,'weight') and contains(., '25.00 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '25.00 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '25.00 %')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-    # Check the values in the contributions column.
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '25.00 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '25.00 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '25.00 %')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '8.33 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '8.33 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '8.33 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-
-  @javascript
-  Scenario: Lowest grade aggregation
-    And I set the following settings for grade item "Course 1":
-      | Aggregation | Lowest grade |
-    And I set the field "Grade report" to "User report"
-    And I set the field "Select all or one user" to "Student 1"
-
-    # Check the values in the weights column.
-    Then "//td[contains(@headers,'weight') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '100.00 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-    # Check the values in the contributions column.
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '100.00 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-
-
-  @javascript
-  Scenario: Highest grade aggregation
-    And I set the following settings for grade item "Course 1":
-      | Aggregation | Highest grade |
-    And I set the field "Grade report" to "User report"
-    And I set the field "Select all or one user" to "Student 1"
-
-    # Check the values in the weights column.
-    Then "//td[contains(@headers,'weight') and contains(., '100.00 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-    # Check the values in the contributions column.
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '100.00 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-
-  @javascript
-  Scenario: Mode of grades aggregation
-    And I set the following settings for grade item "Course 1":
-      | Aggregation | Mode of grades |
-    And I set the field "Grade report" to "User report"
-    And I set the field "Select all or one user" to "Student 1"
-
-    # Check the values in the weights column.
-    Then "//td[contains(@headers,'weight') and contains(., '100.00 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-    # Check the values in the contributions column.
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '100.00 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '0.00 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-
-  @javascript
-  Scenario: Natural aggregation
-    And I set the following settings for grade item "Course 1":
-      | Aggregation | Natural |
-    And I set the following settings for grade item "Test assignment three":
-      | Extra credit | 1 |
-    And I set the field "Grade report" to "User report"
-    And I set the field "Select all or one user" to "Student 1"
-
-    # Check the values in the weights column.
-    Then "//td[contains(@headers,'weight') and contains(., '38.30 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '12.77 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., 'Extra credit')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'weight') and contains(., '33.33 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"
-    # Check the values in the contributions column.
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '38.30 %')]" "xpath_element" should exist in the "Test assignment one" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '12.77 %')]" "xpath_element" should exist in the "Test assignment two" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '-')]" "xpath_element" should exist in the "Test assignment three" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '7.80 %')]" "xpath_element" should exist in the "Test assignment four" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '7.80 %')]" "xpath_element" should exist in the "Test assignment five" "table_row"
-    And "//td[contains(@headers,'contributiontocoursetotal') and contains(., '7.80 %')]" "xpath_element" should exist in the "Test assignment six" "table_row"