Configurable Reports by User Group

Configurable Reports by User Group

by Richard Walker -
Number of replies: 11

I have non-editing teachers that have access to a specific user group (students).  I am trying to see if I can configure a report that will give these non-editing teachers access to view only the information in the report for their students.  It looks like the report gives the information from all students and I do not want users from outside of the user group to be able to view the students reports.  I am trying to only have non-editing teachers view their students similar to how the grade book works.  Is there an option to separate by groups or is there a different plugin that separates by groups?

Average of ratings: -
In reply to Richard Walker

Re: Configurable Reports by User Group

by Lev Zadumkin -

Hi! If you are using SQL report, you can change the query so that the selection includes students only from the group the current user belongs to, using %%CURRENTUSER%% and restrict access by role.

Average of ratings: Useful (1)
In reply to Lev Zadumkin

Re: Configurable Reports by User Group

by Richard Walker -
I was using the User report. I will play with the SQL report and see what I can come up with. Thank you for the response.
In reply to Richard Walker

Re: Configurable Reports by User Group

by Luis de Vasconcelos -
How do you relate teachers to students in your Moodle site? Can a student have more than one teacher?

Does each teacher have their own courses, or do teachers share courses?

Have you looked at the cohorts function?
Average of ratings: Useful (1)
In reply to Luis de Vasconcelos

Re: Configurable Reports by User Group

by Richard Walker -
Courses are shared across teachers. The students use an enrollment key to enter the teacher's group. I am a novice with Moodle and not a programmer. I looked at cohorts, but it looks like I have to assign the students to each of the cohorts. That does not work for us since the students self enroll. We do not know which students are enrolling under each teacher.
In reply to Richard Walker

Re: Configurable Reports by User Group

by Shirley Gregorczyk -
Picture of Particularly helpful Moodlers
Are you placing the students in a Moodle Group? Or are you using the word group as a set of students?
If you were using Moodle Groups and set your permissions correctly - you should have the restrictions you are looking for.
Moodle>Documentations page for Groups
https://docs.moodle.org/35/en/Groups


Have you look at the ad-hoc contributed reports (My SQL) on the Moodle>documentation page?
https://docs.moodle.org/35/en/ad-hoc_contributed_reports
The report titled, User detailed activity in course modules looks to include the group information.
Kind Regards
In reply to Shirley Gregorczyk

Re: Configurable Reports by User Group

by Richard Walker -
Yes, our groups are working fine. The gradebook separates the students by group so teachers only see their students. The Configurable Report does not have an option to separate by groups that I can find. I want to setup a custom report to view only certain activities and separate by teacher group. I have not found a way to do that.
In reply to Richard Walker

Απάντηση: Configurable Reports by User Group

by Chrysa Souliou -
Hello Richard!
I have the same issue with Configurable Reports by User Group..Did you find any solution?
In reply to Chrysa Souliou

Re: Απάντηση: Configurable Reports by User Group

by Richard Walker -
Unfortunately I have not found a solution. I am continuing to use the regular Moodle reports which are a bit unwieldy.
In reply to Richard Walker

Re: Απάντηση: Configurable Reports by User Group

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Try this - you will have to adjust for your category but it pulls by group just fine...

SELECT DISTINCT c.shortname, usr.firstname, usr.lastname, usr.username, usr.email, groups.name
FROM prefix_course AS c
INNER JOIN prefix_context AS cx ON c.id = cx.instanceid
AND cx.contextlevel = '50'
INNER JOIN prefix_role_assignments AS ra ON cx.id = ra.contextid
INNER JOIN prefix_role AS r ON ra.roleid = r.id
INNER JOIN prefix_user AS usr ON ra.userid = usr.id
INNER JOIN prefix_groups AS groups ON c.id = groups.courseid
INNER JOIN prefix_groups_members AS members ON groups.id = members.groupid
WHERE members.userid = usr.id
AND r.id = '5'
AND c.category = 62

ORDER BY groups.name
Average of ratings: Useful (3)
In reply to Richard Walker

Re: Configurable Reports by User Group

by Ron Meske -
Picture of Particularly helpful Moodlers
Hi Richard,

I recently needed the ability to limit reports to only show members that were in the same group as the user running the report and came across your post. Using the suggestion from Emma, I created the following SQL report. In my case I was just looking for course completion, but it shouldn't be too hard to change this to pulling grades instead. I also made use of the Configurable Reports Filter capability.

Hope the following helps you get what you need. I don't know how optimized my approach is, but I am working with just a small set of users on the system.

SELECT DISTINCT
course.fullname course,
CONCAT(user.firstname, ' ', user.lastname) AS 'Name',
user.email as 'Email',
user.city as 'City',
user.department as 'Department',
CASE
WHEN completions.timecompleted IS NOT NULL THEN ( FROM_UNIXTIME(completions.timecompleted, '%m-%d-%Y'))
ELSE '-Not Yet Completed-'
END AS 'Completion'
FROM prefix_course_completions AS completions INNER JOIN prefix_course AS course ON completions.course = course.id AND course.visible = 1 INNER JOIN prefix_context AS cx ON course.id = cx.instanceid AND cx.contextlevel = '50' INNER JOIN prefix_user AS user ON completions.userid = user.id AND user.deleted = 0 AND user.suspended = 0
INNER JOIN (SELECT vm.userid, vm.groupid, vg.id, vg.courseid, vg.name FROM prefix_groups_members AS vm INNER JOIN prefix_groups AS vg ON vg.id=vm.groupid INNER JOIN prefix_course AS c2 ON c2.id = vg.courseid WHERE vm.userid=%%USERID%%) AS groups ON groups.courseid = course.id
INNER JOIN prefix_groups_members AS members ON groups.id = members.groupid WHERE members.userid = user.id AND members.userid %%USERID%% %%FILTER_COURSES:course.id%% %%FILTER_USERS:user.department%%
ORDER BY course
Average of ratings: Useful (1)
In reply to Ron Meske

Re: Configurable Reports by User Group

by Richard Walker -
Emma and Ron thank you for your solutions. I will see if I can get this to work for me and my situation.