Moodle
  1. Moodle
  2. MDL-28488

Import requires is too integrated with backup/restore permissions

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.3, 2.1, 2.2
    • Fix Version/s: 2.0.5, 2.1.2
    • Component/s: Backup
    • Labels:
    • Database:
      Any
    • Testing Instructions:
      Hide

      Ideally, test this issue under 21_STABLE

      There are various things to test here (each one corresponds to a separate commit so should be easy to revert partially if necessary. I hope it won't be necessary). The commit hash is the master one in the instructions below.

      Important note: You may get one warning about "uasort" (in textlib) when executing any backup/restore/import operation. Ignore it, has been addressed as MDL-29319) and does not affect testing this.

      TESTING 8645a28f:

      1. Create 2 courses, "source" and "target" with some activities.
      2. Logged as (editing) teacher, go to "source" course and enable edition.
      3. TEST: The teacher must see the "x2" icon on each activity. Pick one and verify the activity becomes duplicated ok.
      4. In other browser, as admin, prevent 'moodle/backup:backuptargetimport' capability to the (editing) teacher in that course.
      5. TEST: The teacher cannot see the "x2" icon anymore, hence cannot duplicate activities.

      TESTING 77c2ca69:

      1. TEST: In the "source" course page, the teacher gets, in the settings block access to "backup", "restore" and "import". Try one operation of each type and check it ends ok.
      2. As admin, prevent any of the 'moodle/backup:backupcourse' and/or 'moodle/restore:restorecourse' capabilities to the (editing) teacher in that course.
      3. TEST: In the "source" course page, the teacher doesn't get anymore the "backup" and "restore" options. Only "import" remains. Try one import and check it ends ok.
      4. As admin, prevent and/or 'moodle/restore:restoretargetimport' capability to the (editing) teacher in that course.
      5. TEST: In the "source" course page, the teacher doesn't get the "import" option anymore.
      6. TEST: Go to "target" course as teacher. Pick import. In the list of courses you should see the "target" course itself but not the "source" course (because we have prevented it to be used as source for import).

      TESTING 9530e1ed:

      1. As admin, go to admin -> courses -> backup -> general backup defaults: Annotate the "include users" and "include logs" help strings.
      2. admin -> courses -> backup -> automated backup setup
      3. TEST: Verify that the help strings for those 2 settings are 100% the same. It was using different/old strings before.

      TESTING 2a4ba40f:

      1. As admin, prevent the 'moodle/backup:configure' and 'moodle/restore:configure' capabilities to the (editing) teacher in the "target" course.
      2. As (editing) teacher, try one import operation in the "target" course picking the same "target" course as source.
      3. TEST: The teacher sees the "import activities/blocks/filters" settings after picking the course.
      4. TEST: The teacher sees the list of sections and activities to select / unselect them
      5. TEST: The import operation finishes ok.

      TESTING 59fc0cbd:

      1. As admin, go to admin -> courses -> backup -> general backup defaults. Check and lock this setting: "include users" and uncheck and lock this setting: "include blocks".
      2. As (editing teacher) try any import operation.
      3. TEST: No error happens (it used to cause one backup exception after picking the source course)
      4. TEST: The "include blocks" setting is shown checked and unlocked (you can uncheck it) by default.
      5. TEST: The import operation ends ok.
      1. TEST: Run "backup" unit tests. 0 failures expected.
      Show
      Ideally, test this issue under 21_STABLE There are various things to test here (each one corresponds to a separate commit so should be easy to revert partially if necessary. I hope it won't be necessary). The commit hash is the master one in the instructions below. Important note: You may get one warning about "uasort" (in textlib) when executing any backup/restore/import operation. Ignore it, has been addressed as MDL-29319 ) and does not affect testing this. TESTING 8645a28f: Create 2 courses, "source" and "target" with some activities. Logged as (editing) teacher, go to "source" course and enable edition. TEST: The teacher must see the "x2" icon on each activity. Pick one and verify the activity becomes duplicated ok. In other browser, as admin, prevent 'moodle/backup:backuptargetimport' capability to the (editing) teacher in that course. TEST: The teacher cannot see the "x2" icon anymore, hence cannot duplicate activities. TESTING 77c2ca69: TEST: In the "source" course page, the teacher gets, in the settings block access to "backup", "restore" and "import". Try one operation of each type and check it ends ok. As admin, prevent any of the 'moodle/backup:backupcourse' and/or 'moodle/restore:restorecourse' capabilities to the (editing) teacher in that course. TEST: In the "source" course page, the teacher doesn't get anymore the "backup" and "restore" options. Only "import" remains. Try one import and check it ends ok. As admin, prevent and/or 'moodle/restore:restoretargetimport' capability to the (editing) teacher in that course. TEST: In the "source" course page, the teacher doesn't get the "import" option anymore. TEST: Go to "target" course as teacher. Pick import. In the list of courses you should see the "target" course itself but not the "source" course (because we have prevented it to be used as source for import). TESTING 9530e1ed: As admin, go to admin -> courses -> backup -> general backup defaults: Annotate the "include users" and "include logs" help strings. admin -> courses -> backup -> automated backup setup TEST: Verify that the help strings for those 2 settings are 100% the same. It was using different/old strings before. TESTING 2a4ba40f: As admin, prevent the 'moodle/backup:configure' and 'moodle/restore:configure' capabilities to the (editing) teacher in the "target" course. As (editing) teacher, try one import operation in the "target" course picking the same "target" course as source. TEST: The teacher sees the "import activities/blocks/filters" settings after picking the course. TEST: The teacher sees the list of sections and activities to select / unselect them TEST: The import operation finishes ok. TESTING 59fc0cbd: As admin, go to admin -> courses -> backup -> general backup defaults. Check and lock this setting: "include users" and uncheck and lock this setting: "include blocks". As (editing teacher) try any import operation. TEST: No error happens (it used to cause one backup exception after picking the source course) TEST: The "include blocks" setting is shown checked and unlocked (you can uncheck it) by default. TEST: The import operation ends ok. TEST: Run "backup" unit tests. 0 failures expected.
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      18234

      Description

      Currently a user could see the Import link in their course, but if they aren't given full backupcourse and restorecourse capabilities they can't take activities from their CourseA to their CourseB. In our setup, we don't want our teachers to do full course backup and restores, but transferring their own course activities from one course to another should be allowed. In 1.9 this worked, but now a user must have full backup/restore permissions to do Imports.

      Other improvements that need to be made:
      Select all, Deselect all in the import area. If a user is importing a few activities from a full course they must manually uncheck all the things they don't want.

      Best case scenario:
      Have a course:import capability that allows users to Import to and from courses where they have that capability or maybe use manageactivities capability?. They do not need backupcourse or restorecourse capabilities.

        Issue Links

          Activity

          Matthew Davidson created issue -
          Michael de Raadt made changes -
          Field Original Value New Value
          Fix Version/s DEV backlog [ 10464 ]
          Labels triaged
          Affects Version/s 2.0 [ 10122 ]
          Affects Version/s 2.0.1 [ 10420 ]
          Affects Version/s 2.0.2 [ 10421 ]
          Henning Bostelmann made changes -
          Link This issue has been marked as being related by MDL-29072 [ MDL-29072 ]
          Eloy Lafuente (stronk7) made changes -
          Link This issue has been marked as being related by MDL-24518 [ MDL-24518 ]
          Eloy Lafuente (stronk7) made changes -
          Status Open [ 1 ] Development in progress [ 3 ]
          Eloy Lafuente (stronk7) made changes -
          Link This issue has a non-specific relationship to MDL-21668 [ MDL-21668 ]
          Eloy Lafuente (stronk7) made changes -
          Testing Instructions There are various things to test here (each one corresponds to a separate commit so should be easy to revert partially if necessary. I hope it won't be necessary).

          Important note: You may get one warning about "uasort" (in textlib) when executing any backup/restore/import operation. Ignore it, has been addressed as MDL-29319) and does not affect testing this.

          TESTING 8645a28f:

          # Create 2 courses, "source" and "target" with some activities.
          # Logged as (editing) teacher, go to "source" course and enable edition.
          # TEST: The teacher must see the "x2" icon on each activity. Pick one and verify the activity becomes duplicated ok.
          # In other browser, as admin, prevent 'moodle/backup:backuptargetimport' capability to the (editing) teacher in that course.
          # TEST: The teacher cannot see the "x2" icon anymore, hence cannot duplicate activities.

          TESTING 77c2ca69:

          # TEST: In the "source" course page, the teacher gets, in the settings block access to "backup", "restore" and "import". Try one operation of each type and check it ends ok.
          # As admin, prevent any of the 'moodle/backup:backupcourse' and/or 'moodle/restore:restorecourse' capabilities to the (editing) teacher in that course.
          # TEST: In the "source" course page, the teacher doesn't get anymore the "backup" and "restore" options. Only "import" remains. Try one import and check it ends ok.
          # As admin, prevent and/or 'moodle/restore:restoretargetimport' capability to the (editing) teacher in that course.
          # TEST: In the "source" course page, the teacher doesn't get the "import" option anymore.
          # TEST: Go to "target" course as teacher. Pick import. In the list of courses you should see the "target" course itself but not the "source" course (because we have prevented it to be used as source for import).

          TESTING 9530e1ed:

          # As admin, go to admin -> courses -> backup -> general backup defaults: Annotate the "include users" and "include logs" help strings.
          # admin -> courses -> backup -> automated backup setup
          # TEST: Verify that the help strings for those 2 settings are 100% the same. It was using different/old strings before.

          TESTING 2a4ba40f:

          # As admin, prevent the 'moodle/backup:configure' and 'moodle/restore:configure' capabilities to the (editing) teacher in the "target" course.
          # As (editing) teacher, try one import operation in the "target" course picking the same "target" course as source.
          # TEST: The teacher sees the "import activities/blocks/filters" settings after picking the course.
          # TEST: The teacher sees the list of sections and activities to select / unselect them
          # TEST: The import operation finishes ok.

          TESTING 59fc0cbd:

          # As admin, go to admin -> courses -> backup -> general backup defaults. Check and lock these settings: "include users" and "include blocks".
          # As (editing teacher) try any import operation.
          # TEST: No error happens (it used to cause one backup exception)
          # TEST: The "include blocks" setting is shown unchecked and unlocked by default.
          # TEST: The import operation ends ok.

          Eloy Lafuente (stronk7) made changes -
          Testing Instructions There are various things to test here (each one corresponds to a separate commit so should be easy to revert partially if necessary. I hope it won't be necessary).

          Important note: You may get one warning about "uasort" (in textlib) when executing any backup/restore/import operation. Ignore it, has been addressed as MDL-29319) and does not affect testing this.

          TESTING 8645a28f:

          # Create 2 courses, "source" and "target" with some activities.
          # Logged as (editing) teacher, go to "source" course and enable edition.
          # TEST: The teacher must see the "x2" icon on each activity. Pick one and verify the activity becomes duplicated ok.
          # In other browser, as admin, prevent 'moodle/backup:backuptargetimport' capability to the (editing) teacher in that course.
          # TEST: The teacher cannot see the "x2" icon anymore, hence cannot duplicate activities.

          TESTING 77c2ca69:

          # TEST: In the "source" course page, the teacher gets, in the settings block access to "backup", "restore" and "import". Try one operation of each type and check it ends ok.
          # As admin, prevent any of the 'moodle/backup:backupcourse' and/or 'moodle/restore:restorecourse' capabilities to the (editing) teacher in that course.
          # TEST: In the "source" course page, the teacher doesn't get anymore the "backup" and "restore" options. Only "import" remains. Try one import and check it ends ok.
          # As admin, prevent and/or 'moodle/restore:restoretargetimport' capability to the (editing) teacher in that course.
          # TEST: In the "source" course page, the teacher doesn't get the "import" option anymore.
          # TEST: Go to "target" course as teacher. Pick import. In the list of courses you should see the "target" course itself but not the "source" course (because we have prevented it to be used as source for import).

          TESTING 9530e1ed:

          # As admin, go to admin -> courses -> backup -> general backup defaults: Annotate the "include users" and "include logs" help strings.
          # admin -> courses -> backup -> automated backup setup
          # TEST: Verify that the help strings for those 2 settings are 100% the same. It was using different/old strings before.

          TESTING 2a4ba40f:

          # As admin, prevent the 'moodle/backup:configure' and 'moodle/restore:configure' capabilities to the (editing) teacher in the "target" course.
          # As (editing) teacher, try one import operation in the "target" course picking the same "target" course as source.
          # TEST: The teacher sees the "import activities/blocks/filters" settings after picking the course.
          # TEST: The teacher sees the list of sections and activities to select / unselect them
          # TEST: The import operation finishes ok.

          TESTING 59fc0cbd:

          # As admin, go to admin -> courses -> backup -> general backup defaults. Check and lock these settings: "include users" and "include blocks".
          # As (editing teacher) try any import operation.
          # TEST: No error happens (it used to cause one backup exception)
          # TEST: The "include blocks" setting is shown unchecked and unlocked by default.
          # TEST: The import operation ends ok.

          There are various things to test here (each one corresponds to a separate commit so should be easy to revert partially if necessary. I hope it won't be necessary).

          Important note: You may get one warning about "uasort" (in textlib) when executing any backup/restore/import operation. Ignore it, has been addressed as MDL-29319) and does not affect testing this.

          TESTING 8645a28f:

          # Create 2 courses, "source" and "target" with some activities.
          # Logged as (editing) teacher, go to "source" course and enable edition.
          # TEST: The teacher must see the "x2" icon on each activity. Pick one and verify the activity becomes duplicated ok.
          # In other browser, as admin, prevent 'moodle/backup:backuptargetimport' capability to the (editing) teacher in that course.
          # TEST: The teacher cannot see the "x2" icon anymore, hence cannot duplicate activities.

          TESTING 77c2ca69:

          # TEST: In the "source" course page, the teacher gets, in the settings block access to "backup", "restore" and "import". Try one operation of each type and check it ends ok.
          # As admin, prevent any of the 'moodle/backup:backupcourse' and/or 'moodle/restore:restorecourse' capabilities to the (editing) teacher in that course.
          # TEST: In the "source" course page, the teacher doesn't get anymore the "backup" and "restore" options. Only "import" remains. Try one import and check it ends ok.
          # As admin, prevent and/or 'moodle/restore:restoretargetimport' capability to the (editing) teacher in that course.
          # TEST: In the "source" course page, the teacher doesn't get the "import" option anymore.
          # TEST: Go to "target" course as teacher. Pick import. In the list of courses you should see the "target" course itself but not the "source" course (because we have prevented it to be used as source for import).

          TESTING 9530e1ed:

          # As admin, go to admin -> courses -> backup -> general backup defaults: Annotate the "include users" and "include logs" help strings.
          # admin -> courses -> backup -> automated backup setup
          # TEST: Verify that the help strings for those 2 settings are 100% the same. It was using different/old strings before.

          TESTING 2a4ba40f:

          # As admin, prevent the 'moodle/backup:configure' and 'moodle/restore:configure' capabilities to the (editing) teacher in the "target" course.
          # As (editing) teacher, try one import operation in the "target" course picking the same "target" course as source.
          # TEST: The teacher sees the "import activities/blocks/filters" settings after picking the course.
          # TEST: The teacher sees the list of sections and activities to select / unselect them
          # TEST: The import operation finishes ok.

          TESTING 59fc0cbd:

          # As admin, go to admin -> courses -> backup -> general backup defaults. Check and lock this setting: "include users" and uncheck and lock this setting: "include blocks".
          # As (editing teacher) try any import operation.
          # TEST: No error happens (it used to cause one backup exception after picking the source course)
          # TEST: The "include blocks" setting is shown checked and unlocked (you can uncheck it) by default.
          # TEST: The import operation ends ok.

          Eloy Lafuente (stronk7) made changes -
          Status Development in progress [ 3 ] Waiting for integration review [ 10010 ]
          Pull Master Diff URL https://github.com/stronk7/moodle/compare/master...MDL-28488
          Pull Master Branch MDL-28488
          Pull 2.0 Diff URL https://github.com/stronk7/moodle/compare/MOODLE_20_STABLE...MDL-28488_20
          Pull from Repository git://github.com/stronk7/moodle.git
          Pull 2.0 Branch MDL-28488_20
          Fix Version/s 2.0.5 [ 10950 ]
          Fix Version/s 2.1.2 [ 10851 ]
          Fix Version/s DEV backlog [ 10464 ]
          Testing Instructions There are various things to test here (each one corresponds to a separate commit so should be easy to revert partially if necessary. I hope it won't be necessary).

          Important note: You may get one warning about "uasort" (in textlib) when executing any backup/restore/import operation. Ignore it, has been addressed as MDL-29319) and does not affect testing this.

          TESTING 8645a28f:

          # Create 2 courses, "source" and "target" with some activities.
          # Logged as (editing) teacher, go to "source" course and enable edition.
          # TEST: The teacher must see the "x2" icon on each activity. Pick one and verify the activity becomes duplicated ok.
          # In other browser, as admin, prevent 'moodle/backup:backuptargetimport' capability to the (editing) teacher in that course.
          # TEST: The teacher cannot see the "x2" icon anymore, hence cannot duplicate activities.

          TESTING 77c2ca69:

          # TEST: In the "source" course page, the teacher gets, in the settings block access to "backup", "restore" and "import". Try one operation of each type and check it ends ok.
          # As admin, prevent any of the 'moodle/backup:backupcourse' and/or 'moodle/restore:restorecourse' capabilities to the (editing) teacher in that course.
          # TEST: In the "source" course page, the teacher doesn't get anymore the "backup" and "restore" options. Only "import" remains. Try one import and check it ends ok.
          # As admin, prevent and/or 'moodle/restore:restoretargetimport' capability to the (editing) teacher in that course.
          # TEST: In the "source" course page, the teacher doesn't get the "import" option anymore.
          # TEST: Go to "target" course as teacher. Pick import. In the list of courses you should see the "target" course itself but not the "source" course (because we have prevented it to be used as source for import).

          TESTING 9530e1ed:

          # As admin, go to admin -> courses -> backup -> general backup defaults: Annotate the "include users" and "include logs" help strings.
          # admin -> courses -> backup -> automated backup setup
          # TEST: Verify that the help strings for those 2 settings are 100% the same. It was using different/old strings before.

          TESTING 2a4ba40f:

          # As admin, prevent the 'moodle/backup:configure' and 'moodle/restore:configure' capabilities to the (editing) teacher in the "target" course.
          # As (editing) teacher, try one import operation in the "target" course picking the same "target" course as source.
          # TEST: The teacher sees the "import activities/blocks/filters" settings after picking the course.
          # TEST: The teacher sees the list of sections and activities to select / unselect them
          # TEST: The import operation finishes ok.

          TESTING 59fc0cbd:

          # As admin, go to admin -> courses -> backup -> general backup defaults. Check and lock this setting: "include users" and uncheck and lock this setting: "include blocks".
          # As (editing teacher) try any import operation.
          # TEST: No error happens (it used to cause one backup exception after picking the source course)
          # TEST: The "include blocks" setting is shown checked and unlocked (you can uncheck it) by default.
          # TEST: The import operation ends ok.

          Ideally, test this issue under 21_STABLE

          There are various things to test here (each one corresponds to a separate commit so should be easy to revert partially if necessary. I hope it won't be necessary). The commit hash is the master one in the instructions below.

          Important note: You may get one warning about "uasort" (in textlib) when executing any backup/restore/import operation. Ignore it, has been addressed as MDL-29319) and does not affect testing this.

          TESTING 8645a28f:

          # Create 2 courses, "source" and "target" with some activities.
          # Logged as (editing) teacher, go to "source" course and enable edition.
          # TEST: The teacher must see the "x2" icon on each activity. Pick one and verify the activity becomes duplicated ok.
          # In other browser, as admin, prevent 'moodle/backup:backuptargetimport' capability to the (editing) teacher in that course.
          # TEST: The teacher cannot see the "x2" icon anymore, hence cannot duplicate activities.

          TESTING 77c2ca69:

          # TEST: In the "source" course page, the teacher gets, in the settings block access to "backup", "restore" and "import". Try one operation of each type and check it ends ok.
          # As admin, prevent any of the 'moodle/backup:backupcourse' and/or 'moodle/restore:restorecourse' capabilities to the (editing) teacher in that course.
          # TEST: In the "source" course page, the teacher doesn't get anymore the "backup" and "restore" options. Only "import" remains. Try one import and check it ends ok.
          # As admin, prevent and/or 'moodle/restore:restoretargetimport' capability to the (editing) teacher in that course.
          # TEST: In the "source" course page, the teacher doesn't get the "import" option anymore.
          # TEST: Go to "target" course as teacher. Pick import. In the list of courses you should see the "target" course itself but not the "source" course (because we have prevented it to be used as source for import).

          TESTING 9530e1ed:

          # As admin, go to admin -> courses -> backup -> general backup defaults: Annotate the "include users" and "include logs" help strings.
          # admin -> courses -> backup -> automated backup setup
          # TEST: Verify that the help strings for those 2 settings are 100% the same. It was using different/old strings before.

          TESTING 2a4ba40f:

          # As admin, prevent the 'moodle/backup:configure' and 'moodle/restore:configure' capabilities to the (editing) teacher in the "target" course.
          # As (editing) teacher, try one import operation in the "target" course picking the same "target" course as source.
          # TEST: The teacher sees the "import activities/blocks/filters" settings after picking the course.
          # TEST: The teacher sees the list of sections and activities to select / unselect them
          # TEST: The import operation finishes ok.

          TESTING 59fc0cbd:

          # As admin, go to admin -> courses -> backup -> general backup defaults. Check and lock this setting: "include users" and uncheck and lock this setting: "include blocks".
          # As (editing teacher) try any import operation.
          # TEST: No error happens (it used to cause one backup exception after picking the source course)
          # TEST: The "include blocks" setting is shown checked and unlocked (you can uncheck it) by default.
          # TEST: The import operation ends ok.

          # TEST: Run "backup" unit tests. 0 failures expected.
          Pull 2.1 Branch MDL-28488_21
          Pull 2.1 Diff URL https://github.com/stronk7/moodle/compare/MOODLE_21_STABLE...MDL-28488_21
          Eloy Lafuente (stronk7) made changes -
          Affects Version/s 2.2 [ 10656 ]
          Eloy Lafuente (stronk7) made changes -
          Link This issue has a non-specific relationship to MDL-29319 [ MDL-29319 ]
          Sam Hemelryk made changes -
          Currently in integration Yes
          Sam Hemelryk made changes -
          Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
          Integrator samhemelryk
          Sam Hemelryk made changes -
          Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
          moodle.com made changes -
          Tester andyjdavis
          Andrew Davis made changes -
          Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
          Andrew Davis made changes -
          Status Testing in progress [ 10011 ] Tested [ 10006 ]
          Eloy Lafuente (stronk7) made changes -
          Status Tested [ 10006 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Currently in integration Yes
          Integration date 16/Sep/11

            People

            • Votes:
              8 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: