Problem/Motivation
I face an error while deleting question of type MCQ that was assigned with quiz, when i try to delete a question i receive the below error message
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'question_nid' in 'where clause': SELECT id FROM {quiz_multichoice_user_answers} WHERE question_nid = :nid; Array ( [:nid] => 4 ) in MultichoiceQuestion->delete() (line 336 of E:\xampp\htdocs\d7-lab\sites\all\modules\quiz\question_types\multichoice\multichoice.classes.inc).
i am using the below versions
Core
7.34
Quiz
7.x-5.0-alpha7+57-dev
Quiz Multichoice
7.x-5.0-alpha7+57-dev
Proposed resolution
my expectation that the MultichoiceQuestion->delete function have to be modified to depend on quiz_multichoice_answers & quiz_multichoice_user_answers to get the question_nid and delete all answers by users that happened before for this question
this is the first time that i post issues as i like this module and used it in one of my projects so i thought this information may be useful.
Comment | File | Size | Author |
---|---|---|---|
#8 | pdoexception_when-2413821-4.patch | 7.07 KB | djdevin |
#5 | Auswahl_006.png | 58.87 KB | zuernBernhard |
#4 | pdoexception_when-2413821-4.patch | 7.07 KB | djdevin |
#2 | pdoexception_when-2413821-2.patch | 1.73 KB | djdevin |
error-delete-questions.jpg | 71.62 KB | Sherif Darwish |
Comments
Comment #1
djdevinThanks, this is a bug.
Comment #2
djdevinThis is already happening correctly in MultichoiceResponse::delete(), the patch removes the user answer deletion from the Question class. I think the same thing happens in TrueFalse as well.
Additionally I think in _quiz_delete_question we have to fire off the response deletion method. It seems to be deleting responses in both the question and the response class, when it really should be only the response class doing it.
Comment #3
Sherif Darwish CreditAttribution: Sherif Darwish commentedHi,
Thanks for your quick support for the patch, i have also checked the below question types and they have same error when trying to delete a questions
Scale question
Short answer question
True/false question
Long Answer question
The below were deleted without errors
Drag Drop Question
Quiz evaluation question
Quiz directions
Comment #4
djdevinRemoved deletions from question types. This should at least get rid of the fatals, however old data will remain (but it will not be associated with any results - orphaned).
I am going to add code into the question type, to delete all the result answers, which will then correctly remove the per-question type answers. This gets rid of a lot of code in the question types too.
Comment #5
zuernBernhard CreditAttribution: zuernBernhard commentedsame problem for shoranswer and true/false (see attached screenshot)
Comment #6
djdevinIs that with the patch above?
Comment #7
idebr CreditAttribution: idebr commentedI had the same problems as OP and I can confirm the patch resolved the issue.
Comment #8
djdevinComment #11
djdevin