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: Waiting for peer review
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.9.2
    • Fix Version/s: None
    • Component/s: Assignment
    • Labels:
    • Testing Instructions:
      Hide

      Test 1 - Confirm events/actions are still the same

      1. Log in as admin
      2. Create a course and enrol a teacher and a student
      3. Log in as teacher
      4. Create an assignment with "allow submissions from" of today, and "remind me to grade by" as 5 days in the future
      5. Log in as student
      6. Open the assignment and add a submission
      7. Go to your dashboard and confirm there are no events listed in the timeline block
      8. Log in as teacher
      9. Go to your dashboard and confirm there is a "... due to be graded" event and a "Grade 1" action below it in the timeline block

      Test 2 - Unit tests

      1. Run unit tests
      Show
      Test 1 - Confirm events/actions are still the same Log in as admin Create a course and enrol a teacher and a student Log in as teacher Create an assignment with "allow submissions from" of today, and "remind me to grade by" as 5 days in the future Log in as student Open the assignment and add a submission Go to your dashboard and confirm there are no events listed in the timeline block Log in as teacher Go to your dashboard and confirm there is a "... due to be graded" event and a "Grade 1" action below it in the timeline block Test 2 - Unit tests Run unit tests
    • Affected Branches:
      MOODLE_39_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-70049-master_count_submissions

      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
          3 kB
          Alex Rowe
        2. callgraph.png
          2.93 MB
          Alex Rowe
        3. MoodleLoad.PNG
          33 kB
          Alex Rowe

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            agrowe Alex Rowe
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 minute
                1m