Some votes entries are not associated with an anwser.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 14 Aug 2010 08:44:29 +0000 (10:44 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 14 Aug 2010 08:44:29 +0000 (10:44 +0200)
Because of the way votes are written in the database, an entry of
survey_votes can be associated with 0 survey_answers entries. Using
a LEFT JOIN in this case is buggy because it generates NULL entries that
are not supported by the processing code.

Closes #1214

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/survey/survey.inc.php

index b416b28..0c0c645 100644 (file)
@@ -200,10 +200,9 @@ class Survey
         }
         $sql = 'SELECT v.id AS vid, a.question_id AS qid, a.answer AS answer
                   FROM survey_votes AS v
-             LEFT JOIN survey_answers AS a
-                    ON a.vote_id=v.id
+            INNER JOIN survey_answers AS a ON a.vote_id=v.id
                  WHERE v.survey_id={?}
-              ORDER BY vid ASC, qid ASC, answer ASC;';
+              ORDER BY vid ASC, qid ASC, answer ASC';
         $res = XDB::iterator($sql, $this->id); // retrieves all answers from database
         $vid = -1;
         $vid_ = 0;