Moodle
  1. Moodle
  2. MDL-34648

New capability to move a section in a course

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.2
    • Fix Version/s: 2.4
    • Component/s: Course
    • Testing Instructions:
      Hide

      Test pre-requisites

      • Do not upgrade yet, first test require you to test the update
      • A course with topic format
      • Some activities/resources
      • Some sections with other names than defaults
      • Remove the following capabilities from Teacher at Course level
        • moodle/course:movesections
      • Javascript disabled in your browser's settings

      Test #1

      1. Use an outdated Moodle 2.4dev
      2. Navigate to Home ► Site administration ► Users ► Permissions ► Define roles
      3. Create a new role called 'Obi-Wan Kenobi' with archetype student and system/category/course context
      4. Give the capability moodle/course:update to this role
      5. Now update your Moodle so that this patch
      6. Run the upgrade script via Home ► Site administration ► Notifications
      7. Make sure the role 'Obi-Wan Kenobi' has the capability moodle/course:movesections set to allow

      Test #2

      1. As a teacher access the course
      2. Make sure you CAN'T move a section
      3. Enable JavaScript in your browser, and refresh the page
      4. Make sure you CAN'T move a section
      • As an admin, enable moodle/course:movesections for Teacher at Course level
      1. As a teacher access the course
      2. Make sure you CAN now move a section
      3. Disable JavaScript in your browser, and refresh the page
      4. Make sure you CAN now move a section

      Bonus points

      Hack course/format/renderer.php and course/format/topics/renderer.php section_edit_controls() to display the actions, and check that they don't work without the capability with/without JavaScript.

      Show
      Test pre-requisites Do not upgrade yet, first test require you to test the update A course with topic format Some activities/resources Some sections with other names than defaults Remove the following capabilities from Teacher at Course level moodle/course:movesections Javascript disabled in your browser's settings Test #1 Use an outdated Moodle 2.4dev Navigate to Home ► Site administration ► Users ► Permissions ► Define roles Create a new role called 'Obi-Wan Kenobi' with archetype student and system/category/course context Give the capability moodle/course:update to this role Now update your Moodle so that this patch Run the upgrade script via Home ► Site administration ► Notifications Make sure the role 'Obi-Wan Kenobi' has the capability moodle/course:movesections set to allow Test #2 As a teacher access the course Make sure you CAN'T move a section Enable JavaScript in your browser, and refresh the page Make sure you CAN'T move a section As an admin, enable moodle/course:movesections for Teacher at Course level As a teacher access the course Make sure you CAN now move a section Disable JavaScript in your browser, and refresh the page Make sure you CAN now move a section Bonus points Hack course/format/renderer.php and course/format/topics/renderer.php section_edit_controls() to display the actions, and check that they don't work without the capability with/without JavaScript.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-34648-master
    • Rank:
      43093

      Description

      Create a new capability to control the user permissions to move a section within a course

        Activity

        Hide
        Rajesh Taneja added a comment -

        Hello Fred,

        Patch looks spot-on, but I am not sure if we need another capability for movesection.
        IMO course:update capability should let user move section as well.
        Feel free to push it for integration if you think this is required.

        NOTE: You have one extra commit from MDL-28207 (d3bb33b) which you might want to remove before pushing it for integration.

        FYI: I did a quick search and couldn't find any request for similar capability.

        Show
        Rajesh Taneja added a comment - Hello Fred, Patch looks spot-on, but I am not sure if we need another capability for movesection. IMO course:update capability should let user move section as well. Feel free to push it for integration if you think this is required. NOTE: You have one extra commit from MDL-28207 (d3bb33b) which you might want to remove before pushing it for integration. FYI: I did a quick search and couldn't find any request for similar capability.
        Hide
        Frédéric Massart added a comment -

        Hi Raj, thank you for your review. I have rebased my branch so that the extra commit disappeared. That new capability comes from the linked issue in which we decided to add it as a separate issue. I think we're good for integration.

        Cheers

        Show
        Frédéric Massart added a comment - Hi Raj, thank you for your review. I have rebased my branch so that the extra commit disappeared. That new capability comes from the linked issue in which we decided to add it as a separate issue. I think we're good for integration. Cheers
        Hide
        Dan Poltawski added a comment -

        Hi Fred,

        This looks fine but there is one minor issue.

        Can you add to the capability definition (like in some other capabilities definitions).
        'clonepermissionsfrom' => 'moodle/course:update'

        This will ensure that the new capability is given to everyone who previously had course:update, even if the role is not part of an archtype. Can you also add a testing steps to test that this works (create one custom role with course:update, run upgrade etc).

        Show
        Dan Poltawski added a comment - Hi Fred, This looks fine but there is one minor issue. Can you add to the capability definition (like in some other capabilities definitions). 'clonepermissionsfrom' => 'moodle/course:update' This will ensure that the new capability is given to everyone who previously had course:update, even if the role is not part of an archtype. Can you also add a testing steps to test that this works (create one custom role with course:update, run upgrade etc).
        Hide
        Frédéric Massart added a comment -

        Thanks Dan. This has been done!

        Show
        Frédéric Massart added a comment - Thanks Dan. This has been done!
        Hide
        Dan Poltawski added a comment -

        Integrated, thanks!

        Show
        Dan Poltawski added a comment - Integrated, thanks!
        Hide
        Adrian Greeve added a comment -

        Tested with an older version of 2.4.
        Test #1 passed
        Test #2 passed

        Please note: No bonus points acquired.

        Show
        Adrian Greeve added a comment - Tested with an older version of 2.4. Test #1 passed Test #2 passed Please note: No bonus points acquired.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        YEAR!*

        CAF*, TOT!*

        • Your effort amazingly resulted. (unbelievable :-P)
        • Closing as fixed.
        • Tons of thanks.
        Show
        Eloy Lafuente (stronk7) added a comment - YEAR!* CAF*, TOT!* Your effort amazingly resulted. (unbelievable :-P) Closing as fixed. Tons of thanks.
        Hide
        Helen Foster added a comment -

        Fred, thanks for this new capability in Moodle 2.4, which is now documented http://docs.moodle.org/24/en/Capabilities/moodle/course:movesections with a mention on http://docs.moodle.org/24/en/Course_homepage If I've got anything wrong, please shout!

        Show
        Helen Foster added a comment - Fred, thanks for this new capability in Moodle 2.4, which is now documented http://docs.moodle.org/24/en/Capabilities/moodle/course:movesections with a mention on http://docs.moodle.org/24/en/Course_homepage If I've got anything wrong, please shout!

          People

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

            Dates

            • Created:
              Updated:
              Resolved: