Created
May 3, 2012 21:54
-
-
Save mikebuchanon/2589794 to your computer and use it in GitHub Desktop.
query for final grades in moodle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | |
mgi.itemname | |
from mdl_grade_grades mgg | |
join mdl_user mu on mgg.userid=mu.id | |
join mdl_user_enrolments mue on mue.userid=mu.id | |
join mdl_grade_items mgi on mgg.itemid=mgi.id | |
join mdl_course mc on mc.id=mgi.courseid | |
join mdl_enrol me on mue.enrolid=me.id and me.courseid=mc.id | |
join mdl_role_assignments mra on mu.id=mra.userid | |
join mdl_role mr on mra.roleid=mr.id | |
where mc.category = '1' and -- mdl_course_categories.id = '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