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

Rebranded from cleanupcourses to lifecycle

parent 582a4d55
No related branches found
No related tags found
No related merge requests found
Showing
with 187 additions and 183 deletions
# moodle-tool_cleanupcourses
# Course Life Cycle (moodle-tool_lifecycle)
[WIP] This module is currently in development.
The goal is to create a modular plugin, which allows the deprovision of moodle courses.
Deprovision therefore means the cleanup and deletion of courses after they are no longer used.
The goal is to create a modular plugin, which allows the to execute recurring tasks within moodle associated with courses.
Possible use cases are (not limited to):
- Deleting courses at end of life (including asking teachers for permission).
- Doing a rollover at the end of a semester.
- Automatically setting an end date for courses.
To be adaptable to the needs of different institutions the plugin will provide multiple subplugin types.
Those can be adjusted to the needs of your institution.
For more information please have a look at the [wiki](https://github.com/learnweb/moodle-tool_cleanupcourses/wiki).
For more information please have a look at the [wiki](https://github.com/learnweb/moodle-tool_lifecycle/wiki).
......@@ -17,7 +17,7 @@
/**
* Display the list of active processes
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......@@ -28,16 +28,16 @@ $PAGE->set_context(context_system::instance());
require_login(null, false);
require_capability('moodle/site:config', context_system::instance());
admin_externalpage_setup('tool_cleanupcourses_activeprocesses');
admin_externalpage_setup('tool_lifecycle_activeprocesses');
$PAGE->set_url(new \moodle_url('/admin/tool/cleanupcourses/activeprocesses.php'));
$PAGE->set_url(new \moodle_url('/admin/tool/lifecycle/activeprocesses.php'));
$table = new tool_cleanupcourses\table\active_processes_table('tool_cleanupcourses_active_processes');
$table = new tool_lifecycle\table\active_processes_table('tool_lifecycle_active_processes');
$PAGE->set_title(get_string('active_processes_list_header', 'tool_cleanupcourses'));
$PAGE->set_heading(get_string('active_processes_list_header', 'tool_cleanupcourses'));
$PAGE->set_title(get_string('active_processes_list_header', 'tool_lifecycle'));
$PAGE->set_heading(get_string('active_processes_list_header', 'tool_lifecycle'));
$renderer = $PAGE->get_renderer('tool_cleanupcourses');
$renderer = $PAGE->get_renderer('tool_lifecycle');
echo $renderer->header();
......
......@@ -14,22 +14,22 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_cleanupcourses;
use tool_cleanupcourses\entity\trigger_subplugin;
use tool_cleanupcourses\form\form_workflow_instance;
use tool_cleanupcourses\form\form_step_instance;
use tool_cleanupcourses\form\form_trigger_instance;
use tool_cleanupcourses\manager\step_manager;
use tool_cleanupcourses\manager\settings_manager;
use tool_cleanupcourses\manager\trigger_manager;
use tool_cleanupcourses\entity\workflow;
use tool_cleanupcourses\entity\step_subplugin;
use tool_cleanupcourses\manager\workflow_manager;
use tool_cleanupcourses\table\active_manual_workflows_table;
use tool_cleanupcourses\table\workflow_definition_table;
use tool_cleanupcourses\table\active_automatic_workflows_table;
use tool_cleanupcourses\table\step_table;
namespace tool_lifecycle;
use tool_lifecycle\entity\trigger_subplugin;
use tool_lifecycle\form\form_workflow_instance;
use tool_lifecycle\form\form_step_instance;
use tool_lifecycle\form\form_trigger_instance;
use tool_lifecycle\manager\step_manager;
use tool_lifecycle\manager\settings_manager;
use tool_lifecycle\manager\trigger_manager;
use tool_lifecycle\entity\workflow;
use tool_lifecycle\entity\step_subplugin;
use tool_lifecycle\manager\workflow_manager;
use tool_lifecycle\table\active_manual_workflows_table;
use tool_lifecycle\table\workflow_definition_table;
use tool_lifecycle\table\active_automatic_workflows_table;
use tool_lifecycle\table\step_table;
defined('MOODLE_INTERNAL') || die;
......@@ -37,9 +37,9 @@ require_once($CFG->libdir . '/adminlib.php');
require_once(__DIR__ . '/lib.php');
/**
* External Page for showing active cleanup processes
* External Page for showing active lifecycle processes
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......@@ -51,9 +51,9 @@ class admin_page_active_processes extends \admin_externalpage {
*
*/
public function __construct() {
$url = new \moodle_url('/admin/tool/cleanupcourses/activeprocesses.php');
parent::__construct('tool_cleanupcourses_activeprocesses',
get_string('active_processes_list_header', 'tool_cleanupcourses'),
$url = new \moodle_url('/admin/tool/lifecycle/activeprocesses.php');
parent::__construct('tool_lifecycle_activeprocesses',
get_string('active_processes_list_header', 'tool_lifecycle'),
$url);
}
}
......@@ -61,7 +61,7 @@ class admin_page_active_processes extends \admin_externalpage {
/**
* External Page for showing course backups
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......@@ -73,9 +73,9 @@ class admin_page_course_backups extends \admin_externalpage {
*
*/
public function __construct() {
$url = new \moodle_url('/admin/tool/cleanupcourses/coursebackups.php');
parent::__construct('tool_cleanupcourses_coursebackups',
get_string('course_backups_list_header', 'tool_cleanupcourses'),
$url = new \moodle_url('/admin/tool/lifecycle/coursebackups.php');
parent::__construct('tool_lifecycle_coursebackups',
get_string('course_backups_list_header', 'tool_lifecycle'),
$url);
}
}
......@@ -83,7 +83,7 @@ class admin_page_course_backups extends \admin_externalpage {
/**
* External Page for defining settings for subplugins
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......@@ -95,9 +95,9 @@ class admin_page_sublugins extends \admin_externalpage {
*
*/
public function __construct() {
$url = new \moodle_url('/admin/tool/cleanupcourses/adminsettings.php');
parent::__construct('tool_cleanupcourses_adminsettings',
get_string('adminsettings_heading', 'tool_cleanupcourses'),
$url = new \moodle_url('/admin/tool/lifecycle/adminsettings.php');
parent::__construct('tool_lifecycle_adminsettings',
get_string('adminsettings_heading', 'tool_lifecycle'),
$url);
}
}
......@@ -105,7 +105,7 @@ class admin_page_sublugins extends \admin_externalpage {
/**
* Class that handles the display and configuration the settings.
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2015 Tobias Reischmann
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......@@ -119,7 +119,7 @@ class admin_settings {
*/
public function __construct() {
global $PAGE;
$this->pageurl = new \moodle_url('/admin/tool/cleanupcourses/adminsettings.php');
$this->pageurl = new \moodle_url('/admin/tool/lifecycle/adminsettings.php');
$PAGE->set_url($this->pageurl);
}
......@@ -132,28 +132,28 @@ class admin_settings {
// Set up the table.
$this->view_header();
echo $OUTPUT->heading(get_string('active_automatic_workflows_heading', 'tool_cleanupcourses'));
echo $OUTPUT->heading(get_string('active_automatic_workflows_heading', 'tool_lifecycle'));
$table = new active_automatic_workflows_table('tool_cleanupcourses_active_automatic_workflows');
echo $OUTPUT->box_start("cleanupcourses-enable-overflow cleanupcourses-table");
$table = new active_automatic_workflows_table('tool_lifecycle_active_automatic_workflows');
echo $OUTPUT->box_start("lifecycle-enable-overflow lifecycle-table");
$table->out(10, false);
echo $OUTPUT->box_end();
echo $OUTPUT->heading(get_string('active_manual_workflows_heading', 'tool_cleanupcourses'));
echo $OUTPUT->heading(get_string('active_manual_workflows_heading', 'tool_lifecycle'));
$table = new active_manual_workflows_table('tool_cleanupcourses_manual_workflows');
echo $OUTPUT->box_start("cleanupcourses-enable-overflow cleanupcourses-table");
$table = new active_manual_workflows_table('tool_lifecycle_manual_workflows');
echo $OUTPUT->box_start("lifecycle-enable-overflow lifecycle-table");
$table->out(10, false);
echo $OUTPUT->box_end();
echo $OUTPUT->heading(get_string('workflow_definition_heading', 'tool_cleanupcourses'));
echo $OUTPUT->heading(get_string('workflow_definition_heading', 'tool_lifecycle'));
echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('action' => ACTION_WORKFLOW_INSTANCE_FROM, 'sesskey' => sesskey())),
get_string('add_workflow', 'tool_cleanupcourses'));
get_string('add_workflow', 'tool_lifecycle'));
$table = new workflow_definition_table('tool_cleanupcourses_workflow_definitions');
echo $OUTPUT->box_start("cleanupcourses-enable-overflow cleanupcourses-table");
$table = new workflow_definition_table('tool_lifecycle_workflow_definitions');
echo $OUTPUT->box_start("lifecycle-enable-overflow lifecycle-table");
$table->out(10, false);
echo $OUTPUT->box_end();
......@@ -170,7 +170,7 @@ class admin_settings {
// Set up the table.
$this->view_header();
echo $OUTPUT->heading(get_string('adminsettings_edit_workflow_definition_heading', 'tool_cleanupcourses'));
echo $OUTPUT->heading(get_string('adminsettings_edit_workflow_definition_heading', 'tool_lifecycle'));
echo $form->render();
......@@ -183,7 +183,7 @@ class admin_settings {
* @throws \moodle_exception
*/
private function view_workflow_details($workflowid) {
$url = new \moodle_url('/admin/tool/cleanupcourses/workflowsettings.php',
$url = new \moodle_url('/admin/tool/lifecycle/workflowsettings.php',
array('workflowid' => $workflowid, 'sesskey' => sesskey()));
redirect($url);
}
......@@ -223,7 +223,7 @@ class admin_settings {
$this->check_permissions();
// Has to be called before moodleform is created!
admin_externalpage_setup('tool_cleanupcourses_adminsettings');
admin_externalpage_setup('tool_lifecycle_adminsettings');
workflow_manager::handle_action($action, $workflowid);
......@@ -258,7 +258,7 @@ class admin_settings {
/**
* Class that handles the display and configuration of a workflow.
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2015 Tobias Reischmann
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......@@ -277,8 +277,8 @@ class workflow_settings {
public function __construct($workflowid) {
global $PAGE;
// Has to be called before moodleform is created!
admin_externalpage_setup('tool_cleanupcourses_adminsettings');
$this->pageurl = new \moodle_url('/admin/tool/cleanupcourses/workflowsettings.php');
admin_externalpage_setup('tool_lifecycle_adminsettings');
$this->pageurl = new \moodle_url('/admin/tool/lifecycle/workflowsettings.php');
$PAGE->set_url($this->pageurl);
$this->workflowid = $workflowid;
}
......@@ -292,18 +292,18 @@ class workflow_settings {
// Set up the table.
$this->view_header();
echo $OUTPUT->heading(get_string('adminsettings_workflow_definition_steps_heading', 'tool_cleanupcourses'));
echo $OUTPUT->heading(get_string('adminsettings_workflow_definition_steps_heading', 'tool_lifecycle'));
if (!workflow_manager::is_active($this->workflowid)) {
$steps = step_manager::get_step_types();
echo $OUTPUT->single_select(new \moodle_url($PAGE->url,
array('action' => ACTION_STEP_INSTANCE_FORM, 'sesskey' => sesskey(), 'workflowid' => $this->workflowid)),
'subpluginname', $steps, '', array('' => get_string('add_new_step_instance', 'tool_cleanupcourses')));
'subpluginname', $steps, '', array('' => get_string('add_new_step_instance', 'tool_lifecycle')));
}
echo $OUTPUT->single_button( new \moodle_url('/admin/tool/cleanupcourses/adminsettings.php'),
echo $OUTPUT->single_button( new \moodle_url('/admin/tool/lifecycle/adminsettings.php'),
get_string('back'));
$table = new step_table('tool_cleanupcourses_workflows', $this->workflowid);
$table = new step_table('tool_lifecycle_workflows', $this->workflowid);
$table->out(50, false);
$this->view_footer();
......@@ -316,7 +316,7 @@ class workflow_settings {
private function view_step_instance_form($form) {
$workflow = workflow_manager::get_workflow($this->workflowid);
$this->view_instance_form($form,
get_string('adminsettings_edit_step_instance_heading', 'tool_cleanupcourses',
get_string('adminsettings_edit_step_instance_heading', 'tool_lifecycle',
$workflow->title));
}
......@@ -327,7 +327,7 @@ class workflow_settings {
private function view_trigger_instance_form($form) {
$workflow = workflow_manager::get_workflow($this->workflowid);
$this->view_instance_form($form,
get_string('adminsettings_edit_trigger_instance_heading', 'tool_cleanupcourses',
get_string('adminsettings_edit_trigger_instance_heading', 'tool_lifecycle',
$workflow->title));
}
......@@ -436,7 +436,7 @@ class workflow_settings {
// In case the workflow is active, we do not allow changes to the steps or trigger.
if (workflow_manager::is_active($this->workflowid)) {
echo $OUTPUT->notification(
get_string('active_workflow_not_changeable', 'tool_cleanupcourses'),
get_string('active_workflow_not_changeable', 'tool_lifecycle'),
'warning');
} else {
if (!empty($data->id)) {
......@@ -489,7 +489,7 @@ class workflow_settings {
// In case the workflow is active, we do not allow changes to the steps or trigger.
if (workflow_manager::is_active($this->workflowid)) {
echo $OUTPUT->notification(
get_string('active_workflow_not_changeable', 'tool_cleanupcourses'),
get_string('active_workflow_not_changeable', 'tool_lifecycle'),
'warning');
} else {
if (!empty($data->id)) {
......
......@@ -17,7 +17,7 @@
/**
* Displays the tables of active and inactive workflow definitions and handles all action associated with it.
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......@@ -29,7 +29,7 @@ require_login(null, false);
require_capability('moodle/site:config', context_system::instance());
// Create the class for this controller.
$adminsettings = new tool_cleanupcourses\admin_settings();
$adminsettings = new tool_lifecycle\admin_settings();
// Execute the controller.
$adminsettings->execute(optional_param('action', null, PARAM_TEXT),
......
......@@ -14,14 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_cleanupcourses\entity;
namespace tool_lifecycle\entity;
defined('MOODLE_INTERNAL') || die();
/**
* Cleanup Course Process class
* Life Cycle Process class
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......@@ -60,7 +60,7 @@ class process {
}
/**
* Creates a Cleanup Course Process from a db record.
* Creates a Life Cycle Process from a db record.
* @param $record
* @return process
*/
......
......@@ -14,14 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_cleanupcourses\entity;
namespace tool_lifecycle\entity;
defined('MOODLE_INTERNAL') || die();
/**
* Subplugin class
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......
......@@ -14,14 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_cleanupcourses\entity;
namespace tool_lifecycle\entity;
defined('MOODLE_INTERNAL') || die();
/**
* Subplugin class
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......
......@@ -14,14 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_cleanupcourses\entity;
namespace tool_lifecycle\entity;
defined('MOODLE_INTERNAL') || die();
/**
* Trigger subplugin class
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......
......@@ -14,14 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_cleanupcourses\entity;
namespace tool_lifecycle\entity;
defined('MOODLE_INTERNAL') || die();
/**
* Cleanup Course Workflow class
* Life Cycle Workflow class
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......
......@@ -17,16 +17,16 @@
/**
* Offers the possibility to add or modify a step instance.
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\form;
namespace tool_lifecycle\form;
use tool_cleanupcourses\entity\step_subplugin;
use tool_cleanupcourses\manager\lib_manager;
use tool_cleanupcourses\manager\workflow_manager;
use tool_cleanupcourses\step\libbase;
use tool_lifecycle\entity\step_subplugin;
use tool_lifecycle\manager\lib_manager;
use tool_lifecycle\manager\workflow_manager;
use tool_lifecycle\step\libbase;
defined('MOODLE_INTERNAL') || die();
......@@ -104,14 +104,14 @@ class form_step_instance extends \moodleform {
$mform->setType('action', PARAM_TEXT);
$mform->setDefault('action', ACTION_STEP_INSTANCE_FORM);
$mform->addElement('header', 'general_settings_header', get_string('general_settings_header', 'tool_cleanupcourses'));
$mform->addElement('header', 'general_settings_header', get_string('general_settings_header', 'tool_lifecycle'));
$elementname = 'instancename';
$mform->addElement('text', $elementname, get_string('step_instancename', 'tool_cleanupcourses'));
$mform->addElement('text', $elementname, get_string('step_instancename', 'tool_lifecycle'));
$mform->setType($elementname, PARAM_TEXT);
$elementname = 'subpluginnamestatic';
$mform->addElement('static', $elementname, get_string('step_subpluginname', 'tool_cleanupcourses'));
$mform->addElement('static', $elementname, get_string('step_subpluginname', 'tool_lifecycle'));
$mform->setType($elementname, PARAM_TEXT);
$elementname = 'subpluginname';
$mform->addElement('hidden', $elementname);
......@@ -119,7 +119,7 @@ class form_step_instance extends \moodleform {
// Insert the subplugin specific settings.
if (!empty($this->lib->instance_settings())) {
$mform->addElement('header', 'step_settings_header', get_string('step_settings_header', 'tool_cleanupcourses'));
$mform->addElement('header', 'step_settings_header', get_string('step_settings_header', 'tool_lifecycle'));
$this->lib->extend_add_instance_form_definition($mform);
}
......@@ -161,7 +161,7 @@ class form_step_instance extends \moodleform {
$subpluginname = $this->subpluginname;
}
$mform->setDefault('subpluginnamestatic',
get_string('pluginname', 'cleanupcoursesstep_' . $subpluginname));
get_string('pluginname', 'lifecyclestep_' . $subpluginname));
$mform->setDefault('subpluginname', $subpluginname);
// Setting the default values for the local step settings.
......
......@@ -17,17 +17,17 @@
/**
* Offers the possibility to add or modify a step instance.
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\form;
namespace tool_lifecycle\form;
use tool_cleanupcourses\entity\trigger_subplugin;
use tool_cleanupcourses\manager\lib_manager;
use tool_cleanupcourses\manager\trigger_manager;
use tool_cleanupcourses\manager\workflow_manager;
use tool_cleanupcourses\trigger\base;
use tool_lifecycle\entity\trigger_subplugin;
use tool_lifecycle\manager\lib_manager;
use tool_lifecycle\manager\trigger_manager;
use tool_lifecycle\manager\workflow_manager;
use tool_lifecycle\trigger\base;
defined('MOODLE_INTERNAL') || die();
......@@ -109,10 +109,10 @@ class form_trigger_instance extends \moodleform {
$mform->setType('action', PARAM_TEXT);
$mform->setDefault('action', ACTION_TRIGGER_INSTANCE_FORM);
$mform->addElement('header', 'general_settings_header', get_string('general_settings_header', 'tool_cleanupcourses'));
$mform->addElement('header', 'general_settings_header', get_string('general_settings_header', 'tool_lifecycle'));
$elementname = 'instancename';
$mform->addElement('text', $elementname, get_string('trigger_instancename', 'tool_cleanupcourses'));
$mform->addElement('text', $elementname, get_string('trigger_instancename', 'tool_lifecycle'));
$mform->setType($elementname, PARAM_TEXT);
// If workflow is active, then all trigger types have to be used to also show the preset triggers.
......@@ -124,13 +124,13 @@ class form_trigger_instance extends \moodleform {
$elementname = 'subpluginname';
$mform->addElement('select', $elementname,
get_string('trigger_subpluginname', 'tool_cleanupcourses'),
get_string('trigger_subpluginname', 'tool_lifecycle'),
$triggers);
$mform->setType($elementname, PARAM_TEXT);
// Insert the subplugin specific settings.
if (isset($this->lib) && !empty($this->lib->instance_settings())) {
$mform->addElement('header', 'trigger_settings_header', get_string('trigger_settings_header', 'tool_cleanupcourses'));
$mform->addElement('header', 'trigger_settings_header', get_string('trigger_settings_header', 'tool_lifecycle'));
$this->lib->extend_add_instance_form_definition($mform);
}
......
......@@ -17,13 +17,13 @@
/**
* Offers the possibility to add or modify a workflow instance.
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\form;
namespace tool_lifecycle\form;
use tool_cleanupcourses\entity\workflow;
use tool_lifecycle\entity\workflow;
defined('MOODLE_INTERNAL') || die();
......@@ -65,18 +65,18 @@ class form_workflow_instance extends \moodleform {
$mform->setDefault($elementname, $this->workflow->id);
}
$mform->addElement('header', 'general_settings_header', get_string('general_settings_header', 'tool_cleanupcourses'));
$mform->addElement('header', 'general_settings_header', get_string('general_settings_header', 'tool_lifecycle'));
$elementname = 'title';
$mform->addElement('text', $elementname, get_string('workflow_title', 'tool_cleanupcourses'));
$mform->addElement('text', $elementname, get_string('workflow_title', 'tool_lifecycle'));
$mform->setType($elementname, PARAM_TEXT);
if (isset($this->workflow)) {
$mform->setDefault($elementname, $this->workflow->title);
}
$elementname = 'displaytitle';
$mform->addElement('text', $elementname, get_string('workflow_displaytitle', 'tool_cleanupcourses'));
$mform->addHelpButton($elementname, 'workflow_displaytitle', 'tool_cleanupcourses');
$mform->addElement('text', $elementname, get_string('workflow_displaytitle', 'tool_lifecycle'));
$mform->addHelpButton($elementname, 'workflow_displaytitle', 'tool_lifecycle');
$mform->setType($elementname, PARAM_TEXT);
if (isset($this->workflow)) {
$mform->setDefault($elementname, $this->workflow->displaytitle);
......
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_cleanupcourses\local\data;
namespace tool_lifecycle\local\data;
use renderable;
......@@ -23,7 +23,7 @@ defined('MOODLE_INTERNAL') || die();
/**
* Class representing a manual trigger tool
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2018 WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
......
......@@ -17,11 +17,11 @@
/**
* Manager to create & restore backups for courses
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\manager;
namespace tool_lifecycle\manager;
defined('MOODLE_INTERNAL') || die();
......@@ -32,7 +32,7 @@ require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
class backup_manager {
/**
* Creates a course backup in a specific cleanup courses backup folder
* Creates a course backup in a specific life cycle backup folder
* @param int $courseid id of the course the backup should be created for.
* @return bool tells if the backup was completed successfully.
*/
......@@ -44,20 +44,20 @@ class backup_manager {
$record->courseid = $courseid;
$record->fullname = $course->fullname;
$record->shortname = $course->shortname;
$recordid = $DB->insert_record('tool_cleanupcourses_backups', $record, true);
$recordid = $DB->insert_record('tool_lifecycle_backups', $record, true);
$record->id = $recordid;
// Build filename.
$archivefile = date("Y-m-d") . "-ID-{$recordid}-COURSE-{$courseid}.mbz";
// Path of backup folder.
$path = $CFG->dataroot . '/cleanupcourses_backups';
$path = $CFG->dataroot . '/lifecycle_backups';
// If the path doesn't exist, make it so!
if (!is_dir($path)) {
umask(0000);
// Create the directory for Backups.
if (!mkdir($path, $CFG->directorypermissions, true)) {
throw new \moodle_exception(get_string('errorbackuppath', 'tool_cleanupcourses'));
throw new \moodle_exception(get_string('errorbackuppath', 'tool_lifecycle'));
}
}
// Perform Backup.
......@@ -80,7 +80,7 @@ class backup_manager {
$record->backupfile = $archivefile;
$record->backupcreated = time();
$DB->update_record('tool_cleanupcourses_backups', $record, true);
$DB->update_record('tool_lifecycle_backups', $record, true);
return true;
} catch (\moodle_exception $e) {
......@@ -92,7 +92,7 @@ class backup_manager {
/**
* Restores a course backup via a backupid
* The function copies the backup file from the cleanupcourse backup folder to a temporary folder.
* The function copies the backup file from the lifecycle backup folder to a temporary folder.
* It then redirects to the backup/restore.php, which leads the user through the interactive restore process.
* @param int $backupid id of backup entry.
* @throws \moodle_exception
......@@ -100,7 +100,7 @@ class backup_manager {
*/
public static function restore_course_backup($backupid) {
global $DB, $CFG;
$backuprecord = $DB->get_record('tool_cleanupcourses_backups', array('id' => $backupid));
$backuprecord = $DB->get_record('tool_lifecycle_backups', array('id' => $backupid));
// Check if backup tmp dir exists.
$backuptmpdir = $CFG->tempdir . '/backup';
......@@ -112,10 +112,10 @@ class backup_manager {
$targetfilename = \restore_controller::get_tempdir_name($backuprecord->courseid, get_admin()->id);
$target = $backuptmpdir . '/' . $targetfilename;
// Create the location of the actual backup file.
$source = $CFG->dataroot . '/cleanupcourses_backups/' . $backuprecord->backupfile;
$source = $CFG->dataroot . '/lifecycle_backups/' . $backuprecord->backupfile;
// Check if the backup file exists.
if (!file_exists($source)) {
throw new \moodle_exception('errorbackupfiledoesnotexist', 'tool_cleanupprocess', $source);
throw new \moodle_exception('errorbackupfiledoesnotexist', 'tool_lifecycle', $source);
}
// Copy the file to the backup temp dir.
......
......@@ -18,11 +18,11 @@
* Manager for Delayed Courses
* Each entry tells that the trigger-check for a certain course is delayed until a certain timestamp.
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\manager;
namespace tool_lifecycle\manager;
defined('MOODLE_INTERNAL') || die();
......@@ -36,16 +36,16 @@ class delayed_courses_manager {
public static function set_course_delayed($courseid, $duration) {
global $DB;
$delayeduntil = time() + $duration;
$record = $DB->get_record('tool_cleanupcourses_delayed', array('courseid' => $courseid));
$record = $DB->get_record('tool_lifecycle_delayed', array('courseid' => $courseid));
if (!$record) {
$record = new \stdClass();
$record->courseid = $courseid;
$record->delayeduntil = $delayeduntil;
$DB->insert_record('tool_cleanupcourses_delayed', $record);
$DB->insert_record('tool_lifecycle_delayed', $record);
} else {
if ($record->delayeduntil < $delayeduntil) {
$record->delayeduntil = $delayeduntil;
$DB->update_record('tool_cleanupcourses_delayed', $record);
$DB->update_record('tool_lifecycle_delayed', $record);
}
}
}
......@@ -57,7 +57,7 @@ class delayed_courses_manager {
*/
public static function get_course_delayed($courseid) {
global $DB;
$record = $DB->get_record('tool_cleanupcourses_delayed', array('courseid' => $courseid));
$record = $DB->get_record('tool_lifecycle_delayed', array('courseid' => $courseid));
if ($record) {
return $record->delayeduntil;
} else {
......@@ -71,6 +71,6 @@ class delayed_courses_manager {
*/
public static function remove_delay_entry($courseid) {
global $DB;
$DB->delete_records('tool_cleanupcourses_delayed', array('courseid' => $courseid));
$DB->delete_records('tool_lifecycle_delayed', array('courseid' => $courseid));
}
}
......@@ -17,14 +17,14 @@
/**
* Manager to handle interactions by users
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\manager;
namespace tool_lifecycle\manager;
use tool_cleanupcourses\cleanup_processor;
use tool_cleanupcourses\response\step_interactive_response;
use tool_lifecycle\processor;
use tool_lifecycle\response\step_interactive_response;
defined('MOODLE_INTERNAL') || die();
......@@ -55,10 +55,10 @@ class interaction_manager {
$step = step_manager::get_step_instance($stepid);
$process = process_manager::get_process_by_id($processid);
if (!$step) {
throw new \invalid_parameter_exception(get_string('nostepfound', 'tool_cleanupcourses'));
throw new \invalid_parameter_exception(get_string('nostepfound', 'tool_lifecycle'));
}
if (!$process) {
throw new \invalid_parameter_exception(get_string('noprocessfound', 'tool_cleanupcourses'));
throw new \invalid_parameter_exception(get_string('noprocessfound', 'tool_lifecycle'));
}
$interactionlib = lib_manager::get_step_interactionlib($step->subpluginname);
$response = $interactionlib->handle_interaction($process, $step, $action);
......@@ -70,7 +70,7 @@ class interaction_manager {
case step_interactive_response::no_action():
break;
case step_interactive_response::proceed():
$processor = new cleanup_processor();
$processor = new processor();
return $processor->process_course_interactive($processid);
break;
case step_interactive_response::rollback():
......@@ -115,7 +115,7 @@ class interaction_manager {
$interactionlib = lib_manager::get_step_interactionlib($subpluginname);
$process = process_manager::get_process_by_id($processid);
if (!$process) {
throw new \invalid_parameter_exception(get_string('noprocessfound', 'tool_cleanupcourses'));
throw new \invalid_parameter_exception(get_string('noprocessfound', 'tool_lifecycle'));
}
return $interactionlib->get_action_tools($process);
}
......@@ -130,7 +130,7 @@ class interaction_manager {
public static function get_process_status_message($processid) {
$process = process_manager::get_process_by_id($processid);
if (!$process) {
throw new \invalid_parameter_exception(get_string('noprocessfound', 'tool_cleanupcourses'));
throw new \invalid_parameter_exception(get_string('noprocessfound', 'tool_lifecycle'));
}
if ($process->stepindex == 0) {
......@@ -141,7 +141,7 @@ class interaction_manager {
$step = step_manager::get_step_instance_by_workflow_index($process->workflowid, $process->stepindex);
$interactionlib = lib_manager::get_step_interactionlib($step->subpluginname);
if ($interactionlib === null) {
return get_string("workflow_is_running", "tool_cleanupcourses");
return get_string("workflow_is_running", "tool_lifecycle");
}
return $interactionlib->get_status_message($process);
......
......@@ -17,14 +17,14 @@
/**
* Manager to retrive the lib of each subplugin.
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\manager;
namespace tool_lifecycle\manager;
use tool_cleanupcourses\trigger\base_automatic;
use tool_cleanupcourses\trigger\base_manual;
use tool_lifecycle\trigger\base_automatic;
use tool_lifecycle\trigger\base_manual;
defined('MOODLE_INTERNAL') || die();
......@@ -33,7 +33,7 @@ class lib_manager {
/**
* Gets the trigger class of a subplugin lib.
* @param string $subpluginname name of the subplugin
* @return \tool_cleanupcourses\trigger\base
* @return \tool_lifecycle\trigger\base
*/
public static function get_trigger_lib($subpluginname) {
return self::get_lib($subpluginname, 'trigger');
......@@ -42,7 +42,7 @@ class lib_manager {
/**
* Gets the lib class for an manual trigger subplugin.
* @param string $subpluginname name of the subplugin
* @return \tool_cleanupcourses\trigger\base_manual
* @return \tool_lifecycle\trigger\base_manual
* @throws \coding_exception
*/
public static function get_manual_trigger_lib($subpluginname) {
......@@ -56,7 +56,7 @@ class lib_manager {
/**
* Gets the lib class for an automatic trigger subplugin.
* @param string $subpluginname name of the subplugin
* @return \tool_cleanupcourses\trigger\base_automatic
* @return \tool_lifecycle\trigger\base_automatic
* @throws \coding_exception
*/
public static function get_automatic_trigger_lib($subpluginname) {
......@@ -72,7 +72,7 @@ class lib_manager {
/**
* Gets the step class of a subplugin lib.
* @param string $subpluginname name of the subplugin
* @return \tool_cleanupcourses\step\libbase
* @return \tool_lifecycle\step\libbase
*/
public static function get_step_lib($subpluginname) {
return self::get_lib($subpluginname, 'step');
......@@ -81,7 +81,7 @@ class lib_manager {
/**
* Gets the step class of a subplugin lib.
* @param string $subpluginname name of the subplugin
* @return \tool_cleanupcourses\step\interactionlibbase
* @return \tool_lifecycle\step\interactionlibbase
*/
public static function get_step_interactionlib($subpluginname) {
return self::get_lib($subpluginname, 'step', 'interaction');
......@@ -95,14 +95,14 @@ class lib_manager {
* @return
*/
private static function get_lib($subpluginname, $subplugintype, $libsubtype = '') {
$triggerlist = \core_component::get_plugin_list('cleanupcourses' . $subplugintype);
$triggerlist = \core_component::get_plugin_list('lifecycle' . $subplugintype);
if (!array_key_exists($subpluginname, $triggerlist)) {
return null;
}
$filename = $triggerlist[$subpluginname].'/'.$libsubtype.'lib.php';
if (file_exists($filename)) {
require_once($filename);
$extendedclass = "tool_cleanupcourses\\$subplugintype\\$libsubtype$subpluginname";
$extendedclass = "tool_lifecycle\\$subplugintype\\$libsubtype$subpluginname";
if (class_exists($extendedclass)) {
return new $extendedclass();
}
......
......@@ -15,19 +15,19 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Manager for data of Cleanup Course Processes
* Manager for data of Life Cycle Processes
* Data means every additional data, which is produced, stored and queried by steps during the process.
* This class stores and queries the process data using a key/value-store.
* Only strings can be stored. Every other data has to be parsed manually!
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\manager;
namespace tool_lifecycle\manager;
use tool_cleanupcourses\entity\process;
use tool_cleanupcourses\entity\trigger_subplugin;
use tool_lifecycle\entity\process;
use tool_lifecycle\entity\trigger_subplugin;
defined('MOODLE_INTERNAL') || die();
......@@ -51,7 +51,7 @@ class process_data_manager {
} else {
$params['subpluginname'] = step_manager::get_step_instance($stepid)->subpluginname;
}
if ($value = $DB->get_record('tool_cleanupcourses_procdata', $params)) {
if ($value = $DB->get_record('tool_lifecycle_procdata', $params)) {
return $value->value;
}
return null;
......@@ -75,12 +75,12 @@ class process_data_manager {
} else {
$entry['subpluginname'] = step_manager::get_step_instance($stepid)->subpluginname;
}
if ($oldentry = $DB->get_record('tool_cleanupcourses_procdata', $entry)) {
if ($oldentry = $DB->get_record('tool_lifecycle_procdata', $entry)) {
$oldentry->value = $value;
$DB->update_record('tool_cleanupcourses_procdata', $oldentry);
$DB->update_record('tool_lifecycle_procdata', $oldentry);
} else {
$entry['value'] = $value;
$DB->insert_record('tool_cleanupcourses_procdata', (object) $entry);
$DB->insert_record('tool_lifecycle_procdata', (object) $entry);
}
}
......
......@@ -15,15 +15,15 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Manager for Cleanup Course Processes
* Manager for Life Cycle Processes
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\manager;
namespace tool_lifecycle\manager;
use tool_cleanupcourses\entity\process;
use tool_lifecycle\entity\process;
defined('MOODLE_INTERNAL') || die();
......@@ -44,7 +44,7 @@ class process_manager {
$record->workflowid = $workflowid;
$record->timestepchanged = time();
$process = process::from_record($record);
$process->id = $DB->insert_record('tool_cleanupcourses_process', $process);
$process->id = $DB->insert_record('tool_lifecycle_process', $process);
return $process;
}
return null;
......@@ -60,12 +60,12 @@ class process_manager {
public static function manually_trigger_process($courseid, $triggerid) {
$trigger = trigger_manager::get_instance($triggerid);
if (!$trigger) {
throw new \moodle_exception('trigger_does_not_exist', 'tool_cleanupcourses');
throw new \moodle_exception('trigger_does_not_exist', 'tool_lifecycle');
}
$workflow = workflow_manager::get_workflow($trigger->workflowid);
if (!$workflow || !workflow_manager::is_active($workflow->id) || !workflow_manager::is_valid($workflow->id) ||
$workflow->manual !== true) {
throw new \moodle_exception('cannot_trigger_workflow_manually', 'tool_cleanupcourses');
throw new \moodle_exception('cannot_trigger_workflow_manually', 'tool_lifecycle');
}
return self::create_process($courseid, $workflow->id);
}
......@@ -76,7 +76,7 @@ class process_manager {
*/
public static function get_processes() {
global $DB;
$records = $DB->get_records('tool_cleanupcourses_process');
$records = $DB->get_records('tool_lifecycle_process');
$processes = array();
foreach ($records as $record) {
$processes [] = process::from_record($record);
......@@ -91,7 +91,7 @@ class process_manager {
*/
public static function get_process_by_id($processid) {
global $DB;
$record = $DB->get_record('tool_cleanupcourses_process', array('id' => $processid));
$record = $DB->get_record('tool_lifecycle_process', array('id' => $processid));
if ($record) {
return process::from_record($record);
} else {
......@@ -106,7 +106,7 @@ class process_manager {
*/
public static function count_processes_by_workflow($workflowid) {
global $DB;
return $DB->count_records('tool_cleanupcourses_process', array('workflowid' => $workflowid));
return $DB->count_records('tool_lifecycle_process', array('workflowid' => $workflowid));
}
/**
......@@ -121,7 +121,7 @@ class process_manager {
$process->stepindex++;
$process->waiting = false;
$process->timestepchanged = time();
$DB->update_record('tool_cleanupcourses_process', $process);
$DB->update_record('tool_lifecycle_process', $process);
return true;
} else {
self::remove_process($process);
......@@ -136,7 +136,7 @@ class process_manager {
public static function set_process_waiting(&$process) {
global $DB;
$process->waiting = true;
$DB->update_record('tool_cleanupcourses_process', $process);
$DB->update_record('tool_lifecycle_process', $process);
}
/**
......@@ -146,7 +146,7 @@ class process_manager {
public static function rollback_process($process) {
global $CFG;
// TODO: Add logic to revert changes made by steps.
delayed_courses_manager::set_course_delayed($process->courseid, $CFG->cleanupcourses_duration);
delayed_courses_manager::set_course_delayed($process->courseid, $CFG->lifecycle_duration);
self::remove_process($process);
}
......@@ -156,13 +156,13 @@ class process_manager {
*/
private static function remove_process($process) {
global $DB;
$DB->delete_records('tool_cleanupcourses_procdata', array('processid' => $process->id));
$DB->delete_records('tool_cleanupcourses_process', (array) $process);
$DB->delete_records('tool_lifecycle_procdata', array('processid' => $process->id));
$DB->delete_records('tool_lifecycle_process', (array) $process);
}
public static function get_process_by_course_id($courseid) {
global $DB;
$record = $DB->get_record('tool_cleanupcourses_process', array('courseid' => $courseid));
$record = $DB->get_record('tool_lifecycle_process', array('courseid' => $courseid));
if ($record) {
return process::from_record($record);
} else {
......
......@@ -17,11 +17,11 @@
/**
* Manager to retrive the local settings for each step subplugin.
*
* @package tool_cleanupcourses
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\manager;
namespace tool_lifecycle\manager;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__.'/../../lib.php');
......@@ -67,7 +67,7 @@ class settings_manager {
$value = $value['text'];
}
$cleanedvalue = clean_param($value, $setting->paramtype);
$record = $DB->get_record('tool_cleanupcourses_settings',
$record = $DB->get_record('tool_lifecycle_settings',
array(
'instanceid' => $instanceid,
'type' => $type,
......@@ -75,14 +75,14 @@ class settings_manager {
);
if ($record) {
$record->value = $cleanedvalue;
$DB->update_record('tool_cleanupcourses_settings', $record);
$DB->update_record('tool_lifecycle_settings', $record);
} else {
$newrecord = new \stdClass();
$newrecord->instanceid = $instanceid;
$newrecord->name = $setting->name;
$newrecord->value = $cleanedvalue;
$newrecord->type = $type;
$DB->insert_record('tool_cleanupcourses_settings', $newrecord);
$DB->insert_record('tool_lifecycle_settings', $newrecord);
}
}
}
......@@ -117,7 +117,7 @@ class settings_manager {
$settingsvalues = array();
foreach ($lib->instance_settings() as $setting) {
$record = $DB->get_record('tool_cleanupcourses_settings', array('instanceid' => $instanceid,
$record = $DB->get_record('tool_lifecycle_settings', array('instanceid' => $instanceid,
'type' => $type,
'name' => $setting->name));
if ($record) {
......@@ -137,7 +137,7 @@ class settings_manager {
global $DB;
self::validate_type($type);
$DB->delete_records('tool_cleanupcourses_settings',
$DB->delete_records('tool_lifecycle_settings',
array('instanceid' => $instanceid,
'type' => $type));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment