From 2657d7cb46f87bf60a63a3a61653e4c9bbf6d345 Mon Sep 17 00:00:00 2001 From: moodler Date: Tue, 9 Dec 2003 02:00:48 +0000 Subject: [PATCH] Fix to allow quiz import to deal with Macintosh OS files (from Paul Shew) --- mod/quiz/format/default.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mod/quiz/format/default.php b/mod/quiz/format/default.php index 221ad1e5a0..0145c54c7d 100644 --- a/mod/quiz/format/default.php +++ b/mod/quiz/format/default.php @@ -78,12 +78,18 @@ class quiz_default_format { /// Returns complete file with an array, one item per line if (is_readable($filename)) { - return file($filename); + $filearray = file($filename); + + /// Check for Macintosh OS line returns (ie file on one line), and fix + if (ereg("\r", $filearray[0]) AND !ereg("\n", $filearray[0])) { + return explode("\r", $filearray[0]); + } else { + return $filearray; + } } return false; } - function readquestions($lines) { /// Parses an array of lines into an array of questions, /// where each item is a question object as defined by -- 2.39.5