Hi there, i get a SQL error when i press the next button of the Quiz for the Drag Drop question. Here is the message :

PDOException : SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '10-94-106' for key 'PRIMARY': INSERT INTO {quiz_drag_drop_user_answers} (question_nid, question_vid, result_id, score) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 94 [:db_insert_placeholder_1] => 106 [:db_insert_placeholder_2] => 10 [:db_insert_placeholder_3] => 1 ) dans DragDropResponse->save() (line 308 dans sites\all\modules\quiz_drag_drop\quiz_drag_drop.classes.inc).

Comments

alex_21’s picture

After testing somes options from the quiz, it look like this SQL error comes if the option "start again the question if incorrect" is chosen form the edit quiz section. Hope this can help.

npscode’s picture

Hey Alex,

I will look in to this issue. Give me some time.

Thanks,
Naren

alex_21’s picture

Hi,
After some tests and without the option "start again the question if incorrect" from the quiz option, i can reproduce the same kind of error :

PDOException : SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '11-102-142' for key 'PRIMARY': INSERT INTO {quiz_drag_drop_user_answers} (question_nid, question_vid, result_id, score) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 102 [:db_insert_placeholder_1] => 142 [:db_insert_placeholder_2] => 11 [:db_insert_placeholder_3] => 1 ) dans DragDropResponse->save() (line 308 in sites\all\modules\quiz_drag_drop\quiz_drag_drop.classes.inc).

This error come only if the user put all the images of the quiz in the wrong places. Strangely, if we go back to the quiz and do it again, (right or wrong) we can continue and finish the quiz, but the Drag drop question doesn't appears in the results if we get this error.

Thanks.

npscode’s picture

Version: 7.x-1.0 » 7.x-1.4
Status: Active » Closed (fixed)

Hi alex,

Issue is fixed, download 7.x-1.4 version.

Let me know if you still find any issue.

alex_21’s picture

Looks fine, good job !!

Thank Naren.

shenzhuxi’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Issue summary: View changes
Status: Closed (fixed) » Active

With 7.x-1.x-dev and 7.x-1.4, I still have

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'result_id' cannot be null: INSERT INTO {quiz_drag_drop_user_answers} (question_nid, question_vid, result_id, score) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 21 [:db_insert_placeholder_1] => 30 [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => 1 ) in DragDropResponse->save() (line 307 of

It seems because that Quiz 7.x-5.0-beta3 changed something.
I fixed it by:

--- a/quiz_drag_drop.classes.inc
+++ b/quiz_drag_drop.classes.inc
@@ -301,7 +301,7 @@ class DragDropResponse extends QuizQuestionResponse {
         ->fields(array(
           'question_nid' => $this->question->nid,
           'question_vid' => $this->question->vid,
-          'result_id' => $this->rid,
+          'result_id' => $this->result_answer_id,
           'score' => (int) $this->getScore(),
         ))
         ->execute();