Moodle php code : To get all students in a course

// 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);

Leave a Reply

Your email address will not be published. Required fields are marked *