MDL-61052 assign: Do not queue conversions

Identical submissions do not require individual conversions from the document converter. Text passing through
format_text cannot be trusted and is likely to be unique each time, even for the same text.
This commit is contained in:
Damyon Wiese
2018-10-22 11:56:57 +08:00
parent 888d7b585f
commit efacf3a099
2 changed files with 6 additions and 6 deletions
@@ -137,7 +137,8 @@ EOD;
$imgnode->parentNode->replaceChild($textnode, $imgnode);
}
}
return preg_replace('/^<\?xml[^>[]*(\[[^]]*\])?>/', '', $dom->saveHTML());
$count = 1;
return str_replace("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>", "", $dom->saveHTML(), $count);
}
/**
@@ -397,11 +397,10 @@ class assign_submission_onlinetext extends assign_submission_plugin {
// Note that this check is the same logic as the result from the is_empty function but we do
// not call it directly because we already have the submission record.
if ($onlinetextsubmission && !empty($onlinetextsubmission->onlinetext)) {
$finaltext = $this->assignment->download_rewrite_pluginfile_urls($onlinetextsubmission->onlinetext, $user, $this);
$formattedtext = format_text($finaltext,
$onlinetextsubmission->onlineformat,
array('context'=>$this->assignment->get_context()));
if ($onlinetextsubmission) {
// Do not pass the text through format_text. The result may not be displayed in Moodle and
// may be passed to external services such as document conversion or portfolios.
$formattedtext = $this->assignment->download_rewrite_pluginfile_urls($onlinetextsubmission->onlinetext, $user, $this);
$head = '<head><meta charset="UTF-8"></head>';
$submissioncontent = '<!DOCTYPE html><html>' . $head . '<body>'. $formattedtext . '</body></html>';