Permalink
Browse files

MDL-32227: Plagiarism API - add support for plagiarism api to worksho…

…p module
  • Loading branch information...
1 parent 2cbdaa7 commit 67ba9007b778b5df41658be7fff31160f3c76581 @kanikagoyal kanikagoyal committed Jul 23, 2012
Showing with 41 additions and 0 deletions.
  1. +3 −0 mod/workshop/mod_form.php
  2. +18 −0 mod/workshop/renderer.php
  3. +20 −0 mod/workshop/submission.php
@@ -197,6 +197,9 @@ public function definition() {
$mform->addElement('date_time_selector', 'assessmentend', $label, array('optional' => true));
$mform->setAdvanced('assessmentend');
+ $coursecontext = context_course::instance($this->course->id);
+ plagiarism_get_form_elements_module($mform, $coursecontext);
+
// Common module settings, Restrict availability, Activity completion etc. ----
$features = array('groups'=>true, 'groupings'=>true, 'groupmembersonly'=>true,
'outcomes'=>true, 'gradecat'=>false, 'idnumber'=>false);
View
@@ -82,6 +82,7 @@ protected function render_workshop_message(workshop_message $message) {
* @return string HTML
*/
protected function render_workshop_submission(workshop_submission $submission) {
+ global $CFG;
$o = ''; // output HTML code
$anonymous = $submission->is_anonymous();
@@ -134,6 +135,15 @@ protected function render_workshop_submission(workshop_submission $submission) {
$content = format_text($submission->content, $submission->contentformat, array('overflowdiv'=>true));
$content = file_rewrite_pluginfile_urls($content, 'pluginfile.php', $this->page->context->id,
'mod_workshop', 'submission_content', $submission->id);
+ if (!empty($content)) {
+ if (!empty($CFG->enableplagiarism)) {
+ require_once($CFG->libdir.'/plagiarismlib.php');
+ $content .= plagiarism_get_links(array('userid' => $submission->authorid,
+ 'content' => $submission->content,
+ 'cmid' => $this->page->cm->id,
+ 'course' => $this->page->course));
+ }
+ }
$o .= $this->output->container($content, 'content');
$o .= $this->helper_submission_attachments($submission->id, 'html');
@@ -767,6 +777,14 @@ protected function helper_submission_attachments($submissionid, $format = 'html'
} else if ($format == 'text') {
$outputfiles .= $linktxt . PHP_EOL;
}
+
+ if (!empty($CFG->enableplagiarism)) {
+ require_once($CFG->libdir.'/plagiarismlib.php');
+ $outputfiles .= plagiarism_get_links(array('userid' => $file->get_userid(),
+ 'file' => $file,
+ 'cmid' => $this->page->cm->id,
+ 'course' => $this->page->course->id));
+ }
}
if ($format == 'html') {
@@ -207,6 +207,22 @@
}
// store the updated values or re-save the new submission (re-saving needed because URLs are now rewritten)
$DB->update_record('workshop_submissions', $formdata);
+
+ // send submitted content for plagiarism detection
+ $fs = get_file_storage();
+ $files = $fs->get_area_files($workshop->context->id, 'mod_workshop', 'submission_attachment', $submission->id);
+ $eventdata = new stdClass();
+ $eventdata->modulename = 'workshop';
+ $eventdata->cmid = $cm->id;
+ $eventdata->itemid = $submission->id;
+ $eventdata->courseid = $course->id;
+ $eventdata->userid = $USER->id;
+ $eventdata->content = $formdata->content;
+ if ($files) {
+ $eventdata->pathnamehashes = array_keys($files);
+ }
+ events_trigger('assessable_content_uploaded', $eventdata);
+
redirect($workshop->submission_url($formdata->id));
}
}
@@ -265,6 +281,10 @@
// if in edit mode, display the form to edit the submission
if ($edit) {
+ if (!empty($CFG->enableplagiarism)) {
+ require_once($CFG->libdir.'/plagiarismlib.php');
+ echo plagiarism_print_disclosure($cm->id);
+ }
$mform->display();
echo $output->footer();
die();

0 comments on commit 67ba900

Please sign in to comment.