mirror of
https://github.com/moodle/moodle.git
synced 2025-03-19 23:20:09 +01:00
MDL-61168 mod_assign: Truncate only the online text submission
This commit is contained in:
parent
a409707794
commit
5c7351a263
@ -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,
|
||||
|
@ -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 '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user