// to get teacher , change role shortname to "editingteacher"
//students
$role = $DB->get_record("role", array("shortname" => 'student'));
$course = $DB->get_record("course",array("id"=>$course->id));
$context = context_course::instance($course->id);
$users = get_role_users($role->id, $context);