Custom SQL queries report now compatible with Moodle 2.0

Custom SQL queries report now compatible with Moodle 2.0

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

My colleague Derek Woolhead updated the code, and I just dumped in on github. (You can thank Anthony Borrow, and the people at the Oklahoma Moodle Moot who asked him about it for making it happen.)

Average of ratings:Useful (2)
In reply to Tim Hunt

Re: Custom SQL queries report now compatible with Moodle 2.0

by Stuart Mealor -
Picture of Particularly helpful Moodlers

Great stuff, I know a lot of Moodle 2.0 early adopters will really appreciate this very useful admin functionality - thanks to everyone who made this happen smile  Stu.

In reply to Stuart Mealor

Re: Custom SQL queries report now compatible with Moodle 2.0

by Chardelle Busch -
Picture of Core developers

I just tried this out and it's really nice Tim.

FYI for anyone:

If you would rather have the weekly reports run on the first day of the week that you have set in your calendar settings (instead of Saturday), change line 26 of locallib.php to:

define('REPORT_CUSTOMSQL_START_OF_WEEK', $CFG->calendar_startwday);

Prefix is not necessary, you can just bracket the table names, e.g.:

FROM {groups_members} gm

Average of ratings:Useful (1)
In reply to Chardelle Busch

Re: Custom SQL queries report now compatible with Moodle 2.0

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

Oh, of course. {} table names will just work. I had thought we would need to change the code to support them, but I was wrong. Thank you for pointing this out.

I guess we should change the help text to recommend {}, and only leave prefix_ for backwards compatibility.

In reply to Tim Hunt

Re: Custom SQL queries report now compatible with Moodle 2.0

by Joseph Heekin -

Hello Tim,

Thank you guys for making this available, and for upgrading it for Moodle 2.0. I am attempting to install the block now; however, I am seeing this error:

Plugin "block_timhunt-moodle-report_customsql-90d5492" is defective or outdated, can not continue, sorry.

Debug info: Invalid plugin directory name.
Stack trace:
  • line 592 of \lib\upgradelib.php: plugin_defective_exception thrown
  • line 267 of \lib\upgradelib.php: call to upgrade_plugins_blocks()
  • line 1421 of \lib\upgradelib.php: call to upgrade_plugins()
  • line 311 of \admin\index.php: call to upgrade_noncore()

Which I believe is typically indicative with an out-of-date plugin. I am currently using Moodle 2.0.3+ (Build: 20110623). I have tried to download a couple of times, so I am pretty sure I downloaded the one labeled for 2.0.

Any thoughts?

Thanks!

Joey

In reply to Joseph Heekin

Re: Custom SQL queries report now compatible with Moodle 2.0

by Daniel Wright -

Hi Joseph,

I've seen a couple of other problems cause this same error.  First, I've seen it when I inadvertently installed a plugin in the wrong place - a block in mods or vice versa.

I've also seen this error when the plugin's author has written the code to expect a different folder name from the one supplied in the download.  So assuming you've extracted the zip file in the blocks directory, then I think you simply need to rename the folder from "block_timhunt-moodle..." to "configurable_reports".

Hope that helps,

Dan

In reply to Joseph Heekin

Re: Custom SQL queries report now compatible with Moodle 2.0

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

I guess I should have put some install instructions in the readme.txt.;

This in an admin report. You need to install it into the admin/report folder.

When you unzip it, you need to rename the folder to customsql.

So, the code will end up in the admin/report/customsql folder.

In reply to Tim Hunt

Re: Custom SQL queries report now compatible with Moodle 2.0

by Daniel Wright -

Ah yes...customsql...sorry, was thinking about the wrong plugin!

In reply to Tim Hunt

Re: Custom SQL queries report now compatible with Moodle 2.0

by Simon Hanmer -

Tim,

 firstly thanks for this great module - we find it really useful.

We've installed it in our 2.1 site and it works great, but I'm having an issue around roles for this plugin. We have a number of admin staff that we want to give access to the reports so I created a new role 'reporter' assignable at the system level, and set the capability 'report/customsql:view' to allow (the only capability that's configured) and then assigned the admin users the new role at the system level.

However, when the users login, they don't see the 'Reports > Ad-hoc reports' option appear in the settings menu?

Do I need other capabilities?

We're on 2.1.1 and using the 20110505 version of the plugin.

In reply to Simon Hanmer

Re: Custom SQL queries report now compatible with Moodle 2.0

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

It really looks to me from the code as if report/customsql:view should be the only capability necessary.

Oh, I see. The customsql report adds itself to the settings menu if the user has 'report/customsql:view', but the place where it gets added (the Reports category) only gets added to the tree if the user has 'moodle/site:viewreports'. That is probalby why the link is not showing up. (By the way, this seems to have been fixed in Moodle 2.2.)

What happens if one of your users tries typing the URL .../admin/report/customsql/index.php into their browser, does that get them in?

In reply to Tim Hunt

Re: Custom SQL queries report now compatible with Moodle 2.0

by Simon Hanmer -

Tim, I've added the capabilities

  • report/customsql:definequeries
  • report/customsql:view
  • moodle/site:viewreports
as allowed to the role and assigned it to a user at system level. The user still doesn't see the menu entries for ad-hoc reports.
 
If I go direct to the url .../admin/report/customsql/index.php I get an access denied error.
In reply to Simon Hanmer

Re: Custom SQL queries report now compatible with Moodle 2.0

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

In that case I am baffed. I am sure I could work this out, given time, but I don't have a lot of that at the moment.

The way to debug this is probably to go into .../admin/report/customsql/index.php and start adding debugging statements like

echo "got this far 1";

at various points, to see exactly where it gets to before hitting the permisisons problem.

Also, set Debugging to developer level, that will probably give more information.

In reply to Tim Hunt

Re: Custom SQL queries report now compatible with Moodle 2.0

by Simon Hanmer -

Tim,

thanks for having a look anyway - understand you have a lot of calls on your time.

In reply to Tim Hunt

Re: Custom SQL queries report now compatible with Moodle 2.0

by Esteban Garza -

Hello!! I just started using Moodle a couple of weeks ago and I think this would be really useful! Is there an article explaining how can I install this block and what do I need to download in order to do it?

Thank you very much!!!!

In reply to Tim Hunt

Re: Custom SQL queries report now compatible with Moodle 2.0

by Doug Bell -

Hello,

 

Would this plugin allow me to get a report from all of my courses, that would tell me what students are enrolled in what group in the course? I need the ability to get a report from my moodle installation that tells me who is in what group in each course at a level without going into each course and then each group to find out.

 

I am using moodle 2.2

 

Thanks

In reply to Tim Hunt

Re: Custom SQL queries report now compatible with Moodle 2.0

by Diana G -

Hello

How can i do the report of total time of estudents in the cours? it is possible by un jquery sentence?


Thanks