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

Add record snapshots to slot deleted event for accurate auditing and debugging.

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 5.0
    • Quiz
    • MOODLE_500_STABLE
    • MDL-85334-master
    • Hide

      Testing Instructions

      Set up

      • Add multiple questions to a quiz, including random types.

      Trigger the event

      • From the quiz editing interface, delete a non-random question slot.
      • Delete a random question slot as well (optional but recommended to test both paths).

      Verify event data

      • Navigate to Reports->Logs and ensure that the slot_deleted event is fired.
      • To confirm that the event includes the expected questionreferenceid and/or questionsetreferenceid in the other array, where applicable, check the logstore_standard_log table. You can query:

      SELECT * 
      FROM mdl_logstore_standard_log 
      WHERE eventname = '\mod_quiz\event\slot_deleted'
      ORDER BY timecreated DESC;
      

      • Check the other array in the event data includes: questionreferenceid and/or questionsetreferenceid when applicable

      Confirm stability

      • Ensure that slot deletion completes successfully.
      • Run Behat tests related to quiz slot deletion to confirm no regressions occur.
      Show
      Testing Instructions Set up Add multiple questions to a quiz, including random types. Trigger the event From the quiz editing interface, delete a non-random question slot. Delete a random question slot as well (optional but recommended to test both paths). Verify event data Navigate to Reports->Logs and ensure that the slot_deleted event is fired. To confirm that the event includes the expected questionreferenceid and/or questionsetreferenceid in the other array, where applicable, check the logstore_standard_log table. You can query: SELECT *  FROM mdl_logstore_standard_log  WHERE eventname = '\mod_quiz\event\slot_deleted' ORDER BY timecreated DESC; Check the other array in the event data includes:  questionreferenceid and/or   questionsetreferenceid when applicable Confirm stability Ensure that slot deletion completes successfully. Run Behat tests related to quiz slot deletion to confirm no regressions occur.
    • Show
      Fails against automated checks. Checked MDL-85334 using repository: https://github.com/josepico01/moodle/ main (5 errors / 6 warnings) [branch: MDL-85334-master | CI Job ] overview (0/0) , phplint (0/0) , phpcs (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (5/6) , savepoint (0/0) , thirdparty (0/0) , externalbackup (0/0) , grunt (0/0) , shifter (0/0) , mustache (0/0) , gherkin (0/0) , Should these errors be fixed? Built on: Tue May 13 05:16:27 UTC 2025
    • Show
      Launching automatic jobs for branch MDL-85334 -master https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/19398/ PHPUnit (sqlsrv / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66352/ Behat (NonJS - boost and classic / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66353/ Behat (Firefox - boost / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66354/ Behat (Firefox - classic / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66355/ App tests (stable app version) / complete) Built on: Tue May 20 15:24:41 UTC 2025

      Description

      When a quiz slot is deleted, the slot_deleted event is currently triggered after the corresponding database record has been removed. This timing prevents event observers from accessing any information about the deleted slot (such as the question type), which is necessary for some plugins to react appropriately.

      For example, certain plugins need to clear caches related to specific question types when their slots are deleted. Without access to the slot’s data at event time, these actions cannot be performed reliably.

      This patch addresses the issue by adding event snapshots to the slot_deleted event using add_record_snapshot() (recommended in Event API Docs).

      With these snapshots, event observers now have access to the slot’s details at the time of deletion, enabling plugins to perform necessary cleanup or updates based on the deleted slot’s properties.

            josepico Jose Pico
            josepico Jose Pico
            cameron1729 cameron1729
            Tim Hunt Tim Hunt
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

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

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