PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry in quiz_node_results_answers When Quiz Page and Single Page Take

Created on 3 April 2020, about 5 years ago
Updated 18 March 2023, about 2 years ago

When I assign questions as a Single Page by enabling quiz page as below steps:

  1. Create a quiz page node
  2. Assign to a quiz into quiz Questions
  3. Re-order real questions under this
  4. Trying to take the quiz

I am getting the following error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '198390-34690-48238' for key 'result_answer': INSERT INTO {quiz_node_results_answers} (result_id, question_nid, question_vid, tid, number, display_number) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 198390 [:db_insert_placeholder_1] => 34690 [:db_insert_placeholder_2] => 48238 [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 15 [:db_insert_placeholder_5] => 15 ) in drupal_write_record() (line 7457 of /home/sothik/public_html/includes/common.inc).

Temporary Solution:
I have remove the 'result_answer' key's "Unique" index and made it just index.

🐛 Bug report
Status

Active

Version

5.7

Component

Code - Quiz core

Created by

🇧🇩Bangladesh mahsandu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇮Finland anaconda777

    Hi,

    I am seeing this error with 5.8 while true false taken. "Store results: all" and some load on the server.
    This is coming on multiple different sites, and the test is available for both, visitor users and authenticated.

    PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '33107319' for key 'result_answer_id': INSERT INTO {quiz_truefalse_user_answers} (result_answer_id, answer, score) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 33107319 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1 ) function TrueFalseResponse->save() (line 233 file /var/www/html/drupal7/web/sites/all/modules/contrib/quiz/question_types/truefalse/truefalse.classes.inc).

  • Status changed to Closed: outdated 4 months ago
  • 🇺🇸United States smustgrave

    With D7 EOL soon, I'm triaging the queue. Since there is no patch I'm going to say this one is outdated and probably won't make the cut off

Production build 0.71.5 2024