Details
Description
For some of our teachers, the gradebook is loading very slow (if at all). I'm looking through the code to find easy places to optimize and came across this chunk of code in "grade_set_uncategorized":
$instance = get_record($mod->modname, 'id', $mod->instance);
// see if the item is already in the category table and if it is call category select with the id so it is selected
get_record('modules', 'name', $mod->modname);
$item = get_record('grade_item', 'courseid', $course->id, 'modid', $mod->module, 'cminstance', $mod->instance);
if (!$item) {
// set the item to uncategorized in grade_item
$item->courseid = $course->id;
$item->category = $uncat_id->id;
$item->modid = $mod->module;
$item->cminstance = $mod->instance;
$item->id = insert_record('grade_item', $item);
}
You'll notice that the call to "get_record('modules', 'name', $mod->modname)" doesn't save the returned value anywhere. I can't see how this is useful. Am I missing something? Removing only this call has shaved over 300 db queries when view the gradebook in the class I'm working with. This code appears to have been in there for years.
Thanks Bryce for the report. You are right, it does not seem to do anything at all so I commented it out.
Cheers,
Yu