From 77f3b50f786a877e37e2ee881a48fd95665c3e4b Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Thu, 7 Mar 2019 11:06:30 +0800 Subject: [PATCH] MDL-64881 mod_workshop: add task to run allocation plugin cron --- .../task/legacy_workshop_allocation_cron.php | 47 +++++++++++++++++++ mod/workshop/db/tasks.php | 9 ++++ mod/workshop/lang/en/workshop.php | 1 + mod/workshop/upgrade.txt | 4 ++ 4 files changed, 61 insertions(+) create mode 100644 mod/workshop/classes/task/legacy_workshop_allocation_cron.php diff --git a/mod/workshop/classes/task/legacy_workshop_allocation_cron.php b/mod/workshop/classes/task/legacy_workshop_allocation_cron.php new file mode 100644 index 00000000000..bb74f6db7a7 --- /dev/null +++ b/mod/workshop/classes/task/legacy_workshop_allocation_cron.php @@ -0,0 +1,47 @@ +. + +/** + * Legacy workshop allocation plugins cron. + * + * @package mod_workshop + * @copyright 2018 Simey Lameze + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +namespace mod_workshop\task; + +defined('MOODLE_INTERNAL') || die(); + +/** + * Legacy workshop allocation plugins cron. + * + * @package mod_workshop + * @copyright 2018 Simey Lameze + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class legacy_workshop_allocation_cron extends \core\task\scheduled_task { + + public function get_name() { + return get_string('legacyallocationplugincron', 'mod_workshop'); + } + + /** + * Execute all workshop allocation methods plugins cron tasks. + */ + public function execute() { + cron_execute_plugin_type('workshopallocation', 'workshop allocation methods'); + } +} diff --git a/mod/workshop/db/tasks.php b/mod/workshop/db/tasks.php index 9af7246f0a2..3530b9c6d04 100644 --- a/mod/workshop/db/tasks.php +++ b/mod/workshop/db/tasks.php @@ -33,5 +33,14 @@ $tasks = [ 'day' => '*', 'month' => '*', 'dayofweek' => '*' + ], + [ + 'classname' => '\mod_workshop\task\legacy_workshop_allocation_cron', + 'blocking' => 0, + 'minute' => '*', + 'hour' => '*', + 'day' => '*', + 'month' => '*', + 'dayofweek' => '*' ] ]; diff --git a/mod/workshop/lang/en/workshop.php b/mod/workshop/lang/en/workshop.php index 4151e822670..1db7f8d1ffe 100644 --- a/mod/workshop/lang/en/workshop.php +++ b/mod/workshop/lang/en/workshop.php @@ -189,6 +189,7 @@ $string['latesubmissions'] = 'Late submissions'; $string['latesubmissions_desc'] = 'Allow submissions after the deadline'; $string['latesubmissions_help'] = 'If enabled, an author may submit their work after the submissions deadline or during the assessment phase. Late submissions cannot be edited though.'; $string['latesubmissionsallowed'] = 'Late submissions are allowed'; +$string['legacyallocationplugincron'] = 'Legacy cron workshop allocation'; $string['maxbytes'] = 'Maximum submission attachment size'; $string['modulename'] = 'Workshop'; $string['modulename_help'] = 'The workshop activity module enables the collection, review and peer assessment of students\' work. diff --git a/mod/workshop/upgrade.txt b/mod/workshop/upgrade.txt index 8ccc0e6d58f..06bd0e4f416 100644 --- a/mod/workshop/upgrade.txt +++ b/mod/workshop/upgrade.txt @@ -1,6 +1,10 @@ This files describes API changes in /mod/workshop - activity modules, information provided here is intended especially for developers. +=== 3.7 === + +* workshop_cron() has been removed. Sub-plugins should now implement scheduled tasks. + === 3.6 === * The external function get_workshops_by_courses now returns 2 additional fields: submissiontypetext and