2

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?

CloudJake
  • 156
  • 4
  • 22
Nghi Ho
  • 463
  • 1
  • 6
  • 18
  • Please excuse me asking the obvious question, but why do you not want to write SQL code, when it can get you the answer you need in a fairly straightforward manner? – Martin Greenaway May 09 '19 at 15:42

0 Answers0