Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…odule
  • Loading branch information...
commit 103e7cba161dfc93beb8c68cded27ba1ddf9e3a5 1 parent 2cbdaa7
Kanika Goyal kanikagoyal authored
Showing with 62 additions and 0 deletions.
  1. +54 −0 mod/forum/lib.php
  2. +3 −0  mod/forum/mod_form.php
  3. +5 −0 mod/forum/post.php
54 mod/forum/lib.php
View
@@ -3177,6 +3177,14 @@ function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost=fa
$post->course = $course->id;
$post->forum = $forum->id;
$post->message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', $modcontext->id, 'mod_forum', 'post', $post->id);
+ if (!empty($CFG->enableplagiarism)) {
+ require_once($CFG->libdir.'/plagiarismlib.php');
+ $post->message .= plagiarism_get_links(array('userid' => $post->userid,
+ 'content' => $post->message,
+ 'cmid' => $cm->id,
+ 'course' => $post->course,
+ 'forum' => $post->forum));
+ }
// caching
if (!isset($cm->cache)) {
@@ -4022,6 +4030,16 @@ function forum_print_attachments($post, $cm, $type) {
$output .= '<br />';
}
}
+
+ if (!empty($CFG->enableplagiarism)) {
+ require_once($CFG->libdir.'/plagiarismlib.php');
+ $output .= plagiarism_get_links(array('userid' => $post->userid,
+ 'file' => $file,
+ 'cmid' => $cm->id,
+ 'course' => $post->course,
+ 'forum' => $post->forum));
+ $output .= '<br />';
+ }
}
}
@@ -4279,6 +4297,9 @@ function forum_add_new_post($post, $mform, &$message) {
forum_tp_mark_post_read($post->userid, $post, $post->forum);
}
+ // Let Moodle know that assessable content is uploaded (eg for plagiarism detection)
+ forum_trigger_content_uploaded_event($post, $cm, 'forum_add_new_post');
+
return $post->id;
}
@@ -4325,6 +4346,9 @@ function forum_update_post($post, $mform, &$message) {
forum_tp_mark_post_read($post->userid, $post, $post->forum);
}
+ // Let Moodle know that assessable content is uploaded (eg for plagiarism detection)
+ forum_trigger_content_uploaded_event($post, $cm, 'forum_update_post');
+
return true;
}
@@ -4402,6 +4426,9 @@ function forum_add_discussion($discussion, $mform=null, &$message=null, $userid=
forum_tp_mark_post_read($post->userid, $post, $post->forum);
}
+ // Let Moodle know that assessable content is uploaded (eg for plagiarism detection)
+ forum_trigger_content_uploaded_event($post, $cm, 'forum_add_discussion');
+
return $post->discussion;
}
@@ -4525,6 +4552,33 @@ function forum_delete_post($post, $children, $course, $cm, $forum, $skipcompleti
}
/**
+ * Sends post content to plagiarism plugin
+ * @param object $post Forum post object
+ * @param object $cm Course-module
+ * @param string $name
+ * @return bool
+*/
+function forum_trigger_content_uploaded_event($post, $cm, $name) {
+ $context = context_module::instance($cm->id);
+ $fs = get_file_storage();
+ $files = $fs->get_area_files($context->id, 'mod_forum', 'attachment', $post->id, "timemodified", false);
+ $eventdata = new stdClass();
+ $eventdata->modulename = 'forum';
+ $eventdata->name = $name;
+ $eventdata->cmid = $cm->id;
+ $eventdata->itemid = $post->id;
+ $eventdata->courseid = $post->course;
+ $eventdata->userid = $post->userid;
+ $eventdata->content = $post->message;
+ if ($files) {
+ $eventdata->pathnamehashes = array_keys($files);
+ }
+ events_trigger('assessable_content_uploaded', $eventdata);
+
+ return true;
+}
+
+/**
* @global object
* @param object $post
* @param bool $children
3  mod/forum/mod_form.php
View
@@ -139,6 +139,9 @@ function definition() {
$mform->addHelpButton('warnafter', 'warnafter', 'forum');
$mform->disabledIf('warnafter', 'blockperiod', 'eq', 0);
+ $coursecontext = context_course::instance($COURSE->id);
+ plagiarism_get_form_elements_module($mform, $coursecontext);
+
//-------------------------------------------------------------------------------
$this->standard_grading_coursemodule_elements();
5 mod/forum/post.php
View
@@ -877,6 +877,11 @@
} else {
if (!empty($forum->intro)) {
echo $OUTPUT->box(format_module_intro('forum', $forum, $cm->id), 'generalbox', 'intro');
+
+ if (!empty($CFG->enableplagiarism)) {
+ require_once($CFG->libdir.'/plagiarismlib.php');
+ echo plagiarism_print_disclosure($cm->id);
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.