From f0c1799e43cf03ee3893ef56c845b75ab71175fd Mon Sep 17 00:00:00 2001 From: thepurpleblob Date: Wed, 11 Jul 2007 09:18:32 +0000 Subject: [PATCH] MDL-10415: Aiken format returns/ --- question/format/aiken/format.php | 85 ++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 question/format/aiken/format.php diff --git a/question/format/aiken/format.php b/question/format/aiken/format.php new file mode 100644 index 0000000000..1d53d6b0f7 --- /dev/null +++ b/question/format/aiken/format.php @@ -0,0 +1,85 @@ +defaultquestion(); + $endchar = chr(13); + foreach ($lines as $line) { + $stp = strpos($line,$endchar,0); + $newlines = explode($endchar,$line); + $foundQ = 0; + for ($i=0; $i < count($newlines);$i++){ + $nowline = addslashes($newlines[$i]); + ///Go through the array and build an object called $question + ///When done, add $question to $questions + if (strlen($nowline)< 2) { + continue; + } + // This will show everyline when file is being processed + // print("$nowline
"); + $leader = substr(ltrim($nowline),0,2); + if (strpos(".A)B)C)D)E)F)G)H)I)J)A.B.C.D.E.F.G.H.I.J.",$leader)>0){ + //trim off the label and space + $question->answer[] = substr($nowline,3); + $question->fraction[] = 0; + $question->feedback[] = ''; + continue; + } + if ($leader == "AN"){ + $ans = trim(strstr($nowline,":")); + $ans = substr($ans,2,1); + //A becomes 0 since array starts from 0 + $rightans = ord($ans) - 65; + $question->fraction[$rightans] = 1; + $questions[] = $question; + //clear array for next question set + $question = $this->defaultquestion(); + continue; + } else { + //Must be the first line since no leader + $question->qtype = MULTICHOICE; + $question->name = addslashes( substr($nowline,0,50) ); + $question->questiontext = $nowline; + $question->single = 1; + $question->feedback[] = ""; + } + } + } + return $questions; + } + + function readquestion($lines) { + //this is no longer needed but might still be called by default.php + return; + } +} + +?> -- 2.39.5