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

Quiz statistics scheduled task: fix more obvious inefficiencies

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.0.7, 4.1.2
    • 4.0.6, 4.1.1
    • Quiz
    • MOODLE_400_STABLE, MOODLE_401_STABLE
    • MOODLE_400_STABLE, MOODLE_401_STABLE
    • MDL-77094_401
    • Hide

      Setup

      1. Make one or more courses.
      2. In each course, make one or more quizzes, with a few questions.
      3. Enrol a few students in each course.
      4. Attempt each quiz with each student.

      Note: As an alternative you may want to consider doing this once and then backup up an restoring the course backup. I would suggest doing this on the 4.00 branch first, back up the data, and then restore the course into 401 and master before proceeding.

      Test

      1. Run the quiz_statistics\task\recalculate task:

        php admin/cli/scheduled_task.php --execute="quiz_statistics\task\recalculate"
        

      2. Look over the logs from the run in the CLI:
        1. check that the statistics have been calculated for all the quizzes with recent attempts
        2. check that the logs seem informative

      Note:There is an example of the expected output in the description below.

      Show
      Setup Make one or more courses. In each course, make one or more quizzes, with a few questions. Enrol a few students in each course. Attempt each quiz with each student. Note: As an alternative you may want to consider doing this once and then backup up an restoring the course backup. I would suggest doing this on the 4.00 branch first, back up the data, and then restore the course into 401 and master before proceeding. Test Run the quiz_statistics\task\recalculate task: php admin/cli/scheduled_task.php --execute="quiz_statistics\task\recalculate" Look over the logs from the run in the CLI: check that the statistics have been calculated for all the quizzes with recent attempts check that the logs seem informative Note:There is an example of the expected output in the description below.

      At the moment, quiz_statistics\task\recalculate is loading all information about every quiz, before deciding whether it needs to do any work on that quiz. this is unnecessary. On our system, the task is rarely managing to check all quizzes within it's one hour time-limit.

      So, the changes I have made are:

      1. When getting the list of quizzes to consider, order this so that attempts with the most recetly finished attempts are processed first. These are most likely to be the interesting ones.
      2. Also, ensure this query returns all the data we need to determine if there is any work to do for this quiz in only one more DB query. (That one query is unavoidable until MDL-75197 is done.)
      3. Related to this, I made the task output slighly less verbose.
      4. And, this meant that I was able to move more of the code for doing the real work into the try-catch, which is probably good.

      The task output now looks like:

        'Quiz 1' (440000) in course tc_1 (139000) has most recent attempt finished at 1/02/23, 00:51:51 so re-calculating statistics for 4 attempts, start time 1/02/23, 00:51:51 ...
          Calculations completed at 1/02/23, 00:51:51.
        'Quiz 2' (440001) in course tc_1 (139000) has most recent attempt finished at 1/02/23, 00:51:51 so re-calculating statistics for 4 attempts, start time 1/02/23, 00:51:51 ...
          Calculations completed at 1/02/23, 00:51:52.
        'Quiz 3' (440002) in course tc_1 (139000) has most recent attempt finished at 1/02/23, 00:51:51 and statistics from 1/02/23, 00:51:52 so nothing to do.
      

            timhunt Tim Hunt
            timhunt Tim Hunt
            Anupama Sarjoshi Anupama Sarjoshi
            Andrew Lyons Andrew Lyons
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 43 minutes
                3h 43m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.