mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-12096 new simple weighted mean aggregation type; merged from MOODLE_18_STABLE
This commit is contained in:
parent
3d5c00b344
commit
1426edacd9
@ -61,6 +61,7 @@ $options = array(GRADE_AGGREGATE_MEAN =>get_string('aggregatemean', '
|
||||
GRADE_AGGREGATE_MAX =>get_string('aggregatemax', 'grades'),
|
||||
GRADE_AGGREGATE_MODE =>get_string('aggregatemode', 'grades'),
|
||||
GRADE_AGGREGATE_WEIGHTED_MEAN =>get_string('aggregateweightedmean', 'grades'),
|
||||
GRADE_AGGREGATE_WEIGHTED_MEAN2 =>get_string('aggregateweightedmean2', 'grades'),
|
||||
GRADE_AGGREGATE_EXTRACREDIT_MEAN=>get_string('aggregateextracreditmean', 'grades'),
|
||||
GRADE_AGGREGATE_SUM =>get_string('aggregatesum', 'grades'));
|
||||
$defaults = array('value'=>GRADE_AGGREGATE_MEAN, 'forced'=>false, 'adv'=>false);
|
||||
|
@ -37,6 +37,7 @@ class edit_category_form extends moodleform {
|
||||
GRADE_AGGREGATE_MAX =>get_string('aggregatemax', 'grades'),
|
||||
GRADE_AGGREGATE_MODE =>get_string('aggregatemode', 'grades'),
|
||||
GRADE_AGGREGATE_WEIGHTED_MEAN =>get_string('aggregateweightedmean', 'grades'),
|
||||
GRADE_AGGREGATE_WEIGHTED_MEAN2 =>get_string('aggregateweightedmean2', 'grades'),
|
||||
GRADE_AGGREGATE_EXTRACREDIT_MEAN=>get_string('aggregateextracreditmean', 'grades'),
|
||||
GRADE_AGGREGATE_SUM =>get_string('aggregatesum', 'grades'));
|
||||
|
||||
|
@ -738,6 +738,7 @@ class grade_structure {
|
||||
case GRADE_AGGREGATE_MEAN:
|
||||
case GRADE_AGGREGATE_MEDIAN:
|
||||
case GRADE_AGGREGATE_WEIGHTED_MEAN:
|
||||
case GRADE_AGGREGATE_WEIGHTED_MEAN2:
|
||||
case GRADE_AGGREGATE_EXTRACREDIT_MEAN:
|
||||
return '<img src="'.$CFG->pixpath.'/i/agg_mean.gif" class="icon itemicon" alt="'.get_string('aggregation', 'grades').'"/>';
|
||||
case GRADE_AGGREGATE_SUM:
|
||||
|
@ -26,6 +26,7 @@ $string['aggregatesubcatshelp'] = 'The aggregation is usually done only with imm
|
||||
$string['aggregatesum'] = 'Sum of grades';
|
||||
$string['aggregatesonly'] = 'Aggregates only';
|
||||
$string['aggregateweightedmean'] = 'Weighted mean of grades';
|
||||
$string['aggregateweightedmean2'] = 'Simple weighted mean of grades';
|
||||
$string['aggregation'] = 'Aggregation';
|
||||
$string['aggregationcoef'] = 'Aggregation coefficient';
|
||||
$string['aggregationcoefextra'] = 'Extra credit';
|
||||
|
@ -39,6 +39,7 @@ define('GRADE_AGGREGATE_MIN', 4);
|
||||
define('GRADE_AGGREGATE_MAX', 6);
|
||||
define('GRADE_AGGREGATE_MODE', 8);
|
||||
define('GRADE_AGGREGATE_WEIGHTED_MEAN', 10);
|
||||
define('GRADE_AGGREGATE_WEIGHTED_MEAN2', 11);
|
||||
define('GRADE_AGGREGATE_EXTRACREDIT_MEAN', 12);
|
||||
define('GRADE_AGGREGATE_SUM', 13);
|
||||
|
||||
|
@ -605,7 +605,7 @@ class grade_category extends grade_object {
|
||||
$agg_grade = reset($modes);
|
||||
break;
|
||||
|
||||
case GRADE_AGGREGATE_WEIGHTED_MEAN: // Weighted average of all existing final grades
|
||||
case GRADE_AGGREGATE_WEIGHTED_MEAN: // Weighted average of all existing final grades, weight specified in coef
|
||||
$weightsum = 0;
|
||||
$sum = 0;
|
||||
foreach($grade_values as $itemid=>$grade_value) {
|
||||
@ -622,6 +622,24 @@ class grade_category extends grade_object {
|
||||
}
|
||||
break;
|
||||
|
||||
case GRADE_AGGREGATE_WEIGHTED_MEAN2: // Weighted average of all existing final grades, weight is the range of grade (ususally grademax)
|
||||
$weightsum = 0;
|
||||
$sum = 0;
|
||||
foreach($grade_values as $itemid=>$grade_value) {
|
||||
$weight = $items[$itemid]->grademax - $items[$itemid]->grademin;
|
||||
if ($weight <= 0) {
|
||||
continue;
|
||||
}
|
||||
$weightsum += $weight;
|
||||
$sum += $weight * $grade_value;
|
||||
}
|
||||
if ($weightsum == 0) {
|
||||
$agg_grade = null;
|
||||
} else {
|
||||
$agg_grade = $sum / $weightsum;
|
||||
}
|
||||
break;
|
||||
|
||||
case GRADE_AGGREGATE_EXTRACREDIT_MEAN: // special average
|
||||
$num = 0;
|
||||
$sum = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user