Skip to content

Commit 3018036

Browse files
committed
MDL-67526 plagiarism: Final deprecation of plagiarism functions
Following MDL-65835 this now finally deprecates and removes the functions: - plagiarism_save_form_elements(), please use {plugin name}_coursemodule_edit_post_actions() instead - plagiarism_get_form_elements_module(), please use {plugin name}_coursemodule_standard_elements() instead. - plagiarism_plugin::get_form_elements_module(), please use {plugin name}_coursemodule_edit_post_actions() instead. - plagiarism_plugin::save_form_elements(), please use {plugin name}_coursemodule_standard_elements() instead. Signed-off-by: Daniel Ziegenberg <[email protected]>
1 parent 5e1df25 commit 3018036

File tree

8 files changed

+29
-109
lines changed

8 files changed

+29
-109
lines changed

course/modlib.php

-4
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,6 @@ function edit_module_post_actions($moduleinfo, $course) {
405405
}
406406
}
407407

408-
// To be removed (deprecated) with MDL-67526 (both lines).
409-
require_once($CFG->libdir.'/plagiarismlib.php');
410-
plagiarism_save_form_elements($moduleinfo);
411-
412408
// Allow plugins to extend the course module form.
413409
$moduleinfo = plugin_extend_coursemodule_edit_post_actions($moduleinfo, $course);
414410

lib/deprecatedlib.php

+21
Original file line numberDiff line numberDiff line change
@@ -3187,6 +3187,27 @@ function user_get_participants($courseid, $groupid, $accesssince, $roleid, $enro
31873187
return $DB->get_recordset_sql("$select $from $where $sort", $params, $limitfrom, $limitnum);
31883188
}
31893189

