Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-60162

Downloading quiz attempts report gets 'Did you remember to make the first column something unique in your call to get_records?' error

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      I think the unit test coverage is fine. (The unit test I extended was failing until this fix was done.)

      The main thing to test manually is no regressions: So, go to any quiz, and check out all the reports. Make sure there are no errors.

      If you want to test the specific failure manually:

      1. You need developer debug on.
      2. Find or create a quiz.
      3. Find or enrol a student there.
      4. Give the student a second enrolment. (This probaly requires hacking in the DB. E.g. give them both a manual and a self enrolment.)
      5. Make a quiz attempt.
      6. Try to download the Quiz result -> grades report table.

      Before this fix, there was a debugging notice.

      Show
      I think the unit test coverage is fine. (The unit test I extended was failing until this fix was done.) The main thing to test manually is no regressions: So, go to any quiz, and check out all the reports. Make sure there are no errors. If you want to test the specific failure manually: You need developer debug on. Find or create a quiz. Find or enrol a student there. Give the student a second enrolment. (This probaly requires hacking in the DB. E.g. give them both a manual and a self enrolment.) Make a quiz attempt. Try to download the Quiz result -> grades report table. Before this fix, there was a debugging notice.
    • Affected Branches:
      MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE, MOODLE_33_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      There are a few quiz reports in our system generated this error.  These reports usually exhibit MDL-59931, but fixing that did not fix this.  When we download the report as CSV or Excel format, we either get an empty file or a file with some strange characters, e.g. ''.  When I turned on debugging, I would see the followings in the error log and it even exhausted all memory at the end:

      ...
      [php7:notice] PHP Notice: Did you remember to make the first column something unique in your call to get_records? Duplicate value '22750531' found in column 'id'.<ul style="text-align: left" data-rel="backtrace"><li>line 1184 of /lib/dml/mysqli_native_moodle_database.php: call to debugging()</li><li>line 594 of /question/engine/datalib.php: call to mysqli_native_moodle_database->get_records_sql()</li><li>line 335 of /mod/quiz/report/attemptsreport_table.php: call to question_engine_data_mapper->load_questions_usages_latest_steps()</li><li>line 317 of /mod/quiz/report/attemptsreport_table.php: call to quiz_attempts_report_table->load_question_latest_steps()</li><li>line 545 of /mod/quiz/report/attemptsreport_table.php: call to quiz_attempts_report_table->load_extra_data()</li><li>line 314 of /mod/quiz/report/overview/overview_table.php: call to quiz_attempts_report_table->query_db()</li><li>line 1620 of /lib/tablelib.php: call to quiz_overview_table->query_db()</li><li>line 244 of /mod/quiz/report/overview/report.php: call to table_sql in /var/www/html/lib/weblib.php on line 3110, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP Stack trace:, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 1. {main}() /var/www/html/mod/quiz/report.php:0, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 2. quiz_overview_report->display($quiz = *uninitialized*, $cm = *uninitialized*, $course = *uninitialized*) /var/www/html/mod/quiz/report.php:97, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 3. quiz_overview_table->out($pagesize = *uninitialized*, $useinitialsbar = *uninitialized*, $downloadhelpbutton = *uninitialized*) /var/www/html/mod/quiz/report/overview/report.php:244, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 4. quiz_overview_table->query_db($pagesize = *uninitialized*, $useinitialsbar = *uninitialized*) /var/www/html/lib/tablelib.php:1620, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 5. quiz_overview_table->query_db($pagesize = *uninitialized*, $useinitialsbar = *uninitialized*) /var/www/html/mod/quiz/report/overview/overview_table.php:314, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 6. quiz_overview_table->load_extra_data() /var/www/html/mod/quiz/report/attemptsreport_table.php:545, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 7. quiz_overview_table->load_question_latest_steps($qubaids = *uninitialized*) /var/www/html/mod/quiz/report/attemptsreport_table.php:317, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 8. question_engine_data_mapper->load_questions_usages_latest_steps($qubaids = *uninitialized*, $slots = *uninitialized*, $fields = *uninitialized*) /var/www/html/mod/quiz/report/attemptsreport_table.php:335, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 9. mariadb_native_moodle_database->get_records_sql($sql = *uninitialized*, $params = *uninitialized*, $limitfrom = *uninitialized*, $limitnum = *uninitialized*) /var/www/html/question/engine/datalib.php:594, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 10. debugging($message = *uninitialized*, $level = *uninitialized*, $backtrace = *uninitialized*) /var/www/html/lib/dml/mysqli_native_moodle_database.php:1184, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 11. trigger_error(*uninitialized*, *uninitialized*) /var/www/html/lib/weblib.php:3110, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP Notice: Did you remember to make the first column something unique in your call to get_records? Duplicate value '22750531' found in column 'id'.<ul style="text-align: left" data-rel="backtrace"><li>line 1184 of /lib/dml/mysqli_native_moodle_database.php: call to debugging()</li><li>line 594 of /question/engine/datalib.php: call to mysqli_native_moodle_database->get_records_sql()</li><li>line 335 of /mod/quiz/report/attemptsreport_table.php: call to question_engine_data_mapper->load_questions_usages_latest_steps()</li><li>line 317 of /mod/quiz/report/attemptsreport_table.php: call to quiz_attempts_report_table->load_question_latest_steps()</li><li>line 545 of /mod/quiz/report/attemptsreport_table.php: call to quiz_attempts_report_table->load_extra_data()</li><li>line 314 of /mod/quiz/report/overview/overview_table.php: call to quiz_attempts_report_table->query_db()</li><li>line 1620 of /lib/tablelib.php: call to quiz_overview_table->query_db()</li><li>line 244 of /mod/quiz/report/overview/report.php: call to table_sql in /var/www/html/lib/weblib.php on line 3110, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP Stack trace:, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 1. {main}() /var/www/html/mod/quiz/report.php:0, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 2. quiz_overview_report->display($quiz = *uninitialized*, $cm = *uninitialized*, $course = *uninitialized*) /var/www/html/mod/quiz/report.php:97, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 3. quiz_overview_table->out($pagesize = *uninitialized*, $useinitialsbar = *uninitialized*, $downloadhelpbutton = *uninitialized*) /var/www/html/mod/quiz/report/overview/report.php:244, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 4. quiz_overview_table->query_db($pagesize = *uninitialized*, $useinitialsbar = *uninitialized*) /var/www/html/lib/tablelib.php:1620, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 5. quiz_overview_table->query_db($pagesize = *uninitialized*, $useinitialsbar = *uninitialized*) /var/www/html/mod/quiz/report/overview/overview_table.php:314, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 6. quiz_overview_table->load_extra_data() /var/www/html/mod/quiz/report/attemptsreport_table.php:545, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 7. quiz_overview_table->load_question_latest_steps($qubaids = *uninitialized*) /var/www/html/mod/quiz/report/attemptsreport_table.php:317, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 8. question_engine_data_mapper->load_questions_usages_latest_steps($qubaids = *uninitialized*, $slots = *uninitialized*, $fields = *uninitialized*) /var/www/html/mod/quiz/report/attemptsreport_table.php:335, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 9. mariadb_native_moodle_database->get_records_sql($sql = *uninitialized*, $params = *uninitialized*, $limitfrom = *uninitialized*, $limitnum = *uninitialized*) /var/www/html/question/engine/datalib.php:594, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 10. debugging($message = *uninitialized*, $level = *uninitialized*, $backtrace = *uninitialized*) /var/www/html/lib/dml/mysqli_native_moodle_database.php:1184, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 11. trigger_error(*uninitialized*, *uninitialized*) /var/www/html/lib/weblib.php:3110, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 4096 bytes) in /var/www/html/lib/dml/mysqli_native_moodle_database.php on line 1179, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP Stack trace:, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 1. {main}() /var/www/html/mod/quiz/report.php:0, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 2. quiz_overview_report->display($quiz = *uninitialized*, $cm = *uninitialized*, $course = *uninitialized*) /var/www/html/mod/quiz/report.php:97, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 3. quiz_overview_table->out($pagesize = *uninitialized*, $useinitialsbar = *uninitialized*, $downloadhelpbutton = *uninitialized*) /var/www/html/mod/quiz/report/overview/report.php:244, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 4. quiz_overview_table->query_db($pagesize = *uninitialized*, $useinitialsbar = *uninitialized*) /var/www/html/lib/tablelib.php:1620, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 5. quiz_overview_table->query_db($pagesize = *uninitialized*, $useinitialsbar = *uninitialized*) /var/www/html/mod/quiz/report/overview/overview_table.php:314, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 6. quiz_overview_table->load_extra_data() /var/www/html/mod/quiz/report/attemptsreport_table.php:545, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 7. quiz_overview_table->load_question_latest_steps($qubaids = *uninitialized*) /var/www/html/mod/quiz/report/attemptsreport_table.php:317, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 8. question_engine_data_mapper->load_questions_usages_latest_steps($qubaids = *uninitialized*, $slots = *uninitialized*, $fields = *uninitialized*) /var/www/html/mod/quiz/report/attemptsreport_table.php:335, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 9. mariadb_native_moodle_database->get_records_sql($sql = *uninitialized*, $params = *uninitialized*, $limitfrom = *uninitialized*, $limitnum = *uninitialized*) /var/www/html/question/engine/datalib.php:594, referer: http://localhost/mod/quiz/report.php
      [php7:notice] PHP 10. mysqli_result->fetch_assoc() /var/www/html/lib/dml/mysqli_native_moodle_database.php:1179, referer: http://localhost/mod/quiz/report.php

      The problematic quiz report appeared to be in mod/quiz/report/attemptsreport.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              timhunt Tim Hunt
              Reporter:
              carsontam Carson Tam
              Peer reviewer:
              Luca Bösch
              Integrator:
              Andrew Nicols
              Tester:
              Ryan Wyllie
              Participants:
              Component watchers:
              Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                13/Nov/17