Thanks Randy for all your work on the plugin, and for the effort in responding to all of us!
I have been struggling to customise the badges issued by user custom report for several weeks now, and am losing sleep 🤣😳💀
- I'd like to shows all the badges in a specific course, and show if they have been achieved, by group.
- Course users are enrolled into separate exclusive groups (i.e they do not appear in more than one).
*(ideally, it would be great to have an expiry status where there is one, but i haven't tried that yet)
T
For giggles here is the code i have done so far but if there is an easier way i would love to know. So far i can only show badges issued, and i *think* that the code is working for what i want in the
SELECT DISTINCT g.name AS "group name", u.username, b.name AS badgename,
CASE
WHEN b.courseid IS NOT NULL THEN
(SELECT c.shortname
FROM prefix_course c
WHERE c.id = b.courseid)
WHEN b.courseid IS NULL THEN '*'
END AS "course name",
CASE
WHEN t.criteriatype = 1 AND t.method = 1 THEN 'Activity Completion (All)'
WHEN t.criteriatype = 1 AND t.method = 2 THEN 'Activity Completion (Any)'
WHEN t.criteriatype = 2 AND t.method = 2 THEN 'Manual Award'
WHEN t.criteriatype = 4 AND t.method = 1 THEN 'Course Completion (All)'
WHEN t.criteriatype = 4 AND t.method = 2 THEN 'Course Completion (Any)'
ELSE CONCAT ('Other: ', t.criteriatype)
END AS Criteriatype,
DATE_FORMAT( FROM_UNIXTIME( d.dateissued ) , '%Y-%m-%d' ) AS dateissued,
CONCAT ('<a target="_new" href="%%WWWROOT%%/badges/badge.php?hash=',d.uniquehash,'">Badge Details</a>') AS Details
FROM prefix_badge_issued AS d
JOIN prefix_user AS u ON d.userid = u.id
JOIN prefix_badge AS b ON d.badgeid = b.id
JOIN prefix_badge_criteria AS t ON b.id = t.badgeid
JOIN prefix_cohort_members AS cm ON u.id = cm.userid
JOIN prefix_cohort AS ch ON cm.cohortid = ch.id
JOIN prefix_context AS x ON ch.contextid = x.id
JOIN prefix_course AS c ON b.courseid = c.id
JOIN prefix_groups AS g on c.id = g.courseid
JOIN prefix_groups_members AS gm on u.id = gm.userid
WHERE t.criteriatype IN (1,2,3,4)
AND b.courseid = %%COURSEID%%
AND c.category = 157
AND g.name = 'Test Group'
##AND ch.name ='Test Cohort'
Any help would be wholeheartedly appreciated.
