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

Course category deletion action is not shown, while deletion with content move might be possible.

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      There are 3 different test scenarios that needs to be used.

      Pre-requirements

      1. Create test user and allocate it a Manager role (Users -> Permissions ->Assign system roles)
      2. Create category CAT1 at top level
      3. Within CAT1 create categories CAT11 and CAT12
      4. Within CAT11 create course CR1

      No permission to delete ("Manage categories" prohibited)

      In this scenario user does not have category management permission and therefore not able to delete category.

      Change permissions

      1. As admin, navigate to "Manage courses and categories"
      2. Open "Permissions" for CAT1, find "Manage categories" and delete "Manager" role against it.

      Test

      1. Login as test user (you may do it in incognito window or in a different browser not to re-login each time we need to change permissions as admin)
      2. Navigate to "Manage courses and categories"
      3. Observe CAT1 category does not have "Delete" option in the action menu.
      4. Observe "Miscellaneous" category has "Delete" option in the action menu.

      Restore permissions

      1. As admin, navigate to "Manage courses and categories"
      2. Open "Permissions" for CAT1, find "Manage categories" and add "Manager" role permission.

      No permission to delete ("Delete course" and "Create course" prohibited)

      In this scenario user does not have course delete permission and not able to create course in other categories either, therefore not able to delete category CAT11, but able to delete empty category CAT12.

      Change permissions

      1. As admin, navigate to "Manage courses and categories"
      2. Open "Permissions" for CAT11, find "Delete courses" and delete "Manager" role against it.
      3. Open "Permissions" for CAT1, find "Create courses" and delete "Manager" role against it.
      4. Open "Permissions" for "Miscellaneous", find "Create courses" and delete "Manager" role against it.

      Test

      1. Login as test user
      2. Navigate to "Manage courses and categories"
      3. Observe CAT11 category does not have "Delete" option in the action menu.
      4. Observe CAT12 category has "Delete" option in the action menu.

      Restore permissions

      1. As admin, navigate to "Manage courses and categories"
      2. Open "Permissions" for CAT11, find "Delete courses" and add "Manager" role permission.
      3. Open "Permissions" for CAT1, find "Create courses" and add "Manager" role permission.
      4. Open "Permissions" for "Miscellaneous", find "Create courses" and add "Manager" role permission.

      Permission to delete which was not available before this patch ("Delete course" prohibited, but "Create course" is permitted in another category)

      In this scenario user does not have course delete permission, but able to create course in other categories, therefore user is able to delete category CAT11 when its content will be moved on deletion.

      Change permissions

      1. As admin, navigate to "Manage courses and categories"
      2. Open "Permissions" for CAT11, find "Delete courses" and delete "Manager" role against it.

      Test

      1. Login as test user (if you are using incognito window or a different browser, you may actually need to re-login if Delete option at step 3 does not appear for you)
      2. Navigate to "Manage courses and categories"
      3. Observe CAT11 category has "Delete" option in the action menu, click on "Delete"
      4. Category deletion interface is presented.
      5. Observe "What to do" has only one option "Move contents to another category" (shown as text)
      6. Observe "Move into" has a selection of all remaining categories that exist in the system.
      7. Select "CAT1 / CAT12" in the "Move into" select element, click on "Delete"
      8. Observe that CAT11 has been deleted and CR1 course was moved into CAT12.

      Restore permissions

      1. Permission restoring is not required as CAT11 was deleted.
      Show
      There are 3 different test scenarios that needs to be used. Pre-requirements Create test user and allocate it a Manager role (Users -> Permissions ->Assign system roles) Create category CAT1 at top level Within CAT1 create categories CAT11 and CAT12 Within CAT11 create course CR1 No permission to delete ("Manage categories" prohibited) In this scenario user does not have category management permission and therefore not able to delete category. Change permissions As admin, navigate to "Manage courses and categories" Open "Permissions" for CAT1, find "Manage categories" and delete "Manager" role against it. Test Login as test user (you may do it in incognito window or in a different browser not to re-login each time we need to change permissions as admin) Navigate to "Manage courses and categories" Observe CAT1 category does not have "Delete" option in the action menu. Observe "Miscellaneous" category has "Delete" option in the action menu. Restore permissions As admin, navigate to "Manage courses and categories" Open "Permissions" for CAT1, find "Manage categories" and add "Manager" role permission. No permission to delete ("Delete course" and "Create course" prohibited) In this scenario user does not have course delete permission and not able to create course in other categories either, therefore not able to delete category CAT11, but able to delete empty category CAT12. Change permissions As admin, navigate to "Manage courses and categories" Open "Permissions" for CAT11, find "Delete courses" and delete "Manager" role against it. Open "Permissions" for CAT1, find "Create courses" and delete "Manager" role against it. Open "Permissions" for "Miscellaneous", find "Create courses" and delete "Manager" role against it. Test Login as test user Navigate to "Manage courses and categories" Observe CAT11 category does not have "Delete" option in the action menu. Observe CAT12 category has "Delete" option in the action menu. Restore permissions As admin, navigate to "Manage courses and categories" Open "Permissions" for CAT11, find "Delete courses" and add "Manager" role permission. Open "Permissions" for CAT1, find "Create courses" and add "Manager" role permission. Open "Permissions" for "Miscellaneous", find "Create courses" and add "Manager" role permission. Permission to delete which was not available before this patch ("Delete course" prohibited, but "Create course" is permitted in another category) In this scenario user does not have course delete permission, but able to create course in other categories, therefore user is able to delete category CAT11 when its content will be moved on deletion. Change permissions As admin, navigate to "Manage courses and categories" Open "Permissions" for CAT11, find "Delete courses" and delete "Manager" role against it. Test Login as test user (if you are using incognito window or a different browser, you may actually need to re-login if Delete option at step 3 does not appear for you) Navigate to "Manage courses and categories" Observe CAT11 category has "Delete" option in the action menu, click on "Delete" Category deletion interface is presented. Observe "What to do" has only one option "Move contents to another category" (shown as text) Observe "Move into" has a selection of all remaining categories that exist in the system. Select "CAT1 / CAT12" in the "Move into" select element, click on "Delete" Observe that CAT11 has been deleted and CR1 course was moved into CAT12. Restore permissions Permission restoring is not required as CAT11 was deleted.
    • Affected Branches:
      MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_39_STABLE
    • Pull Master Branch:
      MDL-68583-master

      Description

      This has been discovered while working on MDL-67548.

      The deletion form allows to have option "deletion with move" if "full deletion" is not permitted: https://github.com/moodle/moodle/blob/master/course/classes/deletecategory_form.php#L56
      But, user will never see the form in this layout, because of this permission check for the deletion action: https://github.com/moodle/moodle/blob/master/course/classes/management/helper.php#L247

        Attachments

        1. cat_del_move.png
          cat_del_move.png
          19 kB
        2. Screenshot_1.png
          Screenshot_1.png
          74 kB
        3. Screenshot_2.png
          Screenshot_2.png
          103 kB
        4. Screenshot_3.png
          Screenshot_3.png
          117 kB

          Issue Links

            Activity

              People

              Assignee:
              kabalin Ruslan Kabalin
              Reporter:
              kabalin Ruslan Kabalin
              Peer reviewer:
              Paul Holden
              Integrator:
              Sara Arjona (@sarjona)
              Tester:
              Janelle Barcega
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                15/Jun/20

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 6 hours, 8 minutes
                  6h 8m