Error when sorting quiz attempts 3.3.2+

Error when sorting quiz attempts 3.3.2+

by Lewis Miskowicz -
Number of replies: 3

I just updated last night successfully to the October 9th release of 3.3.2+ and I am having issues when sorting through quiz attempts. If I click on a letter of a first or last name to find a certain attempt I get the following error pasted below. I can arrange by surname or first name with no issues. Its only when I try to sort via letter that I see the error. Thanks very much!


×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 'AND lastname LIKE 'Z%' ESCAPE '\\'' at line 29
SELECT COUNT(1) FROM (SELECT DISTINCT CONCAT(u.id, '#', COALESCE(quiza.attempt, 0)) AS uniqueid,
(CASE WHEN (quiza.state = 'finished' AND NOT EXISTS (
SELECT 1 FROM mdl_quiz_attempts qa2
WHERE qa2.quiz = quiza.quiz AND
qa2.userid = quiza.userid AND
qa2.state = 'finished' AND (
COALESCE(qa2.sumgrades, 0) > COALESCE(quiza.sumgrades, 0) OR
(COALESCE(qa2.sumgrades, 0) = COALESCE(quiza.sumgrades, 0) AND qa2.attempt < quiza.attempt)
))) THEN 1 ELSE 0 END) AS gradedattempt,
quiza.uniqueid AS usageid,
quiza.id AS attempt,
u.id AS userid,
u.idnumber, u.firstnamephonetic,u.lastnamephonetic,u.middlename,u.alternatename,u.firstname,u.lastname,
u.picture,
u.imagealt,
u.institution,
u.department,
u.email,
quiza.state,
quiza.sumgrades,
quiza.timefinish,
quiza.timestart,
CASE WHEN quiza.timefinish = 0 THEN null
WHEN quiza.timefinish > quiza.timestart THEN quiza.timefinish - quiza.timestart
ELSE 0 END AS duration FROM mdl_user u
LEFT JOIN mdl_quiz_attempts quiza ON
quiza.userid = u.id AND quiza.quiz = ?
JOIN mdl_user_enrolments ej1_ue ON ej1_ue.userid = u.id
JOIN mdl_enrol ej1_e ON (ej1_e.id = ej1_ue.enrolid AND ej1_e.courseid = ?) WHERE quiza.preview = 0 AND quiza.id IS NOT NULL AND 1 = 1 AND u.deleted = 0) temp AND lastname LIKE ? ESCAPE '\\'
[array (
0 => '53',
1 => '9',
2 => 'Z%',
)]
Error code: dmlreadexception


Stack trace:

  • line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
  • line 1190 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1558 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
  • line 1631 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
  • line 1841 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
  • line 1589 of /lib/tablelib.php: call to moodle_database->count_records_sql()
  • line 542 of /mod/quiz/report/attemptsreport_table.php: call to table_sql->query_db()
  • line 314 of /mod/quiz/report/overview/overview_table.php: call to quiz_attempts_report_table->query_db()
  • line 1630 of /lib/tablelib.php: call to quiz_overview_table->query_db()
  • line 244 of /mod/quiz/report/overview/report.php: call to table_sql->out()
  • line 97 of /mod/quiz/report.php: call to quiz_overview_report->display()

Average of ratings: -
In reply to Lewis Miskowicz

Re: Error when sorting quiz attempts 3.3.2+

by Samy Khalil -

Hi,

I have the same error with Moodle 3.2 when run any grad report,


Even it is sample quiz with only 1 user and 1 question 

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 'AND firstname LIKE 'H%' ESCAPE '\\'' at line 29

SELECT COUNT(1) FROM (SELECT DISTINCT CONCAT(u.id, '#', COALESCE(quiza.attempt, 0)) AS uniqueid,
(CASE WHEN (quiza.state = 'finished' AND NOT EXISTS (
SELECT 1 FROM mdl_quiz_attempts qa2
WHERE qa2.quiz = quiza.quiz AND
qa2.userid = quiza.userid AND
qa2.state = 'finished' AND (
COALESCE(qa2.sumgrades, 0) > COALESCE(quiza.sumgrades, 0) OR
(COALESCE(qa2.sumgrades, 0) = COALESCE(quiza.sumgrades, 0) AND qa2.attempt < quiza.attempt)
))) THEN 1 ELSE 0 END) AS gradedattempt,
quiza.uniqueid AS usageid,
quiza.id AS attempt,
u.id AS userid,
u.idnumber, u.firstnamephonetic,u.lastnamephonetic,u.middlename,u.alternatename,u.firstname,u.lastname,
u.picture,
u.imagealt,
u.institution,
u.department,
u.email,
quiza.state,
quiza.sumgrades,
quiza.timefinish,
quiza.timestart,
CASE WHEN quiza.timefinish = 0 THEN null
WHEN quiza.timefinish > quiza.timestart THEN quiza.timefinish - quiza.timestart
ELSE 0 END AS duration FROM mdl_user u
LEFT JOIN mdl_quiz_attempts quiza ON
quiza.userid = u.id AND quiza.quiz = ?
JOIN mdl_user_enrolments ej1_ue ON ej1_ue.userid = u.id
JOIN mdl_enrol ej1_e ON (ej1_e.id = ej1_ue.enrolid AND ej1_e.courseid = ?) WHERE (quiza.preview = 0 OR quiza.preview IS NULL) AND 1 = 1 AND u.deleted = 0) temp AND firstname LIKE ? ESCAPE '\\'
[array (
0 => '3',
1 => '5',
2 => 'H%',
)]
Error code: dmlreadexception



Anyone has found any fix or reason for this error?  Thanks

In reply to Samy Khalil

Re: Error when sorting quiz attempts 3.3.2+

by Samy Khalil -

Hi,

I found the fix to my issue on this page

https://tracker.moodle.org/browse/MDL-60317

it was a bug and fixed, so check the above link and hopefully it helps you as well.


Good luck

Samy

In reply to Samy Khalil

Re: Error when sorting quiz attempts 3.3.2+

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Lewis,

Following Samy's link there; if you upgrade to the latest version of 3.3 you should find this error fixed.

Jon