Auto assign cohort (deprecated for local_cohortauto)
Maintained by
Dan Marsden, Catalyst IT
This Authentication plugin automatically assigns users into cohorts based on information in their user profile fields.
Comments
Comments are no longer open for new posts. Existing comments remain available to read.
Thanks a lot Andrew for this new release with the improvement I need.
It is exactly what I want and it works great !
Kevin
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
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
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
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";
Error reading from database
More information about this error
Debug info: SQLState: 42000
Error Code: 195
Message: [Microsoft][SQL Server Native Client 11.0][SQL Server]'CONCAT' is not a recognized built-in function name.
SELECT u.id AS uid, CONCAT(u.firstname, ' ', u.lastname) AS usrname FROM mdl_cohort_members AS cm JOIN mdl_user AS u ON u.id = cm.userid WHERE cm.cohortid = '0' ORDER BY usrname
[array (
0 => 0,
)]
Error code: dmlreadexception
Stack trace:
◦line 426 of \lib\dml\moodle_database.php: dml_read_exception thrown
◦line 260 of \lib\dml\sqlsrv_native_moodle_database.php: call to moodle_database->query_end()
◦line 367 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->query_end()
◦line 779 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->do_query()
◦line 827 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->get_recordset_sql()
◦line 37 of \auth\mcae\view.php: call to sqlsrv_native_moodle_database->get_records_sql()
require_once($CFG->dirroot.'/user/profile/lib.php');
at the beginning of auth/mcae/auth.php as it was posted by Francis Vendrell. Thanks again
Really useful plugin though!
But I am confused as to what goes in the various fields. So to achieve this what values would I use - no issue in deleting that cohort as it has no users yet anyway if that is needed.
Thanks