3190+
/**
3191+
* @deprecated Since Moodle 3.9. MDL-65835
3192+
*/
3193+
function plagiarism_save_form_elements() {
3194+
throw new coding_exception(
3195+
'Function plagiarism_save_form_elements() has been removed. ' .
3196+
'Please use {plugin name}_coursemodule_edit_post_actions() instead.'
3197+
);
3198+
}
3199+
3200+
/**
3201+
* @deprecated Since Moodle 3.9. MDL-65835
3202+
*/
3203+
function plagiarism_get_form_elements_module() {
3204+
throw new coding_exception(
3205+
'Function plagiarism_get_form_elements_module() has been removed. ' .
3206+
'Please use {plugin name}_coursemodule_standard_elements() instead.'
3207+
);
3208+
}
3209+
3210+
31903211
/**
31913212
* Returns the list of full course categories to be used in html_writer::select()
31923213
*

lib/plagiarismlib.php

+1-73
Original file line numberDiff line numberDiff line change
@@ -82,65 +82,6 @@ function plagiarism_get_file_results($cmid, $userid, $file) {
8282
return $allresults;
8383
}
8484

85-
/**
86-
* saves/updates plagiarism settings from a modules config page - called by course/modedit.php
87-
*
88-
* @deprecated Since Moodle 3.9. MDL-65835 Please use {plugin name}_coursemodule_edit_post_actions() instead.
89-
* @todo MDL-67526 This is to be moved from here to deprecatedlib.php in Moodle 4.1
90-
* @param object $data - form data
91-
*/
92-
function plagiarism_save_form_elements($data) {
93-
global $CFG;
94-
if (empty($CFG->enableplagiarism)) {
95-
return '';
96-
}
97-
$plagiarismplugins = plagiarism_load_available_plugins();
98-
foreach ($plagiarismplugins as $plugin => $dir) {
99-
require_once($dir.'/lib.php');
100-
$plagiarismclass = "plagiarism_plugin_$plugin";
101-
$plagiarismplugin = new $plagiarismclass;
102-
103-
$reflectionmethod = new ReflectionMethod($plagiarismplugin, 'save_form_elements');
104-
if ($reflectionmethod->getDeclaringClass()->getName() == get_class($plagiarismplugin)) {
105-
$text = 'plagiarism_plugin::save_form_elements() is deprecated.';
106-
$text .= ' Use plagiarism_' . $plugin . '_coursemodule_edit_post_actions() instead';
107-
debugging($text, DEBUG_DEVELOPER);
108-
}
109-
110-
$plagiarismplugin->save_form_elements($data);
111-
}
112-
}
113-
114-
/**
115-
* adds the list of plagiarism settings to a form - called inside modules that have enabled plagiarism
116-
*
117-
* @deprecated Since Moodle 3.9. MDL-65835 Please use {plugin name}_coursemodule_standard_elements() instead.
118-
* @todo MDL-67526 This is to be moved from here to deprecatedlib.php in Moodle 4.1
119-
* @param object $mform - Moodle form object
120-
* @param object $context - context object
121-
* @param string $modulename - Name of the module
122-
*/
123-
function plagiarism_get_form_elements_module($mform, $context, $modulename = "") {
124-
global $CFG;
125-
if (empty($CFG->enableplagiarism)) {
126-
return '';
127-
}
128-
$plagiarismplugins = plagiarism_load_available_plugins();
129-
foreach ($plagiarismplugins as $plugin => $dir) {
130-
require_once($dir.'/lib.php');
131-
$plagiarismclass = "plagiarism_plugin_$plugin";
132-
$plagiarismplugin = new $plagiarismclass;
133-
134-
$reflectionmethod = new ReflectionMethod($plagiarismplugin, 'get_form_elements_module');
135-
if ($reflectionmethod->getDeclaringClass()->getName() == get_class($plagiarismplugin)) {
136-
$text = 'plagiarism_plugin::get_form_elements_module() is deprecated.';
137-
$text .= ' Use plagiarism_' . $plugin . '_coursemodule_standard_elements() instead';
138-
debugging($text, DEBUG_DEVELOPER);
139-
}
140-
141-
$plagiarismplugin->get_form_elements_module($mform, $context, $modulename);
142-
}
143-
}
14485
/**
14586
* Allows a plagiarism plugin to print a button/link at the top of activity overview report pages.
14687
*
@@ -197,12 +138,10 @@ function plagiarism_print_disclosure($cmid) {
197138
/**
198139
* Helper function - also loads lib file of plagiarism plugin
199140
*
200-
* @todo MDL-67872 the deprecated code in this function to be removed in Moodle 4.1
201141
* @return array of available plugins
202142
*/
203143
function plagiarism_load_available_plugins() {
204144
global $CFG;
205-
static $showndeprecatedmessage = array(); // Only show message once per page load.
206145

207146
if (empty($CFG->enableplagiarism)) {
208147
return array();
@@ -211,18 +150,7 @@ function plagiarism_load_available_plugins() {
211150
$availableplugins = array();
212151
foreach ($plagiarismplugins as $plugin => $dir) {
213152
// Check this plugin is enabled and a lib file exists.
214-
if (get_config('plagiarism', $plugin."_use")) {
215-
// Deprecated Since Moodle 3.9.
216-
$pluginenabled = true;
217-
if (empty($showndeprecatedmessage[$plugin])) {
218-
$text = 'The setting plagiarism:'.$plugin.'_use is deprecated.';
219-
$text .= ' Use plagiarism_' . $plugin . ':enabled instead';
220-
debugging($text, DEBUG_DEVELOPER);
221-
$showndeprecatedmessage[$plugin] = true;
222-
}
223-
} else {
224-
$pluginenabled = get_config('plagiarism_'.$plugin, 'enabled');
225-
}
153+
$pluginenabled = get_config('plagiarism_'.$plugin, 'enabled');
226154
if ($pluginenabled && file_exists($dir."/lib.php")) {
227155
require_once($dir.'/lib.php');
228156
$plagiarismclass = "plagiarism_plugin_$plugin";

mod/assign/mod_form.php

-6
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,6 @@ public function definition() {
202202
$mform->addElement('selectyesno', 'sendstudentnotifications', $name);
203203
$mform->addHelpButton('sendstudentnotifications', 'sendstudentnotificationsdefault', 'assign');
204204

205-
// Plagiarism enabling form. To be removed (deprecated) with MDL-67526.
206-
if (!empty($CFG->enableplagiarism)) {
207-
require_once($CFG->libdir . '/plagiarismlib.php');
208-
plagiarism_get_form_elements_module($mform, $ctx->get_course_context(), 'mod_assign');
209-
}
210-
211205
$this->standard_grading_coursemodule_elements();
212206
$name = get_string('blindmarking', 'assign');
213207
$mform->addElement('selectyesno', 'blindmarking', $name);

mod/forum/mod_form.php

-4
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,6 @@ function definition() {
205205
$mform->addHelpButton('warnafter', 'warnafter', 'forum');
206206
$mform->hideIf('warnafter', 'blockperiod', 'eq', 0);
207207

208-
$coursecontext = context_course::instance($COURSE->id);
209-
// To be removed (deprecated) with MDL-67526.
210-
plagiarism_get_form_elements_module($mform, $coursecontext, 'mod_forum');
211-
212208
//-------------------------------------------------------------------------------
213209

214210
// Add the whole forum grading options.

mod/workshop/mod_form.php

-4
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,6 @@ public function definition() {
247247
$label = get_string('assessmentend', 'workshop');
248248
$mform->addElement('date_time_selector', 'assessmentend', $label, array('optional' => true));
249249

250-
$coursecontext = context_course::instance($this->course->id);
251-
// To be removed (deprecated) with MDL-67526.
252-
plagiarism_get_form_elements_module($mform, $coursecontext, 'mod_workshop');
253-
254250
// Common module settings, Restrict availability, Activity completion etc. ----
255251
$features = array('groups' => true, 'groupings' => true,
256252
'outcomes' => true, 'gradecat' => false, 'idnumber' => false);

plagiarism/lib.php

-18
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,6 @@ public function get_links($linkarray) {
7272
public function get_file_results($cmid, $userid, $file) {
7373
return array('analyzed' => '', 'score' => '', 'reporturl' => '');
7474
}
75-
/**
76-
* hook to add plagiarism specific settings to a module settings page
77-
* @deprecated Since Moodle 3.9. MDL-65835 Please use {plugin name}_coursemodule_edit_post_actions() instead.
78-
* @todo MDL-67526 Remove this method.
79-
* @param object $mform - Moodle form
80-
* @param object $context - current context
81-
* @param string $modulename - Name of the module
82-
*/
83-
public function get_form_elements_module($mform, $context, $modulename = "") {
84-
}
85-
/**
86-
* hook to save plagiarism specific settings on a module settings page
87-
* @deprecated Since Moodle 3.9. MDL-65835 Please use {plugin name}_coursemodule_standard_elements() instead.
88-
* @todo MDL-67526 Remove this method.
89-
* @param object $data - data from an mform submission.
90-
*/
91-
public function save_form_elements($data) {
92-
}
9375
/**
9476
* hook to allow a disclosure to be printed notifying users what will happen with their submission
9577
* @param int $cmid - course module id

plagiarism/upgrade.txt

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
This files describes API changes for code that uses the plagiarism API.
22

3+
=== 4.2 ===
4+
* Final deprecation and removal of the following functions:
5+
- plagiarism_save_form_elements(), please use {plugin name}_coursemodule_edit_post_actions() instead.
6+
- plagiarism_get_form_elements_module(), please use {plugin name}_coursemodule_standard_elements() instead.
7+
- plagiarism_plugin::get_form_elements_module(), please use {plugin name}_coursemodule_edit_post_actions() instead.
8+
- plagiarism_plugin::save_form_elements(), please use {plugin name}_coursemodule_standard_elements() instead.
9+
310
=== 4.0 ===
411
* The method update_status() has been deprecated. Please use {plugin name}_before_standard_top_of_body_html() instead.
512
* The method get_configs() has been deprecated and will be removed from the abstract class as it was not used in core.

0 commit comments

Comments
 (0)