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

Added new workflow definition to process_manager

parent 91622f6a
No related branches found
No related tags found
No related merge requests found
......@@ -39,11 +39,11 @@ class process_manager {
*/
public static function create_process($courseid, $trigger) {
global $DB;
if ($trigger->followedby !== null) {
if ($trigger->worflowid !== null) {
$record = new \stdClass();
$record->id = null;
$record->courseid = $courseid;
$record->stepid = $trigger->followedby;
$record->worflowid = $trigger->worflowid;
$record->timestepchanged = time();
$process = process::from_record($record);
$process->id = $DB->insert_record('tool_cleanupcourses_process', $process);
......@@ -88,9 +88,9 @@ class process_manager {
*/
public static function proceed_process(&$process) {
global $DB;
$step = step_manager::get_step_instance($process->stepid);
if ($step->followedby) {
$process->stepid = $step->followedby;
$step = step_manager::get_step_instance_by_workflow_index($process->workflowid, $process->stepindex + 1);
if ($step) {
$process->stepindex++;
$process->waiting = false;
$process->timestepchanged = time();
$DB->update_record('tool_cleanupcourses_process', $process);
......
......@@ -46,6 +46,27 @@ class step_manager extends subplugin_manager {
}
}
/**
* Returns a step instance for a workflow with a specific sortindex.
* @param int $workflowid id of the workflow
* @param int $sortindex sortindex of the step within the workflow
* @return step_subplugin|null
*/
public static function get_step_instance_by_workflow_index($workflowid, $sortindex) {
global $DB;
$record = $DB->get_record('tool_cleanupcourses_step',
array(
'workflowid' => $workflowid,
'sortindex' => $sortindex)
);
if ($record) {
$subplugin = step_subplugin::from_record($record);
return $subplugin;
} else {
return null;
}
}
/**
* Persists a subplugin to the database.
* @param step_subplugin $subplugin
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment