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

Function delete_all_state doesn't delete all state.

XMLWordPrintable

    • MOODLE_405_STABLE, MOODLE_500_STABLE
    • Hide

      Setup:

      1. Create a test course with at least two course modules that can be completed.
        1. Mark one of the modules required for course completion.
      2. Create a test user (or use an already existing one).
      3. Enrol the test user in the course.
      4. Complete the module required for course completion with the test user.

      Test:

      1. As an admin or teacher, edit the course and unlock the completion status to add the second completable module as a course completion requirement.
        1. This should trigger the reset_all_state method which will call the delete_all_state method.
      2. Confirm in the database that both the completion records and the viewed records were deleted from their respective tables.
      Show
      Setup: Create a test course with at least two course modules that can be completed. Mark one of the modules required for course completion. Create a test user (or use an already existing one). Enrol the test user in the course. Complete the module required for course completion with the test user. Test: As an admin or teacher, edit the course and unlock the completion status to add the second completable module as a course completion requirement. This should trigger the reset_all_state method which will call the delete_all_state method. Confirm in the database that both the completion records and the viewed records were deleted from their respective tables.
    • Hide

      Code verified against automated checks.

      Checked MDL-83946 using repository: https://github.com/tbannister/moodle

      More information about this report

      Built on: Tue 10 Dec 2024 04:40:14 PM UTC

      Show
      Code verified against automated checks. Checked MDL-83946 using repository: https://github.com/tbannister/moodle main (0 errors / 0 warnings) [branch: MDL-83946 | CI Job ] More information about this report Built on: Tue 10 Dec 2024 04:40:14 PM UTC

      In the lib/completionlib.php file, there exists a function delete_all_state that does not, despite it's name, delete all the state records for an activity.  The method immediately above it, "delete_all_completion_data" deletes all records from course_modules_completion and course_modules_viewed tables, however "delete_all_state" does not.  The failure to delete records from course_modules_viewed means that viewed data is left behind when course modules are reset.  This can cause problems after the module is reset because other parts of Moodle seem to expect records to exist in either just the completion table, or both tables or neither table.

            Unassigned Unassigned
            tbannister Tyler Bannister
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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