]> git.mjollnir.org Git - moodle.git/commitdiff
WebCT import can now deal with escaped colons in the text bug 1182
authormoodler <moodler>
Thu, 25 Mar 2004 14:50:25 +0000 (14:50 +0000)
committermoodler <moodler>
Thu, 25 Mar 2004 14:50:25 +0000 (14:50 +0000)
mod/quiz/format/webct/format.php

index bf4d5037903074c4f6b8ea90e9b76b94e14fe7ab..d1269f0f6dfd1c4442012f64a9bd641967cc6053 100644 (file)
@@ -85,50 +85,41 @@ class quiz_file_format extends quiz_default_format {
                     unset($questiontext);
                 }
                  else {
-                    $questiontext .= $line;
+                    $questiontext .= str_replace('\:', ':', $line);
                     continue;
                 }
             }
 
             if (is_string($answertext)) {
                 if (ereg("^:",$line)) {
-                    if ($bIsHTMLText) {
-                       $answertext = unhtmlentities($answertext); // answer as HTML text not supported by Moddle
-                    }
                     $answertext = addslashes(trim($answertext));
                     $question->answer[$currentchoice] = $answertext;
                     unset($answertext);
                 }
                  else {
-                    $answertext .= $line;
+                    $answertext .= str_replace('\:', ':', $line);
                     continue;
                 }
             }
 
             if (is_string($responstext)) {
                 if (ereg("^:",$line)) {
-                    if ($bIsHTMLText) {
-                       $responstext = unhtmlentities($responstext); // answer as HTML text not supported by Moddle
-                    }
                     $question->subquestions[$currentchoice] = addslashes(trim($responstext));
                     unset($responstext);
                 }
                  else {
-                    $responstext .= $line;
+                    $responstext .= str_replace('\:', ':', $line);
                     continue;
                 }
             }
 
             if (is_string($feedbacktext)) {
                 if (ereg("^:",$line)) {
-                    if ($bIsHTMLText) {
-                       $feedbacktext = unhtmlentities($feedbacktext); // feedback as HTML text not supported by Moddle
-                    }
                     $question->feedback[$currentchoice] = addslashes(trim($feedbacktext));
                     unset($feedbacktext);
                 }
                  else {
-                    $feedbacktext .= $line;
+                    $feedbacktext .= str_replace('\:', ':', $line);
                     continue;
                 }
             }
@@ -160,9 +151,9 @@ class quiz_file_format extends quiz_default_format {
                         $errors[] = get_string("missingquestion", "quiz", $nQuestionStartLine);
                         $QuestionOK = FALSE;
                     }
-                    if (sizeof($question->answer) <= 1) {  // a question must have at last 2 answers
-                        $errors[] = get_string("missinganswer", "quiz", $nQuestionStartLine);
-                        $QuestionOK = FALSE;
+                    if (empty($question->answer)) {  // a question must have at least 1 answer
+                       $errors[] = get_string("missinganswer", "quiz", $nQuestionStartLine);
+                       $QuestionOK = FALSE;
                     }
                     else {
                         // Perform string length check