MDL-28564 question type importing, improve Jamie's fix.

This commit is contained in:
Tim Hunt
2011-08-22 23:32:48 +01:00
parent 80fa621c50
commit 6310adb3f4
2 changed files with 19 additions and 16 deletions
+3 -10
View File
@@ -986,7 +986,7 @@ class question_type {
array_shift($extraquestionfields);
$expout='';
foreach ($extraquestionfields as $field) {
$exportedvalue = self::wrap_html_special_chars($question->options->$field);
$exportedvalue = $format->xml_escape($question->options->$field);
$expout .= " <$field>{$exportedvalue}</$field>\n";
}
@@ -1003,22 +1003,15 @@ class question_type {
$expout .= " </feedback>\n";
if (is_array($extraanswersfields)) {
foreach ($extraanswersfields as $field) {
$exportedvalue = self::wrap_html_special_chars($answer->$field);
$expout .= " <$field>{$exportedvalue}</$field>\n";
$exportedvalue = $format->xml_escape($answer->$field);
$expout .= " <{$field}>{$exportedvalue}</{$field}>\n";
}
}
$expout .= " </answer>\n";
}
return $expout;
}
protected static function wrap_html_special_chars($text) {
if (!empty($text) && htmlspecialchars($text) != $text) {
$text = '<![CDATA[' . $text . ']]>';
}
return $text;
}
/**
* Abstract function implemented by each question type. It runs all the code