Moodle fetch Student Grades


Hi,

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

 

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

ORDER BY c.idnumber

 

Cheers

Jaswant

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s