Add optional group filter: only enrol members of selected source-course groups - #48
Add optional group filter: only enrol members of selected source-course groups#48Danimarqz wants to merge 7 commits into
Conversation
Per-instance group filter: when one or more groups of the completed course are selected, only students who belong to at least one of them are auto-enrolled into the target course. Empty keeps the original behaviour (everyone who completes the course is enrolled). Stored in the instance customtext2 as a JSON array of group ids. The group list is loaded by AJAX (core_group_get_course_groups) from the course chosen in customint1, via amd module enrol_coursecompleted/groupselector. The filter is enforced in enrol_user(), covering both the immediate and the delayed enrolment paths. Includes tests/groupfilter_test.php.
Translate every plugin string to Spanish, plus the new group-filter strings.
getDataGenerator()->create_group() returns a record; the plugin stores group ids, so intval() on the object warned and stored [1]. Use the group id.
Replace the hand-written amd/build with the real grunt output and add the sourcemap, so the CI JS build check passes.
|
Thank you for your suggestion. I do have a few remarks:
Just collecting ideas... |
|
@ewallah Hi, and thank you so much for taking the time to go through this so carefully — I really appreciate the detailed feedback, it's genuinely helpful. Let me walk through it, because I think a couple of the points assume the change is broader than it actually is, and that's probably my fault for not explaining it well enough up front. The key thing: this is a filter, not group assignment. It doesn't create groups, assign anyone to a group, or add per-group welcome messages. All it does is add an optional condition to the trigger: when the admin picks one or more groups from the completed (source) course, only members of those groups get auto-enrolled. Leave it empty and nothing changes — everyone is enrolled, exactly as today. So it really lives right next to the role/date settings the plugin already has: a condition on who the existing automation acts on, not a new group-management feature inside the plugin. With that framing, point by point:
And genuinely — if after all that you'd still rather keep groups out of this plugin, that's completely fine and I'll just maintain it as a local customisation, no hard feelings at all. But framed as an optional source-course filter, I do think it stays within the spirit of what the plugin already does. Thanks again for engaging with it so thoughtfully. |
What
Adds an optional per-instance group filter. When one or more groups of the completed (source) course are selected, only students who belong to at least one of them are auto-enrolled into the target course. Leaving it empty keeps the current behaviour (everyone who completes the course is enrolled) — fully backward compatible.
Use case: course B enrols users on completion of course A, but you only want a specific cohort (e.g. an "AGOSTO" group in A) enrolled.
How
customtext2as a JSON array of group ids ([]= no restriction). No DB schema change.autocompletemultiselect whose options load by AJAX (core_group_get_course_groups) from the course chosen incustomint1, via AMD moduleenrol_coursecompleted/groupselector. Selected groups preloaded server-side.enrol_user()(single choke point → covers immediate and delayed enrolment paths): users not in any selected group are skipped.estranslation added.tests/groupfilter_test.php.Notes
version.phpbump andv5.3.3-groups1