Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

How to add support for a Plagiarism Plugin to my activity module: Difference between revisions

From MoodleDocs
(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 3 "hooks" that you need to add to your module.
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:
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; //something that identifies this piece of content within your module.
  $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; //user that has submitted this content
  $eventdata->userid      = $USER->id; // User that has submitted this content
  $eventdata->files        = $files; (or $eventdata->file if there is only a single file.)
  $eventdata->pathnamehashes = array_keys($files); // The files that need to be sent to plugin
events_trigger('assessable_file_uploaded', $eventdata);


  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 event as above as the plagiarism plugins already have handlers for this particular event.  $eventdata->files should contain the full file objects like as obtained by $fs->get_area_files - or if a single file object $eventdata->file can be used.
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.
There is currently only one module type being processed by Plagiarism plugins so it's possible that a small amount of modification will need to be done to the plagiarism plugins "event_file_uploaded" function to handle your content if there's anything specific required to manage your content. If you can see a way to improve it - drop the maintainer of the plugin an e-mail.
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]].
this will allow the plagiarism plugin to display the module level settings required to enable plagiarism prevention with the instance of the module.
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, 'assignment'=>$this->assignment));
* 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.


See also