--- cvs20061101/multichoice.module	2006-11-10 06:09:01.000000000 +0100
+++ dev/multichoice.module	2006-11-10 06:22:33.000000000 +0100
@@ -199,14 +199,18 @@ function multichoice_update($node) {
   while(list($key, $value) = each($node->answers)) {
     if ($value['aid']) {
       $value['answer'] = trim($value['answer']);
-      if ($value['delete'] == 1 || empty($value['answer'])) {
+/// beware: not only '', but 0 and '0' also are empty values for PHP
+/// but $value['delete'] can be seen like a C boolean, i.e O (or unset) for false and any non-zero value if true
+      if (!empty($value['delete']) || trim($value['answer']) == '') {
         //Delete this entry
         db_query("DELETE FROM {quiz_question_answer} WHERE aid = %d", $value['aid']);
-      } else {
+      } 
+      else {
         //Update this entry
         db_query("UPDATE {quiz_question_answer} SET answer = '%s', feedback = '%s', points = %s WHERE aid = %d", $value['answer'], $value['feedback'], $value['correct'], $value['aid']);
       }
-    } else if (trim($value['answer']) != "") {
+    } 
+    else if (trim($value['answer']) != "") {
       //If there is an answer, insert a new row
       db_query("INSERT INTO {quiz_question_answer} (aid, question_nid, answer, feedback, points) VALUES(%d, %d, '%s', '%s', %d)", 
         db_next_id('quiz_question_answer_aid'), $node->nid, $value['answer'], $value['feedback'], $value['correct']);
@@ -339,7 +343,6 @@ function multichoice_evaluate_question($
 
   if (isset($_POST['edit']['tries'])) {
     if (is_array($_POST['edit']['tries'])) {
-
       // Multi-answer question
       while(list($key, $try) = each($_POST['edit']['tries'])) {
         $results['answers'] = $question->answers;
@@ -347,7 +350,6 @@ function multichoice_evaluate_question($
       }
     }
     else {
-
       // Single-answer question
       $results['answers'] = $question->answers;
       $results['tried'][] = $question->answers[$_POST['edit']['tries']]['aid'];
@@ -376,7 +378,9 @@ function multichoice_calculate_result($a
   }
   //Finally - have we got any answers left?
   //If so - they weren't knocked out as one of the correct ones so logically they must be incorrect!
-  if (count($tried) > 0) return 0;
+  if (count($tried) > 0) {
+    return 0;
+  }
 
   
   //Finally, we can consider this correct if its passed the above tests!
@@ -393,21 +397,29 @@ function multichoice_calculate_results($
     $cols = array();
     
     $cols[] = $answer['answer'];
-    if($showPoints) $cols[] = (($answer['points'] == 0) ? theme_multichoice_unselected() : theme_multichoice_selected());
+    if ($showPoints) {
+      $cols[] = (($answer['points'] == 0) ? theme_multichoice_unselected() : theme_multichoice_selected());
+    }
     $isSelected = (array_search($answer['aid'], $tried) !== FALSE);
     $cols[] = ($isSelected ? theme_multichoice_selected() : theme_multichoice_unselected());
-    if($showFeedback) $cols[] = ($isSelected ? '<div class="quiz_answer_feedback">'. $answer['feedback'] .'</div>' : '');
+    if ($showFeedback) {
+      $cols[] = ($isSelected ? '<div class="quiz_answer_feedback">'. $answer['feedback'] .'</div>' : '');
+    }
   
     $rows[] = $cols;
-  
   	
-  	if($answer['points'] > 0) {
+  	if ($answer['points'] > 0) {
   	  $correctAnswers[] = $answer['aid'];
   	}
   }
 
   
-  if($correctAnswers === $tried) { $score = 1; } else { $score = 0; }
+  if ($correctAnswers === $tried) { 
+    $score = 1; 
+  } 
+  else { 
+    $score = 0; 
+  }
   
   return array('score' => $score, 'resultstable' => $rows);
 }
