Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-12006

The function "grade_set_uncategorized" in grade/lib.php has a completely useless query that can add hundred's of db calls

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.3
    • Fix Version/s: 1.8.4
    • Component/s: Gradebook
    • Labels:
      None
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE

      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.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/Jan/08