From 4fe75e75cb74e6f124ec5e87d246caa7c88c1ce0 Mon Sep 17 00:00:00 2001 From: Andrew Gosali Date: Tue, 18 Mar 2025 11:13:46 +0700 Subject: [PATCH] MDL-84539 report_participation: use capability viewanonymousevents --- report/participation/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/report/participation/index.php b/report/participation/index.php index 08eb85e71d5..e0883438d32 100644 --- a/report/participation/index.php +++ b/report/participation/index.php @@ -260,6 +260,8 @@ if (!empty($instanceid) && !empty($roleid)) { // Get record from sql_internal_table_reader and merge with records got from legacy log (if needed). if (!$onlyuselegacyreader) { + $anonymoussql = !has_capability('moodle/site:viewanonymousevents', $context) ? 'AND l.anonymous = 0' : ''; + $sql = "SELECT ra.userid, $usernamefields, u.idnumber, COUNT(DISTINCT l.timecreated) AS count FROM {user} u JOIN {role_assignments} ra ON u.id = ra.userid AND ra.contextid $relatedctxsql AND ra.roleid = :roleid @@ -268,7 +270,7 @@ if (!empty($instanceid) && !empty($roleid)) { ON l.contextinstanceid = :instanceid AND l.timecreated > :timefrom" . $crudsql ." AND l.edulevel = :edulevel - AND l.anonymous = 0 + " . $anonymoussql . " AND l.contextlevel = :contextlevel AND (l.origin = 'web' OR l.origin = 'ws') AND l.userid = ra.userid";