Moodle
  1. Moodle
  2. MDL-32005

groups and groupings should have 'idnumber' field

    Details

    • Testing Instructions:
      Hide

      These test instructions will:

      • Create some initial test data
      • Attempt to manipulate (edit, delete) it both:
        • with permission to change the idnumber; and
        • without permission to change the idnumber.
      • test uniqueness constraints
      • test backup/restore of group(ing)s with idnumbers
      • test importing data from CSV
      • test automatic creation of groups and placement into groupings

      Note: The idnumber has been marked as an advanced setting in the forms. You will need to toggle the Show Advanced button to reveal it.

      Run Unit Tests

      A set of unit tests have been created for this feature. These can either be run as a full set of unit tests, or in isolation with:

      phpunit --verbose lib/tests/grouplib_test.php

      Create Test Data

      • Navigate to Settings -> Course administration -> Users -> Groups
      • Create new groups:
        name idnumber
        group-id-1 group-id-1
        group-id-2 group-id-2
        group-noid-1  
        group-noid-2  
      • Open the Groupings tab
      • Create new groupings:
        name idnumber
        grouping-id-1 grouping-id-1
        grouping-id-2 grouping-id-2
        grouping-noid-1  
        grouping-noid-2  

      Test initial deletion

      As a teacher:

      • Open the 'Groups' tab again
      • Select group-id-1
      • Choose 'Delete selected group'
        • Choose yes on the confirmation page
        • Confirm that the group was removed
      • Select group-noid-1
      • Choose 'Delete selected group'
        • Choose yes on the confirmation page
        • Confirm that the group was removed
      • Open the 'Groupings' tab
      • Choose the delete icon on grouping-id-1
        • Choose yes on the confirmation page
        • Confirm that the grouping was removed
      • Choose the delete icon on grouping-noid-1
        • Choose yes on the confirmation page
        • Confirm that the grouping was removed

      Remove permission

      • Remove the moodle/course:changeidnumber capability from the editingteacher role

      Re-Test deletion

      As a teacher:

      • Open the 'Groups' tab again
      • Select group-id-2
      • The delete button should be greyed out

      For extra brownie points, open an inspector and un-grey it

      • Choose 'Delete selected group'
        • Confirm that an error was shown informing the user that they cannot remove the group
      • Select group-noid-2
        • Confirm that the Delete selected group button is no longer greyed out
      • Select both group-id-2 and group-noid-2
        • Confirm that the button is once again greyed out
      • Select group-noid-2
      • Choose 'Delete selected group'
        • Choose yes on the confirmation page
        • Confirm that the group was removed
      • Open the 'Groupings' tab
      • Confirm that there is no delete icon for grouping-id-2
        • Make a note of the id in the address bar for the Grouping-2 edit page
      • Choose the delete icon on grouping-noid-2
        • Replace the id in the address bar with that of grouping-id-2
      • Choose the delete icon on grouping-noid-2
        • Choose yes on the confirmation page
        • Confirm that the grouping was removed

      Test data re-entry

      • Choose the 'Groups' tab again
      • Click the 'Create group' button
      • Create a new group:
        • Use a group name of group-noid-3
        • Confirm that it is not possible to set the idnumber any more
        • Click 'Save changes'
      • Open the 'Groupings' tab again
      • Click the 'Create grouping' button
      • Create a new grouping:
        • Use a grouping name of grouping-noid-3
        • Confirm that it is not possible to set the idnumber any more
        • Click 'Save changes'

      Test update existing entries

      Groups

      Choose the 'Groups' tab again

      • Select group-id-2
      • Choose 'Edit group settings'
        • Change the group name to group-id-2-updated
        • Confirm that you cannot change the idnumber
        • Choose save
      • Select the same group again and click the 'Edit group settings' button
        • Confirm the new name
        • Confirm that the idnumber is still present

      Groupings

      Choose the 'Groupings' tab again

      • Select the edit icon for grouping-id-2
        • Change the group name to grouping-id-2-updated
        • Confirm that you cannot change the idnumber
        • Choose save
      • Select the edit icon for the grouping again
        • Confirm the new name
        • Confirm that the idnumber is still present

      Testing with a user with the permission

      Login as admin

      Groups

      Choose the Groups tab

      • Select group-id-2-updated and choose 'Edit group settings'
        • Change the name again to group-id-2
        • Change the idnumber to group-id-two
        • Choose save settings
      • Select the group again and edit it's settings again
        • Confirm that the new name took
        • Confirm that the idnumber was changed
      • Go back to the edit page
      • Select the group and choose 'Delete selected group'
      • Click yes on the confirmation page
      • Confirm that the group was removed
      • Remove group-noid-3

      Groupings

      Choose the Groupings tab

      • Select grouping-id-2-updated's edit button
        • Change the name to grouping-id-2
        • Change the idnumber
        • Choose save settings
      • Select the grouping again and edit it's settings again
        • Confirm that the new name took
        • Confirm that the idnumber was changed
      • Go back to the edit page
      • Select grouping-id-2's delete button
      • Click yes on the confirmation page
      • Confirm that the group was removed
      • Remove grouping-noid-3

      Testing Uniqueness

      User: As a user with permission to change the idnumber
      These tests check that it is not possible to create group(ing)s with a duplicate idnumber. Please note that:

      • idnumbers are unique within a 'course' (not sitewide); and
      • it is possible to have blank idnumbers for multiple items but this was tested in the initial data creation test instructions.

      Groups

      Navigate to the Groups tab again:

      • Choose Create Group:
      • Choose Create Group:
        • name 'group-x'
        • idnumber 'MDL-32005'
        • Confirm that the group was not created and an error was shown on the form
        • Change the idnumber to 'group-x' and save
      • Re-edit 'group-x':
        • Update idnumber to 'MDL-32005'
        • Choose Save
        • Confirm that the group was not updated and an error was shown on the form
      • Delete both groups

      Groupings

      Navigate to the Groupings tab again:

      • Choose Create Grouping:
      • Choose Create Grouping:
        • name 'grouping-x'
        • idnumber 'MDL-32005'
        • Confirm that the group was not created and an error was shown on the form
        • Change the idnumber to 'grouping-x' and save
      • Re-edit 'grouping-x':
        • Update idnumber to 'MDL-32005'
        • Choose Save
        • Confirm that the group was not updated and an error was shown on the form
      • Delete both groupings

      Backup/Restore with permissions

      User: As an administrator (permission required to backup user data)

      Create several groups:

      Group Name idnumber
      group-id-1 group-id-1
      group-id-2 group-id-2
      group-noid-1  
      group-noid-2  

      And a pair of groupings:

      Name idnumber
      grouping-id grouping-id
      grouping-noid  

      Create a backup of the course including user data

      As user with permission to changeidnumber

      • Delete the following groups:
        • group-id-1
        • group-noid-1
      • Delete both groupings
      • Restore the backup
        • Confirm that:
        • All four groups are back with relevant idnumbers
        • both groupings are back with relevant idnumbers

      To prepare for the next set of tests:

      • Delete the following groups:
        • group-id-1
        • group-noid-1
      • Delete both groupings

      As user without permission to changeidnumber

      • Restore the backup
        • Confirm that:
        • All four groups are back but the re-created groups have no idnumber
        • both groupings are back but have no idnumber

      Note: The behaviour of restoring groups but not adding group members is consistent with existing behaviour

      Importing Groups with an idnumber

      The 'idnumber' field in group import from CSV is already reserved for the course idnumber.

      • Create a new CSV file as follows:

        groupname, description, groupidnumber
        group-id-1, group-id-1, group-id-1
        group-id-2, group-id-2, group-id-2
        group-id-1-duplicate, Duplicate of group-id-1, group-id-1
        group-noid-1, group-noid-1,
        group-noid-2, group-noid-2,

      As user with permission to changeidnumber

      • Remove all of the existing groups and groupings
      • Import the CSV file
      • Confirm:
        • All five groups were created
        • A warning was shown confirming that the idnumber for group-id-1-duplicate already existed
        • group-id-1 and group-id-2 have the correct idnumber
        • group-id-1-duplicate, group-noid-1 and group-noid-2 have no idnumber
      • Remove all of the existing groups and groupings

      As user without permission to changeidnumber

      • Import the CSV file
      • Confirm:
        • All five groups were created
        • None of the groups have an idnumber

      Automatic Creation of groups

      The idnumber changes shouldn't affect automatic creation of groups

      • Create a course with a number of students enrolled within it (e.g. 10)
      • Open the Groups tab
      • Choose 'Auto-create groups'
      • Specify:
        • Group/member count: 2
        • Create in grouping: New Grouping
        • Grouping Name: MDL-32005
      • Preview and submit - ensure that groups and the grouping are created correctly with no idnumber
      Show
      These test instructions will: Create some initial test data Attempt to manipulate (edit, delete) it both: with permission to change the idnumber; and without permission to change the idnumber. test uniqueness constraints test backup/restore of group(ing)s with idnumbers test importing data from CSV test automatic creation of groups and placement into groupings Note: The idnumber has been marked as an advanced setting in the forms. You will need to toggle the Show Advanced button to reveal it. Run Unit Tests A set of unit tests have been created for this feature. These can either be run as a full set of unit tests, or in isolation with: phpunit --verbose lib/tests/grouplib_test.php Create Test Data Navigate to Settings -> Course administration -> Users -> Groups Create new groups: name idnumber group-id-1 group-id-1 group-id-2 group-id-2 group-noid-1   group-noid-2   Open the Groupings tab Create new groupings: name idnumber grouping-id-1 grouping-id-1 grouping-id-2 grouping-id-2 grouping-noid-1   grouping-noid-2   Test initial deletion As a teacher: Open the 'Groups' tab again Select group-id-1 Choose 'Delete selected group' Choose yes on the confirmation page Confirm that the group was removed Select group-noid-1 Choose 'Delete selected group' Choose yes on the confirmation page Confirm that the group was removed Open the 'Groupings' tab Choose the delete icon on grouping-id-1 Choose yes on the confirmation page Confirm that the grouping was removed Choose the delete icon on grouping-noid-1 Choose yes on the confirmation page Confirm that the grouping was removed Remove permission Remove the moodle/course:changeidnumber capability from the editingteacher role Re-Test deletion As a teacher: Open the 'Groups' tab again Select group-id-2 The delete button should be greyed out For extra brownie points, open an inspector and un-grey it Choose 'Delete selected group' Confirm that an error was shown informing the user that they cannot remove the group Select group-noid-2 Confirm that the Delete selected group button is no longer greyed out Select both group-id-2 and group-noid-2 Confirm that the button is once again greyed out Select group-noid-2 Choose 'Delete selected group' Choose yes on the confirmation page Confirm that the group was removed Open the 'Groupings' tab Confirm that there is no delete icon for grouping-id-2 Make a note of the id in the address bar for the Grouping-2 edit page Choose the delete icon on grouping-noid-2 Replace the id in the address bar with that of grouping-id-2 Choose the delete icon on grouping-noid-2 Choose yes on the confirmation page Confirm that the grouping was removed Test data re-entry Choose the 'Groups' tab again Click the 'Create group' button Create a new group: Use a group name of group-noid-3 Confirm that it is not possible to set the idnumber any more Click 'Save changes' Open the 'Groupings' tab again Click the 'Create grouping' button Create a new grouping: Use a grouping name of grouping-noid-3 Confirm that it is not possible to set the idnumber any more Click 'Save changes' Test update existing entries Groups Choose the 'Groups' tab again Select group-id-2 Choose 'Edit group settings' Change the group name to group-id-2-updated Confirm that you cannot change the idnumber Choose save Select the same group again and click the 'Edit group settings' button Confirm the new name Confirm that the idnumber is still present Groupings Choose the 'Groupings' tab again Select the edit icon for grouping-id-2 Change the group name to grouping-id-2-updated Confirm that you cannot change the idnumber Choose save Select the edit icon for the grouping again Confirm the new name Confirm that the idnumber is still present Testing with a user with the permission Login as admin Groups Choose the Groups tab Select group-id-2-updated and choose 'Edit group settings' Change the name again to group-id-2 Change the idnumber to group-id-two Choose save settings Select the group again and edit it's settings again Confirm that the new name took Confirm that the idnumber was changed Go back to the edit page Select the group and choose 'Delete selected group' Click yes on the confirmation page Confirm that the group was removed Remove group-noid-3 Groupings Choose the Groupings tab Select grouping-id-2-updated's edit button Change the name to grouping-id-2 Change the idnumber Choose save settings Select the grouping again and edit it's settings again Confirm that the new name took Confirm that the idnumber was changed Go back to the edit page Select grouping-id-2's delete button Click yes on the confirmation page Confirm that the group was removed Remove grouping-noid-3 Testing Uniqueness User: As a user with permission to change the idnumber These tests check that it is not possible to create group(ing)s with a duplicate idnumber. Please note that: idnumbers are unique within a 'course' (not sitewide); and it is possible to have blank idnumbers for multiple items but this was tested in the initial data creation test instructions. Groups Navigate to the Groups tab again: Choose Create Group: name ' MDL-32005 ' idnumber ' MDL-32005 ' Confirm Group Creation Choose Create Group: name 'group-x' idnumber ' MDL-32005 ' Confirm that the group was not created and an error was shown on the form Change the idnumber to 'group-x' and save Re-edit 'group-x': Update idnumber to ' MDL-32005 ' Choose Save Confirm that the group was not updated and an error was shown on the form Delete both groups Groupings Navigate to the Groupings tab again: Choose Create Grouping: name ' MDL-32005 ' idnumber ' MDL-32005 ' Confirm Group Creation Choose Create Grouping: name 'grouping-x' idnumber ' MDL-32005 ' Confirm that the group was not created and an error was shown on the form Change the idnumber to 'grouping-x' and save Re-edit 'grouping-x': Update idnumber to ' MDL-32005 ' Choose Save Confirm that the group was not updated and an error was shown on the form Delete both groupings Backup/Restore with permissions User: As an administrator (permission required to backup user data) Create several groups: Group Name idnumber group-id-1 group-id-1 group-id-2 group-id-2 group-noid-1   group-noid-2   And a pair of groupings: Name idnumber grouping-id grouping-id grouping-noid   Create a backup of the course including user data As user with permission to changeidnumber Delete the following groups: group-id-1 group-noid-1 Delete both groupings Restore the backup Confirm that: All four groups are back with relevant idnumbers both groupings are back with relevant idnumbers To prepare for the next set of tests: Delete the following groups: group-id-1 group-noid-1 Delete both groupings As user without permission to changeidnumber Restore the backup Confirm that: All four groups are back but the re-created groups have no idnumber both groupings are back but have no idnumber Note: The behaviour of restoring groups but not adding group members is consistent with existing behaviour Importing Groups with an idnumber The 'idnumber' field in group import from CSV is already reserved for the course idnumber. Create a new CSV file as follows: groupname, description, groupidnumber group-id-1, group-id-1, group-id-1 group-id-2, group-id-2, group-id-2 group-id-1-duplicate, Duplicate of group-id-1, group-id-1 group-noid-1, group-noid-1, group-noid-2, group-noid-2, As user with permission to changeidnumber Remove all of the existing groups and groupings Import the CSV file Confirm: All five groups were created A warning was shown confirming that the idnumber for group-id-1-duplicate already existed group-id-1 and group-id-2 have the correct idnumber group-id-1-duplicate, group-noid-1 and group-noid-2 have no idnumber Remove all of the existing groups and groupings As user without permission to changeidnumber Import the CSV file Confirm: All five groups were created None of the groups have an idnumber Automatic Creation of groups The idnumber changes shouldn't affect automatic creation of groups Create a course with a number of students enrolled within it (e.g. 10) Open the Groups tab Choose 'Auto-create groups' Specify: Group/member count: 2 Create in grouping: New Grouping Grouping Name: MDL-32005 Preview and submit - ensure that groups and the grouping are created correctly with no idnumber
    • Difficulty:
      Moderate
    • Affected Branches:
      MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-32005-master-10

      Description

      At present several tables related to users and courses have an idnumber field allowing them to be easily created and maintained by some form of plugin (most likely enrolment). This includes:

      • users
      • cohorts
      • courses
      • course categories

      It would be particularly helpful to many larger institutions if it were possible to also handle groups and groupings in this manner

      Rather than creating a new capability, it would be reasonable to re-use the existing course:changeidnumber capability.

      Additionally, to prevent deletion of automatically created groups, it should not be possible to delete a group if:

      • it has an idnumber set; and
      • the user does not have the moodle/course:changeidnumber capability.

      However if a user does not have the capability but no idnumber is set, it should be possible to remove the group.

        Gliffy Diagrams

          Issue Links

            Activity

            Andrew Nicols created issue -
            Andrew Nicols made changes -
            Field Original Value New Value
            Link This issue has a non-specific relationship to MDL-31973 [ MDL-31973 ]
            Andrew Nicols made changes -
            Summary Course Groups should support idnumber to allow external creation from external source groups and groupings should have 'idnumber' field
            Andrew Nicols made changes -
            Description At present several tables related to users and courses have an idnumber field allowing them to be easily created and maintained by some form of plugin (most likely enrolment). This includes:
            * users
            * cohorts
            * courses
            * course categories

            It would be particularly helpful to many larger institutions if it were possible to also handle groups and groupings in this manner
            At present several tables related to users and courses have an idnumber field allowing them to be easily created and maintained by some form of plugin (most likely enrolment). This includes:
            * users
            * cohorts
            * courses
            * course categories

            It would be particularly helpful to many larger institutions if it were possible to also handle groups and groupings in this manner

            Rather than creating a new capability, it would be reasonable to re-use the existing course:changeidnumber capability.

            Additionally, to prevent deletion of automatically created groups, it should not be possible to delete a group if:
            * it has an idnumber set; and
            * the user does not have the moodle/course:changeidnumber capability.

            However if a user does not have the capability but no idnumber is set, it should be possible to remove the group.
            Andrew Nicols made changes -
            Assignee moodle.com [ moodle.com ] Andrew Nicols [ dobedobedoh ]
            Andrew Nicols made changes -
            Status Open [ 1 ] Development in progress [ 3 ]
            Andrew Nicols made changes -
            Testing Instructions h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create a new group
            ** Specify a name of MDL-32005-1
            ** Specify an idnumber of MDL-32005-1
            * Create another new group
            ** Specify a name of MDL-32005-2
            ** Specify an idnumber of MDL-32005-2
            * Create another new group
            ** Specify a name of MDL-32005-3
            ** Do not specify an idnumber
            * Create another new group
            ** Specify a name of MDL-32005-4
            ** Do not specify an idnumber

            * Open the Groupings tab
            * Create a new grouping
            ** Specify a name of Grouping-1
            ** Specify an idnumber of Grouping-1
            * Create another new grouping
            ** Specify a name of Grouping-2
            ** Specify an idnumber of Grouping-2
            Andrew Nicols made changes -
            Pull Master Diff URL https://git.luns.net.uk/?p=moodle.git;a=commitdiff;h=c62f059a909ab38f09e342703aebd6788d4c4395
            Pull Master Branch MDL-32005-master-1
            Testing Instructions h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create a new group
            ** Specify a name of MDL-32005-1
            ** Specify an idnumber of MDL-32005-1
            * Create another new group
            ** Specify a name of MDL-32005-2
            ** Specify an idnumber of MDL-32005-2
            * Create another new group
            ** Specify a name of MDL-32005-3
            ** Do not specify an idnumber
            * Create another new group
            ** Specify a name of MDL-32005-4
            ** Do not specify an idnumber

            * Open the Groupings tab
            * Create a new grouping
            ** Specify a name of Grouping-1
            ** Specify an idnumber of Grouping-1
            * Create another new grouping
            ** Specify a name of Grouping-2
            ** Specify an idnumber of Grouping-2
            h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create a new group
            ** Specify a name of MDL-32005-1
            ** Specify an idnumber of MDL-32005-1
            * Create another new group
            ** Specify a name of MDL-32005-2
            ** Specify an idnumber of MDL-32005-2
            * Create another new group
            ** Specify a name of MDL-32005-3
            ** Do not specify an idnumber
            * Create another new group
            ** Specify a name of MDL-32005-4
            ** Do not specify an idnumber

            * Open the Groupings tab
            * Create a new grouping
            ** Specify a name of Grouping-1
            ** Specify an idnumber of Grouping-1
            * Create another new grouping
            ** Specify a name of Grouping-2
            ** Specify an idnumber of Grouping-2
            * Create another new grouping
            ** Specify a name of Grouping-3
            ** Do not specify an idnumber
            * Create another new grouping
            ** Specify a name of Grouping-4
            ** Do not specify an idnumber

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select MDL-32005-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select MDL-32005-3
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on Grouping-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on Grouping-3
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select MDL-32005-1 (has idnumber)
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select MDL-32005-3 (no idnumber)
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for Grouping-2 (idnumber)
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on Grouping-4 (no idnumber)
            ** Replace the id in the address bar with that of Grouping-2
            * Choose the delete icon on Grouping-4 (no idnumber)
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of 'MDL-32005-5'
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping nam eof 'Grouping-5'
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            * Choose the 'Groups' tab again
            * Select MDL-32005-2 (has idnumber)
            * Choose 'Edit group settings'
            ** Change the group name to 'MDL-32005-2 modified'
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h3. Testing with a user with the permission
            Login as admin and navigate to the Groups page
            * Select MDL-32005-2 and choose 'Edit group settings'
            ** Change the name again
            ** Change the idnumber
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed

            * Choose the 'Groupings' tab
            * Select Grouping-2's edit button
            ** Change the name again
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select Grouping-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed
            Pull from Repository git://git.luns.net.uk/moodle.git
            Labels patch
            Difficulty Moderate [ 10024 ]
            Andrew Nicols made changes -
            Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
            Dan Poltawski made changes -
            Original Estimate 0 minutes [ 0 ]
            Remaining Estimate 0 minutes [ 0 ]
            Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
            Peer reviewer poltawski
            Dan Poltawski made changes -
            Labels patch patch triaged
            Dan Poltawski made changes -
            Fix Version/s DEV backlog [ 10464 ]
            Dan Poltawski made changes -
            Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
            Andrew Nicols made changes -
            Testing Instructions h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create a new group
            ** Specify a name of MDL-32005-1
            ** Specify an idnumber of MDL-32005-1
            * Create another new group
            ** Specify a name of MDL-32005-2
            ** Specify an idnumber of MDL-32005-2
            * Create another new group
            ** Specify a name of MDL-32005-3
            ** Do not specify an idnumber
            * Create another new group
            ** Specify a name of MDL-32005-4
            ** Do not specify an idnumber

            * Open the Groupings tab
            * Create a new grouping
            ** Specify a name of Grouping-1
            ** Specify an idnumber of Grouping-1
            * Create another new grouping
            ** Specify a name of Grouping-2
            ** Specify an idnumber of Grouping-2
            * Create another new grouping
            ** Specify a name of Grouping-3
            ** Do not specify an idnumber
            * Create another new grouping
            ** Specify a name of Grouping-4
            ** Do not specify an idnumber

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select MDL-32005-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select MDL-32005-3
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on Grouping-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on Grouping-3
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select MDL-32005-1 (has idnumber)
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select MDL-32005-3 (no idnumber)
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for Grouping-2 (idnumber)
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on Grouping-4 (no idnumber)
            ** Replace the id in the address bar with that of Grouping-2
            * Choose the delete icon on Grouping-4 (no idnumber)
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of 'MDL-32005-5'
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping nam eof 'Grouping-5'
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            * Choose the 'Groups' tab again
            * Select MDL-32005-2 (has idnumber)
            * Choose 'Edit group settings'
            ** Change the group name to 'MDL-32005-2 modified'
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h3. Testing with a user with the permission
            Login as admin and navigate to the Groups page
            * Select MDL-32005-2 and choose 'Edit group settings'
            ** Change the name again
            ** Change the idnumber
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed

            * Choose the 'Groupings' tab
            * Select Grouping-2's edit button
            ** Change the name again
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select Grouping-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed
            These test instructions will:
            * Create some initial test data
            * Attempt to manipulate (edit, delete) it both:
            ** with permission to change the idnumber; and
            ** without permission to change the idnumber.
            * test uniqueness constraints
            * test backup/restore of group(ing)s with idnumbers
            * test importing data from CSV

            h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create new groups:
            ||name||idnumber||
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |MDL-32005-noid-1| |
            |MDL-32005-noid-2| |


            * Open the Groupings tab
            * Create new groupings:
            ||name||idnumber||
            |grouping-id-1|grouping-id-1|
            |grouping-id-2|grouping-id-2|
            |grouping-noid-1| |
            |grouping-noid-2| |

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select group-noid-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on grouping-id-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on grouping-noid-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-2
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select group-noid-2
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for grouping-id-2
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on grouping-noid-2
            ** Replace the id in the address bar with that of grouping-id-2
            * Choose the delete icon on grouping-noid-2
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of group-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping name of grouping-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            * Choose the 'Groups' tab again
            * Select group-id-2 (has idnumber)
            * Choose 'Edit group settings'
            ** Change the group name to group-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h3. Testing with a user with the permission
            Login as admin and navigate to the Groups page
            * Select group-id-2-updated and choose 'Edit group settings'
            ** Change the name again to group-id-2
            ** Change the idnumber
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed

            * Choose the 'Groupings' tab
            * Select grouping-id-2's edit button
            ** Change the name to grouping-id-2-updated
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select Grouping-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed

            Andrew Nicols made changes -
            Pull Master Diff URL https://git.luns.net.uk/?p=moodle.git;a=commitdiff;h=cdd22bbe67823fc2b741c51ab2b2904766b24610 https://git.luns.net.uk/?p=moodle.git;a=commitdiff;h=7bf361e5cc0844f345fd51c47f578df1d21b17c2
            Pull Master Branch MDL-32005-master-2 MDL-32005-master-3
            Testing Instructions These test instructions will:
            * Create some initial test data
            * Attempt to manipulate (edit, delete) it both:
            ** with permission to change the idnumber; and
            ** without permission to change the idnumber.
            * test uniqueness constraints
            * test backup/restore of group(ing)s with idnumbers
            * test importing data from CSV

            h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create new groups:
            ||name||idnumber||
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |MDL-32005-noid-1| |
            |MDL-32005-noid-2| |


            * Open the Groupings tab
            * Create new groupings:
            ||name||idnumber||
            |grouping-id-1|grouping-id-1|
            |grouping-id-2|grouping-id-2|
            |grouping-noid-1| |
            |grouping-noid-2| |

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select group-noid-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on grouping-id-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on grouping-noid-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-2
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select group-noid-2
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for grouping-id-2
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on grouping-noid-2
            ** Replace the id in the address bar with that of grouping-id-2
            * Choose the delete icon on grouping-noid-2
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of group-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping name of grouping-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            * Choose the 'Groups' tab again
            * Select group-id-2 (has idnumber)
            * Choose 'Edit group settings'
            ** Change the group name to group-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h3. Testing with a user with the permission
            Login as admin and navigate to the Groups page
            * Select group-id-2-updated and choose 'Edit group settings'
            ** Change the name again to group-id-2
            ** Change the idnumber
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed

            * Choose the 'Groupings' tab
            * Select grouping-id-2's edit button
            ** Change the name to grouping-id-2-updated
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select Grouping-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed

            These test instructions will:
            * Create some initial test data
            * Attempt to manipulate (edit, delete) it both:
            ** with permission to change the idnumber; and
            ** without permission to change the idnumber.
            * test uniqueness constraints
            * test backup/restore of group(ing)s with idnumbers
            * test importing data from CSV
            * test automatic creation of groups and placement into groupings

            h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create new groups:
            ||name||idnumber||
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |MDL-32005-noid-1| |
            |MDL-32005-noid-2| |


            * Open the Groupings tab
            * Create new groupings:
            ||name||idnumber||
            |grouping-id-1|grouping-id-1|
            |grouping-id-2|grouping-id-2|
            |grouping-noid-1| |
            |grouping-noid-2| |

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select group-noid-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on grouping-id-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on grouping-noid-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-2
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select group-noid-2
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for grouping-id-2
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on grouping-noid-2
            ** Replace the id in the address bar with that of grouping-id-2
            * Choose the delete icon on grouping-noid-2
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of group-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping name of grouping-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            h3. Groups
            Choose the 'Groups' tab again
            * Select group-id-2
            * Choose 'Edit group settings'
            ** Change the group name to group-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h4. Groupings
            Choose the 'Groupings' tab again
            * Select the edit icon for grouping-id-2
            ** Change the group name to grouping-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the edit icon for the grouping again
            ** Confirm the new name
            ** Confirm that the idnumber is still present


            h3. Testing with a user with the permission
            Login as admin
            h4. Groups
            Choose the Groups tab
            * Select group-id-2-updated and choose 'Edit group settings'
            ** Change the name again to group-id-2
            ** Change the idnumber to group-id-two
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove group-noid-3

            h4. Groupings
            Choose the Groupings tab
            * Select grouping-id-2-updated's edit button
            ** Change the name to grouping-id-2
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select grouping-id-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove grouping-noid-3

            h3. Testing Uniqueness
            *User:* As a user with permission to change the idnumber
            These tests check that it is not possible to create group(ing)s with a duplicate idnumber. Please note that:
            * idnumbers are unique within a 'course' (not sitewide); and
            * it is possible to have blank idnumbers for multiple items but this was tested in the initial data creation test instructions.

            h4. Groups
            Navigate to the Groups tab again:
            * Choose Create Group:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Group:
            ** name 'group-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'group-x' and save

            h4. Groupings
            Navigate to the Groupings tab again:
            * Choose Create Grouping:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Grouping:
            ** name 'grouping-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'grouping-x' and save

            h3. Backup/Restore with permissions
            *User:* As an administrator (permission required to backup user data)

            Create several groups:
            ||Group Name||idnumber|
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |

            And a pair of groupings:
            ||Name||idnumber||
            |grouping-id|grouping-id|
            |grouping-noid| |

            Create a backup of the course including user data

            h4. As user with permission to changeidnumber
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings
            * Restore the backup
            ** Confirm that:
            ** All four groups are back with relevant idnumbers
            ** both groupings are back with relevant idnumbers

            h4. As user without permission to changeidnumber
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings
            * Restore the backup
            ** Confirm that:
            ** All four groups are back but the re-created groups have no idnumber
            ** both groupings are back but have no idnumber

            *Note:* The behaviour of restoring groups but not adding group members is consistent with existing behaviour

            h3. Importing Groups with an idnumber
            The 'idnumber' field in group import from CSV is already reserved for the course idnumber.

            * Create a new CSV file as follows:
            {code}
            groupname, description, groupidnumber
            group-id-1, group-id-1, group-id-1
            group-id-2, group-id-2, group-id-2
            group-id-1-duplicate, Duplicate of group-id-1, group-id-1
            group-noid-1, group-noid-1,
            group-noid-2, group-noid-2,
            {code}

            h4. As user with permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** A warning was shown confirming that the idnumber for group-id-1-duplicate already existed
            ** group-id-1 and group-id-2 have the correct idnumber
            ** group-id-1-duplicate, group-noid-1 and group-noid-2 have no idnumber

            h4. As user without permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** None of the groups have an idnumber

            h3. Automatic Creation of groups
            The idnumber changes shouldn't affect automatic creation of groups

            * Create a course with a number of students enrolled within it (e.g. 10)
            * Open the Groups tab
            * Choose 'Auto-create groups'
            * Specify:
            ** Group/member count: 2
            ** Create in grouping: Yes
            ** Grouping Name: MDL-32005
            * Preview and submit - ensure that groups and the grouping are created correctly with no idnumber
            Andrew Nicols made changes -
            Testing Instructions These test instructions will:
            * Create some initial test data
            * Attempt to manipulate (edit, delete) it both:
            ** with permission to change the idnumber; and
            ** without permission to change the idnumber.
            * test uniqueness constraints
            * test backup/restore of group(ing)s with idnumbers
            * test importing data from CSV
            * test automatic creation of groups and placement into groupings

            h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create new groups:
            ||name||idnumber||
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |MDL-32005-noid-1| |
            |MDL-32005-noid-2| |


            * Open the Groupings tab
            * Create new groupings:
            ||name||idnumber||
            |grouping-id-1|grouping-id-1|
            |grouping-id-2|grouping-id-2|
            |grouping-noid-1| |
            |grouping-noid-2| |

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select group-noid-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on grouping-id-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on grouping-noid-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-2
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select group-noid-2
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for grouping-id-2
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on grouping-noid-2
            ** Replace the id in the address bar with that of grouping-id-2
            * Choose the delete icon on grouping-noid-2
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of group-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping name of grouping-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            h3. Groups
            Choose the 'Groups' tab again
            * Select group-id-2
            * Choose 'Edit group settings'
            ** Change the group name to group-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h4. Groupings
            Choose the 'Groupings' tab again
            * Select the edit icon for grouping-id-2
            ** Change the group name to grouping-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the edit icon for the grouping again
            ** Confirm the new name
            ** Confirm that the idnumber is still present


            h3. Testing with a user with the permission
            Login as admin
            h4. Groups
            Choose the Groups tab
            * Select group-id-2-updated and choose 'Edit group settings'
            ** Change the name again to group-id-2
            ** Change the idnumber to group-id-two
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove group-noid-3

            h4. Groupings
            Choose the Groupings tab
            * Select grouping-id-2-updated's edit button
            ** Change the name to grouping-id-2
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select grouping-id-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove grouping-noid-3

            h3. Testing Uniqueness
            *User:* As a user with permission to change the idnumber
            These tests check that it is not possible to create group(ing)s with a duplicate idnumber. Please note that:
            * idnumbers are unique within a 'course' (not sitewide); and
            * it is possible to have blank idnumbers for multiple items but this was tested in the initial data creation test instructions.

            h4. Groups
            Navigate to the Groups tab again:
            * Choose Create Group:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Group:
            ** name 'group-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'group-x' and save

            h4. Groupings
            Navigate to the Groupings tab again:
            * Choose Create Grouping:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Grouping:
            ** name 'grouping-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'grouping-x' and save

            h3. Backup/Restore with permissions
            *User:* As an administrator (permission required to backup user data)

            Create several groups:
            ||Group Name||idnumber|
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |

            And a pair of groupings:
            ||Name||idnumber||
            |grouping-id|grouping-id|
            |grouping-noid| |

            Create a backup of the course including user data

            h4. As user with permission to changeidnumber
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings
            * Restore the backup
            ** Confirm that:
            ** All four groups are back with relevant idnumbers
            ** both groupings are back with relevant idnumbers

            h4. As user without permission to changeidnumber
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings
            * Restore the backup
            ** Confirm that:
            ** All four groups are back but the re-created groups have no idnumber
            ** both groupings are back but have no idnumber

            *Note:* The behaviour of restoring groups but not adding group members is consistent with existing behaviour

            h3. Importing Groups with an idnumber
            The 'idnumber' field in group import from CSV is already reserved for the course idnumber.

            * Create a new CSV file as follows:
            {code}
            groupname, description, groupidnumber
            group-id-1, group-id-1, group-id-1
            group-id-2, group-id-2, group-id-2
            group-id-1-duplicate, Duplicate of group-id-1, group-id-1
            group-noid-1, group-noid-1,
            group-noid-2, group-noid-2,
            {code}

            h4. As user with permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** A warning was shown confirming that the idnumber for group-id-1-duplicate already existed
            ** group-id-1 and group-id-2 have the correct idnumber
            ** group-id-1-duplicate, group-noid-1 and group-noid-2 have no idnumber

            h4. As user without permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** None of the groups have an idnumber

            h3. Automatic Creation of groups
            The idnumber changes shouldn't affect automatic creation of groups

            * Create a course with a number of students enrolled within it (e.g. 10)
            * Open the Groups tab
            * Choose 'Auto-create groups'
            * Specify:
            ** Group/member count: 2
            ** Create in grouping: Yes
            ** Grouping Name: MDL-32005
            * Preview and submit - ensure that groups and the grouping are created correctly with no idnumber
            These test instructions will:
            * Create some initial test data
            * Attempt to manipulate (edit, delete) it both:
            ** with permission to change the idnumber; and
            ** without permission to change the idnumber.
            * test uniqueness constraints
            * test backup/restore of group(ing)s with idnumbers
            * test importing data from CSV
            * test automatic creation of groups and placement into groupings

            h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create new groups:
            ||name||idnumber||
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |


            * Open the Groupings tab
            * Create new groupings:
            ||name||idnumber||
            |grouping-id-1|grouping-id-1|
            |grouping-id-2|grouping-id-2|
            |grouping-noid-1| |
            |grouping-noid-2| |

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select group-noid-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on grouping-id-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on grouping-noid-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-2
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select group-noid-2
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for grouping-id-2
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on grouping-noid-2
            ** Replace the id in the address bar with that of grouping-id-2
            * Choose the delete icon on grouping-noid-2
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of group-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping name of grouping-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            h3. Groups
            Choose the 'Groups' tab again
            * Select group-id-2
            * Choose 'Edit group settings'
            ** Change the group name to group-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h4. Groupings
            Choose the 'Groupings' tab again
            * Select the edit icon for grouping-id-2
            ** Change the group name to grouping-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the edit icon for the grouping again
            ** Confirm the new name
            ** Confirm that the idnumber is still present


            h3. Testing with a user with the permission
            Login as admin
            h4. Groups
            Choose the Groups tab
            * Select group-id-2-updated and choose 'Edit group settings'
            ** Change the name again to group-id-2
            ** Change the idnumber to group-id-two
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove group-noid-3

            h4. Groupings
            Choose the Groupings tab
            * Select grouping-id-2-updated's edit button
            ** Change the name to grouping-id-2
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select grouping-id-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove grouping-noid-3

            h3. Testing Uniqueness
            *User:* As a user with permission to change the idnumber
            These tests check that it is not possible to create group(ing)s with a duplicate idnumber. Please note that:
            * idnumbers are unique within a 'course' (not sitewide); and
            * it is possible to have blank idnumbers for multiple items but this was tested in the initial data creation test instructions.

            h4. Groups
            Navigate to the Groups tab again:
            * Choose Create Group:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Group:
            ** name 'group-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'group-x' and save
            * Re-edit 'group-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groups

            h4. Groupings
            Navigate to the Groupings tab again:
            * Choose Create Grouping:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Grouping:
            ** name 'grouping-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'grouping-x' and save
            * Re-edit 'grouping-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groupings

            h3. Backup/Restore with permissions
            *User:* As an administrator (permission required to backup user data)

            Create several groups:
            ||Group Name||idnumber|
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |

            And a pair of groupings:
            ||Name||idnumber||
            |grouping-id|grouping-id|
            |grouping-noid| |

            Create a backup of the course including user data

            h4. As user with permission to changeidnumber
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings
            * Restore the backup
            ** Confirm that:
            ** All four groups are back with relevant idnumbers
            ** both groupings are back with relevant idnumbers

            To prepare for the next set of tests:
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings


            h4. As user without permission to changeidnumber
            * Restore the backup
            ** Confirm that:
            ** All four groups are back but the re-created groups have no idnumber
            ** both groupings are back but have no idnumber

            *Note:* The behaviour of restoring groups but not adding group members is consistent with existing behaviour

            h3. Importing Groups with an idnumber
            The 'idnumber' field in group import from CSV is already reserved for the course idnumber.

            * Create a new CSV file as follows:
            {code}
            groupname, description, groupidnumber
            group-id-1, group-id-1, group-id-1
            group-id-2, group-id-2, group-id-2
            group-id-1-duplicate, Duplicate of group-id-1, group-id-1
            group-noid-1, group-noid-1,
            group-noid-2, group-noid-2,
            {code}

            h4. As user with permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** A warning was shown confirming that the idnumber for group-id-1-duplicate already existed
            ** group-id-1 and group-id-2 have the correct idnumber
            ** group-id-1-duplicate, group-noid-1 and group-noid-2 have no idnumber

            h4. As user without permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** None of the groups have an idnumber

            h3. Automatic Creation of groups
            The idnumber changes shouldn't affect automatic creation of groups

            * Create a course with a number of students enrolled within it (e.g. 10)
            * Open the Groups tab
            * Choose 'Auto-create groups'
            * Specify:
            ** Group/member count: 2
            ** Create in grouping: New Grouping
            ** Grouping Name: MDL-32005
            * Preview and submit - ensure that groups and the grouping are created correctly with no idnumber
            Andrew Nicols made changes -
            Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
            Andrew Nicols made changes -
            Pull Master Diff URL https://git.luns.net.uk/?p=moodle.git;a=commitdiff;h=7bf361e5cc0844f345fd51c47f578df1d21b17c2 https://git.luns.net.uk/?p=moodle.git;a=commitdiff;h=0d44dcbba6aa71ff0eedb513c2ede065640bd535
            Pull Master Branch MDL-32005-master-3 MDL-32005-master-4
            Testing Instructions These test instructions will:
            * Create some initial test data
            * Attempt to manipulate (edit, delete) it both:
            ** with permission to change the idnumber; and
            ** without permission to change the idnumber.
            * test uniqueness constraints
            * test backup/restore of group(ing)s with idnumbers
            * test importing data from CSV
            * test automatic creation of groups and placement into groupings

            h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create new groups:
            ||name||idnumber||
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |


            * Open the Groupings tab
            * Create new groupings:
            ||name||idnumber||
            |grouping-id-1|grouping-id-1|
            |grouping-id-2|grouping-id-2|
            |grouping-noid-1| |
            |grouping-noid-2| |

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select group-noid-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on grouping-id-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on grouping-noid-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-2
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select group-noid-2
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for grouping-id-2
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on grouping-noid-2
            ** Replace the id in the address bar with that of grouping-id-2
            * Choose the delete icon on grouping-noid-2
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of group-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping name of grouping-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            h3. Groups
            Choose the 'Groups' tab again
            * Select group-id-2
            * Choose 'Edit group settings'
            ** Change the group name to group-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h4. Groupings
            Choose the 'Groupings' tab again
            * Select the edit icon for grouping-id-2
            ** Change the group name to grouping-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the edit icon for the grouping again
            ** Confirm the new name
            ** Confirm that the idnumber is still present


            h3. Testing with a user with the permission
            Login as admin
            h4. Groups
            Choose the Groups tab
            * Select group-id-2-updated and choose 'Edit group settings'
            ** Change the name again to group-id-2
            ** Change the idnumber to group-id-two
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove group-noid-3

            h4. Groupings
            Choose the Groupings tab
            * Select grouping-id-2-updated's edit button
            ** Change the name to grouping-id-2
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select grouping-id-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove grouping-noid-3

            h3. Testing Uniqueness
            *User:* As a user with permission to change the idnumber
            These tests check that it is not possible to create group(ing)s with a duplicate idnumber. Please note that:
            * idnumbers are unique within a 'course' (not sitewide); and
            * it is possible to have blank idnumbers for multiple items but this was tested in the initial data creation test instructions.

            h4. Groups
            Navigate to the Groups tab again:
            * Choose Create Group:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Group:
            ** name 'group-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'group-x' and save
            * Re-edit 'group-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groups

            h4. Groupings
            Navigate to the Groupings tab again:
            * Choose Create Grouping:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Grouping:
            ** name 'grouping-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'grouping-x' and save
            * Re-edit 'grouping-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groupings

            h3. Backup/Restore with permissions
            *User:* As an administrator (permission required to backup user data)

            Create several groups:
            ||Group Name||idnumber|
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |

            And a pair of groupings:
            ||Name||idnumber||
            |grouping-id|grouping-id|
            |grouping-noid| |

            Create a backup of the course including user data

            h4. As user with permission to changeidnumber
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings
            * Restore the backup
            ** Confirm that:
            ** All four groups are back with relevant idnumbers
            ** both groupings are back with relevant idnumbers

            To prepare for the next set of tests:
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings


            h4. As user without permission to changeidnumber
            * Restore the backup
            ** Confirm that:
            ** All four groups are back but the re-created groups have no idnumber
            ** both groupings are back but have no idnumber

            *Note:* The behaviour of restoring groups but not adding group members is consistent with existing behaviour

            h3. Importing Groups with an idnumber
            The 'idnumber' field in group import from CSV is already reserved for the course idnumber.

            * Create a new CSV file as follows:
            {code}
            groupname, description, groupidnumber
            group-id-1, group-id-1, group-id-1
            group-id-2, group-id-2, group-id-2
            group-id-1-duplicate, Duplicate of group-id-1, group-id-1
            group-noid-1, group-noid-1,
            group-noid-2, group-noid-2,
            {code}

            h4. As user with permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** A warning was shown confirming that the idnumber for group-id-1-duplicate already existed
            ** group-id-1 and group-id-2 have the correct idnumber
            ** group-id-1-duplicate, group-noid-1 and group-noid-2 have no idnumber

            h4. As user without permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** None of the groups have an idnumber

            h3. Automatic Creation of groups
            The idnumber changes shouldn't affect automatic creation of groups

            * Create a course with a number of students enrolled within it (e.g. 10)
            * Open the Groups tab
            * Choose 'Auto-create groups'
            * Specify:
            ** Group/member count: 2
            ** Create in grouping: New Grouping
            ** Grouping Name: MDL-32005
            * Preview and submit - ensure that groups and the grouping are created correctly with no idnumber
            These test instructions will:
            * Create some initial test data
            * Attempt to manipulate (edit, delete) it both:
            ** with permission to change the idnumber; and
            ** without permission to change the idnumber.
            * test uniqueness constraints
            * test backup/restore of group(ing)s with idnumbers
            * test importing data from CSV
            * test automatic creation of groups and placement into groupings

            h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create new groups:
            ||name||idnumber||
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |


            * Open the Groupings tab
            * Create new groupings:
            ||name||idnumber||
            |grouping-id-1|grouping-id-1|
            |grouping-id-2|grouping-id-2|
            |grouping-noid-1| |
            |grouping-noid-2| |

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select group-noid-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on grouping-id-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on grouping-noid-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-2
            * The delete button should be greyed out

            For extra brownie points, open an inspector and un-grey it
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select group-noid-2
            ** Confirm that the Delete selected group button is no longer greyed out
            * Select both group-id-2 and group-noid-2
            ** Confirm that the button is once again greyed out
            * Select group-noid-2
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for grouping-id-2
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on grouping-noid-2
            ** Replace the id in the address bar with that of grouping-id-2
            * Choose the delete icon on grouping-noid-2
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of group-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping name of grouping-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            h3. Groups
            Choose the 'Groups' tab again
            * Select group-id-2
            * Choose 'Edit group settings'
            ** Change the group name to group-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h4. Groupings
            Choose the 'Groupings' tab again
            * Select the edit icon for grouping-id-2
            ** Change the group name to grouping-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the edit icon for the grouping again
            ** Confirm the new name
            ** Confirm that the idnumber is still present


            h3. Testing with a user with the permission
            Login as admin
            h4. Groups
            Choose the Groups tab
            * Select group-id-2-updated and choose 'Edit group settings'
            ** Change the name again to group-id-2
            ** Change the idnumber to group-id-two
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove group-noid-3

            h4. Groupings
            Choose the Groupings tab
            * Select grouping-id-2-updated's edit button
            ** Change the name to grouping-id-2
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select grouping-id-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove grouping-noid-3

            h3. Testing Uniqueness
            *User:* As a user with permission to change the idnumber
            These tests check that it is not possible to create group(ing)s with a duplicate idnumber. Please note that:
            * idnumbers are unique within a 'course' (not sitewide); and
            * it is possible to have blank idnumbers for multiple items but this was tested in the initial data creation test instructions.

            h4. Groups
            Navigate to the Groups tab again:
            * Choose Create Group:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Group:
            ** name 'group-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'group-x' and save
            * Re-edit 'group-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groups

            h4. Groupings
            Navigate to the Groupings tab again:
            * Choose Create Grouping:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Grouping:
            ** name 'grouping-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'grouping-x' and save
            * Re-edit 'grouping-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groupings

            h3. Backup/Restore with permissions
            *User:* As an administrator (permission required to backup user data)

            Create several groups:
            ||Group Name||idnumber|
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |

            And a pair of groupings:
            ||Name||idnumber||
            |grouping-id|grouping-id|
            |grouping-noid| |

            Create a backup of the course including user data

            h4. As user with permission to changeidnumber
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings
            * Restore the backup
            ** Confirm that:
            ** All four groups are back with relevant idnumbers
            ** both groupings are back with relevant idnumbers

            To prepare for the next set of tests:
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings


            h4. As user without permission to changeidnumber
            * Restore the backup
            ** Confirm that:
            ** All four groups are back but the re-created groups have no idnumber
            ** both groupings are back but have no idnumber

            *Note:* The behaviour of restoring groups but not adding group members is consistent with existing behaviour

            h3. Importing Groups with an idnumber
            The 'idnumber' field in group import from CSV is already reserved for the course idnumber.

            * Create a new CSV file as follows:
            {code}
            groupname, description, groupidnumber
            group-id-1, group-id-1, group-id-1
            group-id-2, group-id-2, group-id-2
            group-id-1-duplicate, Duplicate of group-id-1, group-id-1
            group-noid-1, group-noid-1,
            group-noid-2, group-noid-2,
            {code}

            h4. As user with permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** A warning was shown confirming that the idnumber for group-id-1-duplicate already existed
            ** group-id-1 and group-id-2 have the correct idnumber
            ** group-id-1-duplicate, group-noid-1 and group-noid-2 have no idnumber

            h4. As user without permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** None of the groups have an idnumber

            h3. Automatic Creation of groups
            The idnumber changes shouldn't affect automatic creation of groups

            * Create a course with a number of students enrolled within it (e.g. 10)
            * Open the Groups tab
            * Choose 'Auto-create groups'
            * Specify:
            ** Group/member count: 2
            ** Create in grouping: New Grouping
            ** Grouping Name: MDL-32005
            * Preview and submit - ensure that groups and the grouping are created correctly with no idnumber
            Dan Poltawski made changes -
            Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
            Dan Poltawski made changes -
            Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
            Andrew Nicols made changes -
            Link This issue will help resolve MDL-31437 [ MDL-31437 ]
            Andrew Nicols made changes -
            Link This issue is blocked by MDL-32426 [ MDL-32426 ]
            Andrew Nicols made changes -
            Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
            Andrew Nicols made changes -
            Status Waiting for peer review [ 10012 ] Development in progress [ 3 ]
            Andrew Nicols made changes -
            Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
            Dan Poltawski made changes -
            Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
            Dan Poltawski made changes -
            Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
            Andrew Nicols made changes -
            Pull Master Diff URL https://git.luns.net.uk/?p=moodle.git;a=commitdiff;h=eadeaef00cbfea5ad71b9876608327838308a22d https://git.luns.net.uk/?p=moodle.git;a=commitdiff;h=cf0d98a1e8afa22a57edf26ab58b72da13e73d32
            Pull Master Branch MDL-32005-master-7 MDL-32005-master-8
            Testing Instructions These test instructions will:
            * Create some initial test data
            * Attempt to manipulate (edit, delete) it both:
            ** with permission to change the idnumber; and
            ** without permission to change the idnumber.
            * test uniqueness constraints
            * test backup/restore of group(ing)s with idnumbers
            * test importing data from CSV
            * test automatic creation of groups and placement into groupings

            h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create new groups:
            ||name||idnumber||
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |


            * Open the Groupings tab
            * Create new groupings:
            ||name||idnumber||
            |grouping-id-1|grouping-id-1|
            |grouping-id-2|grouping-id-2|
            |grouping-noid-1| |
            |grouping-noid-2| |

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select group-noid-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on grouping-id-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on grouping-noid-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-2
            * The delete button should be greyed out

            For extra brownie points, open an inspector and un-grey it
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select group-noid-2
            ** Confirm that the Delete selected group button is no longer greyed out
            * Select both group-id-2 and group-noid-2
            ** Confirm that the button is once again greyed out
            * Select group-noid-2
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for grouping-id-2
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on grouping-noid-2
            ** Replace the id in the address bar with that of grouping-id-2
            * Choose the delete icon on grouping-noid-2
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of group-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping name of grouping-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            h3. Groups
            Choose the 'Groups' tab again
            * Select group-id-2
            * Choose 'Edit group settings'
            ** Change the group name to group-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h4. Groupings
            Choose the 'Groupings' tab again
            * Select the edit icon for grouping-id-2
            ** Change the group name to grouping-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the edit icon for the grouping again
            ** Confirm the new name
            ** Confirm that the idnumber is still present


            h3. Testing with a user with the permission
            Login as admin
            h4. Groups
            Choose the Groups tab
            * Select group-id-2-updated and choose 'Edit group settings'
            ** Change the name again to group-id-2
            ** Change the idnumber to group-id-two
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove group-noid-3

            h4. Groupings
            Choose the Groupings tab
            * Select grouping-id-2-updated's edit button
            ** Change the name to grouping-id-2
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select grouping-id-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove grouping-noid-3

            h3. Testing Uniqueness
            *User:* As a user with permission to change the idnumber
            These tests check that it is not possible to create group(ing)s with a duplicate idnumber. Please note that:
            * idnumbers are unique within a 'course' (not sitewide); and
            * it is possible to have blank idnumbers for multiple items but this was tested in the initial data creation test instructions.

            h4. Groups
            Navigate to the Groups tab again:
            * Choose Create Group:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Group:
            ** name 'group-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'group-x' and save
            * Re-edit 'group-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groups

            h4. Groupings
            Navigate to the Groupings tab again:
            * Choose Create Grouping:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Grouping:
            ** name 'grouping-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'grouping-x' and save
            * Re-edit 'grouping-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groupings

            h3. Backup/Restore with permissions
            *User:* As an administrator (permission required to backup user data)

            Create several groups:
            ||Group Name||idnumber|
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |

            And a pair of groupings:
            ||Name||idnumber||
            |grouping-id|grouping-id|
            |grouping-noid| |

            Create a backup of the course including user data

            h4. As user with permission to changeidnumber
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings
            * Restore the backup
            ** Confirm that:
            ** All four groups are back with relevant idnumbers
            ** both groupings are back with relevant idnumbers

            To prepare for the next set of tests:
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings


            h4. As user without permission to changeidnumber
            * Restore the backup
            ** Confirm that:
            ** All four groups are back but the re-created groups have no idnumber
            ** both groupings are back but have no idnumber

            *Note:* The behaviour of restoring groups but not adding group members is consistent with existing behaviour

            h3. Importing Groups with an idnumber
            The 'idnumber' field in group import from CSV is already reserved for the course idnumber.

            * Create a new CSV file as follows:
            {code}
            groupname, description, groupidnumber
            group-id-1, group-id-1, group-id-1
            group-id-2, group-id-2, group-id-2
            group-id-1-duplicate, Duplicate of group-id-1, group-id-1
            group-noid-1, group-noid-1,
            group-noid-2, group-noid-2,
            {code}

            h4. As user with permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** A warning was shown confirming that the idnumber for group-id-1-duplicate already existed
            ** group-id-1 and group-id-2 have the correct idnumber
            ** group-id-1-duplicate, group-noid-1 and group-noid-2 have no idnumber

            h4. As user without permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** None of the groups have an idnumber

            h3. Automatic Creation of groups
            The idnumber changes shouldn't affect automatic creation of groups

            * Create a course with a number of students enrolled within it (e.g. 10)
            * Open the Groups tab
            * Choose 'Auto-create groups'
            * Specify:
            ** Group/member count: 2
            ** Create in grouping: New Grouping
            ** Grouping Name: MDL-32005
            * Preview and submit - ensure that groups and the grouping are created correctly with no idnumber
            These test instructions will:
            * Create some initial test data
            * Attempt to manipulate (edit, delete) it both:
            ** with permission to change the idnumber; and
            ** without permission to change the idnumber.
            * test uniqueness constraints
            * test backup/restore of group(ing)s with idnumbers
            * test importing data from CSV
            * test automatic creation of groups and placement into groupings

            h3. Run Unit Tests
            A set of unit tests have been created for this feature. These can either be run as a full set of unit tests, or in isolation with:
            {code}
            phpunit --verbose lib/tests/grouplib_test.php
            {code}

            h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create new groups:
            ||name||idnumber||
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |


            * Open the Groupings tab
            * Create new groupings:
            ||name||idnumber||
            |grouping-id-1|grouping-id-1|
            |grouping-id-2|grouping-id-2|
            |grouping-noid-1| |
            |grouping-noid-2| |

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select group-noid-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on grouping-id-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on grouping-noid-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-2
            * The delete button should be greyed out

            For extra brownie points, open an inspector and un-grey it
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select group-noid-2
            ** Confirm that the Delete selected group button is no longer greyed out
            * Select both group-id-2 and group-noid-2
            ** Confirm that the button is once again greyed out
            * Select group-noid-2
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for grouping-id-2
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on grouping-noid-2
            ** Replace the id in the address bar with that of grouping-id-2
            * Choose the delete icon on grouping-noid-2
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of group-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping name of grouping-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            h3. Groups
            Choose the 'Groups' tab again
            * Select group-id-2
            * Choose 'Edit group settings'
            ** Change the group name to group-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h4. Groupings
            Choose the 'Groupings' tab again
            * Select the edit icon for grouping-id-2
            ** Change the group name to grouping-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the edit icon for the grouping again
            ** Confirm the new name
            ** Confirm that the idnumber is still present


            h3. Testing with a user with the permission
            Login as admin
            h4. Groups
            Choose the Groups tab
            * Select group-id-2-updated and choose 'Edit group settings'
            ** Change the name again to group-id-2
            ** Change the idnumber to group-id-two
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove group-noid-3

            h4. Groupings
            Choose the Groupings tab
            * Select grouping-id-2-updated's edit button
            ** Change the name to grouping-id-2
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select grouping-id-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove grouping-noid-3

            h3. Testing Uniqueness
            *User:* As a user with permission to change the idnumber
            These tests check that it is not possible to create group(ing)s with a duplicate idnumber. Please note that:
            * idnumbers are unique within a 'course' (not sitewide); and
            * it is possible to have blank idnumbers for multiple items but this was tested in the initial data creation test instructions.

            h4. Groups
            Navigate to the Groups tab again:
            * Choose Create Group:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Group:
            ** name 'group-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'group-x' and save
            * Re-edit 'group-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groups

            h4. Groupings
            Navigate to the Groupings tab again:
            * Choose Create Grouping:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Grouping:
            ** name 'grouping-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'grouping-x' and save
            * Re-edit 'grouping-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groupings

            h3. Backup/Restore with permissions
            *User:* As an administrator (permission required to backup user data)

            Create several groups:
            ||Group Name||idnumber|
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |

            And a pair of groupings:
            ||Name||idnumber||
            |grouping-id|grouping-id|
            |grouping-noid| |

            Create a backup of the course including user data

            h4. As user with permission to changeidnumber
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings
            * Restore the backup
            ** Confirm that:
            ** All four groups are back with relevant idnumbers
            ** both groupings are back with relevant idnumbers

            To prepare for the next set of tests:
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings


            h4. As user without permission to changeidnumber
            * Restore the backup
            ** Confirm that:
            ** All four groups are back but the re-created groups have no idnumber
            ** both groupings are back but have no idnumber

            *Note:* The behaviour of restoring groups but not adding group members is consistent with existing behaviour

            h3. Importing Groups with an idnumber
            The 'idnumber' field in group import from CSV is already reserved for the course idnumber.

            * Create a new CSV file as follows:
            {code}
            groupname, description, groupidnumber
            group-id-1, group-id-1, group-id-1
            group-id-2, group-id-2, group-id-2
            group-id-1-duplicate, Duplicate of group-id-1, group-id-1
            group-noid-1, group-noid-1,
            group-noid-2, group-noid-2,
            {code}

            h4. As user with permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** A warning was shown confirming that the idnumber for group-id-1-duplicate already existed
            ** group-id-1 and group-id-2 have the correct idnumber
            ** group-id-1-duplicate, group-noid-1 and group-noid-2 have no idnumber
            * Remove all of the existing groups and groupings

            h4. As user without permission to changeidnumber
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** None of the groups have an idnumber

            h3. Automatic Creation of groups
            The idnumber changes shouldn't affect automatic creation of groups

            * Create a course with a number of students enrolled within it (e.g. 10)
            * Open the Groups tab
            * Choose 'Auto-create groups'
            * Specify:
            ** Group/member count: 2
            ** Create in grouping: New Grouping
            ** Grouping Name: MDL-32005
            * Preview and submit - ensure that groups and the grouping are created correctly with no idnumber
            Andrew Nicols made changes -
            Testing Instructions These test instructions will:
            * Create some initial test data
            * Attempt to manipulate (edit, delete) it both:
            ** with permission to change the idnumber; and
            ** without permission to change the idnumber.
            * test uniqueness constraints
            * test backup/restore of group(ing)s with idnumbers
            * test importing data from CSV
            * test automatic creation of groups and placement into groupings

            h3. Run Unit Tests
            A set of unit tests have been created for this feature. These can either be run as a full set of unit tests, or in isolation with:
            {code}
            phpunit --verbose lib/tests/grouplib_test.php
            {code}

            h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create new groups:
            ||name||idnumber||
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |


            * Open the Groupings tab
            * Create new groupings:
            ||name||idnumber||
            |grouping-id-1|grouping-id-1|
            |grouping-id-2|grouping-id-2|
            |grouping-noid-1| |
            |grouping-noid-2| |

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select group-noid-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on grouping-id-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on grouping-noid-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-2
            * The delete button should be greyed out

            For extra brownie points, open an inspector and un-grey it
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select group-noid-2
            ** Confirm that the Delete selected group button is no longer greyed out
            * Select both group-id-2 and group-noid-2
            ** Confirm that the button is once again greyed out
            * Select group-noid-2
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for grouping-id-2
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on grouping-noid-2
            ** Replace the id in the address bar with that of grouping-id-2
            * Choose the delete icon on grouping-noid-2
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of group-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping name of grouping-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            h3. Groups
            Choose the 'Groups' tab again
            * Select group-id-2
            * Choose 'Edit group settings'
            ** Change the group name to group-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h4. Groupings
            Choose the 'Groupings' tab again
            * Select the edit icon for grouping-id-2
            ** Change the group name to grouping-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the edit icon for the grouping again
            ** Confirm the new name
            ** Confirm that the idnumber is still present


            h3. Testing with a user with the permission
            Login as admin
            h4. Groups
            Choose the Groups tab
            * Select group-id-2-updated and choose 'Edit group settings'
            ** Change the name again to group-id-2
            ** Change the idnumber to group-id-two
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove group-noid-3

            h4. Groupings
            Choose the Groupings tab
            * Select grouping-id-2-updated's edit button
            ** Change the name to grouping-id-2
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select grouping-id-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove grouping-noid-3

            h3. Testing Uniqueness
            *User:* As a user with permission to change the idnumber
            These tests check that it is not possible to create group(ing)s with a duplicate idnumber. Please note that:
            * idnumbers are unique within a 'course' (not sitewide); and
            * it is possible to have blank idnumbers for multiple items but this was tested in the initial data creation test instructions.

            h4. Groups
            Navigate to the Groups tab again:
            * Choose Create Group:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Group:
            ** name 'group-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'group-x' and save
            * Re-edit 'group-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groups

            h4. Groupings
            Navigate to the Groupings tab again:
            * Choose Create Grouping:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Grouping:
            ** name 'grouping-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'grouping-x' and save
            * Re-edit 'grouping-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groupings

            h3. Backup/Restore with permissions
            *User:* As an administrator (permission required to backup user data)

            Create several groups:
            ||Group Name||idnumber|
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |

            And a pair of groupings:
            ||Name||idnumber||
            |grouping-id|grouping-id|
            |grouping-noid| |

            Create a backup of the course including user data

            h4. As user with permission to changeidnumber
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings
            * Restore the backup
            ** Confirm that:
            ** All four groups are back with relevant idnumbers
            ** both groupings are back with relevant idnumbers

            To prepare for the next set of tests:
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings


            h4. As user without permission to changeidnumber
            * Restore the backup
            ** Confirm that:
            ** All four groups are back but the re-created groups have no idnumber
            ** both groupings are back but have no idnumber

            *Note:* The behaviour of restoring groups but not adding group members is consistent with existing behaviour

            h3. Importing Groups with an idnumber
            The 'idnumber' field in group import from CSV is already reserved for the course idnumber.

            * Create a new CSV file as follows:
            {code}
            groupname, description, groupidnumber
            group-id-1, group-id-1, group-id-1
            group-id-2, group-id-2, group-id-2
            group-id-1-duplicate, Duplicate of group-id-1, group-id-1
            group-noid-1, group-noid-1,
            group-noid-2, group-noid-2,
            {code}

            h4. As user with permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** A warning was shown confirming that the idnumber for group-id-1-duplicate already existed
            ** group-id-1 and group-id-2 have the correct idnumber
            ** group-id-1-duplicate, group-noid-1 and group-noid-2 have no idnumber
            * Remove all of the existing groups and groupings

            h4. As user without permission to changeidnumber
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** None of the groups have an idnumber

            h3. Automatic Creation of groups
            The idnumber changes shouldn't affect automatic creation of groups

            * Create a course with a number of students enrolled within it (e.g. 10)
            * Open the Groups tab
            * Choose 'Auto-create groups'
            * Specify:
            ** Group/member count: 2
            ** Create in grouping: New Grouping
            ** Grouping Name: MDL-32005
            * Preview and submit - ensure that groups and the grouping are created correctly with no idnumber
            These test instructions will:
            * Create some initial test data
            * Attempt to manipulate (edit, delete) it both:
            ** with permission to change the idnumber; and
            ** without permission to change the idnumber.
            * test uniqueness constraints
            * test backup/restore of group(ing)s with idnumbers
            * test importing data from CSV
            * test automatic creation of groups and placement into groupings

            *Note:* The idnumber has been marked as an advanced setting in the forms. You will need to toggle the Show Advanced button to reveal it.

            h3. Run Unit Tests
            A set of unit tests have been created for this feature. These can either be run as a full set of unit tests, or in isolation with:
            {code}
            phpunit --verbose lib/tests/grouplib_test.php
            {code}

            h3. Create Test Data
            * Navigate to Settings -> Course administration -> Users -> Groups
            * Create new groups:
            ||name||idnumber||
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |


            * Open the Groupings tab
            * Create new groupings:
            ||name||idnumber||
            |grouping-id-1|grouping-id-1|
            |grouping-id-2|grouping-id-2|
            |grouping-noid-1| |
            |grouping-noid-2| |

            h3. Test initial deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed
            * Select group-noid-1
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Choose the delete icon on grouping-id-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed
            * Choose the delete icon on grouping-noid-1
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Remove permission
            * Remove the moodle/course:changeidnumber capability from the editingteacher role

            h3. Re-Test deletion
            As a teacher:
            * Open the 'Groups' tab again
            * Select group-id-2
            * The delete button should be greyed out

            For extra brownie points, open an inspector and un-grey it
            * Choose 'Delete selected group'
            ** Confirm that an error was shown informing the user that they cannot remove the group
            * Select group-noid-2
            ** Confirm that the Delete selected group button is no longer greyed out
            * Select both group-id-2 and group-noid-2
            ** Confirm that the button is once again greyed out
            * Select group-noid-2
            * Choose 'Delete selected group'
            ** Choose yes on the confirmation page
            ** Confirm that the group was removed

            * Open the 'Groupings' tab
            * Confirm that there is no delete icon for grouping-id-2
            ** Make a note of the id in the address bar for the Grouping-2 edit page
            * Choose the delete icon on grouping-noid-2
            ** Replace the id in the address bar with that of grouping-id-2
            * Choose the delete icon on grouping-noid-2
            ** Choose yes on the confirmation page
            ** Confirm that the grouping was removed

            h3. Test data re-entry
            * Choose the 'Groups' tab again
            * Click the 'Create group' button
            * Create a new group:
            ** Use a group name of group-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'
            * Open the 'Groupings' tab again
            * Click the 'Create grouping' button
            * Create a new grouping:
            ** Use a grouping name of grouping-noid-3
            ** Confirm that it is not possible to set the idnumber any more
            ** Click 'Save changes'

            h3. Test update existing entries
            h3. Groups
            Choose the 'Groups' tab again
            * Select group-id-2
            * Choose 'Edit group settings'
            ** Change the group name to group-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the same group again and click the 'Edit group settings' button
            ** Confirm the new name
            ** Confirm that the idnumber is still present

            h4. Groupings
            Choose the 'Groupings' tab again
            * Select the edit icon for grouping-id-2
            ** Change the group name to grouping-id-2-updated
            ** Confirm that you cannot change the idnumber
            ** Choose save
            * Select the edit icon for the grouping again
            ** Confirm the new name
            ** Confirm that the idnumber is still present


            h3. Testing with a user with the permission
            Login as admin
            h4. Groups
            Choose the Groups tab
            * Select group-id-2-updated and choose 'Edit group settings'
            ** Change the name again to group-id-2
            ** Change the idnumber to group-id-two
            ** Choose save settings
            * Select the group again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select the group and choose 'Delete selected group'
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove group-noid-3

            h4. Groupings
            Choose the Groupings tab
            * Select grouping-id-2-updated's edit button
            ** Change the name to grouping-id-2
            ** Change the idnumber
            ** Choose save settings
            * Select the grouping again and edit it's settings again
            ** Confirm that the new name took
            ** Confirm that the idnumber was changed
            * Go back to the edit page
            * Select grouping-id-2's delete button
            * Click yes on the confirmation page
            * Confirm that the group was removed
            * Remove grouping-noid-3

            h3. Testing Uniqueness
            *User:* As a user with permission to change the idnumber
            These tests check that it is not possible to create group(ing)s with a duplicate idnumber. Please note that:
            * idnumbers are unique within a 'course' (not sitewide); and
            * it is possible to have blank idnumbers for multiple items but this was tested in the initial data creation test instructions.

            h4. Groups
            Navigate to the Groups tab again:
            * Choose Create Group:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Group:
            ** name 'group-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'group-x' and save
            * Re-edit 'group-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groups

            h4. Groupings
            Navigate to the Groupings tab again:
            * Choose Create Grouping:
            ** name 'MDL-32005'
            ** idnumber 'MDL-32005'
            ** Confirm Group Creation
            * Choose Create Grouping:
            ** name 'grouping-x'
            ** idnumber 'MDL-32005'
            ** Confirm that the group was *not* created and an error was shown on the form
            ** Change the idnumber to 'grouping-x' and save
            * Re-edit 'grouping-x':
            ** Update idnumber to 'MDL-32005'
            ** Choose Save
            ** Confirm that the group was *not* updated and an error was shown on the form
            * Delete both groupings

            h3. Backup/Restore with permissions
            *User:* As an administrator (permission required to backup user data)

            Create several groups:
            ||Group Name||idnumber|
            |group-id-1|group-id-1|
            |group-id-2|group-id-2|
            |group-noid-1| |
            |group-noid-2| |

            And a pair of groupings:
            ||Name||idnumber||
            |grouping-id|grouping-id|
            |grouping-noid| |

            Create a backup of the course including user data

            h4. As user with permission to changeidnumber
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings
            * Restore the backup
            ** Confirm that:
            ** All four groups are back with relevant idnumbers
            ** both groupings are back with relevant idnumbers

            To prepare for the next set of tests:
            * Delete the following groups:
            ** group-id-1
            ** group-noid-1
            * Delete both groupings


            h4. As user without permission to changeidnumber
            * Restore the backup
            ** Confirm that:
            ** All four groups are back but the re-created groups have no idnumber
            ** both groupings are back but have no idnumber

            *Note:* The behaviour of restoring groups but not adding group members is consistent with existing behaviour

            h3. Importing Groups with an idnumber
            The 'idnumber' field in group import from CSV is already reserved for the course idnumber.

            * Create a new CSV file as follows:
            {code}
            groupname, description, groupidnumber
            group-id-1, group-id-1, group-id-1
            group-id-2, group-id-2, group-id-2
            group-id-1-duplicate, Duplicate of group-id-1, group-id-1
            group-noid-1, group-noid-1,
            group-noid-2, group-noid-2,
            {code}

            h4. As user with permission to changeidnumber
            * Remove all of the existing groups and groupings
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** A warning was shown confirming that the idnumber for group-id-1-duplicate already existed
            ** group-id-1 and group-id-2 have the correct idnumber
            ** group-id-1-duplicate, group-noid-1 and group-noid-2 have no idnumber
            * Remove all of the existing groups and groupings

            h4. As user without permission to changeidnumber
            * Import the CSV file
            * Confirm:
            ** All five groups were created
            ** None of the groups have an idnumber

            h3. Automatic Creation of groups
            The idnumber changes shouldn't affect automatic creation of groups

            * Create a course with a number of students enrolled within it (e.g. 10)
            * Open the Groups tab
            * Choose 'Auto-create groups'
            * Specify:
            ** Group/member count: 2
            ** Create in grouping: New Grouping
            ** Grouping Name: MDL-32005
            * Preview and submit - ensure that groups and the grouping are created correctly with no idnumber
            Andrew Nicols made changes -
            Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
            Dan Poltawski made changes -
            Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
            Dan Poltawski made changes -
            Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
            Andrew Nicols made changes -
            Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
            Andrew Nicols made changes -
            Status Waiting for peer review [ 10012 ] Waiting for integration review [ 10010 ]
            Sam Hemelryk made changes -
            Fix Version/s 2.3 [ 10657 ]
            Fix Version/s DEV backlog [ 10464 ]
            Aparup Banerjee made changes -
            Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
            Integrator nebgor
            Currently in integration Yes [ 10041 ]
            Aparup Banerjee made changes -
            Labels patch triaged docs_required patch qa_test_required triaged ui_change
            Aparup Banerjee made changes -
            Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
            Tim Barker made changes -
            Tester rajeshtaneja
            Rajesh Taneja made changes -
            Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
            Rajesh Taneja made changes -
            Rajesh Taneja made changes -
            Status Testing in progress [ 10011 ] Problem during testing [ 10007 ]
            Andrew Nicols made changes -
            Link This issue testing discovered MDL-33092 [ MDL-33092 ]
            Eloy Lafuente (stronk7) made changes -
            Status Problem during testing [ 10007 ] Integration review in progress [ 10004 ]
            Eloy Lafuente (stronk7) made changes -
            Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
            Eloy Lafuente (stronk7) made changes -
            Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
            Eloy Lafuente (stronk7) 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 [ 10041 ]
            Integration date 19/May/12
            Helen Foster made changes -
            Labels docs_required patch qa_test_required triaged ui_change patch qa_test_required triaged ui_change

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: