]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed bug that was pointed out by Tom Cat:
authorkaipe <kaipe>
Sun, 10 Aug 2003 12:09:49 +0000 (12:09 +0000)
committerkaipe <kaipe>
Sun, 10 Aug 2003 12:09:49 +0000 (12:09 +0000)
The reuse of old quiz_answers records for question type multianswer/embedded did not work properly.

mod/quiz/lib.php

index 0f07c75f95880cb8e960bac00c0584a8c4292b56..27628e265a0f0d16e434468670ee8361b97ad746 100644 (file)
@@ -2255,8 +2255,8 @@ function quiz_save_multianswer_alternatives
 // otherwise the ids of the answers.
 
     if (empty($oldalternativeids)
-        or $oldalternatives =
-            get_records_list('quiz_answers', 'id', $oldalternativeids))
+        or !($oldalternatives =
+                get_records_list('quiz_answers', 'id', $oldalternativeids)))
     {
         $oldalternatives = array();
     }
@@ -2280,7 +2280,7 @@ function quiz_save_multianswer_alternatives
             $alt->answer = $altdata->answer;
             $alt->fraction = $altdata->fraction;
             $alt->feedback = $altdata->feedback;
-            if (! $alt->id = insert_record("quiz_answers", $alt)) {
+            if (!($alt->id = insert_record("quiz_answers", $alt))) {
                 return false;
             }
         }
@@ -2319,7 +2319,7 @@ function quiz_save_multianswer_alternatives
         delete_records("quiz_answers", "id", $altobsolete->id);
         
         // Possibly obsolute numerical options are also to be deleted:
-        delete_records("quiz_numerical", 'answer', $alt->id);
+        delete_records("quiz_numerical", 'answer', $altobsolete->id);
     }
 
     // Common alternative options and removal of obsolete options