From 135973fb1c7e0584ffed51445ded749680d8e35b Mon Sep 17 00:00:00 2001 From: thepurpleblob Date: Tue, 10 May 2005 09:23:10 +0000 Subject: [PATCH] Export now uses functions in questiontype classes. Changes in this file reflect slightly different question object layout. --- mod/quiz/format/xml/format.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/mod/quiz/format/xml/format.php b/mod/quiz/format/xml/format.php index 7dc61d726bb..ac84bc5db3e 100755 --- a/mod/quiz/format/xml/format.php +++ b/mod/quiz/format/xml/format.php @@ -448,13 +448,14 @@ function writequestion( $question ) { // output depends on question type switch($question->qtype) { case TRUEFALSE: - $true_percent = round( $question->trueanswer->fraction * 100 ); - $false_percent = round( $question->falseanswer->fraction * 100 ); + $answer = $question->options->answers; + $true_percent = round( $answer['true']->fraction * 100 ); + $false_percent = round( $answer['false']->fraction * 100 ); // true answer $expout .= " \n"; $expout .= $this->writetext("true",3)."\n"; $expout .= " \n"; - $expout .= $this->writetext( $question->trueanswer->feedback,4,false ); + $expout .= $this->writetext( $answer['true']->feedback,4,false ); $expout .= " \n"; $expout .= " \n"; @@ -463,13 +464,13 @@ function writequestion( $question ) { $expout .= " \n"; $expout .= $this->writetext("false")."\n"; $expout .= " \n"; - $expout .= $this->writetext( $question->falseanswer->feedback,4,false ); + $expout .= $this->writetext( $answer['false']->feedback,4,false ); $expout .= " \n"; $expout .= " \n"; break; case MULTICHOICE: - $expout .= " ".$this->get_single($question->single)."\n"; - foreach($question->answers as $answer) { + $expout .= " ".$this->get_single($question->options->single)."\n"; + foreach($question->options->answers as $answer) { $percent = $answer->fraction * 100; $expout .= " \n"; $expout .= $this->writetext( $answer->answer,4,false ); @@ -480,7 +481,7 @@ function writequestion( $question ) { } break; case SHORTANSWER: - foreach($question->answers as $answer) { + foreach($question->options->answers as $answer) { $percent = 100 * $answer->fraction; $expout .= " \n"; $expout .= $this->writetext( $answer->answer,3,false ); @@ -491,12 +492,16 @@ function writequestion( $question ) { } break; case NUMERICAL: - $expout .= "$question->min\n"; - $expout .= "$question->max\n"; - $expout .= "".$this->writetext( $question->answer->feedback )."\n"; + $answer = array_pop( $question->options->answers ); + $tolerance = $question->options->tolerance; + $min = $answer->answer - $tolerance; + $max = $answer->answer + $tolerance; + $expout .= "$min\n"; + $expout .= "$max\n"; + $expout .= "".$this->writetext( $answer->feedback )."\n"; break; case MATCH: - foreach($question->subquestions as $subquestion) { + foreach($question->options->subquestions as $subquestion) { $expout .= "\n"; $expout .= $this->writetext( $subquestion->questiontext ); $expout .= "".$this->writetext( $subquestion->answertext )."\n";