Open boxwell opened 12 years ago
Hi Boxwell, thanks for the report.
I've not previously been able to reproduce this locally, so I'll need some more details about your Moodle and course, such as URL, Moodle version, course format, and where possible copies of the error log entries relevant to that error (basically, as much detail as possible).
I will attempt to force this error on my test server but a detailed error report from you would be considerably more useful.
Regards,
Vaughany.
Apologies for lack of detail, I'm not used to working in a development environment!
Our Moodle setup is as follows: Moodle 2.2+ (Build: 20111209) Running on Windows 64 bit 2008 server, with SQL server 2008 R2.
I've turned developer level debugging on our Moodle setup and this is what I get when changing to staff role:
Error reading from database
Debug info: SQLState: 42S22
Error Code: 207
Message: [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid column name '0'.
SELECT * FROM mdl_block_courseaward_vote WHERE deleted = "0" and course_id = '2950' AND note <> '' [array ( )] Stack trace:
line 394 of \lib\dml\moodle_database.php: dml_read_exception thrown
line 252 of \lib\dml\sqlsrv_native_moodle_database.php: call to moodle_database->query_end()
line 368 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->query_end()
line 773 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->do_query()
line 807 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->get_recordset_sql()
line 1129 of \lib\dml\moodle_database.php: call to sqlsrv_native_moodle_database->get_records_sql()
line 143 of \blocks\courseaward_vote\libvote.php: call to moodle_database->get_records_select()
line 165 of \blocks\courseaward_vote\block_courseaward_vote.php: call to get_notes()
line 280 of \blocks\moodleblock.class.php: call to block_courseaward_vote->get_content()
line 232 of \blocks\moodleblock.class.php: call to block_base->formatted_contents()
line 926 of \lib\blocklib.php: call to block_base->get_content_for_output()
line 978 of \lib\blocklib.php: call to block_manager->create_block_contents()
line 349 of \lib\blocklib.php: call to block_manager->ensure_content_created()
line 6 of \theme\aardvark\layout\general.php: call to block_manager->region_has_content()
line 685 of \lib\outputrenderers.php: call to include()
line 637 of \lib\outputrenderers.php: call to core_renderer->render_page_layout()
line 196 of \course\view.php: call to core_renderer->header()
Anything else you might need then please let me know.
Regards,
Graeme
It seems like MS SQL server was seeing a double-quoted number as a column name. I didn't know it did that, and I'll remember that for the future. I've committed a fix which you can see here:
https://github.com/vaughany/moodle-courseawards/commit/b88ad744c70a6a45ae4a506750c18dda0218fffd
Either pull the change (if you cloned initially) or copy and paste the changed line into courseaward_vote/libvote.php using your favourite text editor. The link above shows the file and line you need to change quite clearly.
I'll leave this issue open for a while so hopefully you will report back on success or failure.
Vaughany.
Hello,
Yes, this has solved the problem. Thanks loads for your quick response and fix. Really appreciated.
Best Regards,
Graeme
Excellent, glad to hear it. :)
Hello again,
We've recently installed your block in our production environment and it is working fantastically, with lots of students providing feedback on the Moodle courses.
When I have come to pull off any of the highest score, most votes, etc reports we get an error reading database. With debugging turned on we get the following:
Debug info: SQLState: 42000
Error Code: 102
Message: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near 'LIMIT'.
SELECT course_id, shortname, fullname, (
SELECT COUNT(vote) FROM mdl_block_courseaward_vote WHERE deleted = '0' AND mdl_block_courseaward_vote.course_id = mdl_course.id GROUP BY course_id ) AS votecount, (
SELECT COUNT(vote) FROM mdl_block_courseaward_vote WHERE deleted = '1' AND mdl_block_courseaward_vote.course_id = mdl_course.id GROUP BY course_id ) AS votecountdeleted, (
SELECT COUNT(note) FROM mdl_block_courseaward_vote WHERE deleted = '0' AND note <> '' AND mdl_block_courseaward_vote.course_id = mdl_course.id GROUP BY course_id ) AS notecount, (
SELECT COUNT(note) FROM mdl_block_courseaward_vote WHERE deleted = '1' AND note <> '' AND mdl_block_courseaward_vote.course_id = mdl_course.id GROUP BY course_id ) AS notecountdeleted, (
SELECT medal FROM mdl_block_courseaward_medal WHERE mdl_block_courseaward_medal.course_id = mdl_block_courseaward_vote.course_id AND deleted = '0' ) AS medal, (
SELECT AVG(vote) FROM mdl_block_courseaward_vote WHERE deleted = '0' AND mdl_block_courseaward_vote.course_id = mdl_course.id GROUP BY course_id ) AS voteavg
FROM mdl_block_courseaward_vote, mdl_course WHERE mdl_block_courseaward_vote.course_id = mdl_course.id GROUP BY mdl_course.id, course_id, shortname, fullname ORDER BY voteavg DESC, votecount DESC LIMIT 5; [array ( )] Stack trace: o line 394 of \lib\dml\moodle_database.php: dml_read_exception thrown o line 252 of \lib\dml\sqlsrv_native_moodle_database.php: call to moodle_database->query_end() o line 368 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->query_end() o line 773 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->do_query() o line 807 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->get_recordset_sql() o line 255 of \report\courseawards\report.php: call to sqlsrv_native_moodle_database->get_records_sql() Output buffer:
Have you any idea what we could do to rectify this?
Thanks again for all your work on this.
Graeme
Hi Graeme. I'll take the easy problems first!
Firstly, the error Invalid get_string() identifier: 'healthcenter' is a language string issue, and I don't think has anything to do with my module. If you have a module with this or a smiliar name installed, I'd investigate there first. It seems related to admin pages generally, not my module specifically.
Secondly, Navigation node intersect: Adding a node that already exists qeupgradehelper is an error relating to the Question Engine Upgrade Helper, a new feature in Moodle 2.2 IIRC, and again nothing to do with my module, but probably related to admin pages generally. This may be fixed in a later version of Moodle.
For the above two errors, I suggest you check your web server's error log as you're likely to see quite a lot more of them (assuming you have debugging turned on within Moodle).
Finally, Incorrect syntax near 'LIMIT' is a problem of my own making. It turns out that MSSQL doesn't have the same LIMIT syntax as other database engines (I use and test on MySQL and have had users test on PostgreSQL for me). It is used to return 'x' rows of data from a database query which may return considerably more, and in this case appears to be returning the 'top 5' of something.
I will look into this as soon as I can. For the time being, Can I suggest the following fix, which will remove the error but will show all results rather than the top 5 or so.
in /report/courseawards/report.php
, comment out the following lines starting on line 234:
if ($limit > 0) {
$query .= " LIMIT ".$limit.";";
} else {
$query .= ";";
}
...and then add in this line:
$query .= ";";
(If you're not aware, 'commenting out' means stopping the code from being executed without removing the code from the file. This is achieved by placing two forward slashes //
at the very start of each line, as in this example:
// if ($limit > 0) {
I hope that's clear.)
Repeat the process on lines starting 475 (which will actually be line 476 as you added a line in, above), and 848 (or 850). This will get you working for now and I will look into fixing the issue more permanently.
Regards, and thanks for the report.
Paul.
Gah, I meant to also ask what versions of Moodle and MSSQL you are running. If you could let me know it would help immensely.
P.
Hi Paul,
We are running: SQL Server 2008 Standard Edition (64 bit) Moodle 2.2 PHP 5.3.8
Hope this helps.
Regards,
Graeme Boxwell Learning Technology Coordinator Sunderland College T: 0191 511 6000 W: www.citysun.ac.uk
From: Paul Vaughan [mailto:notifications@github.com] Sent: 17 September 2012 15:38 To: vaughany/moodle-courseawards Cc: Graeme Boxwell Subject: Re: [moodle-courseawards] Issue with staff role (#2)
Gah, I meant to also ask what versions of Moodle and MSSQL you are running. If you could let me know it would help immensely.
P.
— Reply to this email directly or view it on GitHubhttps://github.com/vaughany/moodle-courseawards/issues/2#issuecomment-8616847.
Hello,
I'm hoping you can help us.
We have installed the course awards block in Moodle 2.2. When we add it to a course site, it seems to be ok, until we change to a teacher role then we get an error message saying "Error reading from database".
It works fine as an admin and also as a student but our teacher role does not like it at all.
If you can think of anything we can do?
We have amended the code as discussed on moodle.org - The block's ability to be placed in certain areas is controlled on line 44 of block_courseaward_vote.php. Change: return array('course-view' => true); ...to: return array('all' => true);
and have made some amends to the language block to change the wording, but this is all.
Any help is greatly apprecaited.
Graeme