MDL-11718 fixed altered aggregation of overridden and locked grades + some speedup and corrections

This commit is contained in:
skodak 2007-10-21 13:22:07 +00:00
parent 029735054a
commit 4c8893ed88
2 changed files with 16 additions and 11 deletions

View File

@ -137,11 +137,15 @@ class grade_report_user extends grade_report {
$canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->courseid));
// fetch or create all grades
foreach ($items as $key=>$unused) {
$grade_item =& $items[$key];
$grade_grade = new grade_grade(array('itemid'=>$grade_item->id, 'userid'=>$this->user->id));
if (!$grade_grade = grade_grade::fetch(array('itemid'=>$items[$key]->id, 'userid'=>$this->user->id))) {
$grade_grade = new grade_grade();
$grade_grade->userid = $this->user->id;
$grade_grade->itemid = $items[$key]->id;
}
$grades[$key] = $grade_grade;
$grades[$key]->grade_item =& $grade_item;
$grades[$key]->grade_item =& $items[$key];
}
if ($canviewhidden) {

View File

@ -494,13 +494,9 @@ class grade_grade extends grade_object {
$unknown = array(); // can not find altered
$altered = array(); // altered grades
foreach($grade_items as $key=>$unused) {
$grade_item =& $grade_items[$key]; // reference for improved caching inside grade_item
$dependson[$grade_items[$key]->id] = $grade_items[$key]->depends_on();
}
$hiddenfound = false;
foreach($grade_grades as $grade_grade) {
foreach($grade_grades as $itemid=>$unused) {
$grade_grade =& $grade_grades[$itemid];
if ($grade_grade->is_excluded()) {
//nothing to do, aggregation is ok
} else if ($grade_grade->is_hidden()) {
@ -509,8 +505,13 @@ class grade_grade extends grade_object {
if (!is_null($grade_grade->finalgrade)) {
$altered[$grade_grade->itemid] = null;
}
} else if (!empty($dependson[$grade_grade->itemid])) {
$todo[] = $grade_grade->itemid;
} else if ($grade_grade->is_locked() or $grade_grade->is_overridden()) {
// no need to recalculate locked or overridden grades
} else {
$dependson[$grade_grade->itemid] = $grade_items[$grade_grade->itemid]->depends_on();
if (!empty($dependson[$grade_grade->itemid])) {
$todo[] = $grade_grade->itemid;
}
}
}
if (!$hiddenfound) {