Moodle
  1. Moodle
  2. MDL-32215

course_sections table can contain duplicate sections

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      Hide

      A)

      • Upgrade should be run on all DBS

      B)
      This test script should be carried out after the upgrade.

      1. Create a new course using all default settings (just enter the names).

      2. Add a label with some text in the third week.

      3. Drag the section around a bunch using the AJAX four-direction arrow thingy. After each move, reload the page to check that it really has moved. Move it to a few different weeks then to the last week and finally leave it at the top week (section 1).

      Note: You need to reload after each move to see if it worked, because the AJAX code ignores errors without reporting to user.

      Note: You may notice slightly odd behaviour with week numbers appearing/disappearing. This is probably a bug in the AJAX code and is not related to this change.

      4. Go to your user profile and turn AJAX off.

      5. Go back to the course page. Move the section with the label down a couple, then up a couple, using the up/down arrows. Verify there are no errors.

      7. Run unit tests (`phpunit courselib_testcase course/tests/courselib_test.php')

      Show
      A) Upgrade should be run on all DBS B) This test script should be carried out after the upgrade. 1. Create a new course using all default settings (just enter the names). 2. Add a label with some text in the third week. 3. Drag the section around a bunch using the AJAX four-direction arrow thingy. After each move, reload the page to check that it really has moved. Move it to a few different weeks then to the last week and finally leave it at the top week (section 1). Note: You need to reload after each move to see if it worked, because the AJAX code ignores errors without reporting to user. Note: You may notice slightly odd behaviour with week numbers appearing/disappearing. This is probably a bug in the AJAX code and is not related to this change. 4. Go to your user profile and turn AJAX off. 5. Go back to the course page. Move the section with the label down a couple, then up a couple, using the up/down arrows. Verify there are no errors. 7. Run unit tests (`phpunit courselib_testcase course/tests/courselib_test.php')
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Pull Master Branch:
      MDL-32215-master
    • Rank:
      38990

      Description

      It is possible for the course_sections table to contain multiple entries with the same 'course' (course id) and section (section number).

      This does not work correctly in the code because (a) what does that mean, and (b) get_all_sections uses section number as key for the array anyway.

      There is already an index on these two fields but it is not set to unique. I propose:

      1) In database update, find all duplicates. For each duplicate, delete all rows except one (leaving the 'original' row with lowest id).

      2) In same update, change index so that it is set to unique.

      3) Adding a unique index may cause problem in code which moves sections (e.g. if it swaps two sections A=2 and B=3 by first setting A to 3 then B to 2, this will conflict - to solve the problem, need to e.g. set A to 10000003 then B to 2 then A to 3). Find and fix this code.

      NOTE: In our VLE 2 system we do not have any such duplicates. In our 1.9 system we do, but only 30 rows. So this is probably a rare problem, however the change will make any future code modifications in this area (such as MDL-24419) safer.

        Issue Links

          Activity

            People

            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: