Skip to content
Snippets Groups Projects
Unverified Commit a9a8882c authored by Tobias Reischmann's avatar Tobias Reischmann
Browse files

Renamed response classes and files

parent a721beab
No related branches found
No related tags found
No related merge requests found
......@@ -50,13 +50,13 @@ class cleanup_processor {
/* @var $trigger trigger\base -> Implementation of the subplugin trigger interface */
foreach ($enabledtrigger as $trigger) {
$response = $triggerclasses[$trigger->name]->check_course($course);
if ($response == TriggerResponse::next()) {
if ($response == trigger_respone::next()) {
continue;
}
if ($response == TriggerResponse::exclude()) {
if ($response == trigger_respone::exclude()) {
break;
}
if ($response == TriggerResponse::trigger()) {
if ($response == trigger_respone::trigger()) {
$this->trigger_course($course->id, $trigger->id);
break;
}
......
......@@ -25,10 +25,11 @@ namespace tool_cleanupcourses;
defined('MOODLE_INTERNAL') || die();
class SubpluginResponse {
class step_response {
const PROCEED = 'proceed';
const WAITING = 'waiting';
const ROLLBACK = 'rollback';
private $value;
......@@ -41,17 +42,24 @@ class SubpluginResponse {
}
/**
* Creates a SubpluginResponse telling that the subplugin finished processing the course.
* Creates a step_response telling that the subplugin finished processing the course.
*/
public static function proceed() {
return new SubpluginResponse(self::PROCEED);
return new step_response(self::PROCEED);
}
/**
* Creates a SubpluginResponse telling that the subplugin is still processing the course.
* Creates a step_response telling that the subplugin is still processing the course.
*/
public static function waiting() {
return new SubpluginResponse(self::WAITING);
return new step_response(self::WAITING);
}
/**
* Creates a step_response telling that a rollback for the process of this course is necessary.
*/
public static function rollback() {
return new step_response(self::ROLLBACK);
}
......
......@@ -25,7 +25,7 @@ namespace tool_cleanupcourses;
defined('MOODLE_INTERNAL') || die();
class TriggerResponse {
class trigger_respone {
const NEXT = 'next';
const EXCLUDE = 'exclude';
......@@ -44,26 +44,26 @@ class TriggerResponse {
/**
* Creates a TriggerResponse telling that the subplugin does not want to process the course.
* This means that the course can be passed to the next trigger.
* @return TriggerResponse
* @return trigger_respone
*/
public static function next() {
return new TriggerResponse(self::NEXT);
return new trigger_respone(self::NEXT);
}
/**
* Creates a TriggerResponse telling that the subplugin wants to exlude the course from cleanup.
* @return TriggerResponse
* @return trigger_respone
*/
public static function exclude() {
return new TriggerResponse(self::EXCLUDE);
return new trigger_respone(self::EXCLUDE);
}
/**
* Creates a TriggerResponse telling that the subplugin wants to trigger the cleanup process for the course.
* @return TriggerResponse
* @return trigger_respone
*/
public static function trigger() {
return new TriggerResponse(self::TRIGGER);
return new trigger_respone(self::TRIGGER);
}
......
......@@ -25,11 +25,11 @@
*/
namespace tool_cleanupcourses\trigger;
use tool_cleanupcourses\TriggerResponse;
use tool_cleanupcourses\trigger_respone;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/../lib.php');
require_once(__DIR__ . '/../../classes/triggerresponse.php');
require_once(__DIR__ . '/../../classes/trigger_response.php');
/**
* Class which implements the basic methods necessary for a cleanyp courses trigger subplugin
......@@ -41,10 +41,10 @@ class dummy implements base {
/**
* Checks the course and returns a repsonse, which tells if the course should be further processed.
* @param $course object to be processed.
* @return TriggerResponse
* @return trigger_respone
*/
public function check_course($course) {
return TriggerResponse::next();
return trigger_respone::next();
}
}
......@@ -25,7 +25,7 @@
*/
namespace tool_cleanupcourses\trigger;
use tool_cleanupcourses\TriggerResponse;
use tool_cleanupcourses\trigger_respone;
defined('MOODLE_INTERNAL') || die();
......@@ -35,7 +35,7 @@ interface base {
/**
* Checks the course and returns a repsonse, which tells if the course should be further processed.
* @param $course object to be processed.
* @return TriggerResponse
* @return trigger_respone
*/
public function check_course($course);
......
......@@ -24,11 +24,11 @@
*/
namespace tool_cleanupcourses\trigger;
use tool_cleanupcourses\TriggerResponse;
use tool_cleanupcourses\trigger_respone;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/../lib.php');
require_once(__DIR__ . '/../../classes/triggerresponse.php');
require_once(__DIR__ . '/../../classes/trigger_response.php');
/**
* Class which implements the basic methods necessary for a cleanup courses trigger subplugin
......@@ -40,13 +40,13 @@ class sitecourse implements base {
/**
* Checks the course and returns a repsonse, which tells if the course should be further processed.
* @param $course object to be processed.
* @return TriggerResponse
* @return trigger_respone
*/
public function check_course($course) {
if ($course->id == SITEID) {
return TriggerResponse::exclude();
return trigger_respone::exclude();
}
return TriggerResponse::next();
return trigger_respone::next();
}
}
......@@ -16,7 +16,7 @@
namespace tool_cleanupcourses\trigger;
use tool_cleanupcourses\TriggerResponse;
use tool_cleanupcourses\trigger_respone;
defined('MOODLE_INTERNAL') || die();
......@@ -45,7 +45,7 @@ class tool_cleanupcourses_trigger_sitecourse_testcase extends \advanced_testcase
$trigger = new sitecourse();
$response = $trigger->check_course($course);
$this->assertEquals($response, TriggerResponse::exclude());
$this->assertEquals($response, trigger_respone::exclude());
}
......@@ -61,7 +61,7 @@ class tool_cleanupcourses_trigger_sitecourse_testcase extends \advanced_testcase
$trigger = new sitecourse();
$response = $trigger->check_course($course);
$this->assertEquals($response, TriggerResponse::next());
$this->assertEquals($response, trigger_respone::next());
}
}
\ No newline at end of file
......@@ -25,11 +25,11 @@
*/
namespace tool_cleanupcourses\trigger;
use tool_cleanupcourses\TriggerResponse;
use tool_cleanupcourses\trigger_respone;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/../lib.php');
require_once(__DIR__ . '/../../classes/triggerresponse.php');
require_once(__DIR__ . '/../../classes/trigger_response.php');
/**
* Class which implements the basic methods necessary for a cleanyp courses trigger subplugin
......@@ -41,16 +41,16 @@ class startdatedelay implements base {
/**
* Checks the course and returns a repsonse, which tells if the course should be further processed.
* @param $course object to be processed.
* @return TriggerResponse
* @return trigger_respone
*/
public function check_course($course) {
global $CFG;
$delay = $CFG->cleanupcoursestrigger_startdatedelay_delay;
$now = time();
if ($course->startdate + $delay < $now) {
return TriggerResponse::trigger();
return trigger_respone::trigger();
}
return TriggerResponse::next();
return trigger_respone::next();
}
}
......@@ -16,7 +16,7 @@
namespace tool_cleanupcourses\trigger;
use tool_cleanupcourses\TriggerResponse;
use tool_cleanupcourses\trigger_respone;
defined('MOODLE_INTERNAL') || die();
......@@ -45,7 +45,7 @@ class tool_cleanupcourses_trigger_startdatedelay_testcase extends \advanced_test
$trigger = new startdatedelay();
$response = $trigger->check_course($course);
$this->assertEquals($response, TriggerResponse::next());
$this->assertEquals($response, trigger_respone::next());
}
......@@ -61,7 +61,7 @@ class tool_cleanupcourses_trigger_startdatedelay_testcase extends \advanced_test
$trigger = new startdatedelay();
$response = $trigger->check_course($course);
$this->assertEquals($response, TriggerResponse::trigger());
$this->assertEquals($response, trigger_respone::trigger());
}
}
\ No newline at end of file
......@@ -23,5 +23,5 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2017051004;
$plugin->version = 2017051201;
$plugin->component = 'tool_cleanupcourses';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment