MDL-53700 competency: Migrate tasks to core
authorFrederic Massart <fred@moodle.com>
Mon, 4 Apr 2016 08:18:42 +0000 (16:18 +0800)
committerFrederic Massart <fred@moodle.com>
Mon, 18 Apr 2016 03:05:58 +0000 (11:05 +0800)
admin/tool/lp/db/tasks.php [deleted file]
admin/tool/lp/tests/task_test.php
lib/classes/task/complete_plans_task.php [moved from admin/tool/lp/classes/task/complete_plans_task.php with 97% similarity]
lib/classes/task/sync_plans_from_template_cohorts_task.php [moved from admin/tool/lp/classes/task/sync_plans_from_template_cohorts_task.php with 97% similarity]
lib/db/tasks.php

diff --git a/admin/tool/lp/db/tasks.php b/admin/tool/lp/db/tasks.php
deleted file mode 100644 (file)
index 8eb2b96..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?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/>.
-
-/**
- * Tasks definitions.
- *
- * @package    tool_lp
- * @copyright  2015 Frédéric Massart - FMCorz.net
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-$tasks = array(
-    array(
-        'classname' => 'tool_lp\task\complete_plans_task',
-        'blocking' => 0,
-        'minute' => 'R',
-        'hour' => '*',
-        'day' => '*',
-        'dayofweek' => '*',
-        'month' => '*'
-    ),
-    array(
-        'classname' => 'tool_lp\task\sync_plans_from_template_cohorts_task',
-        'blocking' => 0,
-        'minute' => 'R',
-        'hour' => '*',
-        'day' => '*',
-        'dayofweek' => '*',
-        'month' => '*'
-    ),
-);
index f32abe5..3d175d2 100644 (file)
@@ -70,8 +70,8 @@ class tool_lp_task_testcase extends advanced_testcase {
 
         $this->assertEquals(2, $created);
 
-        $task = \core\task\manager::get_scheduled_task('\\tool_lp\\task\\sync_plans_from_template_cohorts_task');
-        $this->assertInstanceOf('\tool_lp\task\sync_plans_from_template_cohorts_task', $task);
+        $task = \core\task\manager::get_scheduled_task('\\core\\task\\sync_plans_from_template_cohorts_task');
+        $this->assertInstanceOf('\core\task\sync_plans_from_template_cohorts_task', $task);
 
         // Add two more users to the cohort.
         cohort_add_member($cohort->id, $user3->id);
@@ -181,8 +181,8 @@ class tool_lp_task_testcase extends advanced_testcase {
 
         $this->assertEquals(2, $created);
 
-        $task = \core\task\manager::get_scheduled_task('\\tool_lp\\task\\sync_plans_from_template_cohorts_task');
-        $this->assertInstanceOf('\tool_lp\task\sync_plans_from_template_cohorts_task', $task);
+        $task = \core\task\manager::get_scheduled_task('\\core\\task\\sync_plans_from_template_cohorts_task');
+        $this->assertInstanceOf('\core\task\sync_plans_from_template_cohorts_task', $task);
 
         // Add two more users to the cohort.
         cohort_add_member($cohort->id, $user3->id);
@@ -248,7 +248,7 @@ class tool_lp_task_testcase extends advanced_testcase {
         $cohort = $dg->create_cohort();
         $tpl = $lpg->create_template(array('duedate' => time() + 1000));
         $templatecohort = api::create_template_cohort($tpl->get_id(), $cohort->id);
-        $task = \core\task\manager::get_scheduled_task('\\tool_lp\\task\\sync_plans_from_template_cohorts_task');
+        $task = \core\task\manager::get_scheduled_task('\\core\\task\\sync_plans_from_template_cohorts_task');
 
         // Add 1 user to the cohort.
         cohort_add_member($cohort->id, $user1->id);
@@ -296,8 +296,8 @@ class tool_lp_task_testcase extends advanced_testcase {
         $DB->update_record(plan::TABLE, $record1);
         $DB->update_record(plan::TABLE, $record2);
 
-        $task = \core\task\manager::get_scheduled_task('\\tool_lp\\task\\complete_plans_task');
-        $this->assertInstanceOf('\\tool_lp\\task\\complete_plans_task', $task);
+        $task = \core\task\manager::get_scheduled_task('\\core\\task\\complete_plans_task');
+        $this->assertInstanceOf('\\core\\task\\complete_plans_task', $task);
 
         // Test that draft plan can not be completed on running task.
         $task->execute();
 /**
  * Complete plans task.
  *
- * @package    tool_lp
+ * @package    core_competency
  * @copyright  2015 Frédéric Massart - FMCorz.net
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-namespace tool_lp\task;
+namespace core\task;
 defined('MOODLE_INTERNAL') || die();
 
 use tool_lp\api;
 /**
  * Synchronise plans from template cohorts.
  *
- * @package    tool_lp
+ * @package    core_competency
  * @copyright  2015 Issam Taboubi <issam.taboubi@umontreal.ca>
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-namespace tool_lp\task;
+namespace core\task;
 defined('MOODLE_INTERNAL') || die();
 
 use tool_lp\api;
index 1a56493..49863b8 100644 (file)
@@ -319,5 +319,23 @@ $tasks = array(
         'day' => '*',
         'dayofweek' => '*',
         'month' => '*'
-    )
+    ),
+    array(
+        'classname' => 'core\task\complete_plans_task',
+        'blocking' => 0,
+        'minute' => 'R',
+        'hour' => '*',
+        'day' => '*',
+        'dayofweek' => '*',
+        'month' => '*'
+    ),
+    array(
+        'classname' => 'core\task\sync_plans_from_template_cohorts_task',
+        'blocking' => 0,
+        'minute' => 'R',
+        'hour' => '*',
+        'day' => '*',
+        'dayofweek' => '*',
+        'month' => '*'
+    ),
 );