Skip to content

Commit

Permalink
MDL-18993 implemented frull support for droplow and keephigh in sum a…
Browse files Browse the repository at this point in the history
…ggregation type
  • Loading branch information
skodak committed Apr 29, 2009
1 parent 85db95e commit 59080ee
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/grade/grade_category.php
Expand Up @@ -720,22 +720,25 @@ private function auto_update_max($items) {
return;
}

$max = 0;

//find max grade
//find max grade possible
$maxes = array();
foreach ($items as $item) {
if ($item->aggregationcoef > 0) {
// extra credit from this activity - does not affect total
continue;
}
if ($item->gradetype == GRADE_TYPE_VALUE) {
$max += $item->grademax;
$maxes[] = $item->grademax;
} else if ($item->gradetype == GRADE_TYPE_SCALE) {
$max += $item->grademax; // 0 = nograde, 1 = first scale item, 2 = second scale item
$maxes[] = $item->grademax; // 0 = nograde, 1 = first scale item, 2 = second scale item
}
}
// apply droplow and keephigh
$this->apply_limit_rules($maxes);
$max = array_sum($maxes);

if ($this->grade_item->grademax != $max or $this->grade_item->grademin != 0 or $this->grade_item->gradetype != GRADE_TYPE_VALUE){
// update db if anything changed
if ($this->grade_item->grademax != $max or $this->grade_item->grademin != 0 or $this->grade_item->gradetype != GRADE_TYPE_VALUE) {
$this->grade_item->grademax = $max;
$this->grade_item->grademin = 0;
$this->grade_item->gradetype = GRADE_TYPE_VALUE;
Expand Down Expand Up @@ -800,6 +803,10 @@ public function apply_limit_rules(&$grade_values) {
arsort($grade_values, SORT_NUMERIC);
if (!empty($this->droplow)) {
for ($i = 0; $i < $this->droplow; $i++) {
if (empty($grade_values)) {
// nothing to remove
return;
}
array_pop($grade_values);
}
} elseif (!empty($this->keephigh)) {
Expand Down

0 comments on commit 59080ee

Please sign in to comment.