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

quiz_statistics ad-hoc task should be triggered when attempts are deleted

XMLWordPrintable

    • MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE
    • MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE
    • MDL-79806_401_STABLE
    • MDL-79806_403_STABLE
    • MDL-79806_master
    • Hide

      Queueing the task in response to a quiz attempt is covered by the new attempt_deleted_test class. The actual calculation performed by the task is already covered in statistics_bulk_loader_test.

      Note, for Moodle 4.1, omit the `--classname="\quiz_statistics\task\recalculate"` argument for the CLI script.

      1. Create a quiz, on a course with at least 2 students.
      2. From the CLI, run `php admin/cli/adhoc_task.php --execute --classname="\quiz_statistics\task\recalculate"` to run any queued recalculation tasks.
        • You should see "Ran 0 adhoc tasks" and no output from the recalculate task.
      3. Log in as each student, start and finish 2 attempts of the quiz for each student.
      4. Wait 1 hour or run `UPDATE mdl_task_adhoc SET nextruntime = 0` on your database.
      5. From the CLI, run `php admin/cli/adhoc_task.php --execute --classname="\quiz_statistics\task\recalculate"` again.
        • You should see "Re-calculating statistics for quiz {quizname} ({quizid}) from course {shortname} ({courseid}) with 4 attempts".
        • You should see "Ran 1 adhoc tasks".
      6. Log in as a teacher, go to the quiz, click on the "Results" tab.
      7. Scroll down to the table of attempts.
      8. Select the checkbox next to 1 attempt for each student.
      9. Click "Delete selected attempts" and confirm.
      10. Wait 1 hour or run `UPDATE mdl_task_adhoc SET nextruntime = 0` on your database.
      11. From the CLI, run `php admin/cli/adhoc_task.php --execute --classname="\quiz_statistics\task\recalculate"` again.
        • Confirm you see "Re-calculating statistics for quiz {quizname} ({quizid}) from course {shortname} ({courseid}) with 2 attempts".
        • Confirm you see "Ran 1 adhoc tasks".
        • Before fix: the task was not triggered by the attempt deletion.
      Show
      Queueing the task in response to a quiz attempt is covered by the new attempt_deleted_test class. The actual calculation performed by the task is already covered in statistics_bulk_loader_test. Note, for Moodle 4.1, omit the `--classname="\quiz_statistics\task\recalculate"` argument for the CLI script. Create a quiz, on a course with at least 2 students. From the CLI, run `php admin/cli/adhoc_task.php --execute --classname="\quiz_statistics\task\recalculate"` to run any queued recalculation tasks. You should see "Ran 0 adhoc tasks" and no output from the recalculate task. Log in as each student, start and finish 2 attempts of the quiz for each student. Wait 1 hour or run `UPDATE mdl_task_adhoc SET nextruntime = 0` on your database. From the CLI, run `php admin/cli/adhoc_task.php --execute --classname="\quiz_statistics\task\recalculate"` again. You should see "Re-calculating statistics for quiz {quizname} ({quizid}) from course {shortname} ({courseid}) with 4 attempts". You should see "Ran 1 adhoc tasks". Log in as a teacher, go to the quiz, click on the "Results" tab. Scroll down to the table of attempts. Select the checkbox next to 1 attempt for each student. Click "Delete selected attempts" and confirm. Wait 1 hour or run `UPDATE mdl_task_adhoc SET nextruntime = 0` on your database. From the CLI, run `php admin/cli/adhoc_task.php --execute --classname="\quiz_statistics\task\recalculate"` again. Confirm you see "Re-calculating statistics for quiz {quizname} ({quizid}) from course {shortname} ({courseid}) with 2 attempts". Confirm you see "Ran 1 adhoc tasks". Before fix: the task was not triggered by the attempt deletion.

      Currently, the quiz_statistics ad-hoc task is only triggered when an attempt is submitted. However, it also needs to be triggered when one is delete, since that will likely also change the stats.

      See https://moodle.org/mod/forum/discuss.php?d=450118.

            marxjohnson Mark Johnson
            timhunt Tim Hunt
            Dale Davies Dale Davies
            Tim Hunt Tim Hunt
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            3 Vote for this issue
            Watchers:
            22 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 59 minutes
                2h 59m

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