Issue Details (XML | Word | Printable)

Key: MDL-20860
Type: Bug Bug
Status: Open Open
Priority: Minor Minor
Assignee: Tim Hunt
Reporter: Oleg Sychev
Votes: 0
Watchers: 1
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

SQL error during review of the attempt in HEAD

Created: 17/Nov/09 01:39 AM   Updated: 30/Nov/09 03:13 AM
Component/s: Quiz
Affects Version/s: 2.0
Fix Version/s: 2.0

Participants: Oleg Sychev and Tim Hunt
Security Level: None
Affected Branches: MOODLE_20_STABLE
Fixed Branches: MOODLE_20_STABLE


 Description  « Hide
After finishing a quiz you is redirected to review.php and get an error:

Debug info: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '00 < maxgrade' at line 1<br /><br />SELECT feedbacktext FROM mdl_quiz_feedback WHERE quizid = ? AND mingrade <= ? AND 0,00 < maxgrade<br />[array ( 0 => '6', 1 => '0,00', )]
Stack trace:
line 372 of \lib\dml\moodle_database.php: dml_read_exception thrown
line 656 of \lib\dml\mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 1209 of \lib\dml\moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
line 1284 of \lib\dml\moodle_database.php: call to moodle_database->get_record_sql()
line 1263 of \lib\dml\moodle_database.php: call to moodle_database->get_field_sql()
line 462 of \mod\quiz\locallib.php: call to moodle_database->get_field_select()
line 207 of \mod\quiz\review.php: call to quiz_feedback_for_grade()

P.S. I guess a function displaying SQL in errors could use some upgrading too. It escapes HTML-related things too much, resulting in a things like mingrade <= ? displayed on the page



 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Tim Hunt added a comment - 17/Nov/09 06:27 AM
Ah, the problem seems to be it is using a grade 0,00 which a 'european' decimal point, rather than 0.00. That is breaking the SQL syntax.

Oleg Sychev added a comment - 30/Nov/09 03:13 AM
After some code search and chat with Eloy it seems that $grade should be unformatted by unformat_float() function before been passed to DB. The $grade actually comes from mod/quiz/quiz_format_grade function which uses format_float to convert it to localised format.