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

count_submissions_need_grading called even if user cannot grade the assignment

    XMLWordPrintable

    Details

      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. MDL-70049_Test Passed.PNG
          MDL-70049_Test Passed.PNG
          48 kB
        4. MoodleLoad.PNG
          MoodleLoad.PNG
          33 kB

          Activity

            People

            Assignee:
            agrowe Alex Rowe
            Reporter:
            agrowe Alex Rowe
            Peer reviewer:
            Tim Hunt Tim Hunt
            Integrator:
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Tester:
            Gladys Basiana Gladys Basiana
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan, Matteo Scaramuccia, Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              10/May/21

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 51 minutes
                51m