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

Extend the database enrolment plugin to create groups and add/remove members

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Development in progress
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.2.2, 3.2.5, 3.3.2, 3.5, 3.6
    • Fix Version/s: None
    • Component/s: Enrolments
    • Testing Instructions:
      Hide
      1. Create a test enrolment database - You will need a table for courses, and a table to enrolments, that will link users, courses and groups.
      2. Set up external database enrolments and make sure you set "Remote group code field" to match the column name for the group identified column that you added to the database table.
      3. Run the database enrolment synchronisation script ( /path/to/moodle/enrol/database/cli/sync.php )
      4. After running this validate that groups and groupings have been created for the new enrolments.
      5. Edit the enrolment database by blanking out the group identifier field for some of the enrolments.
      6. Re-run the database enrolment synchronisation script.
      7. Validate that the users have been removed from the groups.
      Show
      Create a test enrolment database - You will need a table for courses, and a table to enrolments, that will link users, courses and groups. Set up external database enrolments and make sure you set "Remote group code field" to match the column name for the group identified column that you added to the database table. Run the database enrolment synchronisation script ( /path/to/moodle/enrol/database/cli/sync.php ) After running this validate that groups and groupings have been created for the new enrolments. Edit the enrolment database by blanking out the group identifier field for some of the enrolments. Re-run the database enrolment synchronisation script. Validate that the users have been removed from the groups.
    • Affected Branches:
      MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-58785_master_neis

      Description

      Much like this http://tracker.moodle.org/browse/MDL-15663 and https://tracker.moodle.org/browse/MDL-34307 but for Moodle 3+.

      Many organisations have requested the ability to synchronise group membership as part of the external database enrolment plugin.

      I am working with Huddresfield New College to submit the patch which they have been using for several years to the main upstream codebase.

      This patch will automatically create groups as required - it will also remove group memberships if students are no longer members on subsequent sync's with the external database.

      As well as creating groups and putting the students in the groups, this patch will also put all groups created for the same course into a grouping. The new groupings are created with an idnumber consisting of an optional prefix (see the localgroupingidnumberprefixfield mentioned below) followed by the course ID (based on the local field used to match the course). If the grouping does not exist it will be created. If one with the correct idnumber already exists the existing one will be used. Note that groupings will be created for all courses mentioned in the course column of the remote database even if the enrolment into that course fails (e.g. because the user lookup fails i.e. the remote user isn't found in the local database).

      It adds the following new fields to the settings page for the database enrolment plugin:

      • remotegroupcodefield - The column in the external enrolment data table which holds the group code
      • remotegroupnamefield - The column in the external enrolment data table which holds the group name (optional) - if this is empty then the group code will be used as the name for the group as well as the code
      • remotegroupdescriptionfield - The column in the external enrolment data table which holds the description for the group (optional)
      • remotegroupidnumberfield - The column in the external enrolment data table which holds the group idnumber (optional)
      • localgroupingidnumberprefixfield - The prefix prepended to all new groupings which are auto-created during the enrolment process (optional)

      Notes:

      • The synchronisation of groups only happens when a full sync of all user enrolments takes place - not when an individual user logs in.
      • Whilst this update will remove group membership if the user is no longer a member of that group in the external database, it will not delete the group if there are no members left in the group.
      • If the remotegroupcodefield on the settings page is left blank then no action will be taken with regards to groupings.
      • If remotegroupcodefield is set, but remotegroupnamefield is not set then new groups will be created using the code as the name.
      • If a group with a given code already exists, then the name, description and idnumber of the existing group will not be updated to match the details specified in the external database if it is different - thus any group name edits after the first sync will need to be done in Moodle, not through the external system. Similarly, if the name, description and idnumber values for the same group vary in the external database from row to row (this would be fundamentally illogical) then the details from the first row encountered will be used (and subsequent variations ignored)
      • If the group code field for a given row is set, but the group name field is empty then the group code will be used as the group name (although, as noted above, if the group already exists then this will be irrelevant as existing group names are not changed by this process).
      • If remotegroupcodefield setting is set and the group code field in any given row of the external database is empty, then the corresponding enrolment will have any existing group assignments which were created by this plugin removed - existing group assignments created by other means (e.g. manually in Moodle UI) will remain.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                43 Vote for this issue
                Watchers:
                36 Start watching this issue

                Dates

                • Created:
                  Updated: