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

Error writing to database when previewing quiz with no way to rectify.

    Details

    • Database:
      Any
    • Testing Instructions:
      Hide

      1. Create a simple quiz that allows multiple attempts (e.g. 1 true-false question).
      2. Enrol user u1 in the course as a student.
      3. As user u1, attempt the quiz.
      4. Now change u1's role from Student to Teacher.
      5. As user u1, try to preview the quiz. You should be able to.

      Previously, step 5 caused an error.

      Show
      1. Create a simple quiz that allows multiple attempts (e.g. 1 true-false question). 2. Enrol user u1 in the course as a student. 3. As user u1, attempt the quiz. 4. Now change u1's role from Student to Teacher. 5. As user u1, try to preview the quiz. You should be able to. Previously, step 5 caused an error.
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      mdl35868-master

      Description

      Steps to reproduce:

      Switch role to student and attempt a quiz.
      Save all and finish.
      Return to normal role.
      Preview the same quiz.

      You will see the following:
      Debug info: Duplicate entry '1-2-1' for key 'mdl_quizatte_quiuseatt_uix'
      INSERT INTO mdl_quiz_attempts (quiz,userid,preview,layout,attempt,timestart,timefinish,timemodified,state,uniqueid) VALUES(?,?,?,?,?,?,?,?,?,?)
      [array (
      0 => '1',
      1 => '2',
      2 => 1,
      3 => '1,0',
      4 => 1,
      5 => 1349710423,
      6 => 0,
      7 => 1349710423,
      8 => 'inprogress',
      9 => 2,
      )]
      Error code: dmlwriteexception
      Stack trace:
      line 410 of /lib/dml/moodle_database.php: dml_write_exception thrown
      line 1029 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      line 1071 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
      line 251 of /mod/quiz/startattempt.php: call to mysqli_native_moodle_database->insert_record()

      This would be tolerable if you could delete said attempt.
      Even with the latest patch from MDL-35163, you are unable to delete the attempt.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  9 Vote for this issue
                  Watchers:
                  9 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    13/May/13