Moodle
  1. Moodle
  2. MDL-29072

Importing into a course requires incorrect capability on the source course

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.4, 2.1.1, 2.2
    • Fix Version/s: 2.0.5, 2.1.2
    • Component/s: Backup
    • Labels:
    • Testing Instructions:
      Hide

      On a Moodle installation (21_STABLE) in standard setup:

      • Create two courses, called "source" and "target". Create some labels in "source" (as example content).
      • On "source", allow the following capabilities for the non-editing teacher role:
        o moodle/backup:backupcourse
        o moodle/backup:configure
        o moodle/backup:backuptargetimport
      • Create a user "U" and enrol the user as follows:
        o into "source" as non-editing teacher,
        o into "target" as editing teacher.
      • Log in as "U".
      • Go to "target" and click on "Import".

      Verify that the course "source" appears in the list. Select "source" and proceed with the import.

      Show
      On a Moodle installation (21_STABLE) in standard setup: Create two courses, called "source" and "target". Create some labels in "source" (as example content). On "source", allow the following capabilities for the non-editing teacher role: o moodle/backup:backupcourse o moodle/backup:configure o moodle/backup:backuptargetimport Create a user "U" and enrol the user as follows: o into "source" as non-editing teacher, o into "target" as editing teacher. Log in as "U". Go to "target" and click on "Import". Verify that the course "source" appears in the list. Select "source" and proceed with the import.
    • Workaround:
      Hide

      Give the capability moodle/restore:restorecourse globally to any user who needs to import course material.

      Show
      Give the capability moodle/restore:restorecourse globally to any user who needs to import course material.
    • 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:

      Description

      At the moment, a user cannot import course contents from course A into course B unless he has the capability moodle/restore:restorecourse in the context of the source course.

      However, according to MDL-24518, this should be controlled by the capability moodle/backup:backuptargetimport .

      To reproduce, on a Moodle installation in standard setup:

      • Create two courses, called "source" and "target". Create some labels in "source" (as example content).
      • On "source", allow the following capabilities for the non-editing teacher role:
        • moodle/backup:backupcourse
        • moodle/backup:configure
        • moodle/backup:backuptargetimport
      • Create a user "U" and enrol the user as follows:
        • into "source" as non-editing teacher,
        • into "target" as editing teacher.
      • Log in as "U".
      • Go to "target" and click on "Import".

      EXPECTED: The list of courses displayed contains the course "source".
      ACTUAL: The list of courses displayed contains only the course "target".

      The underlying problem is that the list is filtered by courses on which the user "U" has the capability moodle/restore:restorecourse . This is done in the constructor of class import_course_search, which is inherited without modification from class restore_course_search.

      Patch will follow.

        Gliffy Diagrams

          Issue Links

            Activity

            Henning Bostelmann created issue -
            Henning Bostelmann made changes -
            Field Original Value New Value
            Description At the moment, a user cannot import course contents from course A into course B unless he has the capability moodle/backup:restorecourse in the context of the *source* course.

            However, according to MDL-24518, this should be controlled by the capability moodle/backup:backuptargetimport .

            To reproduce, on a Moodle installation in standard setup:
            * Create two courses, called "source" and "target". Create some labels in "source" (as example content).
            * On "source", allow the following capabilities for the non-editing teacher role:
            ** moodle/backup:backupcourse
            ** moodle/backup:configure
            ** moodle/backup:backuptargetimport
            * Create a user "U" and enrol the user as follows:
            ** into "source" as non-editing teacher,
            ** into "target" as editing teacher.
            * Log in as "U".
            * Go to "target" and click on "Import".

            EXPECTED: The list of courses displayed contains the course "source".
            ACTUAL: The list of courses displayed contains only the course "target".

            The underlying problem is that the list is filtered by courses on which the user "U" has the capability moodle/restore:restorecourse . This is done in the constructor of class import_course_search, which is inherited without modification from class restore_course_search.

            Patch will follow.
            At the moment, a user cannot import course contents from course A into course B unless he has the capability moodle/restore:restorecourse in the context of the *source* course.

            However, according to MDL-24518, this should be controlled by the capability moodle/backup:backuptargetimport .

            To reproduce, on a Moodle installation in standard setup:
            * Create two courses, called "source" and "target". Create some labels in "source" (as example content).
            * On "source", allow the following capabilities for the non-editing teacher role:
            ** moodle/backup:backupcourse
            ** moodle/backup:configure
            ** moodle/backup:backuptargetimport
            * Create a user "U" and enrol the user as follows:
            ** into "source" as non-editing teacher,
            ** into "target" as editing teacher.
            * Log in as "U".
            * Go to "target" and click on "Import".

            EXPECTED: The list of courses displayed contains the course "source".
            ACTUAL: The list of courses displayed contains only the course "target".

            The underlying problem is that the list is filtered by courses on which the user "U" has the capability moodle/restore:restorecourse . This is done in the constructor of class import_course_search, which is inherited without modification from class restore_course_search.

            Patch will follow.
            Hide
            Henning Bostelmann added a comment -

            MDL-24518 not fixed in Moodle 2.x

            Show
            Henning Bostelmann added a comment - MDL-24518 not fixed in Moodle 2.x
            Henning Bostelmann made changes -
            Link This issue has a non-specific relationship to MDL-24518 [ MDL-24518 ]
            Hide
            Henning Bostelmann added a comment -

            This fix filters the list by moodle/backup:backuptargetimport . I'm not sure whether the other two capabilities (moodle/backup:backupcourse, moodle/backup:configure) are actually needed - and should be included in the filter - or whether the fact that they are needed is a different aspect of the bug. (If you remove them, the import seems to fail at a later stage.)

            I'm providing the fix for the master branch only, will backport it once it's agreed.

            Show
            Henning Bostelmann added a comment - This fix filters the list by moodle/backup:backuptargetimport . I'm not sure whether the other two capabilities (moodle/backup:backupcourse, moodle/backup:configure) are actually needed - and should be included in the filter - or whether the fact that they are needed is a different aspect of the bug. (If you remove them, the import seems to fail at a later stage.) I'm providing the fix for the master branch only, will backport it once it's agreed.
            Henning Bostelmann made changes -
            Status Open [ 1 ] Peer review in progress [ 10013 ]
            Pull Master Diff URL https://github.com/bostelm/moodle/compare/master...MDL-29072
            Pull Master Branch MDL-29072
            Assignee Eloy Lafuente (stronk7) [ stronk7 ] Henning Bostelmann [ bostelm ]
            Peer reviewer stronk7
            Testing Instructions On a Moodle installation in standard setup:

                * Create two courses, called "source" and "target". Create some labels in "source" (as example content).
                * On "source", allow the following capabilities for the non-editing teacher role:
                      o moodle/backup:backupcourse
                      o moodle/backup:configure
                      o moodle/backup:backuptargetimport
                * Create a user "U" and enrol the user as follows:
                      o into "source" as non-editing teacher,
                      o into "target" as editing teacher.
                * Log in as "U".
                * Go to "target" and click on "Import".

            Verify that the course "source" appears in the list. Select "source" and proceed with the import.

            Hide
            Henning Bostelmann added a comment -

            sorry, must have pushed the wrong button

            Show
            Henning Bostelmann added a comment - sorry, must have pushed the wrong button
            Henning Bostelmann made changes -
            Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
            Hide
            Henning Bostelmann added a comment -

            now requesting peer review!

            Show
            Henning Bostelmann added a comment - now requesting peer review!
            Henning Bostelmann made changes -
            Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
            Henning Bostelmann made changes -
            Link This issue has a non-specific relationship to MDL-28488 [ MDL-28488 ]
            Hide
            Eloy Lafuente (stronk7) added a comment -

            Nice one Henning, this does not fix the use case commented in MDL-28488, but is 100x100 correct IMO. The list of courses FROM which content can be imported is 'moodle/backup:backuptargetimport'.

            And the fix seems pretty correct, so sending to integration.

            NOTE for integrators: This should be backported to 20 and 21 stable, hopefully it applies ok.

            Show
            Eloy Lafuente (stronk7) added a comment - Nice one Henning, this does not fix the use case commented in MDL-28488 , but is 100x100 correct IMO. The list of courses FROM which content can be imported is 'moodle/backup:backuptargetimport'. And the fix seems pretty correct, so sending to integration. NOTE for integrators: This should be backported to 20 and 21 stable, hopefully it applies ok.
            Eloy Lafuente (stronk7) made changes -
            Original Estimate 0 minutes [ 0 ]
            Remaining Estimate 0 minutes [ 0 ]
            Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
            Testing Instructions On a Moodle installation in standard setup:

                * Create two courses, called "source" and "target". Create some labels in "source" (as example content).
                * On "source", allow the following capabilities for the non-editing teacher role:
                      o moodle/backup:backupcourse
                      o moodle/backup:configure
                      o moodle/backup:backuptargetimport
                * Create a user "U" and enrol the user as follows:
                      o into "source" as non-editing teacher,
                      o into "target" as editing teacher.
                * Log in as "U".
                * Go to "target" and click on "Import".

            Verify that the course "source" appears in the list. Select "source" and proceed with the import.

            On a Moodle installation (21_STABLE) in standard setup:

                * Create two courses, called "source" and "target". Create some labels in "source" (as example content).
                * On "source", allow the following capabilities for the non-editing teacher role:
                      o moodle/backup:backupcourse
                      o moodle/backup:configure
                      o moodle/backup:backuptargetimport
                * Create a user "U" and enrol the user as follows:
                      o into "source" as non-editing teacher,
                      o into "target" as editing teacher.
                * Log in as "U".
                * Go to "target" and click on "Import".

            Verify that the course "source" appears in the list. Select "source" and proceed with the import.

            Eloy Lafuente (stronk7) made changes -
            Fix Version/s 2.0.5 [ 10950 ]
            Fix Version/s 2.1.2 [ 10851 ]
            Affects Version/s 2.0.4 [ 10652 ]
            Affects Version/s 2.2 [ 10656 ]
            Eloy Lafuente (stronk7) made changes -
            Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
            Eloy Lafuente (stronk7) made changes -
            Status Development in progress [ 3 ] Waiting for integration review [ 10010 ]
            Pull from Repository git://github.com/bostelm/moodle.git
            Sam Hemelryk made changes -
            Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
            Integrator samhemelryk
            Currently in integration Yes
            Hide
            Sam Hemelryk added a comment -

            Thanks guys, this has been integrated now

            Show
            Sam Hemelryk added a comment - Thanks guys, this has been integrated now
            Sam Hemelryk made changes -
            Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
            Hide
            Eloy Lafuente (stronk7) added a comment -

            Side note: I've added extra commit fixing invalid whitespace occurrences.

            Show
            Eloy Lafuente (stronk7) added a comment - Side note: I've added extra commit fixing invalid whitespace occurrences.
            Andrew Davis made changes -
            Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
            Tester andyjdavis
            Hide
            Andrew Davis added a comment -

            Works as expected. Thankyou for the detailed testing instructions

            Show
            Andrew Davis added a comment - Works as expected. Thankyou for the detailed testing instructions
            Andrew Davis made changes -
            Status Testing in progress [ 10011 ] Tested [ 10006 ]
            Hide
            Eloy Lafuente (stronk7) added a comment -

            git & cvs repositories updated with your gorgeous code. Many thanks!

            Closing and ciao

            Show
            Eloy Lafuente (stronk7) added a comment - git & cvs repositories updated with your gorgeous code. Many thanks! Closing and ciao
            Eloy Lafuente (stronk7) made changes -
            Status Tested [ 10006 ] Closed [ 6 ]
            Resolution Fixed [ 1 ]
            Currently in integration Yes
            Integration date 7/Sep/11
            Hide
            Gisele Brugger added a comment -

            Can see this.. the problem is in moodle 2.2.1

            http://moodle.org/mod/forum/discuss.php?d=167476#p860668

            Show
            Gisele Brugger added a comment - Can see this.. the problem is in moodle 2.2.1 http://moodle.org/mod/forum/discuss.php?d=167476#p860668
            Helen Foster made changes -
            Labels patch
            Hide
            Sam Hemelryk added a comment -

            Hi Gisele,

            Looks like Eloy has replied on the forum and pointed you towards MDL-26037 about resolving this.

            Cheers
            Sam

            Show
            Sam Hemelryk added a comment - Hi Gisele, Looks like Eloy has replied on the forum and pointed you towards MDL-26037 about resolving this. Cheers Sam

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: