i got sql query broken because i have created quiz first without creating question.
messagePDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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 ')) AND (parent_vid = '1') AND (parent_nid = '1') AND (question_status = '1') AND' at line 3: SELECT n.nid AS nid, n.type AS type, nr.vid AS vid, nr.title AS title, qnr.question_status AS question_status, qnr.weight AS weight, qnr.max_score AS max_score, n.vid AS latest_vid FROM {node} n INNER JOIN {node_revision} nr ON n.nid = nr.nid LEFT OUTER JOIN {quiz_node_relationship} qnr ON nr.vid = qnr.child_vid WHERE (n.type IN ()) AND (parent_vid = :db_condition_placeholder_0) AND (parent_nid = :db_condition_placeholder_1) AND (question_status = :db_condition_placeholder_2) AND (n.status = :db_condition_placeholder_3) ORDER BY weight ASC; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => 1 [:db_condition_placeholder_2] => 1 [:db_condition_placeholder_3] => 1 ) in quiz_get_questions() (line 3600 of C:\wamp\www\d7\sites\all\modules\contrib\quiz\quiz.module).
This is problem occur due to
quiz.module
line no 3578
if ($include_all_types === TRUE) {
$query->condition('n.type', array_keys(_quiz_get_question_types()), 'IN');
}
should be
$question_type=_quiz_get_question_types();
if ($include_all_types === TRUE && count($question_type)>0) {
$query->condition('n.type', array_keys($question_type), 'IN');
}
Comment | File | Size | Author |
---|---|---|---|
#4 | sql-error-when-creating-a-quiz-1862482-3.patch | 633 bytes | selvamkf |
#3 | 1862482-create-quiz-without-questions-3.patch | 590 bytes | djdevin |
#2 | Create-Quiz-Sql-Error-Handling-1862482-2.patch | 485 bytes | aadityawalawalkar |
#2 | Create_Quiz_Sql_Error-1862482-2.patch | 1.33 KB | aadityawalawalkar |
Comments
Comment #1
cesarmiquel CreditAttribution: cesarmiquel commentedI was getting a similar error when saving a quiz. The problem in my case was that I had only enabled two of the submodules: quiz and quiz_question. When I enabled a question type (like the README says) the error went away.
So, it seems the problem is that users (like myself :-) ) don't read the documentation. I think a way to fix this is to enble, by default quiz_question and one type of question when quiz installs (quiz.install). Another alternative is to detect if all the requirements are enabled and if they aren't show a message via drupal_set_message() or in the status report.
Comment #2
aadityawalawalkar CreditAttribution: aadityawalawalkar commentedPlease find the patches that handles the above issue for quiz module (7.x-4.0-beta1).
1) The first patch (Create-Quiz-Sql-Error-Handling-1862482-2.patch) handles only the error that is thrown if "Quiz Question" and one of "Question types sub module" are not enabled.
2) Second patch (Create_Quiz_Sql_Error-1862482-2.patch) handles:-
a) The error that is thrown if "Quiz Question" and one of "Question types sub module" are not enabled.
b) Checks & enables "Quiz Question" & "Quiz Multichoice" module if they are not enabled when the quiz module is enabled.
Comment #3
djdevinStill happens in 7.x - rerolled.
Comment #4
selvamkf CreditAttribution: selvamkf commentedI have added the patch for latest quiz version. I tested it to see that working.
Comment #5
Sivaji_Ganesh_Jojodae CreditAttribution: Sivaji_Ganesh_Jojodae commentedThank you. I committed the last patch with some changes.