Custom SQL Reporting Capability for Group Member Based on Group Membership

Custom SQL Reporting Capability for Group Member Based on Group Membership

by Samantha DeLand -
Number of replies: 6

We are a service provider that uses our moodle site as an LMS for company trainings.  Companies contract with us to provide online training to their employees.  The trainings are individual courses and companies are setup as Groups within each necessary course.

Currently status reports need to be requested from us by the client, we use a custom SQL Report to pull a site-wide status report that uses the Institution user profile field as a filter.

We are looking to allow the company contact the ability to pull this same (or a similar) report using their login that will also pull the site-wide (multiple course) report, but ONLY if the users Institution field matches there own.

Has anyone needed or developed a report to use here?  I have a friend who does similar work, but not moodle, and he said the report would need to associate characteristics of the "report puller" to match to user fields, and that is the hurdle we would need to figure out first.  Looking forward to any assist someone may be able to add.

Please let me know if additional information would help!

Average of ratings: -
In reply to Samantha DeLand

Re: Custom SQL Reporting Capability for Group Member Based on Group Membership

by Randy Thornton -
Picture of Documentation writers
Samantha,

Your friend is on the right track. The Configurable Reports plugin has a number of variables including one for the user running the report and the current course, which allow it to do such things. A full list of such variables is available here.

If you are using the standard user field of "institution", then with a simple restriction you can turn any query into one that matches some attribute of the person running the report:

(some logic)
JOIN prefix_user u
(more logic)
WHERE u.institution = (SELECT institution FROM prefix_user WHERE id = %%USERID%%)

Something along those lines will give you what you need.

Randy
Average of ratings: Useful (1)
In reply to Randy Thornton

Re: Custom SQL Reporting Capability for Group Member Based on Group Membership

by Samantha DeLand -
Thank you so much Randy!!! I will share this with him now to see if together we can write the SQL needed to get this done. Thankfully we are currently using the Configurable Reports plugin, so that's good.
In reply to Samantha DeLand

Re: Custom SQL Reporting Capability for Group Member Based on Group Membership

by Randy Thornton -
Picture of Documentation writers
Most welcome.

Also, since you are using the Config Reports plugin, you might take a look in the forum dedicated to it, here: https://moodle.org/mod/forum/view.php?id=7979. This is usually the place to post questions about making reports using it.
Average of ratings: Useful (1)
In reply to Randy Thornton

Re: Custom SQL Reporting Capability for Group Member Based on Group Membership

by Samantha DeLand -

Thank you so much again!!  This was my first forum post, so wasnt aware there was one specifically for this plugin.  Ill bookmark this for any future report issues...as I am sure I will run into some.  smile

In reply to Samantha DeLand

Re: Custom SQL Reporting Capability for Group Member Based on Group Membership

by Randy Thornton -
Picture of Documentation writers
No problem, welcome to Moodledom.
In reply to Randy Thornton

Re: Custom SQL Reporting Capability for Group Member Based on Group Membership

by Samantha DeLand -

Hi Randy - I was an vacation last week, but am back in the office today and so I just wanted to thank you again as I have been able to create a specific Role for this use, assigned it to a couple choice clients to beta-test, and have received confirmation from the first client that it worked perfectly!

This is going to be such a time saver for us, and such a great offering for our clients.