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

groups and groupings should have 'idnumber' field

XMLWordPrintable

    • MOODLE_22_STABLE
    • MOODLE_23_STABLE
    • MDL-32005-master-10
    • Moderate
    • 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

      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.

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Dan Poltawski Dan Poltawski
            Aparup Banerjee Aparup Banerjee
            Rajesh Taneja Rajesh Taneja
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.