mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-47006 core_grades: Fix handing of weight to aggregationcoef
Part of MDL-46576.
This commit is contained in:
parent
d6447690bd
commit
351c8e08a9
3 changed files with 12 additions and 7 deletions
|
@ -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') {
|
||||||
$value = $value / 100.0;
|
$aggcoef = $grade_item->get_coefstring();
|
||||||
if (round($grade_item->aggregationcoef2, 4) != round($value, 4)) {
|
if ($aggcoef == 'aggregationcoefextraweightsum') {
|
||||||
$grade_item->weightoverride = 1;
|
$value = $value / 100.0;
|
||||||
|
if (round($grade_item->aggregationcoef2, 4) != round($value, 4)) {
|
||||||
|
$grade_item->weightoverride = 1;
|
||||||
|
}
|
||||||
|
$grade_item->aggregationcoef2 = $value;
|
||||||
|
} else if ($aggcoef == 'aggregationcoefweight') {
|
||||||
|
$grade_item->aggregationcoef = $value;
|
||||||
}
|
}
|
||||||
$grade_item->aggregationcoef2 = $value;
|
|
||||||
} else {
|
} else {
|
||||||
$grade_item->$param = $value;
|
$grade_item->$param = $value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"' : '';
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue