]> git.mjollnir.org Git - moodle.git/commitdiff
improved aggregation - items without value (none + text) are not aggregated; faster...
authorskodak <skodak>
Fri, 3 Aug 2007 08:41:20 +0000 (08:41 +0000)
committerskodak <skodak>
Fri, 3 Aug 2007 08:41:20 +0000 (08:41 +0000)
lang/en_utf8/grades.php
lib/grade/grade_item.php

index 6a97320fa4609925bd4c259fa7b311e5ee187e0d..af9ef0c85c94e6fcd2b603e4bffb414c03dd12b5 100644 (file)
@@ -19,7 +19,7 @@ $string['aggregateminall'] = 'Smallest grade of all grades';
 $string['aggregatemingraded'] = 'Smallest grade of non-empty grades';
 $string['aggregatemaxall'] = 'Highest grade of all grades';
 $string['aggregatemaxgraded'] = 'Highest grade of non-empty grades';
-$string['aggregatemodeall'] = 'Mode of non-empty grades of all grades';
+$string['aggregatemodeall'] = 'Mode of all grades';
 $string['aggregatemodegraded'] = 'Mode of non-empty grades';
 $string['aggregateweightedmeanall'] = 'Weighted mean of all grades';
 $string['aggregateweightedmeangraded'] = 'Weighted mean of non-empty grades';
index 106fb352f33d3a54102c4b51fd16c841bdf70594..614e0adb2925d1ddca0ccc1ead85a63723735db9 100644 (file)
@@ -1125,16 +1125,23 @@ class grade_item extends grade_object {
             }
 
         } else if ($grade_category = $this->load_item_category()) {
+            //only items with numeric or scale values can be aggregated
+            if ($this->gradetype != GRADE_TYPE_VALUE and $this->gradetype != GRADE_TYPE_SCALE) {
+                return array();
+            }
+
             $sql = "SELECT gi.id
                       FROM {$CFG->prefix}grade_items gi
-                     WHERE gi.categoryid ={$grade_category->id}
+                     WHERE gi.categoryid = {$grade_category->id}
+                           AND (gi.gradetype = ".GRADE_TYPE_VALUE." OR gi.gradetype = ".GRADE_TYPE_SCALE.")  
 
                     UNION
 
                     SELECT gi.id
                       FROM {$CFG->prefix}grade_items gi, {$CFG->prefix}grade_categories gc
                      WHERE (gi.itemtype = 'category' OR gi.itemtype = 'course') AND gi.iteminstance=gc.id
-                           AND gc.parent = {$grade_category->id}";
+                           AND gc.parent = {$grade_category->id}
+                           AND (gi.gradetype = ".GRADE_TYPE_VALUE." OR gi.gradetype = ".GRADE_TYPE_SCALE.")";  
 
             if ($children = get_records_sql($sql)) {
                 return array_keys($children);