MDL-47006 core_grades: Fix handing of weight to aggregationcoef

Part of MDL-46576.
This commit is contained in:
John Okely 2014-09-22 11:07:13 +08:00 committed by Adrian Greeve
parent d6447690bd
commit 351c8e08a9
3 changed files with 12 additions and 7 deletions

View file

@ -259,7 +259,7 @@ if ($data = data_submitted() and confirm_sesskey()) {
$recreatetree = true; $recreatetree = true;
// Grade item text inputs // Grade item text inputs
} elseif (preg_match('/^(grademax|aggregationcoef|weight|multfactor|plusfactor)_([0-9]+)$/', $key, $matches)) { } elseif (preg_match('/^(grademax|weight|multfactor|plusfactor)_([0-9]+)$/', $key, $matches)) {
$param = $matches[1]; $param = $matches[1];
$aid = $matches[2]; $aid = $matches[2];
@ -275,11 +275,16 @@ if ($data = data_submitted() and confirm_sesskey()) {
// Convert weight to aggregation coef2. // Convert weight to aggregation coef2.
if ($param === 'weight') { if ($param === 'weight') {
$aggcoef = $grade_item->get_coefstring();
if ($aggcoef == 'aggregationcoefextraweightsum') {
$value = $value / 100.0; $value = $value / 100.0;
if (round($grade_item->aggregationcoef2, 4) != round($value, 4)) { if (round($grade_item->aggregationcoef2, 4) != round($value, 4)) {
$grade_item->weightoverride = 1; $grade_item->weightoverride = 1;
} }
$grade_item->aggregationcoef2 = $value; $grade_item->aggregationcoef2 = $value;
} else if ($aggcoef == 'aggregationcoefweight') {
$grade_item->aggregationcoef = $value;
}
} else { } else {
$grade_item->$param = $value; $grade_item->$param = $value;
} }

View file

@ -382,7 +382,7 @@ class grade_edit_tree {
($aggcoef == 'aggregationcoefextraweight' && $type == 'extra')) { ($aggcoef == 'aggregationcoefextraweight' && $type == 'extra')) {
return '<label class="accesshide" for="weight_'.$item->id.'">'. return '<label class="accesshide" for="weight_'.$item->id.'">'.
get_string('extracreditvalue', 'grades', $item->itemname).'</label>'. get_string('extracreditvalue', 'grades', $item->itemname).'</label>'.
'<input type="text" size="6" id="weight_'.$item->id.'" name="aggregationcoef_'.$item->id.'" '<input type="text" size="6" id="weight_'.$item->id.'" name="weight_'.$item->id.'"
value="'.grade_edit_tree::format_number($item->aggregationcoef).'" />'; value="'.grade_edit_tree::format_number($item->aggregationcoef).'" />';
} elseif (($aggcoef == 'aggregationcoefextrasum' || $aggcoef == 'aggregationcoefextraweightsum') && $type == 'extra') { } elseif (($aggcoef == 'aggregationcoefextrasum' || $aggcoef == 'aggregationcoefextraweightsum') && $type == 'extra') {
$checked = ($item->aggregationcoef > 0) ? 'checked="checked"' : ''; $checked = ($item->aggregationcoef > 0) ? 'checked="checked"' : '';

View file

@ -259,7 +259,7 @@ Feature: We can use calculated grade totals
| Exclude empty grades | 0 | | Exclude empty grades | 0 |
And I set the following settings for grade item "Test assignment six": And I set the following settings for grade item "Test assignment six":
| Weight adjusted | 1 | | Weight adjusted | 1 |
| aggregationcoef2 | 0.5 | | aggregationcoef2 | 50 |
And I set the following settings for grade item "Test assignment three": And I set the following settings for grade item "Test assignment three":
| Extra credit | 1 | | Extra credit | 1 |
And I turn editing mode off And I turn editing mode off