diff --git a/locallib.php b/locallib.php index 554e353..2cc0373 100644 --- a/locallib.php +++ b/locallib.php @@ -24,8 +24,9 @@ function report_componentgrades_get_students($courseid) { global $DB; - return $DB->get_records_sql('SELECT stu.id AS userid, stu.idnumber AS idnumber, stu.firstname, stu.lastname, stu.username AS student - FROM {user} AS stu + return $DB->get_records_sql('SELECT (@id := @id +1) id,stu.id AS userid, stu.idnumber AS idnumber, stu.firstname, stu.lastname, stu.username AS student + FROM (select @id :=0 id) id, + {user} AS stu JOIN {user_enrolments} ue ON ue.userid = stu.id JOIN {enrol} enr ON ue.enrolid = enr.id WHERE enr.courseid = ? @@ -113,4 +114,4 @@ function report_componentgrades_add_data($sheet, $students, $gradinginfopos, $me } } } -} \ No newline at end of file +}