Thanks Deb,
Seems to be pulling the right kind of info
I even managed to change the column titles and add the idnumber column.
A couple of issues though...
1) The report is returning course completions for all courses across the site. How can I restrict this so the report only returns course completions for one course? (the course which the configurable report block is added)
2) The report is returning 896 records which is not the full number records I was expecting,
3) I'm getting a lot of duplicated records in the report, by up to 4 times.
Any ideas?
Cheers,
Andrew
Here's my current code:
SELECT u.idnumber AS 'ID' , u.firstname AS 'First' , u.lastname AS 'Last', aa.data AS 'Employment Type', ab.data AS 'Department', ac.data AS 'Dept', ad.data AS 'Sub Section', ae.data AS 'Section', af.data AS 'Directorate', ag.data AS 'Area',
CASE
WHEN gi.itemtype = 'course'
THEN CONCAT(c.fullname, ' - Total')
ELSE gi.itemname
END AS 'Item Name',
ROUND(gg.finalgrade,2) AS Grade,
FROM_UNIXTIME(gg.timemodified) AS TIME
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_user_info_data AS aa
ON u.ID = aa.userid AND aa.fieldid=1
JOIN prefix_user_info_data AS ab
ON u.ID = ab.userid AND ab.fieldid=2
JOIN prefix_user_info_data AS ac
ON u.ID = ac.userid AND ac.fieldid=3
JOIN prefix_user_info_data AS ad
ON u.ID = ad.userid AND ad.fieldid=4
JOIN prefix_user_info_data AS ae
ON u.ID = ae.userid AND ae.fieldid=5
JOIN prefix_user_info_data AS af
ON u.ID = af.userid AND af.fieldid=6
JOIN prefix_user_info_data AS ag
ON u.ID = ag.userid AND ag.fieldid=7
JOIN prefix_grade_grades AS gg ON gg.userid = u.id AND gg.finalgrade>10 and gg.finalgrade<100
JOIN prefix_grade_items AS gi ON gi.id = gg.itemid
JOIN prefix_course_categories AS cc ON cc.id = c.category
WHERE gi.courseid = c.id
ORDER BY Last