Moodle fetch Student Grades


To fetch student’s grade from Moodle database you can use this query


SELECT u.firstname AS `First Name` , u.lastname AS `Last Name` , AS Email, c.idnumber AS `Course Acronym` , c.fullname AS Course, ROUND( gg.finalgrade, 2 ) Grades, AS City, AS Country, FROM_UNIXTIME( gi.timemodified ) `Grading Date`
FROM mdl_course AS c
JOIN mdl_context AS ctx ON = ctx.instanceid
JOIN mdl_role_assignments AS ra ON ra.contextid =
JOIN mdl_user AS u ON = ra.userid
JOIN mdl_grade_grades AS gg ON gg.userid =
JOIN mdl_grade_items AS gi ON = gg.itemid
WHERE gi.courseid =
AND gi.itemtype = ‘course’
AND c.idnumber IN (‘C101’, ‘C102’, ‘C103’, ‘C104’, ‘C105’)

ORDER BY c.idnumber