Ad-hoc database queries
Maintained by
Tim Hunt, Mahmoud Kassaei, Hieu Vu Van
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.
Comments
Comments are no longer open for new posts. Existing comments remain available to read.
You will need to make a new role "View reports" which give that capability, and which you assign at site-level.
(Alternatively, you could call the role something more meaningful like "Teaching staff" in case you need to use it for other purposes in the future.)
I am using customsql 2014020700.
Error when executing the query: ERROR: Incorrect number of query parameters. Expected 1, got 0.
Debug info:
Error code: queryfailed
Stack trace:
line 476 of /lib/setuplib.php: moodle_exception thrown
line 102 of /report/customsql/view.php: call to print_error()
Using Moodle 2.5.2+ (Build: 20131101), plugin version 2013062400, running on MAMP (PHP Version 5.3.28) and MySQL 5.0.8.
AND mgi.courseid = :course_id
This query works, and returns results for courseid=32...
SELECT DISTINCT firstname, lastname
FROM prefix_user m
INNER JOIN prefix_grade_grades_history mgh
ON m.id =mgh.userid
INNER JOIN prefix_grade_items mgi
ON mgi.id = mgh.itemid
WHERE m.deleted = '0'
AND mgh.source = 'userdelete'
AND mgi.courseid = '32'
ORDER BY m.lastname, m.firstname
But if I try to put a placeholder so that the person running the report can choose the courseid, by replacing
AND mgi.courseid = '32'
with
AND mgi.courseid = ':course_id'
it does give me a placeholder text box on the edit screen, but it returns an error when the query is executed:
Error when executing the query: ERROR: Incorrect number of query parameters. Expected 1, got 0.
Debug info:
Error code: queryfailed
Stack trace:
line 476 of /lib/setuplib.php: moodle_exception thrown
line 102 of /report/customsql/view.php: call to print_error()
So, what am I missing/doing wrong?
A stupid question maybe. I make a query on course completion dates, and give me results in english lang (like "monday 5th May"): is there any way to have results in other languages, such as mine? My DB, as far as i know, and my Moodle have NON ENGLISH lang settings, so I can't figure out how to solve this problem.