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

count_submissions_need_grading called even if user cannot grade the assignment

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.9.2
    • Fix Version/s: None
    • Labels:
      None
    • Affected Branches:
      MOODLE_39_STABLE

      Description

      Tracker issue created from forum post: https://moodle.org/mod/forum/discuss.php?d=412662

      During periods of high load when users are logging in, the function "count_submissions_need_grading" is causing the most load on our database server.

      The function is called from mod_assign_core_calendar_provide_event_action but returning the count of submissions needing grading is returned even if the user does not have the capability of grading that item.

      {{LINE 1549: mod_assign_core_calendar_provide_event_action: /mod/assign/lib.php}}
      {{ if ($event->eventtype == ASSIGN_EVENT_TYPE_GRADINGDUE) {}}
      {{     $name = get_string('grade');}}
      {{     $url = new \moodle_url('/mod/assign/view.php', [}}
      {{         'id' => $cm->id,}}
      {{         'action' => 'grader'}}
      {{     ]);}}
      {{     $itemcount = $assign->count_submissions_need_grading();}}
      {{     $actionable = $assign->can_grade($userid) && (time() >= $assign->get_instance()->allowsubmissionsfromdate);}}
      {{ } else}}

      The query used in $itemcount is expensive for MySQL to be run as it isn't using indexes in some parts, causes full table scans and also uses 2 temporary tables.

      A better option would be checking if the user can grade the item or if it is actionable before counting submissions, and if not, assign "$itemcount = 0;" instead.

        Attachments

        1. before-after.PNG
          before-after.PNG
          3 kB
        2. callgraph.png
          callgraph.png
          2.93 MB
        3. MoodleLoad.PNG
          MoodleLoad.PNG
          33 kB

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            agrowe Alex Rowe
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Matteo Scaramuccia, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: