MDL-52275 core: fixed grade-to-pass being overwritten

Thanks goes to W.J. Roes for the patch.
This commit is contained in:
Mark Nelson 2015-12-23 14:17:25 +08:00
parent ea3ebbf20e
commit 5d0aa9dcfe

View File

@ -187,15 +187,14 @@ if (!empty($add)) {
if ($items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$data->modulename,
'iteminstance'=>$data->instance, 'courseid'=>$course->id))) {
// add existing outcomes
// Add existing outcomes.
foreach ($items as $item) {
if (!empty($item->gradepass)) {
if (!empty($item->outcomeid)) {
$data->{'outcome_' . $item->outcomeid} = 1;
} else if (!empty($item->gradepass)) {
$decimalpoints = $item->get_decimals();
$data->gradepass = format_float($item->gradepass, $decimalpoints);
}
if (!empty($item->outcomeid)) {
$data->{'outcome_'.$item->outcomeid} = 1;
}
}
// set category if present