Skip to content

Commit

Permalink
MDL-69119 qformat_xml: fix mc calculated export
Browse files Browse the repository at this point in the history
The Moodle XML export of multiple choice calculated questions was
missing proper escaping of answers. Also the indentation of the
generated xml was off.

Signed-off-by: Daniel Ziegenberg <[email protected]>
  • Loading branch information
ziegenberg committed Oct 3, 2023
1 parent 43d5aec commit 55ef055
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions question/format/xml/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -1437,20 +1437,20 @@ public function writequestion($question) {

foreach ($question->options->answers as $answer) {
$percent = 100 * $answer->fraction;
$expout .= "<answer fraction=\"{$percent}\">\n";
$expout .= " <answer fraction=\"{$percent}\">\n";
// The "<text/>" tags are an added feature, old files won't have them.
$expout .= " <text>{$answer->answer}</text>\n";
$expout .= " <tolerance>{$answer->tolerance}</tolerance>\n";
$expout .= " <tolerancetype>{$answer->tolerancetype}</tolerancetype>\n";
$expout .= " <correctanswerformat>" .
$expout .= $this->writetext($answer->answer, 3);
$expout .= " <tolerance>{$answer->tolerance}</tolerance>\n";
$expout .= " <tolerancetype>{$answer->tolerancetype}</tolerancetype>\n";
$expout .= " <correctanswerformat>" .
$answer->correctanswerformat . "</correctanswerformat>\n";
$expout .= " <correctanswerlength>" .
$expout .= " <correctanswerlength>" .
$answer->correctanswerlength . "</correctanswerlength>\n";
$expout .= " <feedback {$this->format($answer->feedbackformat)}>\n";
$expout .= $this->writetext($answer->feedback);
$expout .= " <feedback {$this->format($answer->feedbackformat)}>\n";
$expout .= $this->writetext($answer->feedback, 4);
$expout .= $this->write_files($this->feedbackfiles[$answer->id]);
$expout .= " </feedback>\n";
$expout .= "</answer>\n";
$expout .= " </feedback>\n";
$expout .= " </answer>\n";
}
if (isset($question->options->unitgradingtype)) {
$expout .= " <unitgradingtype>" .
Expand Down

0 comments on commit 55ef055

Please sign in to comment.