Site-wide grade report shows more than just course totals

Re: Site-wide grade report shows more than just course totals

by Debbie Unterseher -
Number of replies: 0

I figured it out by looking at the Lerner reports with Grades, although I modified it to concatenate the first and last name and to make sure it just displayed students and the course totals only for a certain category (the semester we are on).  Below is the finished product.



/*The SELECT command pulls out the fields that you want from the tables defined in the JOIN below. The AS part gives it a column header. */


SELECT u.firstname AS 'Name' , u.lastname AS 'Surname', CONCAT(u.firstname,' ',u.lastname) AS 'Display Name', 

c.fullname AS 'Course',



ROUND(gg.finalgrade,2) AS Score,ROUND(gg.rawgrademax,2) AS MAX, ROUND(gg.finalgrade / gg.rawgrademax * 100 ,2) AS Percentage,


/* This is where you tell it what percentage you want > than to be passing */

IF (ROUND(gg.finalgrade / gg.rawgrademax * 100 ,2) > 72,'Yes' , 'No') AS Pass

 

FROM prefix_course AS c 

JOIN prefix_context AS ctx ON c.id = ctx.instanceid 

JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id 

JOIN prefix_user AS u ON u.id = ra.userid 

JOIN prefix_grade_grades AS gg ON gg.userid = u.id 

JOIN prefix_grade_items AS gi ON gi.id = gg.itemid 

JOIN prefix_course_categories AS cc ON cc.id = c.category 


/*WHERE is how it selects the conditions you are looking for

  Below we are looking for only those that are course grades, and in the category 265 and the role of a student */


WHERE  gi.courseid = c.id AND gi.itemtype = 'course' AND cc.parent = 265 AND ra.roleid = 5

ORDER BY `Display Name` ASC

Average of ratings: Useful (2)