Ad-hoc database queries

This report plugin allows Administrators to set up arbitrary database queries to act as ad-hoc reports. Reports can be of two types, either run on demand, or scheduled to run automatically. Other users with the right capability can go in and see a list of queries that they have access to. Results can be viewed on-screen or downloaded as CSV.
Price option: Free

Supports Moodle 1.9-5.1 See all versions
Latest release: 2 weeks ago
Installations: 4762
Downloads (last 90 days): 625

Frankenstyle name: report_customsql
Reports

Comments

Comments are no longer open for new posts. Existing comments remain available to read.

OK. Thanks. Could you possibly copy-and-paste this into the tracker. https://tracker.moodle.org/browse/CONTRIB . I think there is a component for this plugin.
Hi Tim,
firstly thanks for such a great plugin - really makes life a lot easier for us!
Our site is fully hosted with https (due to reasons beyond my control) and this means that with IE, the download functionality doesn't work (see MS KB812935 and KB316431 for more info)
I've found that amending the code in download.php from
header('Content-Disposition: attachment; filename="report.csv"');
header('Content-Type: text/csv; charset=UTF-8');
readfile($csvfilename);
to
header('Content-Disposition: attachment; filename="report.csv"');
header('Content-Type: text/csv; charset=UTF-8');
/// Print header to force download to fix https issue
if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
header('Cache-Control: max-age=10');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
header('Pragma: ');
} else { //normal http - prevent caching at all cost
header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
header('Pragma: no-cache');
}
// End of https fix
readfile($csvfilename);
fixes the issue here.
Michael created CONTRIB-4104 for the : ? issue, and I will reply there.
Hi, Tim.
I was testing this report and it still works nicely in 2.4+. I noted that some of the given examples don't work when there is a ? (question mark) or : (colon) in strings within the query. Substituting CHAR(63) and CHAR(58) respectively allowed the characters through. It would be good if the report plugin could be updated to work around these characters or if the examples could be updated to include the CHAR() substitutions.
Nora: As this is a Report plugin, it is installed by copying into the /report directory within your Moodle installation.
how to install Ad-hoc database queries
Please can you turn on Debugging to get a more detailed error message.
I installed the "Ad-hoc database queries" plugin. It installed fine, but when I go to add a new query, enter the Query SQL and then click the "Save changes" button, I get the error message: "500 Internal Server Error, The server encountered an internal error or misconfiguration and was unable to complete your request."
Can you help? Thanks.
I have now uploaded a version for Moodle 1.9 as well.
Also, it is not clear what version(s) of Moodle are supported/required by this plugin. Looks like Moodle 2.X and up, only.
This is the "Custom SQL Queries Report" plugin. Unfortunately, it is named differently here from the docs page, so searching for it is difficult.