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

Error reading from database in quiz results > manual grading



    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Duplicate
    • Affects Version/s: 2.3
    • Fix Version/s: None
    • Component/s: Quiz
    • Labels:
    • Affected Branches:


      When I click on update grades or grade all in quiz results > Manual grading; Moodle throws an Error reading from database exception. With debug on the following information is returned:

      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 '== 'finished' AND quiza.quiz = '1'' at line 4

      SELECT quiza.*, u.firstname, u.lastname, u.idnumber
      FROM mdl_quiz_attempts quiza
      JOIN mdl_user u ON u.id = quiza.userid
      WHERE quiza.uniqueid = ? AND quiza.state == ? AND quiza.quiz = ?
      [array (
      0 => 1,
      1 => 'finished',
      2 => '1',
      Error code: dmlreadexception
      Stack trace:

      line 413 of /lib/dml/moodle_database.php: dml_read_exception thrown
      line 868 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      line 198 of /mod/quiz/report/grading/report.php: call to mysqli_native_moodle_database->get_records_sql()
      line 348 of /mod/quiz/report/grading/report.php: call to quiz_grading_report->load_attempts_by_usage_ids()
      line 155 of /mod/quiz/report/grading/report.php: call to quiz_grading_report->display_grading_interface()
      line 100 of /mod/quiz/report.php: call to quiz_grading_report->display()

      To recreate:

      1. Login as a teacher and create two essay questions, one with the response format as plain text and allowing unlimited attachments, and one with the response format as HTML editor and not allowing attachments.
      2. Add the essay questions to a quiz. Also add one automatically graded question to the quiz (e.g. true/false).
      3. Login as a student and attempt the quiz, including uploading at least one file.
      4. Check that only one question allows attachments and only one question has the HTML editor.
      5. Login as the teacher and review the student's first attempt. Ensure there is a 'Make comment or override grade' link by each question.
      6. Click that link by the first essay. And add a grade and a comment in the pop-up window, then click Save. Ensure the review page updates to show this.
      7. Repeat for the second essay. Ensure the grader info is displayed in the pop-up.
      8. Browse to Quiz results > Manual grading in the navigation block. Ensure that is shows the two essays, each with one left to grade, and one already graded.
      9. Click the Also show questions that have been graded automatically link, and ensure that the third question is now also shown, with 2 automatically graded.
      10. Click one of the grade / update grades / grade all links, and make sure that works correctly.

      Expected result:

      • The user can access update grades.

      Actual result:

      • Moodle throws an exception; specified above.


          Issue Links



              timhunt Tim Hunt
              timb Tim Barker
              Component watchers:
              Tim Hunt, Andrew Nicols, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              0 Vote for this issue
              0 Start watching this issue