Here's what I did to reproduce:
1. Prior to creating the any quiz, I have created a number of true/false and multiple choice questions (I manually had to enter the score for the correct answer because that too would cause an error if left out)
2. Create new quiz, leaving default options (also no questions), providing just a title
3. Save quiz
4. Click on the edit tab and update *any* information
5. Get the following error:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'max_score' cannot be null: UPDATE {quiz_node_properties} SET max_score=max_score_for_random * number_of_random_questions + ( SELECT SUM(max_score) FROM {quiz_node_relationship} qnr WHERE qnr.question_status = 1 AND parent_vid = quiz_node_properties.vid) WHERE (vid IN (:db_condition_placeholder_0)) ; Array ( [:db_condition_placeholder_0] => 1009 ) in quiz_update_max_score_properties() (line 2574 of /var/www/www.iprhelpdesk.eu/htdocs/sites/all/modules/quiz/quiz.module).
I also get this error when I try to add questions. Basically I cannot save a modified quiz. This is a vanilla install on Drupal 7.12
Comments
Comment #1
dkliewer commentedComment #2
george.plescan commentedSame error for max_score on any CRUD for the quiz.
I tried to look at the queries, not much I can say.
I was lucky to have a older dev version which is working.
Can't blame the developers, there is so much to do to make a good testing platform.
Comment #3
lzimmerman commentedI added the following to quiz.module at the end of the quiz_validate($node) function for debugging:
I'm guessing that the failing SQL query is the following, from quiz_update_max_score_properties($quizzes_to_update):
The calculation would fail if "max_score_for_random" in "max_score_for_random * number_of_random_questions" were null.
I have temporarily fixed the problem by replacing the db_update above (around line 2566), adding a conditional which checks whether $max_score_for_random is null (drupal messages set for debugging). If $max_score_random is null, it sets a 'default' of 1 (value from quiz.install):
I'm not sure whether this will have detrimental effects on other quiz behavior (will max_score be set properly if legitimate values become available?), but it did allow my test quiz (one multiple-choice question) to function.
There's probably a deeper error here, and maybe this workaround will help with debugging.
Comment #4
falcon commentedFixed, thanks