MDL-9137 readding GRADE_AGGREGATE_MODE

This commit is contained in:
skodak
2007-06-18 15:29:20 +00:00
parent b8ff92b66b
commit 95affb8a35
2 changed files with 12 additions and 3 deletions
+11 -3
View File
@@ -448,13 +448,21 @@ class grade_category extends grade_object {
$gradevalue = array_pop($grades);
break;
case GRADE_AGGREGATE_MEAN_ALL: // Arithmetic average of all grade items including event NULLs; NULL grade caunted as minimum
$num = count($dependson); // you can calculate sum from this one if you multiply it with count($this->dependson();-)
case GRADE_AGGREGATE_MEAN_ALL: // Arithmetic average of all grade items including even NULLs; NULL grade caunted as minimum
$num = count($dependson); // you can calculate sum from this one if you multiply it with count($this->dependson() ;-)
$sum = array_sum($grades);
$gradevalue = $sum / $num;
break;
case GRADE_AGGREGATE_MEAN_GRADED: // Arithmetic average of all final grades, unfinished not calculated
case GRADE_AGGREGATE_MODE: // the most common value, the highest one if multimode
$freq = array_count_values($grades);
arsort($freq); // sort by frequency keeping keys
$top = reset($freq); // highest frequency count
$modes = array_keys($freq, $top); // search for all modes (have the same highest count)
rsort($modes, SORT_NUMERIC); // get highes mode
$gradevalue = reset($modes);
case GRADE_AGGREGATE_MEAN_GRADED: // Arithmetic average of all final grades, unfinished are not calculated
$num = count($grades);
$sum = array_sum($grades);
$gradevalue = $sum / $num;
+1
View File
@@ -37,6 +37,7 @@ define('GRADE_AGGREGATE_MEDIAN', 1);
define('GRADE_AGGREGATE_MEAN_GRADED', 2);
define('GRADE_AGGREGATE_MIN', 3);
define('GRADE_AGGREGATE_MAX', 4);
define('GRADE_AGGREGATE_MODE', 5);
define('GRADE_CHILDTYPE_ITEM', 0);
define('GRADE_CHILDTYPE_CAT', 1);