Skip to content
Permalink
Browse files

MDL-52702 plagiarism: Improvements to base plugin class

  • Loading branch information...
micaherne committed Jan 8, 2016
1 parent e65dfd9 commit 5e43eea080228c86370fb19ae4e767497243d5e4
Showing with 31 additions and 9 deletions.
  1. +1 −1 lang/en/admin.php
  2. +5 −3 lib/plagiarismlib.php
  3. +19 −5 plagiarism/lib.php
  4. +6 −0 plagiarism/upgrade.txt
@@ -1032,7 +1032,7 @@
$string['tasklegacycron'] = 'Legacy cron processing for plugins';
$string['taskmessagingcleanup'] = 'Background processing for messaging';
$string['taskpasswordresetcleanup'] = 'Cleanup password reset attempts';
$string['taskplagiarismcron'] = 'Background processing for plagiarism plugins';
$string['taskplagiarismcron'] = 'Background processing for legacy cron in plagiarism plugins';
$string['taskportfoliocron'] = 'Background processing for portfolio plugins';
$string['taskquestioncron'] = 'Background processing for question engine';
$string['taskregistrationcron'] = 'Site registration';
@@ -171,12 +171,14 @@ function plagiarism_cron() {
}
$plagiarismplugins = plagiarism_load_available_plugins();
foreach($plagiarismplugins as $plugin => $dir) {
mtrace('Processing cron function for plagiarism_plugin_' . $plugin . '...', '');
cron_trace_time_and_memory();
require_once($dir.'/lib.php');
$plagiarismclass = "plagiarism_plugin_$plugin";
$plagiarismplugin = new $plagiarismclass;
$plagiarismplugin->cron();
if (method_exists($plagiarismplugin, 'cron')) {
mtrace('Processing cron function for plagiarism_plugin_' . $plugin . '...', '');
cron_trace_time_and_memory();
$plagiarismplugin->cron();
}
}
}
/**
@@ -19,8 +19,7 @@
* lib.php - Contains Plagiarism base class used by plugins.
*
* @since Moodle 2.0
* @package moodlecore
* @subpackage plagiarism
* @package core_plagiarism
* @copyright 2010 Dan Marsden http://danmarsden.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -29,8 +28,16 @@
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
//dummy class - all plugins should be based off this.
class plagiarism_plugin {
/**
* Plagiarism base class used by plugins.
*
* @since Moodle 2.0
* @package core_plagiarism
* @copyright 2010 Dan Marsden http://danmarsden.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class plagiarism_plugin {
/**
* Return the list of form element names.
@@ -90,10 +97,17 @@ public function print_disclosure($cmid) {
*/
public function update_status($course, $cm) {
}
/**
* hook for cron
* Deprecated cron method.
*
* This method was added by mistake in the previous versions of Moodle, do not override it since it is never called.
* To implement cron you need to register a scheduled task, see https://docs.moodle.org/dev/Task_API.
* For backward compatibility with the old cron API the method cron() from this class can also be used.
*
* @deprecated since Moodle 3.1 MDL-52702 - please use scheduled tasks instead.
*/
public function plagiarism_cron() {
debugging('plagiarism_plugin::plagiarism_cron() is deprecated. Please use scheduled tasks instead', DEBUG_DEVELOPER);
}
}
@@ -0,0 +1,6 @@
This files describes API changes for code that uses the plagiarism API.

=== 3.1 ===

1) The plagiarism_plugin::plagiarism_cron() and plagiarism_plugin::cron() methods have been deprecated.
Plugins should now use scheduled tasks.

0 comments on commit 5e43eea

Please sign in to comment.
You can’t perform that action at this time.