Small bug fixed where last question of a file wasn't detected if it
wasn't followed by a blank line
This commit is contained in:
+17
-11
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user