mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 14:03:52 +01:00
MDL-11718 fixed altered aggregation of overridden and locked grades + some speedup and corrections
This commit is contained in:
parent
029735054a
commit
4c8893ed88
@ -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) {
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user