Ad-hoc database queries

Reports ::: report_customsql
Maintained by TimTim Hunt, at the OU (Perry building)Mahmoud Kassaei, Anupama Sarjoshi
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.
Latest release:
4486 sites
1k downloads
167 fans
Current versions available: 10

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 quickly set up ad-hoc reports, without having to create a whole new admin report plugin.

Screenshots

Screenshot #0

Contributors

Tim
Tim Hunt (Lead maintainer)
at the OU (Perry building)
Mahmoud Kassaei: Developer
Anupama Sarjoshi: Tester & Developer
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • Tim
    Thu, 6 Aug 2015, 5:00 PM
    A scheduled query can be sent to an email address. Look at the bottom of the form when creating a query.
  • Marcus Green
    Mon, 10 Aug 2015, 10:33 PM
    Tim or Mahmoud, it would be useful if you were to update the links to the documents to a later version
    as it is pointing to 2.2 at the moment with lots of references to Moodle 1.9 which makes it look rather
    out of date. If you just take out the version bit (the 22) it should automatically redirect to the latest version
    i.e. https://docs.moodle.org/en/Custom_SQL_queries_report
  • Tim
    Mon, 10 Aug 2015, 10:36 PM
    Thanks Marcus. Link updated.
  • wen photo
    Wed, 19 Aug 2015, 3:21 PM
    As Kathleen pointed out, it would be super awesome if we could add direct SFTP (with scheduling) capability to this plugin. Thanks for the great work!
  • charles okaformbah
    Wed, 19 Aug 2015, 4:11 PM
    Hi Tim. Need help on schedule, the query works fine but I don't seem to understand why it does not do query scheduled to my email. Don't know if I am doing something wrong or is there a cronjob I need to setup. Here is an imageprint of my setting http://prntscr.com/86cj20
  • Tim
    Wed, 19 Aug 2015, 4:14 PM
    Best to ask for help in the forum https://moodle.org/mod/forum/view.php?id=7979
  • Kat Bodine
    Mon, 21 Sept 2015, 9:58 PM
    Actually a csv file cannot be sent to an email address directly. A link to the file can be sent to a Moodle user and indirectly forwarded to that users email address, but the user still needs to log into Moodle to retrieve the csv file or create one from the data included in the email.

    We are using this tool to collect daily attendance to be imported to our SIS. Ideally I would like to have the csv file automatically dropped to ftp. The few extra steps we take daily to download the report and place it in a file is mildly annoying. BUT that being said is still 1000 times better than collecting and posting attendance by hand. Not complaining, I am very grateful for this tool. Just a suggestion regarding the ftp drop.
  • Tim
    Mon, 21 Sept 2015, 10:01 PM
    Well, if someone can code that option without making either the user interface, or the back-end code, too much more complicated, then I would certainly accept the change (and it should certainly be possible to do). However, doubt I will have the time or inclination to code this myself.
  • time!
    Wed, 11 Nov 2015, 2:48 PM
    Automating Attendance from all courses

    Hi,
    I'm wondering if anyone has written AN SQL query for generating an attendance report for all students for all courses?

    Love the power of this!
  • tim nixon
    Thu, 19 Nov 2015, 8:44 PM
    I am having a hopefully simple issue. Moodle is installed under centos..
    When I schedule a run of a sql query it never runs. The command crontab -l shows nothing scheduled and I see no cron.php in the report/customsql directory

    Is there something I need to do to have a query run at a specific time?

    Thanks
    Tim
  • tim nixon
    Thu, 19 Nov 2015, 10:12 PM
    Regarding the issue with the customsql not automatically running, as a side note I did have to add the whet call for everything else (forums, badges) to the crontab manually.
    So maybe someone knows what to add for the sql database query?

    Tim
  • Tim
    Thu, 19 Nov 2015, 10:34 PM
  • tim nixon
    Fri, 20 Nov 2015, 1:11 AM
    After I changed the cron to use cli it seems to at least look at it, but the job was scheduled for 12:00 and at 12:00 I see this in the logs
    Starting admin reports
    Processing cron function for report_customsql...
    ... started 12:00:02. Current memory use 59.9MB.
    ... Looking for old temp CSV files to delete.
    done. (2 dbqueries, 0 seconds)

    I know the query is good since the exact same one can be run on-demand

    Any ideas?
    Thanks
  • Tim
    Fri, 20 Nov 2015, 1:16 AM
    Sorry, don't know why it is not working for you. We use this feature all the time at the Open University, and it does work. So, you just have to work out how to get it set up on your server, and I am afraid I don't think I can be much help there. Sorry.
  • tim nixon
    Fri, 20 Nov 2015, 1:26 AM
    Is there a command that might fire it off manually? I could cron that
Please login to post comments