Skip to content

Commit

Permalink
MDL-47704 Grades: Fix for set_usedinaggregation
Browse files Browse the repository at this point in the history
Used in aggregation was not resetting previously set values
when recalculating an aggregation. This meant that items no longer
in the aggregation, were displayed with stale weights in the user report.
  • Loading branch information
Damyon Wiese committed Oct 16, 2014
1 parent ec72585 commit ba0d277
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/grade/grade_category.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,24 @@ private function aggregate_grades($userid,
private function set_usedinaggregation($userid, $usedweights, $novalue, $dropped, $extracredit) {
global $DB;

// First set them all to weight null and status = 'unknown'.
if ($allitems = grade_item::fetch_all(array('categoryid'=>$this->id))) {
list($itemsql, $itemlist) = $DB->get_in_or_equal(array_keys($allitems), SQL_PARAMS_NAMED, 'g');

$itemlist['userid'] = $userid;

$DB->set_field_select('grade_grades',
'aggregationstatus',
'unknown',
"itemid $itemsql AND userid = :userid",
$itemlist);
$DB->set_field_select('grade_grades',
'aggregationweight',
0,
"itemid $itemsql AND userid = :userid",
$itemlist);
}

// Included.
if (!empty($usedweights)) {
// The usedweights items are updated individually to record the weights.
Expand Down

0 comments on commit ba0d277

Please sign in to comment.