From f539f4c7b0ee454cc290c0b6ebcede1bbc2b7168 Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Wed, 21 Feb 2024 16:00:57 +0100 Subject: [PATCH] Add pre and post bulk operation for interactive processing --- classes/processor.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/classes/processor.php b/classes/processor.php index 81a0e73f..8661716c 100644 --- a/classes/processor.php +++ b/classes/processor.php @@ -154,11 +154,31 @@ public function process_courses() { * @param int $processid Id of the process * @return boolean if true, interaction finished. * If false, the current step is still processing and cares for displaying the view. - * @throws \coding_exception - * @throws \dml_exception */ public function process_course_interactive($processid) { $process = process_manager::get_process_by_id($processid); + $steps = step_manager::get_step_types(); + /* @var \tool_lifecycle\step\libbase[] $steplibs stores the lib classes of all step subplugins.*/ + $steplibs = []; + foreach ($steps as $id => $step) { + $steplibs[$id] = lib_manager::get_step_lib($id); + $steplibs[$id]->pre_processing_bulk_operation(); + } + $result = $this->process_course_interactive_recursive($process); + foreach ($steps as $id => $step) { + $steplibs[$id]->post_processing_bulk_operation(); + } + return $result; + } + + /** + * See process_course_interactive(). + * + * @param int $processid Id of the process + * @return boolean if true, interaction finished. + * If false, the current step is still processing and cares for displaying the view. + */ + function process_course_interactive_recursive($process) { $step = step_manager::get_step_instance_by_workflow_index($process->workflowid, $process->stepindex + 1); // If there is no next step, then proceed, which will delete/finish the process. if (!$step) { @@ -178,7 +198,7 @@ public function process_course_interactive($processid) { break; case step_interactive_response::proceed(): // In case of proceed, call recursively. - return $this->process_course_interactive($processid); + return $this->process_course_interactive($process); break; case step_interactive_response::rollback(): delayed_courses_manager::set_course_delayed_for_workflow($process->courseid, true, $process->workflowid);