I'm using this report as my starting point: (https://docs.moodle.org/310/en/ad-hoc_contributed_reports#Site-Wide_Grade_Report_with_All_Items), and the query works, but the filter I added in Moodle had no effect on the report. From another forum, I learned that I need to edit the code to incorporate the filter into the query for it to have any effect. I tried checking the documentation for this plugin to figure out what I need to add to the SQL code.
I added these lines:
WHERE 1=1
%%FILTER_SEARCHTEXT:u.username%%
in the code below, but can't seem to get the syntax right. Moodle keeps telling me that I have an error and need to check the manual that corresponds to my version of MariaDB, but I'm not sure where to find what to find my version information. How do I find this information, and what am I doing wrong?
SELECT u.firstname AS 'First' , u.lastname AS 'Last',
CONCAT(u.firstname,' ',u.lastname) AS 'Display Name',
u.username AS 'Username',
c.fullname AS 'Course',
CASE
WHEN gi.itemtype = 'course'
THEN ' Course Total'
ELSE gi.itemname
END AS 'Item Name',
ROUND(gg.finalgrade,2) AS Grade,
FROM_UNIXTIME(gg.timemodified) AS Time
WHERE 1=1
%%FILTER_SEARCHTEXT:u.username%%
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 gi.courseid = c.id
ORDER BY lastname
CONCAT(u.firstname,' ',u.lastname) AS 'Display Name',
u.username AS 'Username',
c.fullname AS 'Course',
CASE
WHEN gi.itemtype = 'course'
THEN ' Course Total'
ELSE gi.itemname
END AS 'Item Name',
ROUND(gg.finalgrade,2) AS Grade,
FROM_UNIXTIME(gg.timemodified) AS Time
WHERE 1=1
%%FILTER_SEARCHTEXT:u.username%%
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 gi.courseid = c.id
ORDER BY lastname