Skip to content

Commit

Permalink
Merge branch 'MDL-61168-master' of git://github.com/junpataleta/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Feb 5, 2018
2 parents b048116 + 5c7351a commit 5bdda5e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
8 changes: 6 additions & 2 deletions mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3140,20 +3140,24 @@ public function download_rewrite_pluginfile_urls($text, $user, $plugin) {
* 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 = '';

$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,
Expand Down
15 changes: 10 additions & 5 deletions mod/assign/submission/onlinetext/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,18 @@ public function view_summary(stdClass $submission, & $showviewlink) {
$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)) {
Expand All @@ -366,12 +370,13 @@ public function view_summary(stdClass $submission, & $showviewlink) {
'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 '';
Expand Down

0 comments on commit 5bdda5e

Please sign in to comment.