Your Moodle version

Reports: Ad-hoc database queries

Maintained by Tim at Lone Pine Koala Sanctuary Tim Hunt
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.

This report, created by The Open University, lets Administrators set up arbitrary SQL select queries that anyone with the appropriate permissions can then run. Reports can be set to be runnable on-demand, or automatically run weekly or monthly.

The results are displayed as a fairly plain HTML table, and can also be downloaded as CSV.

The idea is that this lets you quicly set up ad-hoc reports, without having to create a whole new admin report plugin.




Tim at Lone Pine Koala Sanctuary
Tim Hunt (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Rafael Amaral
    Tue, Dec 17, 2013, 9:05 PM
    Dear Tim,

    I have updated my moodle 1.9 for 2.0.1, however, some plugins not have been actualized, I need removed then.
    I try upload a version 2.0 (or major), but the Moodle show this error:

    Plugin "mod_customsql" is defective or outdated, can not continue, sorry.


  • Tim at Lone Pine Koala Sanctuary
    Tue, Dec 17, 2013, 9:47 PM
    customsql is a Report, not an Activity. Therefore, putting the code in mod/customsql does not work. It needs to go in report/customsql.

    Also, 2.0.1 is terribly old. You really should upgrade to 2.6.0.
  • Picture of Rafael Amaral
    Tue, Dec 17, 2013, 11:25 PM
    Ok, Tim! Thank you by help. Following some articles, seems that the best option should be migrate first for 2.0, after, to migrate for 2.x.
    What you tell me?
  • Picture of Rafael Amaral
    Tue, Dec 17, 2013, 11:43 PM
    Hello Tim,

    this Moodle version haven't the report folder. Trying create one, but, nothing of different ocurred. Trying to move the plugin for folder /course/report, however, same message of error appeared. The Moodle show another message, telling that the plugin be in wrong folder.
    Can you help me?

    Thank you!
  • Tim at Lone Pine Koala Sanctuary
    Tue, Dec 17, 2013, 11:44 PM
    You would be much better asking for help in the installation forum: As I say, You don't want to use 2.0. It is terribly old, and does not have things like the report folder.
  • Picture of Rafael Amaral
    Wed, Dec 18, 2013, 12:35 AM
    Ok, Tim.
    I'll verify there.
    Thank you,
  • Picture of Andrea Gregory (Gordon)
    Thu, Jan 23, 2014, 12:36 AM
    Hi All

    Just wondering if there's any update on the 'side-pre' issue? .. i.e. on 2.5 you click on add new query then you get this error... Coding error detected, it must be fixed by a programmer: Trying to reference an unknown block region side-pre ...

    line 884 of /lib/blocklib.php: coding_exception thrown
    line 984 of /lib/blocklib.php: call to block_manager->check_region_is_known()
    line 997 of /lib/blocklib.php: call to block_manager->ensure_instances_exist()
    line 315 of /lib/blocklib.php: call to block_manager->ensure_content_created()
    line 1232 of /lib/outputrenderers.php: call to block_manager->get_content_for_region()
    line 3053 of /lib/outputrenderers.php: call to core_renderer->blocks_for_region()
    line 87 of /theme/stockport/layout/columns2.php: call to core_renderer->blocks()
    line 847 of /lib/outputrenderers.php: call to include()
    line 777 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
    line 114 of /report/customsql/edit.php: call to core_renderer->header()

  • Picture of Michael Haskell
    Wed, Feb 5, 2014, 9:56 AM
    Is there an official word on 2.6 support?
  • Tim at Lone Pine Koala Sanctuary
    Thu, Feb 6, 2014, 2:53 AM
    OK, I just uploaded a new version, that should be compatible with Moodle 2.4 to 2.6.

    The exciting new features is that you can group reports into categories, which helps manage them if you have many.
  • Tim at Lone Pine Koala Sanctuary
    Thu, Feb 6, 2014, 7:48 PM
    Note that there are some issues with the new version released yesterday. Thanks to those people who reported them, and suggested fixes. I will sort this out tomorrow. In the mean-time I have hidden version 2.5.
  • Tim at Lone Pine Koala Sanctuary
    Fri, Feb 7, 2014, 9:10 PM
    Fixed version (2.6) now available.
  • Picture of Perry Way
    Wed, Mar 5, 2014, 3:22 AM
    Hello, I tried installing this module and got the following error:

    Default exception handler: Plugin "mod_customsql" is installed in incorrect location "$CFG->dirroot/mod/customsql", expected location is "" Debug:
    Error code: detectedmisplacedplugin
    * line 583 of \lib\upgradelib.php: plugin_misplaced_exception thrown
    * line 395 of \lib\upgradelib.php: call to upgrade_plugins_modules()
    * line 1584 of \lib\upgradelib.php: call to upgrade_plugins()
    * line 431 of \admin\index.php: call to upgrade_noncore()
  • Tim at Lone Pine Koala Sanctuary
    Wed, Mar 5, 2014, 6:18 AM
    The error message is confusing. It should read

    Default exception handler: Plugin "report_customsql" is installed in incorrect location "$CFG->dirroot/mod/customsql", expected location is "$CFG->dirroot/report/customsql"
  • George
    Wed, Apr 16, 2014, 5:54 AM
    I need a query to count the number of students and Non-editing teachers who are enrolled per course. The final report must have Country, course's name, Number of students, Number of Non editing teachers. That's all. Can someone help me?
1 2 3
Please login to post comments