List of users assigned category-level roles (site-wide)

List of users assigned category-level roles (site-wide)

by Mark Roche -
Number of replies: 2

Hi,

This question was posed back in 2013 but there was no response.

What I want is a list of all users assigned a Category-level role across the site.

We are running 3.6.3

Can anyone help?

Ta,

Mark

Average of ratings: -
In reply to Mark Roche

Re: List of users assigned category-level roles (site-wide)

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If you install https://moodle.org/plugins/report_customsql then

SELECT
cc.id AS categoryid,
cc.name AS categoryname,
r.shortname AS role,
u.username,
u.firstname,
u.lastname,
u.email

FROM mdl_user u
JOIN mdl_role_assignments ra ON ra.userid = u.id
JOIN mdl_context ctx ON ctx.id = ra.contextid
JOIN mdl_course_categories cc ON cc.id = ctx.instanceid
JOIN mdl_role r ON r.id = ra.roleid

WHERE ctx.contextlevel = 40
Average of ratings: Useful (2)
In reply to Tim Hunt

Re: List of users assigned category-level roles (site-wide)

by Mark Roche -
Thanks for the prompt reply, Tim.

That's looks just the ticket and loads of other very useful reports as well.

M