From f5fb84cee74ad3d22cece428ec707450e35f5645 Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 7 May 2003 05:46:01 +0000 Subject: [PATCH] Small bug fixed where last question of a file wasn't detected if it wasn't followed by a blank line --- mod/quiz/format/default.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/mod/quiz/format/default.php b/mod/quiz/format/default.php index 153329c386..f6289422a4 100644 --- a/mod/quiz/format/default.php +++ b/mod/quiz/format/default.php @@ -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; -- 2.39.5