forked from danmarsden/moodle-plagiarism_new
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.php
145 lines (123 loc) · 4.83 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* lib.php - Contains Plagiarism plugin specific functions called by Modules.
*
* @since 2.0
* @package plagiarism_new
* @subpackage plagiarism
* @copyright 2010 Dan Marsden http://danmarsden.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
//get global class
global $CFG;
require_once($CFG->dirroot.'/plagiarism/lib.php');
///// Turnitin Class ////////////////////////////////////////////////////
class plagiarism_plugin_new extends plagiarism_plugin {
/**
* hook to allow plagiarism specific information to be displayed beside a submission
* @param array $linkarraycontains all relevant information for the plugin to generate a link
* @return string
*
*/
public function get_links($linkarray) {
//$userid, $file, $cmid, $course, $module
$cmid = $linkarray['cmid'];
$userid = $linkarray['userid'];
$file = $linkarray['file'];
$output = '';
//add link/information about this file to $output
return $output;
}
/* hook to save plagiarism specific settings on a module settings page
* @param object $data - data from an mform submission.
*/
public function save_form_elements($data) {
}
/**
* hook to add plagiarism specific settings to a module settings page
* @param object $mform - Moodle form
* @param object $context - current context
*/
public function get_form_elements_module($mform, $context) {
//Add elements to form using standard mform like:
//$mform->addElement('hidden', $element);
//$mform->disabledIf('plagiarism_draft_submit', 'var4', 'eq', 0);
}
/**
* hook to allow a disclosure to be printed notifying users what will happen with their submission
* @param int $cmid - course module id
* @return string
*/
public function print_disclosure($cmid) {
global $OUTPUT;
$plagiarismsettings = (array)get_config('plagiarism');
//TODO: check if this cmid has plagiarism enabled.
echo $OUTPUT->box_start('generalbox boxaligncenter', 'intro');
$formatoptions = new stdClass;
$formatoptions->noclean = true;
echo format_text($plagiarismsettings['new_student_disclosure'], FORMAT_MOODLE, $formatoptions);
echo $OUTPUT->box_end();
}
/**
* hook to allow status of submitted files to be updated - called on grading/report pages.
*
* @param object $course - full Course object
* @param object $cm - full cm object
*/
public function update_status($course, $cm) {
//called at top of submissions/grading pages - allows printing of admin style links or updating status
}
/**
* called by admin/cron.php
*
*/
public function cron() {
//do any scheduled task stuff
}
}
function event_file_uploaded($eventdata) {
$result = true;
//a file has been uploaded - submit this to the plagiarism prevention service.
return $result;
}
function event_files_done($eventdata) {
$result = true;
//mainly used by assignment finalize - used if you want to handle "submit for marking" events
//a file has been uploaded/finalised - submit this to the plagiarism prevention service.
return $result;
}
function event_mod_created($eventdata) {
$result = true;
//a new module has been created - this is a generic event that is called for all module types
//make sure you check the type of module before handling if needed.
return $result;
}
function event_mod_updated($eventdata) {
$result = true;
//a module has been updated - this is a generic event that is called for all module types
//make sure you check the type of module before handling if needed.
return $result;
}
function event_mod_deleted($eventdata) {
$result = true;
//a module has been deleted - this is a generic event that is called for all module types
//make sure you check the type of module before handling if needed.
return $result;
}