diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 4d84daffd7d..e3a9b5838af 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -3140,13 +3140,14 @@ class assign { * Render the content in editor that is often used by plugin. * * @param string $filearea - * @param int $submissionid + * @param int $submissionid * @param string $plugintype * @param string $editor * @param string $component + * @param bool $shortentext Whether to shorten the text content. * @return string */ - public function render_editor_content($filearea, $submissionid, $plugintype, $editor, $component) { + public function render_editor_content($filearea, $submissionid, $plugintype, $editor, $component, $shortentext = false) { global $CFG; $result = ''; @@ -3154,6 +3155,9 @@ class assign { $plugin = $this->get_submission_plugin_by_type($plugintype); $text = $plugin->get_editor_text($editor, $submissionid); + if ($shortentext) { + $text = shorten_text($text, 140); + } $format = $plugin->get_editor_format($editor, $submissionid); $finaltext = file_rewrite_pluginfile_urls($text, diff --git a/mod/assign/submission/onlinetext/locallib.php b/mod/assign/submission/onlinetext/locallib.php index 8afd96ffadf..85ea4dc3314 100644 --- a/mod/assign/submission/onlinetext/locallib.php +++ b/mod/assign/submission/onlinetext/locallib.php @@ -347,14 +347,18 @@ class assign_submission_onlinetext extends assign_submission_plugin { $showviewlink = true; if ($onlinetextsubmission) { + // This contains the shortened version of the text plus an optional 'Export to portfolio' button. $text = $this->assignment->render_editor_content(ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $onlinetextsubmission->submission, $this->get_type(), 'onlinetext', - 'assignsubmission_onlinetext'); + 'assignsubmission_onlinetext', true); + // The actual submission text. $onlinetext = trim($onlinetextsubmission->onlinetext); - $shorttext = shorten_text($text, 140); + // The shortened version of the submission text. + $shorttext = shorten_text($onlinetext, 140); + $plagiarismlinks = ''; if (!empty($CFG->enableplagiarism)) { @@ -366,12 +370,13 @@ class assign_submission_onlinetext extends assign_submission_plugin { 'course' => $this->assignment->get_course()->id, 'assignment' => $submission->assignment)); } - if ($text != $shorttext) { + // We compare the actual text submission and the shortened version. If they are not equal, we show the word count. + if ($onlinetext != $shorttext) { $wordcount = get_string('numwords', 'assignsubmission_onlinetext', count_words($onlinetext)); - return $plagiarismlinks . $wordcount . $shorttext; + return $plagiarismlinks . $wordcount . $text; } else { - return $plagiarismlinks . $shorttext; + return $plagiarismlinks . $text; } } return '';