Skip to content

Commit

Permalink
MDL-65835 plagiarism: Initial deprecation of old functions.
Browse files Browse the repository at this point in the history
This is the initial deprecation of:
* plagiarism_save_form_elements
* plagiarism_get_form_elements_module
* plagiarism_plugin::get_form_elements_module
* plagiarism_plugin::save_form_elements
  • Loading branch information
abgreeve committed Jan 2, 2020
1 parent 7850f76 commit d0d65b4
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions course/modlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ function edit_module_post_actions($moduleinfo, $course) {
if ($hasgrades) {
grade_regrade_final_grades($course->id);
}

// To be removed (deprecated) with MDL-67526 (both lines).
require_once($CFG->libdir.'/plagiarismlib.php');
plagiarism_save_form_elements($moduleinfo);

Expand Down
20 changes: 20 additions & 0 deletions lib/plagiarismlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ function plagiarism_get_file_results($cmid, $userid, $file) {
/**
* saves/updates plagiarism settings from a modules config page - called by course/modedit.php
*
* @deprecated Since Moodle 3.9. MDL-65835 Please use {plugin name}_coursemodule_edit_post_actions() instead.
* @todo MDL-67526 This is to be moved from here to deprecatedlib.php in Moodle 4.3
* @param object $data - form data
*/
function plagiarism_save_form_elements($data) {
Expand All @@ -93,13 +95,23 @@ function plagiarism_save_form_elements($data) {
require_once($dir.'/lib.php');
$plagiarismclass = "plagiarism_plugin_$plugin";
$plagiarismplugin = new $plagiarismclass;

$reflectionmethod = new ReflectionMethod($plagiarismplugin, 'save_form_elements');
if ($reflectionmethod->getDeclaringClass()->getName() == get_class($plagiarismplugin)) {
$text = 'plagiarism_plugin::save_form_elements() is deprecated.';
$text .= ' Use plagiarism_' . $plugin . '_coursemodule_edit_post_actions() instead';
debugging($text, DEBUG_DEVELOPER);
}

$plagiarismplugin->save_form_elements($data);
}
}

/**
* adds the list of plagiarism settings to a form - called inside modules that have enabled plagiarism
*
* @deprecated Since Moodle 3.9. MDL-65835 Please use {plugin name}_coursemodule_standard_elements() instead.
* @todo MDL-67526 This is to be moved from here to deprecatedlib.php in Moodle 4.3
* @param object $mform - Moodle form object
* @param object $context - context object
* @param string $modulename - Name of the module
Expand All @@ -114,6 +126,14 @@ function plagiarism_get_form_elements_module($mform, $context, $modulename = "")
require_once($dir.'/lib.php');
$plagiarismclass = "plagiarism_plugin_$plugin";
$plagiarismplugin = new $plagiarismclass;

$reflectionmethod = new ReflectionMethod($plagiarismplugin, 'get_form_elements_module');
if ($reflectionmethod->getDeclaringClass()->getName() == get_class($plagiarismplugin)) {
$text = 'plagiarism_plugin::get_form_elements_module() is deprecated.';
$text .= ' Use plagiarism_' . $plugin . '_coursemodule_standard_elements() instead';
debugging($text, DEBUG_DEVELOPER);
}

$plagiarismplugin->get_form_elements_module($mform, $context, $modulename);
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ information provided here is intended especially for developers.
- question_is_only_toplevel_category_in_context
* format_float() now accepts a special value (-1) as the $decimalpoints parameter
which means auto-detecting number of decimal points.
* plagiarism_save_form_elements() has been deprecated. Please use {plugin name}_coursemodule_edit_post_actions() instead.
* plagiarism_get_form_elements_module() has been deprecated. Please use {plugin name}_coursemodule_standard_elements() instead.

=== 3.8 ===
* Add CLI option to notify all cron tasks to stop: admin/cli/cron.php --stop
Expand Down
2 changes: 1 addition & 1 deletion mod/assign/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function definition() {
$mform->addElement('selectyesno', 'sendstudentnotifications', $name);
$mform->addHelpButton('sendstudentnotifications', 'sendstudentnotificationsdefault', 'assign');

// Plagiarism enabling form.
// Plagiarism enabling form. To be removed (deprecated) with MDL-67526.
if (!empty($CFG->enableplagiarism)) {
require_once($CFG->libdir . '/plagiarismlib.php');
plagiarism_get_form_elements_module($mform, $ctx->get_course_context(), 'mod_assign');
Expand Down
1 change: 1 addition & 0 deletions mod/forum/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ function definition() {
$mform->hideIf('warnafter', 'blockperiod', 'eq', 0);

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

//-------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions mod/workshop/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ public function definition() {
$mform->addElement('date_time_selector', 'assessmentend', $label, array('optional' => true));

$coursecontext = context_course::instance($this->course->id);
// To be removed (deprecated) with MDL-67526.
plagiarism_get_form_elements_module($mform, $coursecontext, 'mod_workshop');

// Common module settings, Restrict availability, Activity completion etc. ----
Expand Down
7 changes: 6 additions & 1 deletion plagiarism/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,18 @@ public function get_file_results($cmid, $userid, $file) {
}
/**
* hook to add plagiarism specific settings to a module settings page
* @deprecated Since Moodle 3.9. MDL-65835 Please use {plugin name}_coursemodule_edit_post_actions() instead.
* @todo MDL-67526 Remove this method.
* @param object $mform - Moodle form
* @param object $context - current context
* @param string $modulename - Name of the module
*/
public function get_form_elements_module($mform, $context, $modulename = "") {
}
/* hook to save plagiarism specific settings on a module settings page
/**
* hook to save plagiarism specific settings on a module settings page
* @deprecated Since Moodle 3.9. MDL-65835 Please use {plugin name}_coursemodule_standard_elements() instead.
* @todo MDL-67526 Remove this method.
* @param object $data - data from an mform submission.
*/
public function save_form_elements($data) {
Expand Down
6 changes: 6 additions & 0 deletions plagiarism/upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
This files describes API changes for code that uses the plagiarism API.

=== 3.9 ===

* The method get_form_elements_module has been deprecated. Please use {plugin name}_coursemodule_edit_post_actions() instead.
* The method save_form_elements has been deprecated. Please use {plugin name}_coursemodule_standard_elements() instead.

=== 3.7 ===

* The plagiarism_cron() function has been deleted, plugins should implement their own scheduled tasks.
Expand Down

0 comments on commit d0d65b4

Please sign in to comment.