SQL error when deleting quiz
| Project: | Quiz |
| Version: | 6.x-4.x-dev |
| Component: | Code - Quiz module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
When deleting a quiz I got this error:
user warning: 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 question.status = 1 ORDER BY weight' at line 7 query: SELECT DISTINCT question.nid, question.vid, question.type, nr.title, nr.body, nr.format, qnr.question_status, qnr.weight FROM node question INNER JOIN node_revisions nr ON question.nid = nr.nid LEFT JOIN quiz_node_relationship qnr ON nr.vid = qnr.child_vid AND qnr.parent_vid = 1811 AND qnr.question_status != 2 WHERE question.type IN ( 'long_answer','matching','multichoice','quiz_directions','scale','short_answer','truefalse' ) AND qnr.parent_vid = 1811 AND qnr.parent_nid = AND question.status = 1 ORDER BY weight in /Applications/MAMP/htdocs/drupal-6.13/sites/all/modules/quiz/quiz.module on line 2425.
It looks like the problem is in this section:
if (!is_null($quiz_vid)) {
$where_add[] = 'qnr.parent_vid = '. (int) $quiz_vid;
$where_add[] = 'qnr.parent_nid = '. $quiz->nid;
}
and that $quiz->nid is empty. This could be do to this line not loading correctly,
$quiz = node_load((int) arg(1));
I have to run now and can't debug it at the moment, but thought I should at least report it.

#1
I appreciate you for reporting this bug. The following change has fixed this bug for me
// FIX nid is passed as an argument.
-function _quiz_get_questions($quiz_vid = NULL, $include_all_types = TRUE, $nid_keys = FALSE) {
- $quiz = node_load((int) arg(1));
+function _quiz_get_questions($quiz_nid = NULL, $quiz_vid = NULL, $include_all_types = TRUE, $nid_keys = FALSE) {
+ $quiz = node_load($quiz_nid);
The same has been changed in all the function calls.
./quiz.module:1906: $existing_questions = _quiz_get_questions($quiz->vid, TRUE, TRUE);./quiz.module:2385:function _quiz_get_questions($quiz_vid = NULL, $include_all_types = TRUE, $nid_keys = FALSE) {
./quiz.admin.inc:253: $questions = _quiz_get_questions($quiz->vid);
./includes/qcollection/qcollection.module:98: $questions = _quiz_get_questions($node->vid);
./includes/qcollection/qcollection.inc:119: $questions = _quiz_get_questions($quiz->vid);
./quiz.pages.inc:206: $questions = _quiz_get_questions($node->vid);
Marking this as fixed.
#2
Automatically closed -- issue fixed for 2 weeks with no activity.