Final grade of members of a cohort

Final grade of members of a cohort

by Julio Rodriguez -
Number of replies: 0

Hello,

How do I get the final grade of the members of a cohort?

I have the following query, but the rows are repeated:


SELECT DISTINCT u.firstname, u.lastname, ROUND(g.finalgrade,2)                                                          

FROM mdl_cohort AS h

JOIN mdl_cohort_members AS hm ON hm.cohortid = h.id

JOIN mdl_user AS u ON u.id = hm.userid

JOIN mdl_user_enrolments AS ue ON ue.userid = hm.id

JOIN mdl_grade_grades AS g ON g.userid = hm.id 

JOIN mdl_grade_items AS gi ON gi.id = g.itemid 

JOIN mdl_enrol AS e ON e.id = ue.enrolid

JOIN mdl_role_assignments AS ra ON ra.userid = hm.id

JOIN mdl_context AS ct ON ct.id = ra.contextid AND ct.contextlevel = 50

JOIN mdl_course AS c ON c.id = ct.instanceid AND e.courseid = c.id

JOIN mdl_role AS r ON r.id = ra.roleid AND r.shortname = 'student'


WHERE cohortid='$idp' AND gi.courseid = c.id AND gi.itemtype = 'course' ORDER BY u.firstname 


Thank you

Attachment Captura de pantalla (2111).png