require_once($CFG->libdir.'/completionlib.php');
/**
+ * Legacy - here for plugin use only, not used in scheduled tasks.
* Update user's course completion statuses
*
* First update all criteria completions, then aggregate all criteria completions
- * and update overall course completions
+ * and update overall course completions.
*/
function completion_cron() {
-
completion_cron_mark_started();
completion_cron_criteria();
completion_cron_completions();
}
-
+/**
+ * Update user's course completion statuses
+ *
+ * First update all criteria completions, then aggregate all criteria completions
+ * and update overall course completions
+ */
+function completion_regular_cron() {
+ // Two Functions which check criteria and learner completions regularly for accurate data.
+ completion_cron_criteria();
+ completion_cron_completions();
+}
+/**
+ * Marks users as started if the config option is set.
+ *
+ * One function which takes a long time 60+ minutes to enrol users onto completion started.
+ */
+function completion_daily_cron() {
+ completion_cron_mark_started();
+}
/**
* Mark users as started if the config option is set
*
$string['taskcalendarcron'] = 'Send calendar notifications';
$string['taskcheckforupdates'] = 'Check for updates';
$string['taskcompletioncron'] = 'Calculate completion data';
+$string['taskcompletioncronregular'] = 'Calculate regular completion data';
+$string['taskcompletioncrondaily'] = 'Completion mark as started';
$string['taskcontextcleanup'] = 'Cleanup contexts';
$string['taskcreatecontexts'] = 'Create missing contexts';
$string['taskdeletecachetext'] = 'Delete old text cache records';
namespace core\task;
/**
- * Simple task to run the completion cron.
+ * Simple task to run the daily completion cron.
+ * @copyright 2013 onwards Martin Dougiamas http://dougiamas.com.
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
-class completion_cron_task extends scheduled_task {
+class completion_cron_daily_task extends scheduled_task {
/**
* Get a descriptive name for this task (shown to admins).
* @return string
*/
public function get_name() {
- return get_string('taskcompletioncron', 'admin');
+ return get_string('taskcompletioncrondaily', 'admin');
}
/**
global $CFG;
if ($CFG->enablecompletion) {
- // Completion cron.
+ // Daily Completion cron.
require_once($CFG->dirroot.'/completion/cron.php');
- completion_cron();
+ completion_daily_cron();
}
}
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * A scheduled task.
+ *
+ * @package core
+ * @copyright 2013 onwards Martin Dougiamas http://dougiamas.com
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+namespace core\task;
+
+/**
+ * Simple task to run the regular completion cron.
+ * @copyright 2013 onwards Martin Dougiamas http://dougiamas.com.
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
+ */
+class completion_cron_regular_task extends scheduled_task {
+
+ /**
+ * Get a descriptive name for this task (shown to admins).
+ *
+ * @return string
+ */
+ public function get_name() {
+ return get_string('taskcompletioncronregular', 'admin');
+ }
+
+ /**
+ * Do the job.
+ * Throw exceptions on errors (the job will be retried).
+ */
+ public function execute() {
+ global $CFG;
+
+ if ($CFG->enablecompletion) {
+ // Regular Completion cron.
+ require_once($CFG->dirroot.'/completion/cron.php');
+ completion_regular_cron();
+ }
+ }
+
+}
'month' => '*'
),
array(
- 'classname' => 'core\task\completion_cron_task',
+ 'classname' => 'core\task\completion_cron_regular_task',
'blocking' => 0,
'minute' => '*',
'hour' => '*',
'dayofweek' => '*',
'month' => '*'
),
+ array(
+ 'classname' => 'core\task\completion_cron_daily_task',
+ 'blocking' => 0,
+ 'minute' => 'R',
+ 'hour' => 'R',
+ 'day' => '*',
+ 'dayofweek' => '*',
+ 'month' => '*'
+ ),
array(
'classname' => 'core\task\portfolio_cron_task',
'blocking' => 0,