I want to get all users who have the correct group and role (in a course).
Pre-condition: I don't want to write sql query.
Below is my current code, using course_enrolment_manager
to filter:
function get_users_by_group_and_role ($course, $groupid, $roleid) {
$manager= new course_enrolment_manager($PAGE, $course, null, $roleid, '', $groupid);
return $manager->get_users('id');
}
I don't think this isn't a good solution as the purpose of course_enrolment_manager
is different from mine. Does anyone know a better method for implementing this?