Moodle
  1. Moodle
  2. MDL-32988

Course modules availability information not deleted on course deletion.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.3, 2.3
    • Fix Version/s: 2.2.4
    • Component/s: Conditional activities
    • Labels:
      None
    • Testing Instructions:
      Hide

      0. You must have completion options enabled on server.
      1. Create a new course with completion tracking enabled.
      2. Create a new Page with completion set to let students manually mark complete.
      3. In database, run this query:

      select count(*) from coremdl_course_modules_completion
      

      Where 'coremdl_' is your database prefix.
      Note the result, let's call it X. For example in my case, X = 125
      4. Turn editing off.
      5. Tick the ticky-box next to the Page
      6. Run the query again and note the result, let's call it Y. Y should be = X+1 (126 in my case)
      7. Do this database update to bust your page module:

      update coremdl_modules set name='frog' where name='page' 
      

      8. Delete the course by changing the URL in address bad from 'view.php' to 'delete.php'. Click continue.
      9. Repeat the first query. Call the result Z.

      Z should be = X (125 in my case) but due to this bug, before the fix it is actually = Y (126).

      Note: You may want to repair your page module at this point

      update coremdl_modules set name='page' where name='frog' 
      
      Show
      0. You must have completion options enabled on server. 1. Create a new course with completion tracking enabled. 2. Create a new Page with completion set to let students manually mark complete. 3. In database, run this query: select count(*) from coremdl_course_modules_completion Where 'coremdl_' is your database prefix. Note the result, let's call it X. For example in my case, X = 125 4. Turn editing off. 5. Tick the ticky-box next to the Page 6. Run the query again and note the result, let's call it Y. Y should be = X+1 (126 in my case) 7. Do this database update to bust your page module: update coremdl_modules set name='frog' where name='page' 8. Delete the course by changing the URL in address bad from 'view.php' to 'delete.php'. Click continue. 9. Repeat the first query. Call the result Z. Z should be = X (125 in my case) but due to this bug, before the fix it is actually = Y (126). Note: You may want to repair your page module at this point update coremdl_modules set name='page' where name='frog'
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE
    • Pull Master Branch:
      MDL-32988-master
    • Rank:
      40161

      Description

      In lib/moodlelib.php the function remove_course_contents is responsible (obviously) for removing contents from the course on deletion. However, in 2.2 the course_modules are being deleted before the removal of the availability, meaning the availability is never removed as the course module no longer exists.

        Activity

        Hide
        Sam Marshall added a comment -

        Looking at the code, it seems:

        a) This applies to both completion and availability data.

        b) This occurs only after it has tried to delete all the modules using the normal method, so it only applies to any modules that failed to delete normally.

        Working on a test script.

        Show
        Sam Marshall added a comment - Looking at the code, it seems: a) This applies to both completion and availability data. b) This occurs only after it has tried to delete all the modules using the normal method, so it only applies to any modules that failed to delete normally. Working on a test script.
        Hide
        Sam Marshall added a comment -

        I fixed it just by switching the order and tested as above. Since this is a trivial change, submitting for integration review. (No rush, it's not very important.)

        Show
        Sam Marshall added a comment - I fixed it just by switching the order and tested as above. Since this is a trivial change, submitting for integration review. (No rush, it's not very important.)
        Hide
        Mark Nelson added a comment -
        Show
        Mark Nelson added a comment - Yeh, just to confirm, that is solution I used - https://github.com/markn86/moodle/commit/20651b1a1bb4d1475e143dba1720219c374cf034
        Hide
        Aparup Banerjee added a comment -

        Thanks guys, thats been pushed into master and picked into 22 as well.

        Show
        Aparup Banerjee added a comment - Thanks guys, thats been pushed into master and picked into 22 as well.
        Hide
        Ankit Agarwal added a comment -

        works as expected.
        Passing
        Thanks

        Show
        Ankit Agarwal added a comment - works as expected. Passing Thanks
        Hide
        Eloy Lafuente (stronk7) added a comment -

        U P S T R E A M I Z E D !

        Many thanks for the hard work, closing this as fixed.

        Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - U P S T R E A M I Z E D ! Many thanks for the hard work, closing this as fixed. Ciao

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: