]> git.mjollnir.org Git - moodle.git/commitdiff
Small bug fixed where last question of a file wasn't detected if it
authormoodler <moodler>
Wed, 7 May 2003 05:46:01 +0000 (05:46 +0000)
committermoodler <moodler>
Wed, 7 May 2003 05:46:01 +0000 (05:46 +0000)
wasn't followed by a blank line

mod/quiz/format/default.php

index 153329c386b4db38869d68f037a38d901b81629c..f6289422a4c90f9a0630289af5312c046e1640a3 100644 (file)
@@ -91,17 +91,23 @@ class quiz_default_format {
         $currentquestion = array();
 
         foreach ($lines as $line) {
-           $line = trim($line);
-           if (empty($line)) {
-               if (!empty($currentquestion)) {
-                   if ($question = $this->readquestion($currentquestion)) {
-                       $questions[] = $question;
-                   }
-                   $currentquestion = array();
-               }
-           } else {
-               $currentquestion[] = $line;
-           }
+            $line = trim($line);
+            if (empty($line)) {
+                if (!empty($currentquestion)) {
+                    if ($question = $this->readquestion($currentquestion)) {
+                        $questions[] = $question;
+                    }
+                    $currentquestion = array();
+                }
+            } else {
+                $currentquestion[] = $line;
+            }
+        }
+
+        if (!empty($currentquestion)) {  // There may be a final question
+            if ($question = $this->readquestion($currentquestion)) {
+                $questions[] = $question;
+            }
         }
 
         return $questions;