mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-51498 core_grades: Prevent unnecessary grade record fetching
All of these changes make use of already fetched grade data. Without these changes, the gradebook regrade process does not scale well with very large courses because it fetches many grade records, one at a time.
This commit is contained in:
parent
d230899db8
commit
5f6e2fc9d3
@ -466,7 +466,7 @@ class grade_category extends grade_object {
|
||||
WHERE id $usql";
|
||||
$items = $DB->get_records_sql($sql, $params);
|
||||
foreach ($items as $id => $item) {
|
||||
$items[$id] = new grade_item($item);
|
||||
$items[$id] = new grade_item($item, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -501,10 +501,13 @@ class grade_category extends grade_object {
|
||||
$grademinoverrides = array();
|
||||
|
||||
foreach ($rs as $used) {
|
||||
$grade = new grade_grade($used);
|
||||
$grade = new grade_grade($used, false);
|
||||
if (isset($items[$grade->itemid])) {
|
||||
// Prevent grade item to be fetched from DB.
|
||||
$grade->grade_item =& $items[$grade->itemid];
|
||||
} else if ($grade->itemid == $this->grade_item->id) {
|
||||
// This grade's grade item is not in $items.
|
||||
$grade->grade_item =& $this->grade_item;
|
||||
}
|
||||
if ($grade->userid != $prevuser) {
|
||||
$this->aggregate_grades($prevuser,
|
||||
@ -882,7 +885,7 @@ class grade_category extends grade_object {
|
||||
& $weights = null,
|
||||
$grademinoverrides = array(),
|
||||
$grademaxoverrides = array()) {
|
||||
$category_item = $this->get_grade_item();
|
||||
$category_item = $this->load_grade_item();
|
||||
$grademin = $category_item->grademin;
|
||||
$grademax = $category_item->grademax;
|
||||
|
||||
|
@ -694,7 +694,7 @@ class grade_item extends grade_object {
|
||||
// aggregate the category grade
|
||||
} else if ($this->is_category_item() or $this->is_course_item()) {
|
||||
// aggregate category grade item
|
||||
$category = $this->get_item_category();
|
||||
$category = $this->load_item_category();
|
||||
$category->grade_item =& $this;
|
||||
if ($category->generate_grades($userid)) {
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user