Smart Cohort

Local plugins ::: local_cnw_smartcohort
Maintained by CNW Co.CNW Zrt.
With Smart Cohort modul, users automatically added to cohorts based on filters.
Latest release:
349 sites
83 downloads
43 fans
Current versions available: 2

We developed the Smart Cohort module based on our years of experience in Moodle operation and development. Course creators, site administrators and teachers are surely familiar with cohorts in the system that allow new colleagues / students to be easily enrolled in the appropriate courses. The users only have to be added to the group and the rest is automatically arranged by the system.


The Smart Cohort Module allows authorized users to define filtering criteria and to specify which cohort the filtered users would be added to. This add-on works well with any authentication plugins, so when the user is created or its data gets updated, the system checks for which groups to add to or remove the user from based on the filtering criteria.


The module was originally developed for our partners, but we feel like that this community would also find it useful, so we've made it available to you for free. With the help of this module it's easier for our partners to identify courses based on area, job, position, and they do not have to deal with managing cohorts.

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3

Contributors

CNW Co.
CNW Zrt. (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Przemek Kaszubski
    Sun, Jul 4, 2021, 12:13 AM
    Hi, any chance for an upgrade for Moodle 3.10?
  • Erich Klein
    Wed, Aug 18, 2021, 11:19 PM
    Could you update the plugin? the idea seems perfect for what im looking for. The rules stay on in progress for ever in moodle 3.11
  • Proper Bo, am tellin thee!
    Tue, May 10, 2022, 6:22 PM
    Hello, did @Thibault Hermes manage to upload the contributions, as the plugin with Doesn't Contain is exactly what I am looking for right now. Is there a way to get this version please?
  • Jean-Gabriel DEPINOY
    Tue, Oct 11, 2022, 7:49 PM
    Hello,
    Can a deletion of users who no longer meet the criteria of the cohort be considered in a future development?
    Indeed, I use Azure AD and the Microsoft Dev Center to manage my users.
    when a student leaves a training, I remove them from Azure AD but they remain enrolled in the cohort.
  • Goria Gori
    Thu, Apr 27, 2023, 5:19 PM
    When deleting a previously created filter, the deletion operation remains frozen indefinitely.
    Additionally, the email filter does not work. It is possible to create filters in the Smartcohort plugin as follows: if the value of the "Email Address" field is equal to, different from, begins with, or ends with a certain value.

    I am trying to exclude ALL users who do not have an email address ending in "@my-organization.com" using a filter to populate a cohort named "External Users." However, if I use the "different from" filter (than "@my-organization.com"), it considers all Moodle emails, as they are all different from "@my-organization.com". This results in all Moodle users being added to the cohort, which is not the desired outcome.

    If we look at how Moodle's "native" filters work (users -> batch actions on users), it is possible to achieve the desired result by using the "does not contain" filter with "@my-organization.com". I do get the list of external users that I am trying to automatically place in a cohort.

    This filter is unusable to properly filter email addresses. It should behave like Moodle's filter.
  • Goria Gori
    Wed, May 17, 2023, 8:36 PM
    Hello everyone,
    I just wanted to let you know that a patch is now available for the Smart Cohort plugin. This patch addresses two issues that have been reported:
    1. the not equal filter was not properly handling email addresses, leading to incorrect results :

    I added the following code block to handle the "not equals" operator for the email field

    if (!empty($queryParams) && $rule->field == 'email' && $operator == '<>') {
    $sql .= " AND u.email NOT LIKE '" . implode('', $queryParams) . "'";
    $queryWhere == false;
    }

    the code checks if there are non-empty query parameters and if the current field is the email field with the "not equals" operator,It appends an additional condition to the SQL query using NOT LIKE to exclude the specified email(s) from the results.
    The $queryWhere variable is set to false to indicate that an additional condition has been added.
    link to the pull request :

    https://github.com/cnw-co/moodle-local_cnw_smartcohort/pull/6

    2. Display filters when deleting were not working as expected:
    I modified the parameter $with_deleted from false to true in the if statement:

    if ($with_deleted == true) {
    return $DB->get_records_sql("SELECT * FROM {cnw_sc_filters} WHERE deleted_flag = 0");
    } else {
    return $DB->get_records('cnw_sc_filters');
    }

    This change ensures that when the $with_deleted parameter is set to true, the function retrieves all records from the cnw_sc_filters table, including those with a deleted_flag value of 0 (not deleted).

    link to the pull request :

    https://github.com/cnw-co/moodle-local_cnw_smartcohort/pull/7
  • Вячеслав Душин
    Wed, Aug 16, 2023, 1:51 PM
    Good day! Please add an operator or to filters.
  • Вячеслав Душин
    Wed, Aug 16, 2023, 2:21 PM
    Release 2.0.1 removes active filters every other time.
  • Вячеслав Душин
    Fri, Aug 18, 2023, 1:58 PM
    Good day! If you add two rules for the same User profile fields, the number of users filtered by this rule after saving is not displayed correctly.
  • CNW Co.
    Mon, Aug 21, 2023, 9:46 PM
    Hello, Вячеслав Душин!

    We plan to add an or operator in a later release, until then most filtering cases requiring it can be done with more rules.

    Thank you for reporting these issues!
    The one with the active filter removal was fixed. We could not reproduce the other one. Could you give us more details, please?
  • Albert Pujadas Gómez
    Tue, Dec 5, 2023, 10:50 PM
    Hi! the plugin seems to not be working, it stays loading all the time, we tried to use the patch but it isn't working anyways, we need to classify the users by the domain of their email. How can we do it? Thanks!
  • CNW Co.
    Tue, Dec 5, 2023, 11:48 PM
    Dear Albert,

    Can you provide a cronlog and tasklog for me?
    My e-mail address is: moodle (at) cnw (dot) com

    Thanks!
  • Martin Jane
    Tue, Mar 19, 2024, 7:44 AM
    Hi,
    I’ve recently installed the Smart Cohort Plugin. When I create a rule they always remain “in progress”.
    Looking at the task log it fails due to trying to order by Name which is an unknown field.
    My Moodle version is 4.0.2 and I downloaded the smart cohort plugin version 2.0.5 (2023081800)
    I can send through a task log. It won't let me post it here.
  • Mike North
    Fri, Aug 23, 2024, 9:05 PM
    Great plugin, however the rules can only be applied to the first 25 cohorts that have been created within moodle.

    These are the 25 cohorts that appear on page 1 when viewing System Cohorts (Accounts > System Cohorts) and those on page 2 and beyond don't appear in the plugin's drop down list of cohorts that rules can be applied to.

    Can this be extended so rules can be applied to all cohorts within moodle?

    Many thanks.

    Plugin version 2.05 (2023081800)
    Moodle version 4.0.4 (Build: 20220912)
  • Hanna Kubrak
    Mon, Mar 17, 2025, 7:23 PM
    Hello everyone,
    We have been using the Smart Cohort plugin for some time now, many thanks to the developers! Managers have the ability to manage Smart Cohorts and can do so by pasting the link into the address bar of their browser. However, they do not see the link to this page in "Site Administration". Is this intentional or is there a bug in my system? If you have had this problem, has anyone been able to fix it?
    Moodle 4.1
    Plugin 1.0.0 (2019050603).
    Any help is appreciated!
1 2 3 4
Please login to post comments