From 4f390427d58d4e9ce5cdc4fba1e2bdb04f33ff26 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Wed, 17 Jan 2007 17:29:08 +0000 Subject: [PATCH] Minor problem with restoring numerical questions. --- question/restorelib.php | 8 +++++++- question/type/numerical/questiontype.php | 3 --- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/question/restorelib.php b/question/restorelib.php index d8c0c63786..e4ca6f7d70 100644 --- a/question/restorelib.php +++ b/question/restorelib.php @@ -311,7 +311,8 @@ 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']; @@ -333,6 +334,11 @@ $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); diff --git a/question/type/numerical/questiontype.php b/question/type/numerical/questiontype.php index 476ab9631b..58ebac7fce 100644 --- a/question/type/numerical/questiontype.php +++ b/question/type/numerical/questiontype.php @@ -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 -- 2.39.5