Skip to content

Commit

Permalink
MDL-61052 assign: Do not queue conversions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Damyon Wiese committed Oct 22, 2018
1 parent 6d03e5e commit 3bea0fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion mod/assign/feedback/editpdf/classes/document_services.php
Expand Up @@ -137,7 +137,8 @@ protected static function strip_images($html) {
$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);
}

/**
Expand Down
7 changes: 3 additions & 4 deletions mod/assign/submission/onlinetext/locallib.php
Expand Up @@ -398,10 +398,9 @@ public function get_files(stdClass $submission, stdClass $user) {
// 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()));
// 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>';

Expand Down

0 comments on commit 3bea0fa

Please sign in to comment.