From: thepurpleblob Date: Mon, 9 Aug 2004 13:55:20 +0000 (+0000) Subject: more fixes - xml export now pretty much working X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=29a95feb9453b2c44097b3cb6c9a37630a7f2240;p=moodle.git more fixes - xml export now pretty much working --- diff --git a/mod/quiz/format/xml/format.php b/mod/quiz/format/xml/format.php index f9aad38fd4..012b2dc457 100755 --- a/mod/quiz/format/xml/format.php +++ b/mod/quiz/format/xml/format.php @@ -126,8 +126,7 @@ function get_qtype( $type_id ) { $name = 'cloze'; break; default: - $name = ''; - error( "question type $type_id is not defined in get_qtype" ); + $name = 'Unknown'; } return $name; } @@ -142,6 +141,17 @@ function writetext( $raw ) { return "$raw\n"; } +function presave_process( $content ) { + // override method to allow us to add xml headers and footers + + $content = "\n" . + "\n" . + $content . "\n" . + ""; + + return $content; +} + function writequestion( $question ) { // turns question into string // question reflects database fields for general question and specific to type @@ -150,7 +160,7 @@ function writequestion( $question ) { $expout = ""; // add comment - $expout .= "\n\n\n"; + $expout .= "\n\n\n"; // add opening tag $question_type = $this->get_qtype( $question->qtype ); @@ -199,7 +209,7 @@ function writequestion( $question ) { case NUMERICAL: $expout .= "$question->min\n"; $expout .= "$question->max\n"; - $expout .= "".$this->writetext( $answer->feedback )."\n"; + $expout .= "".$this->writetext( $question->answer->feedback )."\n"; break; case MATCH: foreach($question->subquestions as $subquestion) { @@ -210,18 +220,21 @@ function writequestion( $question ) { } break; case DESCRIPTION: - $expout .= "\n"; + // nothing more to do for this type break; case MULTIANSWER: $expout .= "\n"; break; default: - error( "No handler for qtype $question->qtype for GIFT export" ); + $expout .= "\n"; } // close the question tag $expout .= "\n"; + // run through xml tidy function - return $this->indent_xhtml( $expout, ' ' ); + $tidy_expout = $this->indent_xhtml( $expout, ' ' ) . "\n\n"; + + return $tidy_expout; } }