Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
query for final grades in moodle
select mc.shortname as course_Id,mu.username,
case when ABS(ROUND(mgg.finalgrade, 0) - mgg.finalgrade) <= 0.0000005 then cast(mgg.finalgrade as text) else 'Pending...' end as final_grade,
from mdl_grade_grades mgg
join mdl_user mu on
join mdl_user_enrolments mue on
join mdl_grade_items mgi on
join mdl_course mc on
join mdl_enrol me on and
join mdl_role_assignments mra on
join mdl_role mr on
where mc.category = '1' and -- = '1'; id=1 => name='Spring 2012' as an example
mr.shortname='student' and -- only get people enrolled with a 'student' role in the course
mgi.itemname ilike '%Final%Grade%'; --anything with 'final' and 'grade' in it regardless of case and surrounding text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment