MDL-50287 completion: avoid introducing uncessary functions
authorDan Poltawski <dan@moodle.com>
Thu, 27 Aug 2015 13:33:10 +0000 (14:33 +0100)
committerDan Poltawski <dan@moodle.com>
Thu, 27 Aug 2015 13:57:56 +0000 (14:57 +0100)
Also fix copyright

completion/cron.php
lib/classes/task/completion_cron_daily_task.php
lib/classes/task/completion_cron_regular_task.php
lib/deprecatedlib.php

index c252de4..f56e5dd 100644 (file)
@@ -15,7 +15,7 @@
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
- * Cron job for reviewing and aggregating course completion criteria
+ * Code used by scheduled tasks for reviewing and aggregating course completion criteria.
  *
  * @package core_completion
  * @category completion
 defined('MOODLE_INTERNAL') || die();
 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.
- */
-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
  *
index ace3a5b..fa014b1 100644 (file)
@@ -49,7 +49,7 @@ class completion_cron_daily_task extends scheduled_task {
         if ($CFG->enablecompletion) {
             // Daily Completion cron.
             require_once($CFG->dirroot.'/completion/cron.php');
-            completion_daily_cron();
+            completion_cron_mark_started();
         }
     }
 
index 29a0c52..215679c 100644 (file)
  * A scheduled task.
  *
  * @package    core
- * @copyright  2013 onwards Martin Dougiamas  http://dougiamas.com
+ * @copyright  2015 Josh Willcock
  * @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.
+ * @copyright  2015 Josh Willcock
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
  */
 class completion_cron_regular_task extends scheduled_task {
@@ -49,7 +49,8 @@ class completion_cron_regular_task extends scheduled_task {
         if ($CFG->enablecompletion) {
             // Regular Completion cron.
             require_once($CFG->dirroot.'/completion/cron.php');
-            completion_regular_cron();
+            completion_cron_criteria();
+            completion_cron_completions();
         }
     }
 
index 8c85c9d..2758fee 100644 (file)
@@ -2378,4 +2378,25 @@ function get_referer($stripquery = true) {
     } else {
         return '';
     }
-}
\ No newline at end of file
+}
+
+/**
+ * Update user's course completion statuses
+ *
+ * First update all criteria completions, then aggregate all criteria completions
+ * and update overall course completions.
+ *
+ * @deprecated since Moodle 3.0 MDL-50287 - please do not use this function any more.
+ * @todo Remove this function in Moodle 3.2 MDL-51226.
+ */
+function completion_cron() {
+    global $CFG;
+    require_once($CFG->dirroot.'/completion/cron.php');
+
+    debugging('completion_cron() is deprecated. Functionality has been moved to scheduled tasks.', DEBUG_DEVELOPER);
+    completion_cron_mark_started();
+
+    completion_cron_criteria();
+
+    completion_cron_completions();
+}