-
Improvement
-
Resolution: Fixed
-
Minor
-
2.3
-
MOODLE_23_STABLE
-
MOODLE_28_STABLE
-
wip-
MDL-36014-master -
Currently teachers in the course are unable to use enrol_cohort because the capability to view cohorts (moodle/cohort:view) is checked on the level where cohort was created - system or course category. Since editingteacher role is given inside the course, the teacher by default can not use enrol_cohort. At the same time teacher is able to auto-create groups from cohort memebers.
It was decided to allow users in the courses to view cohorts defined in the above contexts unless admin/manager has unchecked 'visibile' checkbox for the cohort.
In this issue:
- we add field cohort.visible and support it when editing, uploading cohorts and in web services.
- add API methods cohort_can_view_cohort() and cohort_get_available_cohorts() that replace similar methods and plain DB queries in enrolment plugins and auto-create group form
- remove checking of capability moodle/cohort:view from enrol_cohort plugin (capability 'moodle/course:enrolconfig' is still required)
------
Original description:
The point is to allow teachers to use cohorts in enrolments plugins without having extra role in contexts above course.
- moodle/cohort:view - is used in has_capability() called with the category context where the cohort is defined (in future it may be cohort context itself)
- new moodle/cohort:viewabove would be used in course contexts, giving user permission to use all cohorts defined in system and parent course categories.
The list of available cohorts in enrol_manual and enrol_self would be constructed as a sum of cohorts allowed by both capabilities.
Combination of these two capabilities should give use enough enough flexibility in different scenarios - see https://moodle.org/mod/forum/discuss.php?d=213598