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

Steps can now proceed!

parent da4ca9a9
No related branches found
No related tags found
No related merge requests found
......@@ -52,13 +52,13 @@ class cleanup_processor {
foreach ($enabledtrigger as $trigger) {
$lib = lib_manager::get_trigger_lib($trigger->subpluginname);
$response = $lib->check_course($course);
if ($response === trigger_response::next()) {
if ($response == trigger_response::next()) {
continue;
}
if ($response === trigger_response::exclude()) {
if ($response == trigger_response::exclude()) {
break;
}
if ($response === trigger_response::trigger()) {
if ($response == trigger_response::trigger()) {
process_manager::create_process($course->id, trigger_subplugin::from_record($trigger));
break;
}
......@@ -77,13 +77,17 @@ class cleanup_processor {
$lib = lib_manager::get_step_lib($step->subpluginname);
$course = get_course($process->courseid);
$result = $lib->process_course($course);
if ($result === step_response::waiting()) {
if ($result == step_response::waiting()) {
break;
} elseif ($result === step_response::proceed()) {
process_manager::proceed_process($process);
} elseif ($result === step_response::rollback()){
} elseif ($result == step_response::proceed()) {
if (!process_manager::proceed_process($process)) {
break;
}
} elseif ($result == step_response::rollback()){
// TODO: Implement Rollback!
break;
} else {
throw new \moodle_exception('Return code \''. var_dump($result) . '\' is not allowed!');
}
}
}
......
......@@ -62,18 +62,21 @@ class process_manager {
/**
* Proceeds the process to the next step.
* @param process $process
* @return true, if followedby another step; otherwise false.
*/
public static function proceed_process(&$process) {
global $DB;
$step = step_manager::get_step_instance($process->stepid);
if ($step->followedby !== null) {
if ($step->followedby) {
$process->stepid = $step->followedby;
$DB->update_record('tool_cleanupcourses_process', $process);
return true;
} else {
if (get_course($process->courseid)) {
debugging('Course should no longer exist!!!!');
}
$DB->delete_records('tool_cleanupcourses_process', $process);
$DB->delete_records('tool_cleanupcourses_process', (array) $process);
return false;
}
}
......
......@@ -34,5 +34,6 @@ class process_cleanup extends \core\task\scheduled_task {
public function execute() {
$processor = new cleanup_processor();
$processor->call_trigger();
$processor->process_courses();
}
}
\ No newline at end of file
......@@ -23,5 +23,5 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2017052202;
$plugin->version = 2017052203;
$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