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

Remove 'numsections' from topics and weeks, allow teachers to create and delete sections as they are needed

    Details

    • Testing Instructions:
      Hide

      Test 1
      BEFORE UPGRADE (preferably on 3.2 or earlier)

      1. Create two courses in weeks and topics formats, add activities to the last section(s) and then "decrease number of sections" so you have orphaned activities.
      2. Create and save backups of these courses, you'll need them in test 3 below
      3. Upgrade to integration master
      4. Make sure the activities that used to be orphaned now show in their sections with the warning "Available but not visible on the course page" and the sections containing them are hidden

      Test 2 - creating and editing courses

      1. Create courses in weeks and topics formats, make sure the "Number of sections" is present in the "create course" form and the number of sections in the newly created courses matches whatever you selected
      2. Edit settings for these courses, make sure there is no "Number of sections" field any more
      3. On the course itself in the editing mode there should be "Add section" link in the bottom and no +/- links
      4. Make sure you can add sections to the end and delete any sections in the section edit menu
      5. Add block "Section links" and make sure it displays all links to the sections and the current topic/week is highlighted

      Test 3 - restoring into another course.

      1. Use backup files created in test 1
      2. On integration master restore these backups as a new course and make sure that restored orphaned sections are hidden and activities inside them are "Available but not visible on course page"
      3. Restore this backup into existing course that has lesser number of sections (select "overwrite course configuration"), make sure the orphaned sections were restored as hidden
      4. Restore this backup into existing course that has greater number of sections by merging (select "overwrite course configuration"), make sure that visibility of existing sections did not change
      5. Restore this backup into existing course that has greater number of sections selecting "delete course contents" and "overwrite course configuration", the orphaned sections should be hidden and the number of sections should be the same as in the restored course
      6. Restore the backup into existing course by merging without overwriting course configuration. The number of sections should become the maximum of what was in original course and the backup course. Note: if you do not select "overwrite course configuration" the information about number of sections in the backup file is not processed so no sections will be marked hidden by the restore process.

      Test 4 - restore in 3.2.

      1. Create a course in topics/weeks format on integration master and back it up
      2. Restore it on 3.2 as a new course, the number of sections should be set properly

      We do not guarantee that restoring into earlier moodle versions will work but I tried to make it compatible

      Show
      Test 1 BEFORE UPGRADE (preferably on 3.2 or earlier) Create two courses in weeks and topics formats, add activities to the last section(s) and then "decrease number of sections" so you have orphaned activities. Create and save backups of these courses, you'll need them in test 3 below Upgrade to integration master Make sure the activities that used to be orphaned now show in their sections with the warning "Available but not visible on the course page" and the sections containing them are hidden Test 2 - creating and editing courses Create courses in weeks and topics formats, make sure the "Number of sections" is present in the "create course" form and the number of sections in the newly created courses matches whatever you selected Edit settings for these courses, make sure there is no "Number of sections" field any more On the course itself in the editing mode there should be "Add section" link in the bottom and no +/- links Make sure you can add sections to the end and delete any sections in the section edit menu Add block "Section links" and make sure it displays all links to the sections and the current topic/week is highlighted Test 3 - restoring into another course. Use backup files created in test 1 On integration master restore these backups as a new course and make sure that restored orphaned sections are hidden and activities inside them are "Available but not visible on course page" Restore this backup into existing course that has lesser number of sections (select "overwrite course configuration"), make sure the orphaned sections were restored as hidden Restore this backup into existing course that has greater number of sections by merging (select "overwrite course configuration"), make sure that visibility of existing sections did not change Restore this backup into existing course that has greater number of sections selecting "delete course contents" and "overwrite course configuration", the orphaned sections should be hidden and the number of sections should be the same as in the restored course Restore the backup into existing course by merging without overwriting course configuration. The number of sections should become the maximum of what was in original course and the backup course. Note: if you do not select "overwrite course configuration" the information about number of sections in the backup file is not processed so no sections will be marked hidden by the restore process. Test 4 - restore in 3.2. Create a course in topics/weeks format on integration master and back it up Restore it on 3.2 as a new course, the number of sections should be set properly We do not guarantee that restoring into earlier moodle versions will work but I tried to make it compatible
    • Affected Branches:
      MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE
    • Pull Master Branch:
      wip-MDL-57769-master

      Description

      Each section in the course is represented by one record in course_sections table. However formats topics and weeks (and many cloned formats in plugins directory) have 'numsections' parameter that often conflicts with actual number of sections.

      This parameter can not be removed since some teachers use it to create "orphaned" activities that are available but not visible on the course page. MDL-4782 will provide necessary functionality for it.

      Problems that will be resolved by removing 'numsections' field:

      • It is confusing for the majority of teachers. Also many don't understand that "orphaned" activities are actually available
      • Controls to add/remove section in the bottom of the page are also not user-friendly (MDL-34706), in fact why not allow to insert sections anywhere? (MDL-51221). It is already possible to delete any section
      • It creates problems when importing courses or restoring a course into existing, uploading courses using templates (MDL-56590, MDL-15659) - the records from course_sections get created, activities are imported but numsections is not changed. This results in confusing orphaned activities in the course

      What we need to do:

      • create an upgrade script that converts all existing "orphaned" sections in topics and weeks formats into hidden sections with visible activities in them ("stealth" activities)
      • remove the course format option 'numsections' from formats weeks and topics and all usages of it
      • when restoring course from the backup made before the change respect 'numsections' and convert extra sections into hidden sections with stealth activities
      • when making backups include 'numsections' so that these backups can be restored into previous versions of moodle (even though we warn that such restore may not work)
      • in existing WS retrieving course contents return the 'numsections' for backward-compatibility that will be calculated on-the-fly as the maximum section number
      • make sure that all contributed formats with 'numsections' attribute continue working; provide documentation for developers on how to upgrade their plugins
      • leave the "Number of sections" in the create course form and in the default course settings so that new courses are created with the number of empty sections

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  1 Vote for this issue
                  Watchers:
                  15 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    15/May/17