Skip to content

Commit

Permalink
Merge branch 'MDL-67526_final-deprecation-of-plagiarism-functions' of h…
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjona committed Mar 17, 2023
2 parents 66d1d50 + 3018036 commit adc7bd5
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 109 deletions.
4 changes: 0 additions & 4 deletions course/modlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,6 @@ function edit_module_post_actions($moduleinfo, $course) {
}
}

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

// Allow plugins to extend the course module form.
$moduleinfo = plugin_extend_coursemodule_edit_post_actions($moduleinfo, $course);

Expand Down
21 changes: 21 additions & 0 deletions lib/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3187,6 +3187,27 @@ function user_get_participants($courseid, $groupid, $accesssince, $roleid, $enro
return $DB->get_recordset_sql("$select $from $where $sort", $params, $limitfrom, $limitnum);
}

/**
* @deprecated Since Moodle 3.9. MDL-65835
*/
function plagiarism_save_form_elements() {
throw new coding_exception(
'Function plagiarism_save_form_elements() has been removed. ' .
'Please use {plugin name}_coursemodule_edit_post_actions() instead.'
);
}

/**
* @deprecated Since Moodle 3.9. MDL-65835
*/
function plagiarism_get_form_elements_module() {
throw new coding_exception(
'Function plagiarism_get_form_elements_module() has been removed. ' .
'Please use {plugin name}_coursemodule_standard_elements() instead.'
);
}


/**
* Returns the list of full course categories to be used in html_writer::select()
*
Expand Down
74 changes: 1 addition & 73 deletions lib/plagiarismlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,65 +82,6 @@ function plagiarism_get_file_results($cmid, $userid, $file) {
return $allresults;
}

/**
* 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.1
* @param object $data - form data
*/
function plagiarism_save_form_elements($data) {
global $CFG;
if (empty($CFG->enableplagiarism)) {
return '';
}
$plagiarismplugins = plagiarism_load_available_plugins();
foreach ($plagiarismplugins as $plugin => $dir) {
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.1
* @param object $mform - Moodle form object
* @param object $context - context object
* @param string $modulename - Name of the module
*/
function plagiarism_get_form_elements_module($mform, $context, $modulename = "") {
global $CFG;
if (empty($CFG->enableplagiarism)) {
return '';
}
$plagiarismplugins = plagiarism_load_available_plugins();
foreach ($plagiarismplugins as $plugin => $dir) {
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);
}
}
/**
* Allows a plagiarism plugin to print a button/link at the top of activity overview report pages.
*
Expand Down Expand Up @@ -197,12 +138,10 @@ function plagiarism_print_disclosure($cmid) {
/**
* Helper function - also loads lib file of plagiarism plugin
*
* @todo MDL-67872 the deprecated code in this function to be removed in Moodle 4.1
* @return array of available plugins
*/
function plagiarism_load_available_plugins() {
global $CFG;
static $showndeprecatedmessage = array(); // Only show message once per page load.

if (empty($CFG->enableplagiarism)) {
return array();
Expand All @@ -211,18 +150,7 @@ function plagiarism_load_available_plugins() {
$availableplugins = array();
foreach ($plagiarismplugins as $plugin => $dir) {
// Check this plugin is enabled and a lib file exists.
if (get_config('plagiarism', $plugin."_use")) {
// Deprecated Since Moodle 3.9.
$pluginenabled = true;
if (empty($showndeprecatedmessage[$plugin])) {
$text = 'The setting plagiarism:'.$plugin.'_use is deprecated.';
$text .= ' Use plagiarism_' . $plugin . ':enabled instead';
debugging($text, DEBUG_DEVELOPER);
$showndeprecatedmessage[$plugin] = true;
}
} else {
$pluginenabled = get_config('plagiarism_'.$plugin, 'enabled');
}
$pluginenabled = get_config('plagiarism_'.$plugin, 'enabled');
if ($pluginenabled && file_exists($dir."/lib.php")) {
require_once($dir.'/lib.php');
$plagiarismclass = "plagiarism_plugin_$plugin";
Expand Down
6 changes: 0 additions & 6 deletions mod/assign/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,6 @@ public function definition() {
$mform->addElement('selectyesno', 'sendstudentnotifications', $name);
$mform->addHelpButton('sendstudentnotifications', 'sendstudentnotificationsdefault', 'assign');

// 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');
}

$this->standard_grading_coursemodule_elements();
$name = get_string('blindmarking', 'assign');
$mform->addElement('selectyesno', 'blindmarking', $name);
Expand Down
4 changes: 0 additions & 4 deletions mod/forum/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,6 @@ function definition() {
$mform->addHelpButton('warnafter', 'warnafter', 'forum');
$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');

//-------------------------------------------------------------------------------

// Add the whole forum grading options.
Expand Down
4 changes: 0 additions & 4 deletions mod/workshop/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,6 @@ public function definition() {
$label = get_string('assessmentend', 'workshop');
$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. ----
$features = array('groups' => true, 'groupings' => true,
'outcomes' => true, 'gradecat' => false, 'idnumber' => false);
Expand Down
18 changes: 0 additions & 18 deletions plagiarism/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,6 @@ public function get_links($linkarray) {
public function get_file_results($cmid, $userid, $file) {
return array('analyzed' => '', 'score' => '', 'reporturl' => '');
}
/**
* 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
* @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) {
}
/**
* hook to allow a disclosure to be printed notifying users what will happen with their submission
* @param int $cmid - course module id
Expand Down
7 changes: 7 additions & 0 deletions plagiarism/upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
This files describes API changes for code that uses the plagiarism API.

=== 4.2 ===
* Final deprecation and removal of the following 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.

=== 4.0 ===
* The method update_status() has been deprecated. Please use {plugin name}_before_standard_top_of_body_html() instead.
* The method get_configs() has been deprecated and will be removed from the abstract class as it was not used in core.
Expand Down

0 comments on commit adc7bd5

Please sign in to comment.