]> git.mjollnir.org Git - moodle.git/commitdiff
Minor problem with restoring numerical questions.
authortjhunt <tjhunt>
Wed, 17 Jan 2007 17:29:08 +0000 (17:29 +0000)
committertjhunt <tjhunt>
Wed, 17 Jan 2007 17:29:08 +0000 (17:29 +0000)
question/restorelib.php
question/type/numerical/questiontype.php

index d8c0c637866ed8398e62a63b72d70c29c5fe16a4..e4ca6f7d7025ffc5f82617b6050773bb0c103878 100644 (file)
         global $CFG;
 
         $status = true;
-
+        $qtype = backup_todb($info['#']['QTYPE']['0']['#']);
+        
         //Get the answers array
         if (isset($info['#']['ANSWERS']['0']['#']['ANSWER'])) {
             $answers = $info['#']['ANSWERS']['0']['#']['ANSWER'];
                 $answer->fraction = backup_todb($ans_info['#']['FRACTION']['0']['#']);
                 $answer->feedback = backup_todb($ans_info['#']['FEEDBACK']['0']['#']);
 
+                // Update 'match everything' answers for numerical questions coming from old backup files.
+                if ($qtype == 'numerical' && $answer->answer == '') {
+                    $answer->answer = '*';
+                }
+
                 //The structure is equal to the db, so insert the question_answers
                 $newid = insert_record ("question_answers",$answer);
 
index 476ab9631bb361992ebf04d55ee35a2993f99a46..58ebac7fced0abaa777519cc673f402f21f3ccca 100644 (file)
@@ -466,9 +466,6 @@ class question_numerical_qtype extends question_shortanswer_qtype {
             $numerical = new stdClass;
             $numerical->question = $new_question_id;
             $numerical->answer = backup_todb($num_info['#']['ANSWER']['0']['#']);
-            if ($numerical->answer = '') {
-                $numerical->answer = '*';
-            }
             $numerical->tolerance = backup_todb($num_info['#']['TOLERANCE']['0']['#']);
 
             //We have to recode the answer field