$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';
}
} 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);