Skip to content

Commit

Permalink
more fixes - xml export now pretty much working
Browse files Browse the repository at this point in the history
  • Loading branch information
thepurpleblob committed Aug 9, 2004
1 parent 389a4df commit 29a95fe
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions mod/quiz/format/xml/format.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ function get_qtype( $type_id ) {
$name = 'cloze'; $name = 'cloze';
break; break;
default: default:
$name = ''; $name = 'Unknown';
error( "question type $type_id is not defined in get_qtype" );
} }
return $name; return $name;
} }
Expand All @@ -142,6 +141,17 @@ function writetext( $raw ) {
return "<text>$raw</text>\n"; return "<text>$raw</text>\n";
} }


function presave_process( $content ) {
// override method to allow us to add xml headers and footers

$content = "<?xml version=\"1.0\"?>\n" .
"<quiz>\n" .
$content . "\n" .
"</quiz>";

return $content;
}

function writequestion( $question ) { function writequestion( $question ) {
// turns question into string // turns question into string
// question reflects database fields for general question and specific to type // question reflects database fields for general question and specific to type
Expand All @@ -150,7 +160,7 @@ function writequestion( $question ) {
$expout = ""; $expout = "";


// add comment // add comment
$expout .= "\n\n<!-- question: $question->id name: $question->name -->\n"; $expout .= "\n\n<!-- question: $question->id -->\n";


// add opening tag // add opening tag
$question_type = $this->get_qtype( $question->qtype ); $question_type = $this->get_qtype( $question->qtype );
Expand Down Expand Up @@ -199,7 +209,7 @@ function writequestion( $question ) {
case NUMERICAL: case NUMERICAL:
$expout .= "<min>$question->min</min>\n"; $expout .= "<min>$question->min</min>\n";
$expout .= "<max>$question->max</max>\n"; $expout .= "<max>$question->max</max>\n";
$expout .= "<feedback>".$this->writetext( $answer->feedback )."</feedback>\n"; $expout .= "<feedback>".$this->writetext( $question->answer->feedback )."</feedback>\n";
break; break;
case MATCH: case MATCH:
foreach($question->subquestions as $subquestion) { foreach($question->subquestions as $subquestion) {
Expand All @@ -210,18 +220,21 @@ function writequestion( $question ) {
} }
break; break;
case DESCRIPTION: case DESCRIPTION:
$expout .= "<!-- DESCRIPTION type is not supported -->\n"; // nothing more to do for this type
break; break;
case MULTIANSWER: case MULTIANSWER:
$expout .= "<!-- CLOZE type is not supported -->\n"; $expout .= "<!-- CLOZE type is not supported -->\n";
break; break;
default: default:
error( "No handler for qtype $question->qtype for GIFT export" ); $expout .= "<!-- Question type is unknown or not supported (Type=$question->qtype) -->\n";
} }
// close the question tag // close the question tag
$expout .= "</question>\n"; $expout .= "</question>\n";

// run through xml tidy function // run through xml tidy function
return $this->indent_xhtml( $expout, ' ' ); $tidy_expout = $this->indent_xhtml( $expout, ' ' ) . "\n\n";

return $tidy_expout;
} }
} }


Expand Down

0 comments on commit 29a95fe

Please sign in to comment.