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

Subsections are not removed from the 'course_sections' table when deleted causing maxsections bounds failure

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.5.1
    • Course, Subsection
    • MOODLE_405_STABLE
    • Hide
      1. Turn on developer level debugging.
      2. Enable 'Subsections' in 'Site administration' -> 'Activity modules' -> 'Manage activities'.
      3. Set 'moodlecourse | maxsections' (in 'Site administration' -> 'Courses' -> 'Course default settings'.
      4. Create a Custom sections course with 9 sections.
      5. Turn editing on.
      6. Confirm that you can add both subsections and sections.
      7. Add a sub section to a section.
      8. You should see that there is the message 'You have reached the maximum number of sections allowed for a course.', however you can still see the '+' to add a new subsection.
      9. Refresh and observe that the ability to add a subsection is removed and replaced with a pure 'Add an activity or resource' button.
      10. Delete the subsection.
      11. Observe that you can't still add a subsection or section even though the number of sections is now nine as the subsection (the tenth) is no longer there.
      12. Refresh the page.
      13. Confirm that you now have the '+ Add section' button at the bottom but still can't add a new subsection even though with nine sections and ten max you should.
      14. Click on '+ Add section' and confirm that the 'maxsectionslimit' error with 'Cannot create new section as it would exceed the maximum number of sections allowed for this course ({$a}).' occurs (note that there is also a string bug here with the data for the string not being passed in).
      15. Examine the database and see that in 'course_sections' table the deleted subsection (with 'mod_subsection' for the component') is still there for the course even though it was deleted.
      16. Examine the database and see that in the 'subsection' table the deleted subsection is still there even though it was deleted.
      Show
      Turn on developer level debugging. Enable 'Subsections' in 'Site administration' -> 'Activity modules' -> 'Manage activities'. Set 'moodlecourse | maxsections' (in 'Site administration' -> 'Courses' -> 'Course default settings'. Create a Custom sections course with 9 sections. Turn editing on. Confirm that you can add both subsections and sections. Add a sub section to a section. You should see that there is the message 'You have reached the maximum number of sections allowed for a course.', however you can still see the '+' to add a new subsection. Refresh and observe that the ability to add a subsection is removed and replaced with a pure 'Add an activity or resource' button. Delete the subsection. Observe that you can't still add a subsection or section even though the number of sections is now nine as the subsection (the tenth) is no longer there. Refresh the page. Confirm that you now have the '+ Add section' button at the bottom but still can't add a new subsection even though with nine sections and ten max you should. Click on '+ Add section' and confirm that the 'maxsectionslimit' error with 'Cannot create new section as it would exceed the maximum number of sections allowed for this course ({$a}).' occurs (note that there is also a string bug here with the data for the string not being passed in). Examine the database and see that in 'course_sections' table the deleted subsection (with 'mod_subsection' for the component') is still there for the course even though it was deleted. Examine the database and see that in the 'subsection' table the deleted subsection is still there even though it was deleted.

      Subsections don't tidy up the database when removed and as such cause a max section error and incorrect UI configutration.

        1. Screenshot 2024-12-18 132853.png
          49 kB
          Gareth J Barnard
        2. Screenshot 2024-12-18 133010.png
          58 kB
          Gareth J Barnard
        3. Screenshot 2024-12-18 134046.png
          25 kB
          Gareth J Barnard

            Unassigned Unassigned
            gb2048 Gareth J Barnard
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 minute
                1m

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