in Moodle 3.10 and 3.11 everything seems to work but when there are multiple attempts the report displays only the first attempt, since in the SELECT query the first column is the userid.
Moodle shows the following error:
Did you remember to make the first column something unique in your call to get_records? Duplicate value '3' found in column 'userid'.
line 1282 of /lib/dml/mysqli_native_moodle_database.php: call to debugging()
line 143 of /mod/quiz/report/archive/report.php: call to mysqli_native_moodle_database->get_records_sql()
line 123 of /mod/quiz/report/archive/report.php: call to quiz_archive_report->quizreportgetstudentandattempts()
line 104 of /mod/quiz/report/archive/report.php: call to quiz_archive_report->display_archive()
line 97 of /mod/quiz/report.php: call to quiz_archive_report->display()
Solve the problem is really simple, you should set the attemptid as first column, as follow (report.php, row 139-141):
$sql = "SELECT DISTINCT quiza.id attemptid, u.id userid, u.firstname, u.lastname FROM {user} u " .
"LEFT JOIN {quiz_attempts} quiza " .
"ON quiza.userid = u.id WHERE quiza.quiz = :quizid ORDER BY u.lastname ASC, u.firstname ASC";
Hi,
in Moodle 3.10 and 3.11 everything seems to work but when there are multiple attempts the report displays only the first attempt, since in the SELECT query the first column is the userid. Moodle shows the following error:
Solve the problem is really simple, you should set the attemptid as first column, as follow (report.php, row 139-141): $sql = "SELECT DISTINCT quiza.id attemptid, u.id userid, u.firstname, u.lastname FROM {user} u " . "LEFT JOIN {quiz_attempts} quiza " . "ON quiza.userid = u.id WHERE quiza.quiz = :quizid ORDER BY u.lastname ASC, u.firstname ASC";
Thanks, Giorgio