Moodle

SQL error during review of the attempt in HEAD

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Quiz
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

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

Activity

Hide
Tim Hunt added a comment -

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.

Show
Tim Hunt added a comment - 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.
Hide
Oleg Sychev added a comment -

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.

Show
Oleg Sychev added a comment - 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.
Hide
Tim Hunt added a comment -

Yuck, there was a real mess there in the code. Thank you for noticing before it was too late to fix it.

Please can you test the latest version when you get time.

Show
Tim Hunt added a comment - Yuck, there was a real mess there in the code. Thank you for noticing before it was too late to fix it. Please can you test the latest version when you get time.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: