How to add support for a Plagiarism Plugin to my activity module: Difference between revisions
Dan Marsden (talk | contribs) (Created page with "== Overview == There are 3 "hooks" that you need to add to your module. === Sending Data to the Plagiarism plugin === Plagiarism plugins use Moodles event api to trigger events t...") |
No edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
== Overview == | == Overview == | ||
There are | There are 4 main "hooks" that you need to add to your module. | ||
=== Sending Data to the Plagiarism plugin === | === Sending Data to the Plagiarism plugin === | ||
Plagiarism plugins use Moodles event api to trigger events to allow a plugin to "do something" with some content. | Plagiarism plugins use Moodles event api to trigger events to allow a plugin to "do something" with some content. | ||
Add an event to your code like this: | |||
* If only file is to be sent - | |||
$eventdata = new stdClass(); | $eventdata = new stdClass(); | ||
$eventdata->modulename = 'modulename'; | $eventdata->modulename = 'modulename'; | ||
$eventdata->cmid = $this->cm->id; | $eventdata->cmid = $this->cm->id; | ||
$eventdata->itemid = $somehelpfulid; // | $eventdata->itemid = $somehelpfulid; // Something that identifies this piece of content within your module. | ||
$eventdata->courseid = $this->course->id; | $eventdata->courseid = $this->course->id; | ||
$eventdata->userid = $USER->id; // | $eventdata->userid = $USER->id; // User that has submitted this content | ||
$eventdata-> | $eventdata->pathnamehashes = array_keys($files); // The files that need to be sent to plugin | ||
events_trigger('assessable_file_uploaded', $eventdata); | |||
events_trigger(' | * If content (or file both) to be sent - | ||
$eventdata = new stdClass(); | |||
$eventdata->modulename = 'modulename'; | |||
$eventdata->cmid = $this->cm->id; | |||
$eventdata->itemid = $somehelpfulid; // Something that identifies this piece of content within your module. | |||
$eventdata->courseid = $this->course->id; | |||
$eventdata->userid = $USER->id; // User that has submitted this content | |||
$eventdata->content = $content; // The text content (such as online text) that has to be sent | |||
$eventdata->pathnamehashes = array_keys($files); // The files that has to be sent to plugin | |||
events_trigger('assessable_content_uploaded', $eventdata); | |||
It's a good idea to keep the name of the | It's a good idea to keep the name of the events as above as the plagiarism plugins already have handlers for these particular events. $eventdata->pathnamehashes should contain the hashes of full file objects like as obtained by $fs->get_area_files. | ||
Currently supported modules are - assignment, assignment 2.2, forum, workshop. | |||
If you can see a way to improve it - drop the maintainer of the plugin an e-mail. | |||
=== Module level configuration options === | === Module level configuration options === | ||
in the form used to generate your module settings - usually /mod_form.php add the code: | in the form used to generate your module settings - usually /mod_form.php add the code: | ||
plagiarism_get_form_elements_module($mform, $course_context); | plagiarism_get_form_elements_module($mform, $course_context, $modulename); // $modulename - name of the module as per [[Frankenstyle]]. | ||
For example for forum it will look like - | |||
plagiarism_get_form_elements_module($mform, $coursecontext, 'mod_forum'); | |||
This will allow the plagiarism plugin to display the module level settings required to enable plagiarism prevention with the instance of the module. | |||
=== Printing the response from the plagiarism plugin === | === Printing the response from the plagiarism plugin === | ||
Once the Plagiarism plugin has "done something" with your content it will need to display a link or content specific to that submission. Usually this will be on the students "view" and on the teachers "view submissions" page. | Once the Plagiarism plugin has "done something" with your content it will need to display a link or content specific to that submission. Usually this will be on the students "view" and on the teachers "view submissions" page. | ||
add something like this to wherever the users submission is displayed: | add something like this to wherever the users submission is displayed: | ||
$output .= plagiarism_get_links(array('userid'=>$userid, 'file'=>$file, 'cmid'=>$this->cm->id, 'course'=>$this->course, ' | * To display file results - | ||
$output .= plagiarism_get_links(array('userid'=>$userid, 'file'=>$file, 'cmid'=>$this->cm->id, 'course'=>$this->course, $modulename=>$this->id)); | |||
* To display content (text) results - | |||
$output .= plagiarism_get_links(array('userid'=>$userid, 'content'=>$content, 'cmid'=>$this->cm->id, 'course'=>$this->course, $modulename=>$this->module)); | |||
For example for forum - | |||
$output .= plagiarism_get_links(array('userid' => $post->userid, 'file' => $file, 'cmid' => $cm->id, 'course' => $post->course, 'forum' => $post->forum)); | |||
$output .= plagiarism_get_links(array('userid' => $post->userid, 'content' => $post->message, 'cmid' => $cm->id, 'course' => $post->course, | |||
'forum' => $post->forum)); | |||
=== Printing student Disclosure === | === Printing student Disclosure === | ||
Line 31: | Line 57: | ||
plagiarism_print_disclosure($this->cm->id); | plagiarism_print_disclosure($this->cm->id); | ||
If a plagiarism plugin is enabled in your module instance this will display a message to the student to inform them. | If a plagiarism plugin is enabled in your module instance this will display a message to the student to inform them. | ||
==See also== | |||
* [[Plagiarism_plugins]] |
Latest revision as of 16:50, 11 June 2018
Overview
There are 4 main "hooks" that you need to add to your module.
Sending Data to the Plagiarism plugin
Plagiarism plugins use Moodles event api to trigger events to allow a plugin to "do something" with some content. Add an event to your code like this:
- If only file is to be sent -
$eventdata = new stdClass(); $eventdata->modulename = 'modulename'; $eventdata->cmid = $this->cm->id; $eventdata->itemid = $somehelpfulid; // Something that identifies this piece of content within your module. $eventdata->courseid = $this->course->id; $eventdata->userid = $USER->id; // User that has submitted this content $eventdata->pathnamehashes = array_keys($files); // The files that need to be sent to plugin events_trigger('assessable_file_uploaded', $eventdata);
- If content (or file both) to be sent -
$eventdata = new stdClass(); $eventdata->modulename = 'modulename'; $eventdata->cmid = $this->cm->id; $eventdata->itemid = $somehelpfulid; // Something that identifies this piece of content within your module. $eventdata->courseid = $this->course->id; $eventdata->userid = $USER->id; // User that has submitted this content $eventdata->content = $content; // The text content (such as online text) that has to be sent $eventdata->pathnamehashes = array_keys($files); // The files that has to be sent to plugin events_trigger('assessable_content_uploaded', $eventdata);
It's a good idea to keep the name of the events as above as the plagiarism plugins already have handlers for these particular events. $eventdata->pathnamehashes should contain the hashes of full file objects like as obtained by $fs->get_area_files. Currently supported modules are - assignment, assignment 2.2, forum, workshop. If you can see a way to improve it - drop the maintainer of the plugin an e-mail.
Module level configuration options
in the form used to generate your module settings - usually /mod_form.php add the code:
plagiarism_get_form_elements_module($mform, $course_context, $modulename); // $modulename - name of the module as per Frankenstyle.
For example for forum it will look like -
plagiarism_get_form_elements_module($mform, $coursecontext, 'mod_forum');
This will allow the plagiarism plugin to display the module level settings required to enable plagiarism prevention with the instance of the module.
Printing the response from the plagiarism plugin
Once the Plagiarism plugin has "done something" with your content it will need to display a link or content specific to that submission. Usually this will be on the students "view" and on the teachers "view submissions" page. add something like this to wherever the users submission is displayed:
- To display file results -
$output .= plagiarism_get_links(array('userid'=>$userid, 'file'=>$file, 'cmid'=>$this->cm->id, 'course'=>$this->course, $modulename=>$this->id));
- To display content (text) results -
$output .= plagiarism_get_links(array('userid'=>$userid, 'content'=>$content, 'cmid'=>$this->cm->id, 'course'=>$this->course, $modulename=>$this->module));
For example for forum -
$output .= plagiarism_get_links(array('userid' => $post->userid, 'file' => $file, 'cmid' => $cm->id, 'course' => $post->course, 'forum' => $post->forum)); $output .= plagiarism_get_links(array('userid' => $post->userid, 'content' => $post->message, 'cmid' => $cm->id, 'course' => $post->course, 'forum' => $post->forum));
Printing student Disclosure
When using Plagiarism prevention tools it is vital that the student is informed about this - on the modules "submission" page - or view.php or similar - you should add the following code:
plagiarism_print_disclosure($this->cm->id);
If a plagiarism plugin is enabled in your module instance this will display a message to the student to inform them.