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

Import can include section conditions which still point to old course

    Details

    • Testing Instructions:
      Hide

      1. Create course with shortname/fullname xA and all default settings.
      2. In section 1 add a new Lesson called 'Lesson A' with all default settings.
      3. Edit settings for section 2. Set grade condition to 'Lesson A' and at least 50%. Set to show restriction information. Save changes.
      4. In section 2 add a new Book called 'Book A' with all default settings.
      5. Create course with shortname/fullname xB and all default settings.
      6. Click 'Import' under course administration. Select course xA and continue.
      7. Leave the three tickboxes ticked (default), and continue.
      8. Select None, then tick both Book A and the section that contains Book A, and continue.
      9. Perform import.

      EXPECTED: Book A should appear in section 2, but there should be no conditions on that section.
      BEFORE FIX: Section 2 displays the following: 'Restricted (completely hidden, no message): Not available until you achieve a required score in !missing.'

      11. Delete Book A from section 2.
      12. In section 1 add a new Lesson called 'Lesson B' with all default settings.
      13. Edit settings for section 2. Set the grade condition to 'Lesson B' and at least 50%. Set to show restriction information. Save changes. (The message should now show it's not available until you get a score in Lesson B.)
      14. Repeat the import process in steps 6-9.

      EXPECTED: Book A should appear in section 2. The existing condition (on Lesson B) should remain on section 2.
      BEFORE FIX: Section 2 displays conditions on both 'Lesson B' AND 'Lesson A'.

      15. Delete Book A from section 2.
      16. Repeat the import process, but this time select Lesson A (and its section) in addition to Book A and its section.

      EXPECTED: Book A should be imported again, and so should Lesson A; section 2 should now have conditions on both 'Lesson B' and 'Lesson A'. (The 'Lesson A' refers to the new copy on this course; I checked in database.)

      Note: You can repeat the test from step 13 if you delete the book again, or from step 6 if you delete the book and edit the section settings to reset them.

      Show
      1. Create course with shortname/fullname xA and all default settings. 2. In section 1 add a new Lesson called 'Lesson A' with all default settings. 3. Edit settings for section 2. Set grade condition to 'Lesson A' and at least 50%. Set to show restriction information. Save changes. 4. In section 2 add a new Book called 'Book A' with all default settings. 5. Create course with shortname/fullname xB and all default settings. 6. Click 'Import' under course administration. Select course xA and continue. 7. Leave the three tickboxes ticked (default), and continue. 8. Select None, then tick both Book A and the section that contains Book A, and continue. 9. Perform import. EXPECTED: Book A should appear in section 2, but there should be no conditions on that section. BEFORE FIX: Section 2 displays the following: 'Restricted (completely hidden, no message): Not available until you achieve a required score in !missing.' 11. Delete Book A from section 2. 12. In section 1 add a new Lesson called 'Lesson B' with all default settings. 13. Edit settings for section 2. Set the grade condition to 'Lesson B' and at least 50%. Set to show restriction information. Save changes. (The message should now show it's not available until you get a score in Lesson B.) 14. Repeat the import process in steps 6-9. EXPECTED: Book A should appear in section 2. The existing condition (on Lesson B) should remain on section 2. BEFORE FIX: Section 2 displays conditions on both 'Lesson B' AND 'Lesson A'. 15. Delete Book A from section 2. 16. Repeat the import process, but this time select Lesson A (and its section) in addition to Book A and its section. EXPECTED: Book A should be imported again, and so should Lesson A; section 2 should now have conditions on both 'Lesson B' and 'Lesson A'. (The 'Lesson A' refers to the new copy on this course; I checked in database.) Note: You can repeat the test from step 13 if you delete the book again, or from step 6 if you delete the book and edit the section settings to reset them.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull Master Branch:
      MDL-39000-master

      Description

      This is not trivial bug to reproduce, but it actually happened and caused a lot of unrest between students complaining about blocked access to course sections that they should have available.

      ----------------
      How to reproduce:
      1. Enable conditional access in Advanced functions.
      2. Create 2 courses A and B, inside each course section 1 create Lesson A and B respectively.
      3. In Course A section 2 create Book A.
      4. Set Course A section 2 available when grade from Lesson A is above 50% and set to display availablity conditions.
      5. In Course B set section 2 available when grade from Lesson B is above 50%and set to display availablity conditions.
      6. Import Book A from Course A to Course B. It gets imported with section 2 condition reference to Lesson A from Course A!
      7. Sign test Student into both Course A and Course B as student

      8. Log out or in another browser log in as Student and go to Course A. Complete Lesson A and you should have grade for Lesson A.
      9. Check that you have avalable section 2 with Book A.
      10. Log out to clear your session.
      11. Log in as Student and go directly to Course B. The conditional logic will try to evaluate your access to Course B section 2 and will set both your Lesson B and Lesson A to "false" in $SESSION->gradescorecache.
      11. Go to Course A and check that you do not have secton 2 with Book A available despite that you should have (Student still have proper grade in database, but it is ignored while it is set in session cache).
      ---------------

      Location of the bug:
      lib/conditionlib.php condition_info_base->get_cached_grade_score()
      lines 1144-1150:
      // And if it's still not set, well it doesn't exist (eg
      // maybe the user set it as a condition, then deleted the
      // grade item) so we call it false
      if (!array_key_exists($gradeitemid, $SESSION->gradescorecache))

      { $SESSION->gradescorecache[$gradeitemid] = false; }

      This doesn't account for grade items existing in other courses with conditional references to them imported to the current course. Or maybe the problem is to allow conditional references to non-existent modules with selective import.

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  13/May/13