MDL-9137 readding GRADE_AGGREGATE_MODE
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user