Select Moodle version:

Authentication: Autoenrol cohort

auth_mcae
This Authentication plugin automatically enrol users into cohorts. Cohort name depends on user profile field.
Maintained by: Picture of Andrew Kama Andrew Kama

This Authentication plugin automatically enrol users into cohorts.

Cohort name depends on user profile field.

How to use:

  1. Copy plugin into /moodle/auth directory
  2. Go to Site administration - Notifications page and install it
  3. Go to Plugins - Authentication and enable plugin
  4. Configure main rules (template for cohort name)
    second rule (replace empty field)
    and replacement array
  5. Enable unenrol option

Cohorts are created in CONTEXT_SYSTEM

See README.md for details

EXAMPLE:

You have a custom profile fields "status" (student, teacher or admin) and "course". 

You wnat to enrol many users into cohorts like "course - status" than enrol cohorts into courses.

At configuration page set:

Main template to %profile_field_course - %profile_field_status

Empty field text (When field is empty this value used) to none

Result:

When 1st course student logins, he enrol to cohort named "1 - student"

When 1st course teacher logins, he enrol to cohort named "1 - teacher"

When admin logins, he enrol to cohort named "none - admin" (Course not set, status - admin)

To rename "none - admin" cohort to "Administration" you must set a replacement array field at the configuration page (1 replacement per line, old_value|new_value)

In our case: none - admin|Administrator

Result:

When admin logins, he enrol to cohort named "Administrator"

Screenshots

screenshot
screenshot
screenshot

Contributors

Picture of Andrew Kama
Andrew Kama (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Alan Hare
    Tue, Apr 16, 2013, 1:00 AM
    FIXED: Changed line (36) in /auth/mcae/view.php to read

    From:
    $sql = "SELECT u.id AS uid, CONCAT(u.firstname, ' ', u.lastname) AS usrname FROM {cohort_members} AS cm JOIN {user} AS u ON u.id = cm.userid WHERE cm.cohortid = ? ORDER BY usrname";

    TO:
    $sql = "SELECT u.id AS uid, (u.firstname + ' ' + u.lastname) AS usrname FROM {cohort_members} AS cm JOIN {user} AS u ON u.id = cm.userid WHERE cm.cohortid = ? ORDER BY usrname";
  • Picture of Sam Stegers
    Thu, Jun 6, 2013, 10:14 PM
    Great plugin indeed!!

    However when change the value in the profile field based on which the autoenrol occurs, the user is nicely enrolled into the new cohort.

    BUT!!

    The user also stays enrolled in the previous cohort, thus the user is now enrolled in the "old" cohort and in the "new" cohort.

    Would it be possible to add this to the plugin? Perhaps a setting where you can define is the plugin should or should not unenrol users when the profile fields are changed.

    Highest regards,

    Sam
  • Picture of Andrew Kama
    Fri, Jun 7, 2013, 2:57 PM
    Hi Sam!

    To enable autounenroll users:
    1. Go to moodle/auth/mcae/convert.php page
    2. Select cohorts you want and convert to "auth_mcae"
    3. At the plugin configuration page check "Enable / Disable automatic unenrol" option.

    If "Enable / Disable automatic unenrol" option enabled:
    1. Manually created cohorts are managed by admin
    2. Automatically created cohorts are managed by plugin
    3. To view cohort members go to moodle/auth/mcae/view.php page
  • Picture of John Anderson
    Wed, Jun 19, 2013, 9:11 AM
    Can I use this to auto enrol a user to a cohort based on email domain? Or does it have to be a profile field ?
  • Picture of John Anderson
    Thu, Jun 20, 2013, 8:55 AM
    I cannot understand the instructions. Could someone who has had success with this plugin provide their examples? I would like to help with the documentation, after I have a working example.
  • Picture of Kevin TREUSSIER
    Wed, Jul 3, 2013, 4:02 PM
    Very great Plugin !

    It's exactly what I need to create cohort corresponding to groups that exist in a shibboleth attributes that I receipt.

    I just need 1 improvement if it's possible :
    The field I request contain multi-values, separate by a ";" (in exemple "gs2;GIPAD-GS2", or "gs2;AII-GS2")
    Is it possible to split this cohort in 2 or more cohorts, defining by a separator parameter (in my case ";" to obtain 3 cohorts ("gs2", "GIPAD-GS2" and "AII-GS2") rather than 2 ("gs2;GIPAD-GS2" and "gs2;AII-GS2")) ?

    Thanks a lot for this plugin.

    Kevin
  • Picture of Kevin TREUSSIER
    Mon, Aug 12, 2013, 6:59 PM
    Hello,

    Thanks a lot Andrew for this new release with the improvement I need.
    It is exactly what I want and it works great !

    Kevin
  • Picture of chispol rios
    Tue, Aug 20, 2013, 7:48 AM
    Hi, is there more documentation related this plugin?
  • Picture of Andrew C
    Thu, Aug 22, 2013, 4:37 AM
    Fantastic plugin.
  • Picture of Jared Annis
    Thu, Sep 19, 2013, 7:23 AM
    Great job on this plugin! It works great as long as I log into moodle directly. I'm using Drupal-Moodle SSO for most of my end users, however. Is there a way have Moodle authentiate through Drupal Service, and then still auto enrol the user into a cohort?
  • Picture of Julia Küfner
    Thu, Sep 19, 2013, 8:21 PM
    Does anyone use this plugin with mnet ? It works great for all other authentication methods but with mnet it doesn't seem to be called when the user logs in ?
  • Picture of Seyit Kaya
    Sat, Sep 28, 2013, 12:23 AM
    How can i use it please explain
  • Picture of Seyit Kaya
    Sat, Sep 28, 2013, 12:28 AM
    How can i use it please explain i cant do it
  • Picture of Carlos Rubalcava
    Thu, Oct 17, 2013, 6:02 AM
    At what point does this gets done? At login or at signup or at course access?
  • François Lizotte
    Fri, Mar 7, 2014, 3:57 AM
    Hi, I think this module could really be useful, but I can't figure out the syntax. All I want to do is to enrol students in a cohort according to a profile field. Let's say field Program = Science. Then, all users having science would be enroled in the Science cohort.
1 2 3
Please login to post comments