diff --git a/.travis.yml b/.travis.yml index 0ae66010b576eb6c17cc7475afa0ef3c38fe9b3a..ed0c41f75ba47a068a6d9323fee9748edc2ba401 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,6 +66,7 @@ jobs: install: - moodle-plugin-ci install --no-init script: + - moodle-plugin-ci phpdoc - moodle-plugin-ci phplint - moodle-plugin-ci phpcpd - moodle-plugin-ci phpmd diff --git a/adminlib.php b/adminlib.php index 6171d60c2a09098d56b3d2a19df3bfdba40a3431..90ea5a1ba5a977a2ca3d6a2bc0663b0f9175e392 100644 --- a/adminlib.php +++ b/adminlib.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Admin lib providing multiple classes for admin settings. + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle; use tool_lifecycle\entity\trigger_subplugin; @@ -50,6 +57,7 @@ class admin_page_active_processes extends \admin_externalpage { /** * The constructor - calls parent constructor * + * @throws \moodle_exception */ public function __construct() { $url = new \moodle_url('/admin/tool/lifecycle/activeprocesses.php'); @@ -67,6 +75,11 @@ class admin_page_active_processes extends \admin_externalpage { * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class admin_page_deactivated_workflows extends \admin_externalpage { + /** + * admin_page_deactivated_workflows constructor. + * @throws \coding_exception + * @throws \moodle_exception + */ public function __construct() { $url = new \moodle_url('/admin/tool/lifecycle/deactivatedworkflows.php'); parent::__construct('tool_lifecycle_deactivatedworkflows', @@ -87,6 +100,7 @@ class admin_page_course_backups extends \admin_externalpage { /** * The constructor - calls parent constructor * + * @throws \moodle_exception */ public function __construct() { $url = new \moodle_url('/admin/tool/lifecycle/coursebackups.php'); @@ -108,6 +122,7 @@ class admin_page_sublugins extends \admin_externalpage { /** * The constructor - calls parent constructor * + * @throws \moodle_exception */ public function __construct() { $url = new \moodle_url('/admin/tool/lifecycle/adminsettings.php'); @@ -131,6 +146,7 @@ class admin_settings { /** * Constructor for this subplugin settings + * @throws \moodle_exception */ public function __construct() { global $PAGE; @@ -141,6 +157,7 @@ class admin_settings { /** * Write the HTML for the submission plugins table. + * @throws \moodle_exception */ private function view_plugins_table() { global $OUTPUT, $PAGE; @@ -188,6 +205,7 @@ class admin_settings { * Write the HTML for the add workflow form. * * @param form_workflow_instance $form + * @throws \coding_exception */ private function view_workflow_instance_form($form) { global $OUTPUT; @@ -205,7 +223,7 @@ class admin_settings { /** * Redirect to workflow details page. * - * @param $workflowid int id of the workflow. + * @param int $workflowid Id of the workflow. * @throws \moodle_exception */ private function view_workflow_details($workflowid) { @@ -233,6 +251,11 @@ class admin_settings { /** * Check this user has permission to edit the subplugin settings + * @throws \coding_exception + * @throws \dml_exception + * @throws \moodle_exception + * @throws \require_login_exception + * @throws \required_capability_exception */ private function check_permissions() { // Check permissions. @@ -243,7 +266,13 @@ class admin_settings { /** * This is the entry point for this controller class. + * @param string $action Action string (see {@link action}). + * @param int $workflowid Id of the workflow. + * @throws \coding_exception + * @throws \dml_exception * @throws \moodle_exception + * @throws \require_login_exception + * @throws \required_capability_exception */ public function execute($action, $workflowid) { global $PAGE; @@ -340,6 +369,9 @@ class workflow_settings { /** * Constructor for this subplugin settings + * @param int $workflowid Id of the workflow. + * @throws \coding_exception + * @throws \moodle_exception */ public function __construct($workflowid) { global $PAGE; @@ -353,6 +385,7 @@ class workflow_settings { /** * Write the HTML for the submission plugins table. + * @throws \moodle_exception */ private function view_plugins_table() { global $OUTPUT, $PAGE; @@ -393,7 +426,8 @@ class workflow_settings { /** * Write the HTML for the step instance form. * - * @param $form \moodleform form to be displayed. + * @param \moodleform $form Form to be displayed. + * @throws \coding_exception */ private function view_step_instance_form($form) { $workflow = workflow_manager::get_workflow($this->workflowid); @@ -405,7 +439,8 @@ class workflow_settings { /** * Write the HTML for the trigger instance form. * - * @param $form \moodleform form to be displayed. + * @param \moodleform $form Form to be displayed. + * @throws \coding_exception */ private function view_trigger_instance_form($form) { $workflow = workflow_manager::get_workflow($this->workflowid); @@ -417,8 +452,8 @@ class workflow_settings { /** * Write the HTML for subplugin instance form with specific header. * - * @param $form \moodleform form to be displayed. - * @param $header string header of the form. + * @param \moodleform $form Form to be displayed. + * @param string $header Header of the form. */ private function view_instance_form($form, $header) { global $OUTPUT; @@ -452,6 +487,11 @@ class workflow_settings { /** * Check this user has permission to edit the subplugin settings + * @throws \coding_exception + * @throws \dml_exception + * @throws \moodle_exception + * @throws \require_login_exception + * @throws \required_capability_exception */ private function check_permissions() { // Check permissions. @@ -462,10 +502,11 @@ class workflow_settings { /** * This is the entry point for this controller class. - * @param $action string action string to be executed. - * @param $subpluginid int id of the subplugin associated. - * @param $workflowid int id of the workflow associated. + * @param string $action Action string to be executed. + * @param int $subpluginid Id of the subplugin associated. + * @param int $workflowid Id of the workflow associated. * @throws \coding_exception + * @throws \moodle_exception */ public function execute($action, $subpluginid, $workflowid) { $this->check_permissions(); @@ -495,6 +536,7 @@ class workflow_settings { * * @return bool True, if no further action handling or output should be conducted. * @throws \coding_exception + * @throws \moodle_exception */ private function handle_trigger_instance_form() { global $PAGE; @@ -540,11 +582,12 @@ class workflow_settings { /** * Retrieves the relevant parameters for the trigger instance form from the sent params. * Thereby it store the data in the given parameters. - * @param $triggertomodify int id of the trigger instance to be modified. - * @param $subpluginname string name of the subplugin, the trigger instance belongs to. - * @param $triggersettings array settings of the trigger instance. + * @param int $triggertomodify Id of the trigger instance to be modified. + * @param string $subpluginname Name of the subplugin, the trigger instance belongs to. + * @param array $triggersettings Settings of the trigger instance. * @return bool * @throws \coding_exception + * @throws \dml_exception */ private function retrieve_trigger_parameters(&$triggertomodify, &$subpluginname, &$triggersettings) { if ($triggerid = optional_param('subplugin', null, PARAM_INT)) { @@ -568,6 +611,8 @@ class workflow_settings { * Handles actions for the trigger instance form and causes related forms to be rendered. * * @return bool True, if no further action handling or output should be conducted. + * @throws \coding_exception + * @throws \moodle_exception */ private function handle_step_instance_form() { global $PAGE; @@ -610,11 +655,12 @@ class workflow_settings { /** * Retrieves the relevant parameters for the step instance form from the sent params. * Thereby it store the data in the given parameters. - * @param $steptomodify int id of the step instance to be modified. - * @param $subpluginname string name of the subplugin, the step instance belongs to. - * @param $stepsettings array settings of the step instance. + * @param int $steptomodify Id of the step instance to be modified. + * @param string $subpluginname Name of the subplugin, the step instance belongs to. + * @param array $stepsettings Settings of the step instance. * @return bool * @throws \coding_exception + * @throws \dml_exception */ private function retrieve_step_parameters(&$steptomodify, &$subpluginname, &$stepsettings) { if ($stepid = optional_param('subplugin', null, PARAM_INT)) { diff --git a/classes/action.php b/classes/action.php index ce306341c97861dbe4a62e2ecf828e665ee39430..85150f309360c6528bca5e0ebdd8f3aa3d74c9c6 100644 --- a/classes/action.php +++ b/classes/action.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Delivers all available action names throughout the plugin. + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle; defined('MOODLE_INTERNAL') || die(); @@ -21,30 +27,48 @@ defined('MOODLE_INTERNAL') || die(); /** * Delivers all available action names throughout the plugin. * @package tool_lifecycle - * @group tool_lifecycle * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class action { - const UP_TRIGGER = 'enable'; + /** @var string Moving a trigger one position up. */ + const UP_TRIGGER = 'up_trigger'; + /** @var string Moving a trigger one position down. */ const DOWN_TRIGGER = 'down_trigger'; + /** @var string Moving a step one position up. */ const UP_STEP = 'up_step'; + /** @var string Moving a step one position down. */ const DOWN_STEP = 'down_step'; + /** @var string Moving a workflow one position up. */ const UP_WORKFLOW = 'up_workflow'; + /** @var string Moving a workflow one position down. */ const DOWN_WORKFLOW = 'down_workflow'; + /** @var string View the step instance form. */ const STEP_INSTANCE_FORM = 'step_instance_form'; + /** @var string View the trigger instance form. */ const TRIGGER_INSTANCE_FORM = 'trigger_instance_form'; + /** @var string Delete a trigger instance. */ const TRIGGER_INSTANCE_DELETE = 'trigger_instance_delete'; + /** @var string Delete a step instance. */ const STEP_INSTANCE_DELETE = 'step_instance_delete'; + /** @var string View the workflow instance form. */ const WORKFLOW_INSTANCE_FROM = 'workflow_instance_form'; + /** @var string Upload a workflow definition file. */ const WORKFLOW_UPLOAD_FROM = 'workflow_upload_form'; + /** @var string Create a backup for a workflow. */ const WORKFLOW_BACKUP = 'workflow_instance_backup'; + /** @var string Delete a workflow. */ const WORKFLOW_DELETE = 'workflow_instance_delete'; + /** @var string Duplicate a workflow. */ const WORKFLOW_DUPLICATE = 'workflow_instance_duplicate'; + /** @var string Activate a workflow. */ const WORKFLOW_ACTIVATE = 'workflow_instance_activate'; + /** @var string Disable e a workflow. */ const WORKFLOW_DISABLE = 'workflow_instance_disable'; + /** @var string Abort and disable a workflow. */ const WORKFLOW_ABORTDISABLE = 'workflow_instance_abortdisable'; + /** @var string Abort a workflow. */ const WORKFLOW_ABORT = 'workflow_instance_abort'; } \ No newline at end of file diff --git a/classes/entity/process.php b/classes/entity/process.php index a0ce049f5913d54088677bc808ef67c9bdd614bb..5a21cb09ba47376d8f4c7c93fc8fb0bf3585d16e 100644 --- a/classes/entity/process.php +++ b/classes/entity/process.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Life Cycle Process class + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle\entity; defined('MOODLE_INTERNAL') || die(); @@ -25,27 +32,35 @@ defined('MOODLE_INTERNAL') || die(); * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - class process { - /** int id of the process*/ + /** @var int $id Id of the process*/ public $id; - /** int id of the workflow */ + /** @var int $workflowid Id of the workflow */ public $workflowid; - /** int id of the course*/ + /** @var int $courseid Id of the course*/ public $courseid; - /** bool true if course is in status waiting*/ + /** @var bool $waiting True if course is in status waiting*/ public $waiting; - /** int sortindex of the step within the workflow */ + /** @var int $stepindex Sortindex of the step within the workflow */ public $stepindex; - /** timestamp date the process was moved to the current step instance */ + /** @var /timestamp $timestepchanged Date the process was moved to the current step instance */ public $timestepchanged; + /** + * Process constructor. + * @param int $id Id of the process. + * @param int $workflowid Id of the workflow. + * @param int $courseid Id of the course. + * @param int $stepindex Sortindex of the step within the workflow. + * @param bool $waiting True if course is in status waiting. + * @param null $timestepchanged Date the process was moved to the current step instance. + */ private function __construct($id, $workflowid, $courseid, $stepindex, $waiting = false, $timestepchanged = null) { $this->id = $id; $this->workflowid = $workflowid; @@ -61,7 +76,7 @@ class process { /** * Creates a Life Cycle Process from a db record. - * @param $record + * @param object $record Data object. * @return process */ public static function from_record($record) { diff --git a/classes/entity/step_subplugin.php b/classes/entity/step_subplugin.php index d75dd568493c7361477f7078b41b924ae2fa3a28..4e4ce20c44a794282e6cf7c4ee682c4c5b77ab32 100644 --- a/classes/entity/step_subplugin.php +++ b/classes/entity/step_subplugin.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Subplugin class + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle\entity; defined('MOODLE_INTERNAL') || die(); @@ -25,12 +32,11 @@ defined('MOODLE_INTERNAL') || die(); * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - class step_subplugin extends subplugin { /** * Creates a subplugin from a db record. - * @param $record + * @param object $record Data object. * @return step_subplugin */ public static function from_record($record) { diff --git a/classes/entity/subplugin.php b/classes/entity/subplugin.php index b968b6b320c0f947965ff8767d1f310bb4fce521..ca8f51c85868ae31c7938188358fdbc5cf2add28 100644 --- a/classes/entity/subplugin.php +++ b/classes/entity/subplugin.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Subplugin class + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle\entity; defined('MOODLE_INTERNAL') || die(); @@ -25,28 +32,27 @@ defined('MOODLE_INTERNAL') || die(); * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - abstract class subplugin{ - /** int Id of subplugin */ + /** @var int $id Id of subplugin */ public $id; - /** string instancename of the step*/ + /** @var string $instancename Instancename of the step*/ public $instancename; - /** int id of the workflow this step belongs to*/ + /** @var int $workflowid Id of the workflow this step belongs to*/ public $workflowid; - /** string name of subplugin */ + /** @var string $subpluginname Name of subplugin */ public $subpluginname; - /** int sort index, which defines the order, + /** @var int $sortindex Sort index, which defines the order, * in which the steps wihtin a workflow are executed*/ public $sortindex; /** * Creates a subplugin with subpluginname and optional id. - * @oaram string $instancename name of the subplugin instance + * @param string $instancename name of the subplugin instance * @param string $subpluginname name of the subplugin * @param int $workflowid id of the workflow the subplugin belongs to * @param int $id id of the subplugin diff --git a/classes/entity/trigger_subplugin.php b/classes/entity/trigger_subplugin.php index 73b2acfb7edae0abca1034ce07b76fe9c410fb77..9d5093792ef3490ed737bfae94609d876e0e8b68 100644 --- a/classes/entity/trigger_subplugin.php +++ b/classes/entity/trigger_subplugin.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Trigger subplugin class + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle\entity; defined('MOODLE_INTERNAL') || die(); @@ -25,12 +32,11 @@ defined('MOODLE_INTERNAL') || die(); * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - class trigger_subplugin extends subplugin{ /** * Creates a subplugin from a db record. - * @param $record + * @param object $record Data object. * @return trigger_subplugin */ public static function from_record($record) { diff --git a/classes/entity/workflow.php b/classes/entity/workflow.php index 43f34f3053d55b54e92f7aa592655639eb19ac50..f442da1421e88fdc0a72d03b45cf2c21de9832dd 100644 --- a/classes/entity/workflow.php +++ b/classes/entity/workflow.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Life Cycle Workflow class + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle\entity; defined('MOODLE_INTERNAL') || die(); @@ -25,40 +32,53 @@ defined('MOODLE_INTERNAL') || die(); * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - class workflow { - /** int id of the workflow*/ + /** @var int $id Id of the workflow. */ public $id; - /** title of the workflow */ + /** @var string @title Title of the workflow. */ public $title; - /** timestamp the workflow was set active */ + /** @var /timestamp $timeactive Time the workflow was set active. */ public $timeactive; - /** timestamp the workflow was deactivated */ + /** @var /timestamp $timedeactive Time the workflow was deactivated. */ public $timedeactive; - /** int sort index of all active workflows */ + /** @var int $sortindex Sort index of all active workflows. */ public $sortindex; - /** bool|null true if workflow is manually triggered*/ + /** @var bool|null $manual True if workflow is manually triggered. */ public $manual; - /** title that is displayed to users */ + /** @var string $displaytitle Title that is displayed to users. */ public $displaytitle; - /** @var int the delay in case of rollback */ + /** @var int $rollbackdelay The delay in case of rollback. */ public $rollbackdelay; - /** @var int the delay in case of finished course */ + /** @var int $finishdelay The delay in case of finished course. */ public $finishdelay; + /** @var bool $delayforallworkflows True if a delay counts for all workflows. */ public $delayforallworkflows; + /** + * Workflow constructor. + * @param int $id Id of the workflow. + * @param string $title Title of the workflow. + * @param /timestamp $timeactive Time the workflow was set active. + * @param /timestamp $timedeactive Time the workflow was deactivated. + * @param int $sortindex Sort index of all active workflows. + * @param bool $manual True if workflow is manually triggered. + * @param string $displaytitle Title that is displayed to users. + * @param int $rollbackdelay The delay in case of rollback. + * @param int $finishdelay The delay in case of finished course. + * @param bool $delayforallworkflows True if a delay counts for all workflows. + */ private function __construct($id, $title, $timeactive, $timedeactive, $sortindex, $manual, $displaytitle, - $rollbackdelay, $finishdelay, $delayforallworkflows) { + $rollbackdelay, $finishdelay, $delayforallworkflows) { $this->id = $id; $this->title = $title; $this->timeactive = $timeactive; @@ -73,7 +93,7 @@ class workflow { /** * Creates a Workflow from a DB record. - * @param $record + * @param object $record Data object. * @return workflow */ public static function from_record($record) { diff --git a/classes/event/process_proceeded.php b/classes/event/process_proceeded.php index a05a116ea5bfbbf0b3f98b3e0a4b74ec4d1d18f7..47a97750d2fb5671691ff747732d7aa73c526a2f 100644 --- a/classes/event/process_proceeded.php +++ b/classes/event/process_proceeded.php @@ -21,7 +21,6 @@ * @copyright 2019 Justus Dieckmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - namespace tool_lifecycle\event; use moodle_url; @@ -52,6 +51,8 @@ class process_proceeded extends \core\event\base { * * @param process $process * @return process_proceeded + * @throws \coding_exception + * @throws \dml_exception */ public static function event_from_process($process) { $data = array( @@ -95,6 +96,7 @@ class process_proceeded extends \core\event\base { * Return localised event name. * * @return string + * @throws \coding_exception */ public static function get_name() { return get_string('process_proceeded_event', 'tool_lifecycle'); @@ -104,6 +106,7 @@ class process_proceeded extends \core\event\base { * Returns relevant URL. * * @return moodle_url + * @throws \moodle_exception */ public function get_url() { return new moodle_url('/admin/tool/lifecycle/view.php'); @@ -134,6 +137,9 @@ class process_proceeded extends \core\event\base { } } + /** + * Implementation of get_other_mapping. + */ public static function get_other_mapping() { // No backup and restore. return false; diff --git a/classes/event/process_rollback.php b/classes/event/process_rollback.php index a5be9dc5067792956f68eda6b46b6e85574df528..85331a67fcad154b426e2f5518e4dc6fc2598870 100644 --- a/classes/event/process_rollback.php +++ b/classes/event/process_rollback.php @@ -51,6 +51,8 @@ class process_rollback extends \core\event\base { * * @param process $process * @return process_rollback + * @throws \coding_exception + * @throws \dml_exception */ public static function event_from_process($process) { $data = array( @@ -94,6 +96,7 @@ class process_rollback extends \core\event\base { * Return localised event name. * * @return string + * @throws \coding_exception */ public static function get_name() { return get_string('process_rollback_event', 'tool_lifecycle'); @@ -103,6 +106,7 @@ class process_rollback extends \core\event\base { * Returns relevant URL. * * @return moodle_url + * @throws \moodle_exception */ public function get_url() { return new moodle_url('/admin/tool/lifecycle/view.php'); @@ -133,6 +137,9 @@ class process_rollback extends \core\event\base { } } + /** + * Implementation of get_other_mapping. + */ public static function get_other_mapping() { // No backup and restore. return false; diff --git a/classes/event/process_triggered.php b/classes/event/process_triggered.php index 415592402d7adfcf8cd6c4c203af0a67654c1872..ab25e44795c46d9a0cfa23294658430e05cc4ecc 100644 --- a/classes/event/process_triggered.php +++ b/classes/event/process_triggered.php @@ -50,6 +50,8 @@ class process_triggered extends \core\event\base { * * @param process $process * @return process_triggered + * @throws \coding_exception + * @throws \dml_exception */ public static function event_from_process($process) { $data = array( @@ -90,6 +92,7 @@ class process_triggered extends \core\event\base { * Return localised event name. * * @return string + * @throws \coding_exception */ public static function get_name() { return get_string('process_triggered_event', 'tool_lifecycle'); @@ -99,6 +102,7 @@ class process_triggered extends \core\event\base { * Returns relevant URL. * * @return moodle_url + * @throws \moodle_exception */ public function get_url() { return new moodle_url('/admin/tool/lifecycle/view.php'); @@ -125,6 +129,9 @@ class process_triggered extends \core\event\base { } } + /** + * Implementation of get_other_mapping. + */ public static function get_other_mapping() { // No backup and restore. return false; diff --git a/classes/form/form_step_instance.php b/classes/form/form_step_instance.php index 010558d90213557677a65e2d5c4dc811b2e389cf..c098a666b1a1086a63d697314514a51645006e1d 100644 --- a/classes/form/form_step_instance.php +++ b/classes/form/form_step_instance.php @@ -21,7 +21,6 @@ * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - namespace tool_lifecycle\form; use tool_lifecycle\action; @@ -36,10 +35,12 @@ require_once($CFG->libdir . '/formslib.php'); /** * Provides a form to modify a step instance + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class form_step_instance extends \moodleform { - /** * @var step_subplugin */ diff --git a/classes/form/form_trigger_instance.php b/classes/form/form_trigger_instance.php index 3ca5047cc65b67fbf3e2bea4fda76f6bdfa8e6ed..4847b0b9d7923cecc6873c72258fb1a9d1534f02 100644 --- a/classes/form/form_trigger_instance.php +++ b/classes/form/form_trigger_instance.php @@ -21,7 +21,6 @@ * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - namespace tool_lifecycle\form; use tool_lifecycle\action; @@ -37,10 +36,12 @@ require_once($CFG->libdir . '/formslib.php'); /** * Provides a form to modify a step instance + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class form_trigger_instance extends \moodleform { - /** * @var trigger_subplugin */ @@ -74,7 +75,7 @@ class form_trigger_instance extends \moodleform { * @param trigger_subplugin $trigger step entity. * @param string $subpluginname name of the trigger subplugin. * @param array $settings settings of the step. - * @throws \moodle_exception if neither step nor subpluginname are set. + * @throws \coding_exception */ public function __construct($url, $workflowid, $trigger = null, $subpluginname = null, $settings = null) { $this->trigger = $trigger; @@ -189,6 +190,13 @@ class form_trigger_instance extends \moodleform { } } + /** Validate the form. + * @param array $data array of ("fieldname"=>value) of submitted data + * @param array $files array of uploaded files "element_name"=>tmp_file_path + * @return array of "element_name"=>"error_description" if there are errors, + * or an empty array if everything is OK (true allowed for backwards compatibility too). + * @throws \coding_exception + */ public function validation($data, $files) { $error = parent::validation($data, $files); if (empty($data['instancename'])) { diff --git a/classes/form/form_upload_workflow.php b/classes/form/form_upload_workflow.php index 04d785eefeebb324124039ab021fc0b0803cbe44..8573c0df3cf587fdbedc8ca7e718117b455a22c9 100644 --- a/classes/form/form_upload_workflow.php +++ b/classes/form/form_upload_workflow.php @@ -23,14 +23,15 @@ */ namespace tool_lifecycle\form; -use tool_lifecycle\entity\workflow; - defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir . '/formslib.php'); /** * Provides a form to modify a workflow instance + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class form_upload_workflow extends \moodleform { diff --git a/classes/form/form_workflow_instance.php b/classes/form/form_workflow_instance.php index afaffd24699c7b281358113f8f7e97ee6060588e..71e934defe312e5632d9c528575e73faf092d053 100644 --- a/classes/form/form_workflow_instance.php +++ b/classes/form/form_workflow_instance.php @@ -31,10 +31,12 @@ require_once($CFG->libdir . '/formslib.php'); /** * Provides a form to modify a workflow instance + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class form_workflow_instance extends \moodleform { - /** * @var workflow */ @@ -42,9 +44,8 @@ class form_workflow_instance extends \moodleform { /** * Constructor - * @param \moodle_url $url. + * @param \moodle_url $url Url of the page. * @param workflow $workflow workflow entity. - * @throws \moodle_exception if neither step nor subpluginname are set. */ public function __construct($url, $workflow) { $this->workflow = $workflow; diff --git a/classes/local/backup/backup_lifecycle_workflow.php b/classes/local/backup/backup_lifecycle_workflow.php index 46a172d4f4b7e48926fd20f004b8400a98bb61bb..1abe072ce3b2b893d42b0f95c735842dba5856e0 100644 --- a/classes/local/backup/backup_lifecycle_workflow.php +++ b/classes/local/backup/backup_lifecycle_workflow.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Class to backup a workflow. + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle\local\backup; use tool_lifecycle\entity\step_subplugin; @@ -27,6 +33,12 @@ use tool_lifecycle\settings_type; defined('MOODLE_INTERNAL') || die(); +/** + * Class to backup a workflow. + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class backup_lifecycle_workflow { /** @var $workflow workflow */ @@ -40,6 +52,11 @@ class backup_lifecycle_workflow { /** @var $tempfilename string */ private $tempfilename; + /** + * backup_lifecycle_workflow constructor. + * @param int $workflowid Id of the workflow a backup should be created for. + * @throws \dml_exception + */ public function __construct($workflowid) { $this->workflow = workflow_manager::get_workflow($workflowid); $this->steps = step_manager::get_step_instances($workflowid); @@ -137,6 +154,10 @@ class backup_lifecycle_workflow { } } + /** + * Get temporary filename + * @return string + */ public function get_temp_filename() { return $this->tempfilename; } diff --git a/classes/local/backup/restore_lifecycle_workflow.php b/classes/local/backup/restore_lifecycle_workflow.php index 08af3da91ec418933cf4f60a9ff51049d5747867..d02b18499e7c18bde96717f70143d604161481c5 100644 --- a/classes/local/backup/restore_lifecycle_workflow.php +++ b/classes/local/backup/restore_lifecycle_workflow.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Class to restore a workflow. + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle\local\backup; use tool_lifecycle\entity\step_subplugin; @@ -27,6 +33,12 @@ use tool_lifecycle\settings_type; defined('MOODLE_INTERNAL') || die(); +/** + * Class to restore a workflow. + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class restore_lifecycle_workflow { /** @var $workflow workflow */ @@ -42,6 +54,10 @@ class restore_lifecycle_workflow { /** @var $writer \XMLWriter */ private $reader; + /** + * Restore_lifecycle_workflow constructor. + * @param string $xmldata XML-Data the workflow should be restored from. + */ public function __construct($xmldata) { $this->reader = new \XMLReader(); $this->reader->XML($xmldata); diff --git a/classes/local/data/manual_trigger_tool.php b/classes/local/data/manual_trigger_tool.php index cd211debd0e6cc43956c44d523147969cd31d41b..39126fa0335b1d0af9f88802d98fc2ccb9358f0a 100644 --- a/classes/local/data/manual_trigger_tool.php +++ b/classes/local/data/manual_trigger_tool.php @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Class representing a manual trigger tool + * + * @package tool_lifecycle + * @copyright 2018 WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle\local\data; use renderable; @@ -27,21 +34,27 @@ defined('MOODLE_INTERNAL') || die(); * @copyright 2018 WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - class manual_trigger_tool implements renderable { - /** int id of the trigger the tool belongs to*/ + /** @var int $triggerid Id of the trigger the tool belongs to. */ public $triggerid; - /** string icon, which is displayed to the user in the trigger tools menu*/ + /** @var string $icon Icon, which is displayed to the user in the trigger tools menu. */ public $icon; - /** string name, which is displayed to the user in the trigger tools menu*/ + /** @var string $displayname Name, which is displayed to the user in the trigger tools menu. */ public $displayname; - /** string capability required to use and display this tool*/ + /** @var string $capability Capability, which is required to use and display this tool. */ public $capability; + /** + * manual_trigger_tool constructor. + * @param int $triggerid Id of the trigger the tool belongs to. + * @param string $icon Icon, which is displayed to the user in the trigger tools menu. + * @param string $displayname Name, which is displayed to the user in the trigger tools menu. + * @param string $capability Capability, which is required to use and display this tool. + */ public function __construct($triggerid, $icon, $displayname, $capability) { $this->triggerid = $triggerid; $this->icon = $icon; diff --git a/classes/manager/backup_manager.php b/classes/manager/backup_manager.php index c27284960886b3578acc2bcfaf1bd130c1863b0e..7c270ba0dab243131cc163c6eff4cf12bf2cd399 100644 --- a/classes/manager/backup_manager.php +++ b/classes/manager/backup_manager.php @@ -29,6 +29,13 @@ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php'); require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php'); +/** + * Manager to create & restore backups for courses + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class backup_manager { /** diff --git a/classes/manager/delayed_courses_manager.php b/classes/manager/delayed_courses_manager.php index 93e2c1f2d268a90c71e4e01986366de3b2cf3c9c..d07a698b68ab54d1461bb119023694e186f75f97 100644 --- a/classes/manager/delayed_courses_manager.php +++ b/classes/manager/delayed_courses_manager.php @@ -15,20 +15,33 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Manager for Delayed Courses - * Each entry tells that the trigger-check for a certain course is delayed until a certain timestamp. + * Manager for Delayed Courses. * + * Each entry tells that the trigger-check for a certain course is delayed until a certain timestamp. * @package tool_lifecycle * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - namespace tool_lifecycle\manager; defined('MOODLE_INTERNAL') || die(); - +/** + * Manager for Delayed Courses. + * + * Each entry tells that the trigger-check for a certain course is delayed until a certain timestamp. + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class delayed_courses_manager { + /** + * Sets a delay for a course for specific workflow. + * @param int $courseid Id of the course. + * @param bool $becauserollback True, if the delay is caused by a rollback. + * @param int $workfloworid Id of the workflow. + * @throws \dml_exception + */ public static function set_course_delayed_for_workflow($courseid, $becauserollback, $workfloworid) { global $DB; if (is_object($workfloworid)) { @@ -63,6 +76,12 @@ class delayed_courses_manager { } + /** + * Get the delayes courses for specific workflow. + * @param int $workflowid Id of the workflow. + * @return array + * @throws \dml_exception + */ public static function get_delayed_courses_for_workflow($workflowid) { global $DB; $sql = 'SELECT courseid FROM {tool_lifecycle_delayed_workf} WHERE delayeduntil > :now AND workflowid = :workflowid'; @@ -73,6 +92,7 @@ class delayed_courses_manager { * Creates an instance of a delayed course. * @param int $courseid id of the course * @param int $duration number of seconds + * @throws \dml_exception */ public static function set_course_delayed($courseid, $duration) { global $DB; @@ -95,6 +115,7 @@ class delayed_courses_manager { * Queries if a course was delayed. * @param int $courseid id of the course * @return null|int timestamp until when the course is delayed (null if no entry exists). + * @throws \dml_exception */ public static function get_course_delayed($courseid) { global $DB; @@ -119,6 +140,7 @@ class delayed_courses_manager { /** * Deletes the delay entry for a course. * @param int $courseid id of the course + * @throws \dml_exception */ public static function remove_delay_entry($courseid) { global $DB; diff --git a/classes/manager/interaction_manager.php b/classes/manager/interaction_manager.php index 1dc9904dce454f1a722d191cb6c8780ca8a7cbc3..67996fcb57be7d32ad649b5e0f0903352d65bd3b 100644 --- a/classes/manager/interaction_manager.php +++ b/classes/manager/interaction_manager.php @@ -29,6 +29,13 @@ use tool_lifecycle\response\step_interactive_response; defined('MOODLE_INTERNAL') || die(); +/** + * Manager to handle interactions by users + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class interaction_manager { /** @@ -50,6 +57,8 @@ class interaction_manager { * @param string $action action string * @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 * @throws \invalid_parameter_exception */ public static function handle_interaction($stepid, $processid, $action) { @@ -85,7 +94,9 @@ class interaction_manager { } /** + * Save the interaction that happened in the database. * @param process $process + * @param string $action Action name. * @throws \dml_exception */ public static function save_interaction($process, $action) { @@ -134,6 +145,8 @@ class interaction_manager { * @param int $processid if of the process the action tools are requested for * @return array of action tools * @throws \invalid_parameter_exception + * @throws \coding_exception + * @throws \dml_exception */ public static function get_action_tools($subpluginname, $processid) { $interactionlib = lib_manager::get_step_interactionlib($subpluginname); @@ -146,10 +159,11 @@ class interaction_manager { /** * Returns the status message for the given process. - * @param string $subpluginname name of the step subplugin * @param int $processid id of the process the status message is requested for * @return string status message * @throws \invalid_parameter_exception + * @throws \coding_exception + * @throws \dml_exception */ public static function get_process_status_message($processid) { $process = process_manager::get_process_by_id($processid); diff --git a/classes/manager/lib_manager.php b/classes/manager/lib_manager.php index 2db928d681d26b8ce21338f50be13f1bc986333c..3d4873d54897d4e916440a078a7b6c97c0fbff0a 100644 --- a/classes/manager/lib_manager.php +++ b/classes/manager/lib_manager.php @@ -23,11 +23,20 @@ */ namespace tool_lifecycle\manager; +use tool_lifecycle\step\libbase; +use tool_lifecycle\trigger\base; use tool_lifecycle\trigger\base_automatic; use tool_lifecycle\trigger\base_manual; defined('MOODLE_INTERNAL') || die(); +/** + * Manager to retrive the lib of each subplugin. + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class lib_manager { /** @@ -92,7 +101,7 @@ class lib_manager { * @param string $subpluginname name of the subplugin * @param string $subplugintype type of the subplugin (e.g. trigger, step) * @param string $libsubtype allows to query different lib classes. - * @return + * @return null|base|libbase */ private static function get_lib($subpluginname, $subplugintype, $libsubtype = '') { $triggerlist = \core_component::get_plugin_list('lifecycle' . $subplugintype); diff --git a/classes/manager/process_data_manager.php b/classes/manager/process_data_manager.php index eae43e1fc9474271ec31e0a4e682ba73354ce370..afd2dd98fd011dce83af2476b58fa0c7aad24b87 100644 --- a/classes/manager/process_data_manager.php +++ b/classes/manager/process_data_manager.php @@ -15,7 +15,8 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Manager for data of Life Cycle 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! @@ -31,6 +32,17 @@ use tool_lifecycle\entity\trigger_subplugin; defined('MOODLE_INTERNAL') || die(); +/** + * 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_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class process_data_manager { /** @@ -39,6 +51,7 @@ class process_data_manager { * @param int $stepid id of the step. * @param string $key key the value is stored at. * @return string | null value for the given parameters. + * @throws \dml_exception */ public static function get_process_data($processid, $stepid, $key) { global $DB; @@ -63,6 +76,7 @@ class process_data_manager { * @param int $stepid id of the step. * @param string $key key the value is stored at. * @param string $value value for the given parameters. + * @throws \dml_exception */ public static function set_process_data($processid, $stepid, $key, $value) { global $DB; diff --git a/classes/manager/process_manager.php b/classes/manager/process_manager.php index c064fe0fc816a7798ef1b6d3c7f8b7e47ea1516d..97af8d4ab488062dc51a28c18833c6c41324a6a6 100644 --- a/classes/manager/process_manager.php +++ b/classes/manager/process_manager.php @@ -29,6 +29,13 @@ use tool_lifecycle\event\process_rollback; defined('MOODLE_INTERNAL') || die(); +/** + * Manager for Life Cycle Processes + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class process_manager { /** @@ -36,6 +43,7 @@ class process_manager { * @param int $courseid id of the course * @param int $workflowid id of the workflow * @return process|null + * @throws \dml_exception */ public static function create_process($courseid, $workflowid) { global $DB; @@ -54,8 +62,8 @@ class process_manager { /** * Creates a process based on a manual trigger. - * @param $courseid int id of the course to be triggerd. - * @param $triggerid int id of the triggering trigger. + * @param int $courseid Id of the course to be triggerd. + * @param int $triggerid Id of the triggering trigger. * @return process the triggered process instance. * @throws \moodle_exception for invalid workflow definition or missing trigger. */ @@ -75,6 +83,7 @@ class process_manager { /** * Returns all current active processes. * @return process[] + * @throws \dml_exception */ public static function get_processes() { global $DB; @@ -90,6 +99,7 @@ class process_manager { * Creates a process for the course which is at the respective step the trigger is followed by. * @param int $processid id of the process * @return process + * @throws \dml_exception */ public static function get_process_by_id($processid) { global $DB; @@ -105,6 +115,7 @@ class process_manager { * Counts all processes for the given workflow id. * @param int $workflowid id of the workflow * @return int number of processes. + * @throws \dml_exception */ public static function count_processes_by_workflow($workflowid) { global $DB; @@ -115,6 +126,7 @@ class process_manager { * Returns all processes for given workflow id * @param int $workflowid id of the workflow * @return array of proccesses initiated by specifed workflow id + * @throws \dml_exception */ public static function get_processes_by_workflow($workflowid) { global $DB; @@ -129,7 +141,9 @@ class process_manager { /** * Proceeds the process to the next step. * @param process $process - * @return true, if followedby another step; otherwise false. + * @return true, if followed by another step; otherwise false. + * @throws \coding_exception + * @throws \dml_exception */ public static function proceed_process(&$process) { global $DB; @@ -150,6 +164,7 @@ class process_manager { /** * Sets the process status on waiting. * @param process $process + * @throws \dml_exception */ public static function set_process_waiting(&$process) { global $DB; @@ -160,6 +175,8 @@ class process_manager { /** * Currently only removes the current process. * @param process $process process the rollback should be triggered for. + * @throws \coding_exception + * @throws \dml_exception */ public static function rollback_process($process) { process_rollback::event_from_process($process)->trigger(); @@ -180,6 +197,7 @@ class process_manager { /** * Removes the process and all data connected to it. * @param process $process process to be deleted. + * @throws \dml_exception */ private static function remove_process($process) { global $DB; @@ -187,6 +205,12 @@ class process_manager { $DB->delete_records('tool_lifecycle_process', (array) $process); } + /** + * Return the process of a course. + * @param int $courseid Id of the course. + * @return process|null Process instance or null if none exists. + * @throws \dml_exception + */ public static function get_process_by_course_id($courseid) { global $DB; $record = $DB->get_record('tool_lifecycle_process', array('courseid' => $courseid)); diff --git a/classes/manager/settings_manager.php b/classes/manager/settings_manager.php index c4201f97db3614e79df99c8d226fed5c6a68c981..fbdd29652915cf0b6ede2f31b1a61f0e4bdbd453 100644 --- a/classes/manager/settings_manager.php +++ b/classes/manager/settings_manager.php @@ -28,6 +28,13 @@ use tool_lifecycle\settings_type; defined('MOODLE_INTERNAL') || die(); require_once(__DIR__.'/../../lib.php'); +/** + * Manager to retrive the local settings for each step subplugin. + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class settings_manager { /** @@ -115,8 +122,10 @@ class settings_manager { /** * Returns an array of local subplugin settings for a given instance id * @param int $instanceid id of the step instance - * @param 'step'|'trigger' $type type of the subplugin. + * @param string $type Type of the setting (see {@link settings_type}). * @return array|null settings key-value pairs + * @throws \coding_exception + * @throws \dml_exception */ public static function get_settings($instanceid, $type) { global $DB; @@ -155,7 +164,9 @@ class settings_manager { /** * Removes all local settings for a given instance id * @param int $instanceid id of the step instance - * @param 'step'|'trigger' $type type of the subplugin. + * @param string $type Type of the setting (see {@link settings_type}). + * @throws \coding_exception + * @throws \dml_exception */ public static function remove_settings($instanceid, $type) { global $DB; @@ -168,7 +179,7 @@ class settings_manager { /** * Validates the type param for the two possibilities 'step' and 'trigger'. - * @param $type string type subplugin the settings should be saved, queried or removed. + * @param string $type Type of the setting (see {@link settings_type}). * @throws \coding_exception */ private static function validate_type($type) { diff --git a/classes/manager/step_manager.php b/classes/manager/step_manager.php index e3d118123232131a0e7ce50a179fdd8ba51e6dbc..3eb769825f2bd3686461ebe2c3c932435aaadeb3 100644 --- a/classes/manager/step_manager.php +++ b/classes/manager/step_manager.php @@ -29,12 +29,20 @@ use tool_lifecycle\settings_type; defined('MOODLE_INTERNAL') || die(); +/** + * Manager for Subplugins + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class step_manager extends subplugin_manager { /** * Returns a step instance if one with the is is available. * @param int $stepinstanceid id of the step instance * @return step_subplugin|null + * @throws \dml_exception */ public static function get_step_instance($stepinstanceid) { global $DB; @@ -52,6 +60,7 @@ class step_manager extends subplugin_manager { * @param int $workflowid id of the workflow * @param int $sortindex sortindex of the step within the workflow * @return step_subplugin|null + * @throws \dml_exception */ public static function get_step_instance_by_workflow_index($workflowid, $sortindex) { global $DB; @@ -71,6 +80,8 @@ class step_manager extends subplugin_manager { /** * Persists a subplugin to the database. * @param step_subplugin $subplugin + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function insert_or_update(step_subplugin &$subplugin) { global $DB; @@ -88,6 +99,9 @@ class step_manager extends subplugin_manager { * Removes all step instances from the database. * Should only be used, when uninstalling the subplugin. * @param string $subpluginname step instance id + * @throws \coding_exception + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function remove_all_instances($subpluginname) { $steps = self::get_step_instances_by_subpluginname($subpluginname); @@ -99,6 +113,9 @@ class step_manager extends subplugin_manager { /** * Removes a step instance from the database. * @param int $stepinstanceid step instance id + * @throws \coding_exception + * @throws \dml_exception + * @throws \dml_transaction_exception */ private static function remove($stepinstanceid) { global $DB; @@ -115,6 +132,8 @@ class step_manager extends subplugin_manager { /** * Removes a subplugin from the sortindex of a workflow and adjusts all other indizes. * @param step_subplugin $toberemoved + * @throws \dml_exception + * @throws \dml_transaction_exception */ private static function remove_from_sortindex(&$toberemoved) { global $DB; @@ -134,6 +153,8 @@ class step_manager extends subplugin_manager { * Changes the sortindex of a step by swapping it with another. * @param int $stepid id of the step * @param bool $up tells if the step should be set up or down + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function change_sortindex($stepid, $up) { global $DB; @@ -173,6 +194,7 @@ class step_manager extends subplugin_manager { * Gets the list of step instances of a workflow. * @param int $workflowid id of the workflow * @return array of step instances. + * @throws \dml_exception */ public static function get_step_instances($workflowid) { global $DB; @@ -188,7 +210,9 @@ class step_manager extends subplugin_manager { /** * Gets the list of step instances for a specific subpluginname. + * @param string $subpluginname Name of the subplugin. * @return step_subplugin[] array of step instances. + * @throws \dml_exception */ public static function get_step_instances_by_subpluginname($subpluginname) { global $DB; @@ -203,6 +227,7 @@ class step_manager extends subplugin_manager { /** * Gets the list of step subplugins. * @return array of step subplugins. + * @throws \coding_exception */ public static function get_step_types() { $subplugins = \core_component::get_plugin_list('lifecyclestep'); @@ -218,6 +243,9 @@ class step_manager extends subplugin_manager { * @param string $action action to be executed * @param int $subpluginid id of the step instance * @param int $workflowid id of the workflow + * @throws \coding_exception + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function handle_action($action, $subpluginid, $workflowid) { $step = self::get_step_instance($subpluginid); @@ -245,6 +273,7 @@ class step_manager extends subplugin_manager { * @param int $stepid id of the step process data should be saved for. * @return bool if true data is saved instance dependent. * Otherwise it does not matter which instance of a subplugin created the data. + * @throws \dml_exception */ public static function is_process_data_instance_dependent($stepid) { $step = self::get_step_instance($stepid); @@ -259,6 +288,7 @@ class step_manager extends subplugin_manager { * Gets the count of steps belonging to a workflow. * @param int $workflowid id of the workflow. * @return int count of the steps. + * @throws \dml_exception */ public static function count_steps_of_workflow($workflowid) { global $DB; @@ -269,7 +299,9 @@ class step_manager extends subplugin_manager { /** * Removes all instances, which belong to the workflow instance. - * @param $workflowid int id of the workflow. + * @param int $workflowid Id of the workflow. + * @throws \coding_exception + * @throws \dml_exception */ public static function remove_instances_of_workflow($workflowid) { global $DB; @@ -282,8 +314,12 @@ class step_manager extends subplugin_manager { /** * Copies all steps of a workflow to a new one. - * @param $oldworkflowid int id of the old workflow - * @param $newworkflowid int id of the new workflow + * @param int $oldworkflowid Id of the old workflow + * @param int $newworkflowid Id of the new workflow + * @throws \coding_exception + * @throws \dml_exception + * @throws \dml_transaction_exception + * @throws \moodle_exception */ public static function duplicate_steps($oldworkflowid, $newworkflowid) { $steps = self::get_step_instances($oldworkflowid); diff --git a/classes/manager/subplugin_manager.php b/classes/manager/subplugin_manager.php index a702048a901941b10af293a46132880f75a3dd19..1e53076cb81cdacc7cce1810b457bde359c804fe 100644 --- a/classes/manager/subplugin_manager.php +++ b/classes/manager/subplugin_manager.php @@ -24,13 +24,34 @@ namespace tool_lifecycle\manager; defined('MOODLE_INTERNAL') || die(); +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Manager for Subplugins + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ abstract class subplugin_manager { /** * Determines if there exists a subplugin for the given name and type - * @param $subpluginname - * @param $subplugintype + * @param string $subpluginname Name of the subplugin. + * @param string $subplugintype Type of the subplugin. * @return bool */ protected static function is_subplugin($subpluginname, $subplugintype) { diff --git a/classes/manager/trigger_manager.php b/classes/manager/trigger_manager.php index 7833104040ddd7262c2d5ca7e05da51e8f5ac298..ddae60b2f261604a52cdb6a363c9398437e024c4 100644 --- a/classes/manager/trigger_manager.php +++ b/classes/manager/trigger_manager.php @@ -30,11 +30,21 @@ use tool_lifecycle\settings_type; defined('MOODLE_INTERNAL') || die(); +/** + * Manager for Trigger subplugins + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class trigger_manager extends subplugin_manager { /** * Creates a preset workflow for the trigger subplugin. - * @param $subpluginname string name of the trigger subplugin. + * @param string $subpluginname Name of the trigger subplugin. + * @throws \coding_exception + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function register_workflow($subpluginname) { $workflow = workflow_manager::create_workflow( @@ -50,8 +60,9 @@ class trigger_manager extends subplugin_manager { /** * Returns a subplugin object. - * @param int $subpluginid id of the subplugin + * @param int $instanceid Id of the subplugin. * @return trigger_subplugin + * @throws \dml_exception */ public static function get_instance($instanceid) { return self::get_subplugin_by_id($instanceid); @@ -61,6 +72,7 @@ class trigger_manager extends subplugin_manager { * Returns all instances for a trigger subplugin. * @param string $subpluginname name of the subplugin * @return trigger_subplugin[] + * @throws \dml_exception */ public static function get_instances($subpluginname) { global $DB; @@ -77,6 +89,7 @@ class trigger_manager extends subplugin_manager { * Returns a subplugin object. * @param int $subpluginid id of the subplugin * @return trigger_subplugin + * @throws \dml_exception */ private static function get_subplugin_by_id($subpluginid) { global $DB; @@ -92,6 +105,8 @@ class trigger_manager extends subplugin_manager { /** * Persists a subplugin to the database. * @param trigger_subplugin $subplugin + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function insert_or_update(trigger_subplugin &$subplugin) { global $DB; @@ -109,6 +124,8 @@ class trigger_manager extends subplugin_manager { * Removes all trigger instances from the database. * Should only be used, when uninstalling the subplugin. * @param string $subpluginname trigger instance id + * @throws \dml_exception + * @throws \coding_exception */ public static function remove_all_instances($subpluginname) { $triggers = self::get_instances($subpluginname); @@ -120,6 +137,9 @@ class trigger_manager extends subplugin_manager { /** * Removes a trigger instance from the database. * @param int $triggerinstanceid trigger instance id + * @throws \coding_exception + * @throws \dml_exception + * @throws \dml_transaction_exception */ private static function remove($triggerinstanceid) { global $DB; @@ -136,8 +156,9 @@ class trigger_manager extends subplugin_manager { /** * Returns the triggers instances for the workflow id. - * @param $workflowid int id of the workflow definition. + * @param int $workflowid Id of the workflow definition. * @return trigger_subplugin[] returns the trigger instances for the workflow. + * @throws \dml_exception */ public static function get_triggers_for_workflow($workflowid) { global $DB; @@ -153,6 +174,8 @@ class trigger_manager extends subplugin_manager { /** * Removes a subplugin from the sortindex of a workflow and adjusts all other indizes. * @param trigger_subplugin $toberemoved + * @throws \dml_exception + * @throws \dml_transaction_exception */ private static function remove_from_sortindex(&$toberemoved) { global $DB; @@ -172,6 +195,8 @@ class trigger_manager extends subplugin_manager { * Changes the sortindex of a trigger by swapping it with another. * @param int $triggerid id of the trigger * @param bool $up tells if the trigger should be set up or down + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function change_sortindex($triggerid, $up) { global $DB; @@ -210,6 +235,7 @@ class trigger_manager extends subplugin_manager { /** * Gets the list of step subplugins. * @return array of step subplugins. + * @throws \coding_exception */ public static function get_trigger_types() { $subplugins = \core_component::get_plugin_list('lifecycletrigger'); @@ -223,6 +249,7 @@ class trigger_manager extends subplugin_manager { /** * Gets the list of step subplugins, which are not preset and can therefore be chosen from trigger form dropdown.. * @return array of step subplugins. + * @throws \coding_exception */ public static function get_chooseable_trigger_types() { $triggers = self::get_trigger_types(); @@ -242,6 +269,9 @@ class trigger_manager extends subplugin_manager { * @param string $action action to be executed * @param int $subpluginid id of the trigger instance * @param int $workflowid id of the workflow + * @throws \coding_exception + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function handle_action($action, $subpluginid, $workflowid) { $trigger = self::get_instance($subpluginid); @@ -267,6 +297,7 @@ class trigger_manager extends subplugin_manager { * Gets the count of triggers belonging to a workflow. * @param int $workflowid id of the workflow. * @return int count of the steps. + * @throws \dml_exception */ public static function count_triggers_of_workflow($workflowid) { global $DB; @@ -277,7 +308,9 @@ class trigger_manager extends subplugin_manager { /** * Removes all instances, which belong to the workflow instance. - * @param $workflowid int id of the workflow. + * @param int $workflowid Id of the workflow. + * @throws \coding_exception + * @throws \dml_exception */ public static function remove_instances_of_workflow($workflowid) { global $DB; @@ -290,8 +323,12 @@ class trigger_manager extends subplugin_manager { /** * Copies the triggers of a workflow to a new one. - * @param $oldworkflowid int id of the old workflow - * @param $newworkflowid int id of the new workflow + * @param int $oldworkflowid Id of the old workflow + * @param int $newworkflowid Id of the new workflow + * @throws \coding_exception + * @throws \dml_exception + * @throws \dml_transaction_exception + * @throws \moodle_exception */ public static function duplicate_triggers($oldworkflowid, $newworkflowid) { $triggers = self::get_triggers_for_workflow($oldworkflowid); diff --git a/classes/manager/workflow_manager.php b/classes/manager/workflow_manager.php index e2565465a8007c4a33e5408f10be410e3c2fcb59..6aa0d2569856846877e70538522a013988cdd042 100644 --- a/classes/manager/workflow_manager.php +++ b/classes/manager/workflow_manager.php @@ -21,25 +21,32 @@ * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - namespace tool_lifecycle\manager; use tool_lifecycle\action; use tool_lifecycle\entity\trigger_subplugin; use tool_lifecycle\entity\workflow; use tool_lifecycle\local\backup\backup_lifecycle_workflow; -use tool_lifecycle\local\exporter\workflow_exporter; use tool_lifecycle\local\data\manual_trigger_tool; use tool_lifecycle\settings_type; defined('MOODLE_INTERNAL') || die(); +/** + * Manager for Life Cycle Workflows + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class workflow_manager { /** * Persists a workflow to the database. * * @param workflow $workflow + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function insert_or_update(workflow &$workflow) { global $DB; @@ -57,6 +64,7 @@ class workflow_manager { * * @param int $workflowid id of the workflow * @param boolean $hard if set, will remove the workflow without checking if it's removable! Mainly for testing. + * @throws \dml_exception */ public static function remove($workflowid, $hard = false) { global $DB; @@ -71,6 +79,8 @@ class workflow_manager { * Disables a workflow * * @param int $workflowid id of the workflow + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function disable($workflowid) { $workflow = self::get_workflow($workflowid); @@ -86,6 +96,8 @@ class workflow_manager { * Deletes all running processes of given workflow * * @param int $workflowid id of the workflow + * @throws \coding_exception + * @throws \dml_exception */ public static function abortprocesses($workflowid) { $processes = process_manager::get_processes_by_workflow($workflowid); @@ -99,6 +111,7 @@ class workflow_manager { * * @param int $workflowid id of the workflow * @return workflow|null + * @throws \dml_exception */ public static function get_workflow($workflowid) { global $DB; @@ -115,6 +128,7 @@ class workflow_manager { * Returns all existing workflows. * * @return workflow[] + * @throws \dml_exception */ public static function get_workflows() { global $DB; @@ -130,6 +144,7 @@ class workflow_manager { * Returns all active workflows. * * @return workflow[] + * @throws \dml_exception */ public static function get_active_workflows() { global $DB; @@ -147,6 +162,7 @@ class workflow_manager { * Returns all active automatic workflows. * * @return workflow[] + * @throws \dml_exception */ public static function get_active_automatic_workflows() { global $DB; @@ -165,6 +181,7 @@ class workflow_manager { * Returns triggers of active manual workflows. * * @return trigger_subplugin[] + * @throws \dml_exception */ public static function get_active_manual_workflow_triggers() { global $DB; @@ -183,6 +200,8 @@ class workflow_manager { * You need to check the capability based on course and user before diplaying it. * * @return manual_trigger_tool[] list of tools, available in the whole system. + * @throws \coding_exception + * @throws \dml_exception */ public static function get_manual_trigger_tools_for_active_workflows() { $triggers = self::get_active_manual_workflow_triggers(); @@ -198,6 +217,9 @@ class workflow_manager { * Activate a workflow * * @param int $workflowid id of the workflow + * @throws \coding_exception + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function activate_workflow($workflowid) { global $DB; @@ -228,6 +250,10 @@ class workflow_manager { * * @param string $action action to be executed * @param int $workflowid id of the workflow + * @throws \coding_exception + * @throws \dml_exception + * @throws \dml_transaction_exception + * @throws \moodle_exception */ public static function handle_action($action, $workflowid) { if (!empty($action)) { @@ -277,6 +303,8 @@ class workflow_manager { * * @param int $workflowid id of the workflow * @param bool $up tells if the workflow should be set up or down + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function change_sortindex($workflowid, $up) { global $DB; @@ -319,7 +347,7 @@ class workflow_manager { * Checks if the workflow definition is valid. * The main purpose of this function is, to check if a trigger definition exists and if this definition is complete. * - * @param $workflowid int id of the workflow. + * @param int $workflowid Id of the workflow. * @return bool true, if the definition is valid. */ public static function is_valid($workflowid) { @@ -333,8 +361,9 @@ class workflow_manager { /** * Checks if the workflow is active. * - * @param $workflowid int id of the workflow. + * @param int $workflowid Id of the workflow. * @return bool true, if the workflow is active. + * @throws \dml_exception */ public static function is_active($workflowid) { $workflow = self::get_workflow($workflowid); @@ -344,8 +373,9 @@ class workflow_manager { /** * Checks if the workflow is deactive. * - * @param $workflowid int id of the workflow. + * @param int $workflowid Id of the workflow. * @return bool true, if the workflow was deactivated. + * @throws \dml_exception */ public static function is_deactivated($workflowid) { $workflow = self::get_workflow($workflowid); @@ -359,9 +389,11 @@ class workflow_manager { * Creates a workflow with a specific title. Is used to create preset workflows for trigger plugins or for * duplication of workflows. * - * @param $title string title of the workflow. - * @param $displaytitle string display title of the workflow. + * @param string $title Title of the workflow. + * @param string $displaytitle Display title of the workflow. * @return workflow the created workflow. + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function create_workflow($title, $displaytitle = null) { $record = new \stdClass(); @@ -377,8 +409,10 @@ class workflow_manager { /** * Duplicates a workflow including its trigger, all its steps and their settings. * - * @param $workflowid int id of the workflow to copy. + * @param int $workflowid Id of the workflow to copy. * @return workflow the created workflow. + * @throws \dml_exception + * @throws \dml_transaction_exception */ public static function duplicate_workflow($workflowid) { $oldworkflow = self::get_workflow($workflowid); @@ -413,7 +447,7 @@ class workflow_manager { /** * Checks if it should be possible to disable a workflow * - * @param $workflowid + * @param int $workflowid Id of the workflow. * @return bool */ public static function is_disableable($workflowid) { @@ -430,8 +464,9 @@ class workflow_manager { /** * Workflows should only be editable if never been activated before * - * @param $workflowid + * @param int $workflowid Id of the workflow * @return bool + * @throws \dml_exception */ public static function is_editable($workflowid) { if (self::is_active($workflowid) || @@ -444,8 +479,9 @@ class workflow_manager { /** * Workflows should only be abortable if disabled but some processes are still running * - * @param $workflowid + * @param int $workflowid Id of the workflow. * @return bool + * @throws \dml_exception */ public static function is_abortable($workflowid) { $countprocesses = process_manager::count_processes_by_workflow($workflowid); @@ -458,8 +494,9 @@ class workflow_manager { /** * Workflows should only be removable if disableable and no more processes are running * - * @param $workflowid + * @param int $workflowid Id of the workflow. * @return bool + * @throws \dml_exception */ public static function is_removable($workflowid) { $countprocesses = process_manager::count_processes_by_workflow($workflowid); diff --git a/classes/plugininfo/lifecyclestep.php b/classes/plugininfo/lifecyclestep.php index c98c550908e1705ba811fb3be0119a20bd837bce..cfc53df62e4776f24eec3e0d4b0c46ab32d419a1 100644 --- a/classes/plugininfo/lifecyclestep.php +++ b/classes/plugininfo/lifecyclestep.php @@ -17,11 +17,10 @@ /** * Pluginfo for life cycle step * - * @package tool_lifecycle + * @package tool_lifecycle * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - namespace tool_lifecycle\plugininfo; use core\plugininfo\base; @@ -30,8 +29,22 @@ use tool_lifecycle\manager\workflow_manager; defined('MOODLE_INTERNAL') || die(); - +/** + * Pluginfo for life cycle step + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class lifecyclestep extends base { + + /** + * Should there be a way to uninstall the plugin via the administration UI. + * + * By default uninstallation is not allowed, plugin developers must enable it explicitly! + * + * @return bool + */ public function is_uninstall_allowed() { if ($this->is_standard()) { return false; @@ -46,6 +59,11 @@ class lifecyclestep extends base { return true; } + /** + * Remove the plugin. + * @param \progress_trace $progress + * @return bool + */ public function uninstall(\progress_trace $progress) { step_manager::remove_all_instances($this->name); return true; diff --git a/classes/plugininfo/lifecycletrigger.php b/classes/plugininfo/lifecycletrigger.php index 7b252e98460b4f633be7947daaaeb81f4290fc7d..12652a320bb6226ca0054a469c9de9ec30bb07c5 100644 --- a/classes/plugininfo/lifecycletrigger.php +++ b/classes/plugininfo/lifecycletrigger.php @@ -21,7 +21,6 @@ * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - namespace tool_lifecycle\plugininfo; use core\plugininfo\base; @@ -33,8 +32,22 @@ use tool_usertours\step; defined('MOODLE_INTERNAL') || die(); - +/** + * Pluginfo for life cycle trigger + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class lifecycletrigger extends base { + + /** + * Should there be a way to uninstall the plugin via the administration UI. + * + * By default uninstallation is not allowed, plugin developers must enable it explicitly! + * + * @return bool + */ public function is_uninstall_allowed() { if ($this->is_standard()) { return false; @@ -49,6 +62,12 @@ class lifecycletrigger extends base { return true; } + /** + * Uninstall the plugin. + * @param \progress_trace $progress + * @return bool + * @throws \moodle_exception + */ public function uninstall(\progress_trace $progress) { $lib = lib_manager::get_trigger_lib($this->name); if ($lib->has_multiple_instances()) { diff --git a/classes/processor.php b/classes/processor.php index f01a985b420ab4eded2069490cc6c49cec807ea7..3256c59733c9b7348e1f0e1a006259868d3f8e4d 100644 --- a/classes/processor.php +++ b/classes/processor.php @@ -38,12 +38,15 @@ use tool_lifecycle\response\trigger_response; defined('MOODLE_INTERNAL') || die; +/** + * Offers functionality to trigger, process and finish lifecycle processes. + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class processor { - public function __construct() { - - } - /** * Processes the trigger plugins for all relevant courses. */ @@ -95,7 +98,6 @@ class processor { * Calls the process_course() method of each step submodule currently responsible for a given course. */ public function process_courses() { - global $CFG; foreach (process_manager::get_processes() as $process) { $workflow = workflow_manager::get_workflow($process->workflowid); while (true) { @@ -138,13 +140,17 @@ class processor { } /** + * In case we are in an interactive environment because the user is lead through the interactive interfaces + * of multiple steps, this function cares for a redirection and processing through these steps until we reach a + * no longer interactive state of the workflow. * - * @param $processid int id of the process + * @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) { - global $CFG; $process = process_manager::get_process_by_id($processid); $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. @@ -180,9 +186,11 @@ class processor { /** * Returns a record set with all relevant courses. * Relevant means that there is currently no lifecycle process running for this course. - * @params $triggers trigger[] list of triggers, which will be asked for additional where requirements. - * @params $exclude int[] list of course id, which should be excluded from execution. + * @param trigger[] $triggers List of triggers, which will be asked for additional where requirements. + * @param int[] $exclude List of course id, which should be excluded from execution. * @return \moodle_recordset with relevant courses. + * @throws \coding_exception + * @throws \dml_exception */ public function get_course_recordset($triggers, $exclude) { global $DB; diff --git a/classes/response/step_interactive_response.php b/classes/response/step_interactive_response.php index c9e2cb2cce22bed8d55e18992fa94dc7502bce0a..d37340406ec44a796f69a407db777632b72855a9 100644 --- a/classes/response/step_interactive_response.php +++ b/classes/response/step_interactive_response.php @@ -25,13 +25,25 @@ namespace tool_lifecycle\response; defined('MOODLE_INTERNAL') || die(); +/** + * Possible Responses of a Subplugin for interaction handling + * + * @package tool_lifecycle + * @copyright 2018 WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class step_interactive_response { + /** @var string Proceed the workflow to the next step. */ const PROCEED = 'proceed'; + /** @var string The called action is not known to the processing plugin. */ const NOACTION = 'noaction'; + /** @var string The processing plugin is still processing. */ const STILLPROCESSING = 'stillprocessing'; + /** @var string The process should be rolled back. */ const ROLLBACK = 'rollback'; + /** @var string Value of the response. */ private $value; /** diff --git a/classes/response/step_response.php b/classes/response/step_response.php index 60085037528596dc10f33e2a82b3589b354914a8..9a1c643e03a41d4ef398f36026e2cf721b2ebf59 100644 --- a/classes/response/step_response.php +++ b/classes/response/step_response.php @@ -25,12 +25,23 @@ namespace tool_lifecycle\response; defined('MOODLE_INTERNAL') || die(); +/** + * Possible Responses of a Subplugin + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class step_response { + /** @var string Proceed the workflow to the next step. */ const PROCEED = 'proceed'; + /** @var string The step is still processing the course and probably waiting for some interaction. */ const WAITING = 'waiting'; + /** @var string The process should be rolled back. */ const ROLLBACK = 'rollback'; + /** @var string Value of the response. */ private $value; /** diff --git a/classes/response/trigger_response.php b/classes/response/trigger_response.php index 090704e58c5e1098a8ac51fad36087d4afd5542d..4c3fcec5b50bbaba22a27471f9cd080c97f4c845 100644 --- a/classes/response/trigger_response.php +++ b/classes/response/trigger_response.php @@ -25,12 +25,23 @@ namespace tool_lifecycle\response; defined('MOODLE_INTERNAL') || die(); +/** + * Possible Responses of a Trigger Subplugin + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class trigger_response { + /** @var string Ask the next workflow if it wants to trigger the course. */ const NEXT = 'next'; + /** @var string Exclude the course from being processed by this and any succeeding workflow. */ const EXCLUDE = 'exclude'; + /** @var string Trigger a process for this workflow if all other triggers of this workflow say the same. */ const TRIGGER = 'trigger'; + /** @var string Value of the response. */ private $value; /** diff --git a/classes/settings_type.php b/classes/settings_type.php index 20c56996a68781391bb8f87a8a8a04ebc03661e0..245630b50cdc9478d75be1f1c2e95c489e68bc99 100644 --- a/classes/settings_type.php +++ b/classes/settings_type.php @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Defines available settings_types. + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle; defined('MOODLE_INTERNAL') || die(); @@ -21,13 +27,13 @@ defined('MOODLE_INTERNAL') || die(); /** * Defines available settings_types. * @package tool_lifecycle - * @category - * @group tool_lifecycle * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class settings_type { + /** @var string Represents the type for a step subplugin. */ const STEP = 'step'; + /** @var string Represents the type for a trigger subplugin. */ const TRIGGER = 'trigger'; } \ No newline at end of file diff --git a/classes/table/active_automatic_workflows_table.php b/classes/table/active_automatic_workflows_table.php index 6b5b998d120f901969657e03f7cd043fc4d3d16b..b647704f1bf4895d92704462b733fb88a9cf6bfd 100644 --- a/classes/table/active_automatic_workflows_table.php +++ b/classes/table/active_automatic_workflows_table.php @@ -21,7 +21,6 @@ * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - namespace tool_lifecycle\table; use tool_lifecycle\action; @@ -34,8 +33,21 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); require_once(__DIR__ . '/../../lib.php'); +/** + * Table listing all active automatically triggered workflows. + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class active_automatic_workflows_table extends active_workflows_table { + /** + * Constructor for active_automatic_workflows_table. + * @param int $uniqueid Unique id of this table. + * @throws \coding_exception + * @throws \dml_exception + */ public function __construct($uniqueid) { parent::__construct($uniqueid); global $PAGE, $DB; @@ -49,6 +61,9 @@ class active_automatic_workflows_table extends active_workflows_table { $this->init(); } + /** + * Initialize the table. + */ public function init() { $this->define_columns(['title', 'timeactive', 'trigger', 'processes', 'sortindex', 'tools']); $this->define_headers([ @@ -66,8 +81,9 @@ class active_automatic_workflows_table extends active_workflows_table { /** * Render sortindex column. * - * @param $row + * @param object $row Row data. * @return string action buttons for changing sortorder of active workflows + * @throws \coding_exception */ public function col_sortindex($row) { global $OUTPUT; diff --git a/classes/table/active_manual_workflows_table.php b/classes/table/active_manual_workflows_table.php index e82afaa3dbd5360cb6ab994594d4889848b2a7b1..f1bdfd635730371d91e59d8d4ea5fed2f068b712 100644 --- a/classes/table/active_manual_workflows_table.php +++ b/classes/table/active_manual_workflows_table.php @@ -33,8 +33,21 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); require_once(__DIR__ . '/../../lib.php'); +/** + * Table listing all active manually triggered workflows. + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class active_manual_workflows_table extends active_workflows_table { + /** + * Constructor for active_manual_workflows_table. + * @param int $uniqueid Unique id of this table. + * @throws \coding_exception + * @throws \dml_exception + */ public function __construct($uniqueid) { parent::__construct($uniqueid); global $PAGE, $DB; @@ -48,6 +61,9 @@ class active_manual_workflows_table extends active_workflows_table { $this->init(); } + /** + * Initialize the table. + */ public function init() { $this->define_columns(['title', 'timeactive', 'trigger', 'processes', 'tools']); $this->define_headers([ diff --git a/classes/table/active_processes_table.php b/classes/table/active_processes_table.php index d0b220dc15eebce633ab0de076e392a3ca4d3ada..63308695ef1fe71a9a508ed4e60435552c540894 100644 --- a/classes/table/active_processes_table.php +++ b/classes/table/active_processes_table.php @@ -27,8 +27,19 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); +/** + * Table listing active processes + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class active_processes_table extends \table_sql { + /** + * Constructor for active_processes_table. + * @param int $uniqueid Unique id of this table. + */ public function __construct($uniqueid) { parent::__construct($uniqueid); global $PAGE; @@ -46,6 +57,9 @@ class active_processes_table extends \table_sql { $this->init(); } + /** + * Initialize the table. + */ public function init() { $this->define_columns(['courseid', 'courseshortname', 'coursefullname', 'instancename']); $this->define_headers([ @@ -58,7 +72,7 @@ class active_processes_table extends \table_sql { /** * Render courseid column. - * @param $row + * @param object $row Row data. * @return string course link */ public function col_courseid($row) { @@ -67,7 +81,7 @@ class active_processes_table extends \table_sql { /** * Render courseshortname column. - * @param $row + * @param object $row Row data. * @return string course link */ public function col_courseshortname($row) { @@ -76,7 +90,7 @@ class active_processes_table extends \table_sql { /** * Render coursefullname column. - * @param $row + * @param object $row Row data. * @return string course link */ public function col_coursefullname($row) { @@ -85,7 +99,7 @@ class active_processes_table extends \table_sql { /** * Render instancename column. - * @param $row + * @param object $row Row data. * @return string pluginname of the instance */ public function col_instancename($row) { diff --git a/classes/table/active_workflows_table.php b/classes/table/active_workflows_table.php index c2d5b27ec6c61da76e247463fb3305e848f6b0e3..9bd5d812421e08f95d1c2bd485047873b4335587 100644 --- a/classes/table/active_workflows_table.php +++ b/classes/table/active_workflows_table.php @@ -34,13 +34,22 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); require_once(__DIR__ . '/../../lib.php'); +/** + * Table listing all active workflow definitions. + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ abstract class active_workflows_table extends workflow_table { /** * Render tools column for active workflows. * - * @param $row + * @param object $row Row data. * @return string action buttons for workflows + * @throws \coding_exception + * @throws \moodle_exception */ public function col_tools($row) { global $OUTPUT; diff --git a/classes/table/course_backups_table.php b/classes/table/course_backups_table.php index 69254095ff40350642a779af089a2e6dd61ee3f4..78d1f08f8779da1cbfe449711b329cbe26bb0791 100644 --- a/classes/table/course_backups_table.php +++ b/classes/table/course_backups_table.php @@ -27,8 +27,19 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); +/** + * Table listing course backups + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class course_backups_table extends \table_sql { + /** + * Constructor for course_backups_table. + * @param int $uniqueid Unique id of this table. + */ public function __construct($uniqueid) { parent::__construct($uniqueid); global $PAGE; @@ -42,6 +53,9 @@ class course_backups_table extends \table_sql { $this->init(); } + /** + * Initialize the table. + */ public function init() { $this->define_columns(['courseid', 'courseshortname', 'coursefullname', 'backupcreated', 'download', 'restore']); $this->define_headers([ @@ -56,7 +70,7 @@ class course_backups_table extends \table_sql { /** * Render courseid column. - * @param $row + * @param object $row Row data. * @return string course link */ public function col_courseid($row) { @@ -69,7 +83,7 @@ class course_backups_table extends \table_sql { /** * Render courseshortname column. - * @param $row + * @param object $row Row data. * @return string course link */ public function col_courseshortname($row) { @@ -82,7 +96,7 @@ class course_backups_table extends \table_sql { /** * Render coursefullname column. - * @param $row + * @param object $row Row data. * @return string course link */ public function col_coursefullname($row) { @@ -95,7 +109,7 @@ class course_backups_table extends \table_sql { /** * Render backupcreated column. - * @param $row + * @param object $row Row data. * @return string date of the backupcreated */ public function col_backupcreated($row) { @@ -104,8 +118,10 @@ class course_backups_table extends \table_sql { /** * Render download column. - * @param $row + * @param object $row Row data. * @return string action buttons for downloading a backup. + * @throws \coding_exception + * @throws \moodle_exception */ public function col_download($row) { return \html_writer::link( @@ -116,8 +132,10 @@ class course_backups_table extends \table_sql { /** * Render restore column. - * @param $row + * @param object $row Row data. * @return string action buttons for restoring a course. + * @throws \coding_exception + * @throws \moodle_exception */ public function col_restore($row) { return \html_writer::link( diff --git a/classes/table/deactivated_workflows_table.php b/classes/table/deactivated_workflows_table.php index 58becc09bdf070a85bf2fe7a95b06a31b9f367b2..7c7f59ed65b5445901bc340da246b61e72bc7465 100644 --- a/classes/table/deactivated_workflows_table.php +++ b/classes/table/deactivated_workflows_table.php @@ -21,7 +21,6 @@ * @copyright 2018 Yorick Reum, JMU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - namespace tool_lifecycle\table; use tool_lifecycle\action; @@ -33,12 +32,18 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); +/** + * Table listing deactivated workflows + * + * @package tool_lifecycle + * @copyright 2018 Yorick Reum, JMU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class deactivated_workflows_table extends workflow_table { /** - * deactivated_workflows_table constructor. - * - * @param string $uniqueid + * Constructor for deactivated_workflows_table. + * @param int $uniqueid Unique id of this table. */ public function __construct($uniqueid) { parent::__construct($uniqueid); @@ -53,6 +58,9 @@ class deactivated_workflows_table extends workflow_table { $this->init(); } + /** + * Initialize the table. + */ public function init() { $this->define_columns(['title', 'timedeactive', 'processes', 'tools']); $this->define_headers([ @@ -68,8 +76,10 @@ class deactivated_workflows_table extends workflow_table { /** * Render tools column. * - * @param $row + * @param object $row Row data. * @return string action buttons for workflows + * @throws \coding_exception + * @throws \moodle_exception */ public function col_tools($row) { global $OUTPUT; diff --git a/classes/table/interaction_attention_table.php b/classes/table/interaction_attention_table.php index ded5263de7e32c9b2c6108464ec9a30730fd2d6a..845b4136c9d66b94ab22cff689dacd1bbafa97d2 100644 --- a/classes/table/interaction_attention_table.php +++ b/classes/table/interaction_attention_table.php @@ -31,8 +31,20 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); +/** + * Table listing all courses for a specific user and a specific subplugin + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class interaction_attention_table extends interaction_table { + /** + * Constructor for deactivated_workflows_table. + * @param int $uniqueid Unique id of this table. + * @param int[] $courseids List of ids for courses that require attention. + */ public function __construct($uniqueid, $courseids) { parent::__construct($uniqueid); global $PAGE; @@ -76,8 +88,10 @@ class interaction_attention_table extends interaction_table { /** * Render tools column. - * @param $row + * @param object $row Row data. * @return string pluginname of the subplugin + * @throws \coding_exception + * @throws \invalid_parameter_exception */ public function col_tools($row) { $output = ''; @@ -92,7 +106,7 @@ class interaction_attention_table extends interaction_table { /** * Render date column. - * @param $row + * @param object $row Row data. * @return string pluginname of the subplugin */ public function col_date($row) { @@ -109,12 +123,13 @@ class interaction_attention_table extends interaction_table { /** * Util function for writing an action icon link * - * @param string $action URL parameter to include in the link + * @param string $action URL parameter to include in the link * @param string $processid URL parameter to include in the link - * @param int $stepinstanceid ID of the step instance - * @param string $alt The string description of the link used as the title and alt text + * @param int $stepinstanceid ID of the step instance + * @param string $alt The string description of the link used as the title and alt text * * @return string The icon/link + * @throws \moodle_exception */ private function format_icon_link($action, $processid, $stepinstanceid, $alt) { global $PAGE, $OUTPUT; diff --git a/classes/table/interaction_remaining_table.php b/classes/table/interaction_remaining_table.php index 63569acf96de4a50f83e06c0b53e1ef616865469..8d84ea9ffe52393660e565cb742ec857e02683a6 100644 --- a/classes/table/interaction_remaining_table.php +++ b/classes/table/interaction_remaining_table.php @@ -30,11 +30,23 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); +/** + * Table listing all courses for a specific user and a specific subplugin + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class interaction_remaining_table extends interaction_table { - /** manual_trigger_tool[] list of all available trigger tools. */ + /** @var manual_trigger_tool[] $availabletools list of all available trigger tools. */ private $availabletools; + /** + * Constructor for deactivated_workflows_table. + * @param int $uniqueid Unique id of this table. + * @param int[] $courseids List of ids for courses that require no attention. + */ public function __construct($uniqueid, $courseids) { parent::__construct($uniqueid); global $PAGE; @@ -97,8 +109,10 @@ class interaction_remaining_table extends interaction_table { /** * Render tools column. - * @param $row - * @return string pluginname of the subplugin + * @param object $row Row data. + * @return string Rendered tools html + * @throws \coding_exception + * @throws \moodle_exception */ public function col_tools($row) { global $PAGE, $OUTPUT; @@ -130,6 +144,14 @@ class interaction_remaining_table extends interaction_table { return $OUTPUT->render($menu); } + /** + * Render status column. + * @param object $row Row data. + * @return string Rendered status html + * @throws \coding_exception + * @throws \dml_exception + * @throws \invalid_parameter_exception + */ public function col_status($row) { $processstatus = parent::col_status($row); // If current process has status, show status. @@ -147,6 +169,13 @@ class interaction_remaining_table extends interaction_table { return $interactionlib->get_action_string($row->action, $userlink); } + + /** + * Render lastmodified column. + * @param object $row Row data. + * @return string Rendered lastmodified html + * @throws \coding_exception + */ public function col_lastmodified($row) { if (!$row->lastmodified) { return ''; diff --git a/classes/table/interaction_table.php b/classes/table/interaction_table.php index ba207ea1e7fcce4be5a91b92145d728a8173cf37..8b2db10eac0353db601ea9312042fe4ab8dff0a9 100644 --- a/classes/table/interaction_table.php +++ b/classes/table/interaction_table.php @@ -33,8 +33,19 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); +/** + * Table listing all courses for a specific user and a specific subplugin + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ abstract class interaction_table extends \table_sql { + /** + * Constructor for interaction_table. + * @param int $uniqueid Unique id of this table. + */ public function __construct($uniqueid) { parent::__construct($uniqueid); $this->set_attribute('class', $this->attributes['class'] . ' ' . $uniqueid); @@ -47,7 +58,7 @@ abstract class interaction_table extends \table_sql { /** * Render coursefullname column. - * @param $row + * @param object $row Row data. * @return string course link */ public function col_coursefullname($row) { @@ -57,7 +68,7 @@ abstract class interaction_table extends \table_sql { /** * Render startdate column. - * @param $row + * @param object $row Row data. * @return string human readable date * @throws \coding_exception */ @@ -72,15 +83,18 @@ abstract class interaction_table extends \table_sql { /** * Render tools column. - * @param $row - * @return string pluginname of the subplugin + * @param object $row Row data. + * @return string Rendered tools html */ public abstract function col_tools($row); /** * Render status column. - * @param $row - * @return string pluginname of the subplugin + * @param object $row Row data. + * @return string Rendered status html. + * @throws \coding_exception + * @throws \dml_exception + * @throws \invalid_parameter_exception */ public function col_status($row) { if ($row->processid !== null) { diff --git a/classes/table/step_table.php b/classes/table/step_table.php index 4afb9a885f060f3c38f3da5d956c681e582ab2dd..0b85115569deddd349e7753cee7718c8e58bd5f7 100644 --- a/classes/table/step_table.php +++ b/classes/table/step_table.php @@ -34,15 +34,25 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); require_once(__DIR__ . '/../../lib.php'); +/** + * Table listing step instances + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class step_table extends \table_sql { - /** int workflowid */ + /** @var int $workflowid If of the workflow. */ private $workflowid; /** * step_table constructor. - * @param string $uniqueid - * @param int $workflowid + * @param string $uniqueid Unique id of the table. + * @param int $workflowid Id of the workflow instance. + * @throws \coding_exception + * @throws \dml_exception + * @throws \moodle_exception */ public function __construct($uniqueid, $workflowid) { parent::__construct($uniqueid); @@ -58,6 +68,14 @@ class step_table extends \table_sql { $this->init(); } + /** + * Take the data returned from the db_query and go through all the rows + * processing each col using either col_{columnname} method or other_cols + * method or if other_cols returns NULL then put the data straight into the + * table. + * + * After calling this function, don't forget to call close_recordset. + */ public function build_table() { $triggers = trigger_manager::get_triggers_for_workflow($this->workflowid); foreach ($triggers as $trigger) { @@ -75,6 +93,9 @@ class step_table extends \table_sql { return parent::build_table(); } + /** + * Initialize the table. + */ public function init() { $columns = ['type', 'instancename', 'subpluginname']; $headers = [ @@ -106,8 +127,9 @@ class step_table extends \table_sql { /** * Render the type column. This column displays Trigger or Step, depending of the type of the subplugin. - * @param $row + * @param object $row Row data. * @return string type of the subplugin + * @throws \coding_exception */ public function col_type($row) { if ($row->type == 'step') { @@ -118,8 +140,9 @@ class step_table extends \table_sql { /** * Render subpluginname column. - * @param $row + * @param object $row Row data. * @return string pluginname of the subplugin + * @throws \coding_exception */ public function col_subpluginname($row) { @@ -133,8 +156,10 @@ class step_table extends \table_sql { /** * Render sortindex column. - * @param $row + * @param object $row Row data. * @return string action buttons for changing sortorder of the subplugin + * @throws \coding_exception + * @throws \moodle_exception */ public function col_sortindex($row) { global $OUTPUT; @@ -185,8 +210,10 @@ class step_table extends \table_sql { /** * Render edit column. - * @param $row + * @param object $row Row data. * @return string action button for editing of the subplugin + * @throws \coding_exception + * @throws \moodle_exception */ public function col_edit($row) { @@ -203,8 +230,10 @@ class step_table extends \table_sql { /** * Render show column. - * @param $row + * @param object $row Row data. * @return string action button for editing of the subplugin + * @throws \coding_exception + * @throws \moodle_exception */ public function col_show_action($row) { @@ -221,8 +250,10 @@ class step_table extends \table_sql { /** * Render delete column. - * @param $row + * @param object $row Row data. * @return string action button for deleting the subplugin + * @throws \coding_exception + * @throws \moodle_exception */ public function col_delete($row) { @@ -244,6 +275,7 @@ class step_table extends \table_sql { * @param string $icon The key to the icon to use (e.g. 't/up') * @param string $alt The string description of the link used as the title and alt text * @return string The icon/link + * @throws \moodle_exception */ private function format_icon_link($action, $subpluginid, $icon, $alt) { global $PAGE, $OUTPUT; diff --git a/classes/table/workflow_definition_table.php b/classes/table/workflow_definition_table.php index d3ad10c8e053682fd854e957abcb76a914452e57..631865c97c397d6d7b09b79734d462f9ee9ee58f 100644 --- a/classes/table/workflow_definition_table.php +++ b/classes/table/workflow_definition_table.php @@ -34,8 +34,19 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); require_once(__DIR__ . '/../../lib.php'); +/** + * Table listing all workflow definitions. + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class workflow_definition_table extends workflow_table { + /** + * Constructor for workflow_definition_table. + * @param int $uniqueid Unique id of this table. + */ public function __construct($uniqueid) { parent::__construct($uniqueid); global $PAGE; @@ -47,6 +58,9 @@ class workflow_definition_table extends workflow_table { $this->init(); } + /** + * Initialize the table. + */ public function init() { $this->define_columns(['title', 'timeactive', 'tools']); $this->define_headers([ @@ -60,8 +74,10 @@ class workflow_definition_table extends workflow_table { /** * Render activate column. - * @param $row + * @param object $row Row data. * @return string activate time for workflows + * @throws \coding_exception + * @throws \moodle_exception */ public function col_timeactive($row) { global $OUTPUT, $PAGE; @@ -82,8 +98,10 @@ class workflow_definition_table extends workflow_table { /** * Render tools column. - * @param $row + * @param object $row Row data. * @return string action buttons for workflows + * @throws \coding_exception + * @throws \moodle_exception */ public function col_tools($row) { global $OUTPUT; diff --git a/classes/table/workflow_table.php b/classes/table/workflow_table.php index bbaa98d06d568141a997f69bc00b9c7911c836a7..6ad652729aba4b6e0d352786646de9af6ca6f352 100644 --- a/classes/table/workflow_table.php +++ b/classes/table/workflow_table.php @@ -34,8 +34,19 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); require_once(__DIR__ . '/../../lib.php'); +/** + * Table listing all active automatically triggered workflows. + * + * @package tool_lifecycle + * @copyright 2018 Jan Dageförde WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ abstract class workflow_table extends \table_sql { + /** + * Constructor for workflow_table. + * @param int $uniqueid Unique id of this table. + */ public function __construct($uniqueid) { parent::__construct($uniqueid); $this->set_attribute('class', $this->attributes['class'] . ' ' . $uniqueid); @@ -43,7 +54,8 @@ abstract class workflow_table extends \table_sql { /** * Render title column. - * @param $row + * @param object $row Row data. + * @return string Rendered title. */ public function col_title($row) { return $row->title . '<br><span class="workflow_displaytitle">' . $row->displaytitle . '</span>'; @@ -51,8 +63,10 @@ abstract class workflow_table extends \table_sql { /** * Render activate column. - * @param $row + * @param object $row Row data. * @return string activate time for workflows + * @throws \coding_exception + * @throws \moodle_exception */ public function col_timeactive($row) { global $OUTPUT, $PAGE; @@ -68,8 +82,9 @@ abstract class workflow_table extends \table_sql { /** * Render deactivated column. - * @param $row + * @param object $row Row data. * @return string deactivate time for workflows + * @throws \coding_exception */ public function col_timedeactive($row) { if ($row->timedeactive) { @@ -80,7 +95,7 @@ abstract class workflow_table extends \table_sql { /** * Render the trigger column. - * @param $row + * @param object $row Row data. * @return string instancename of the trigger */ public function col_trigger($row) { @@ -97,8 +112,9 @@ abstract class workflow_table extends \table_sql { /** * Render the processes column. It shows the number of active processes for the workflow instance. - * @param $row - * @return string instancename of the trigger + * @param object $row Row data. + * @return string Number of processes. + * @throws \dml_exception */ public function col_processes($row) { return process_manager::count_processes_by_workflow($row->id); @@ -106,8 +122,10 @@ abstract class workflow_table extends \table_sql { /** * Render tools column. - * @param $row + * @param object $row Row data. * @return string action buttons for workflows + * @throws \coding_exception + * @throws \moodle_exception */ public function col_tools($row) { global $OUTPUT; @@ -131,6 +149,7 @@ abstract class workflow_table extends \table_sql { * @param string $icon The key to the icon to use (e.g. 't/up') * @param string $alt The string description of the link used as the title and alt text * @return string The icon/link + * @throws \moodle_exception */ protected function format_icon_link($action, $workflowid, $icon, $alt) { global $OUTPUT; diff --git a/classes/task/lifecycle_task.php b/classes/task/lifecycle_task.php index 12092dfdb2128a7548891357314a9d2ea52727f4..a1b5481dcbd36446c4a31b1465b9dce5752fb305 100644 --- a/classes/task/lifecycle_task.php +++ b/classes/task/lifecycle_task.php @@ -29,12 +29,28 @@ use tool_lifecycle\processor; defined('MOODLE_INTERNAL') || die; +/** + * Scheduled task for working on lifecycle processes + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class lifecycle_task extends \core\task\scheduled_task { + /** + * Get a descriptive name for this task (shown to admins). + * + * @return string + * @throws \coding_exception + */ public function get_name() { return get_string('lifecycle_task', 'tool_lifecycle'); } + /** + * Do the job. + */ public function execute() { $processor = new processor(); $processor->call_trigger(); diff --git a/classes/view_controller.php b/classes/view_controller.php index 02e09ebeabd1c710b763bc9b2cda26ea098dcfdb..28d636d99afd5e445ed2317ec309a30d63baaa46 100644 --- a/classes/view_controller.php +++ b/classes/view_controller.php @@ -48,7 +48,9 @@ class view_controller { * Handles actions triggered in the view.php and displays the view. * * @param \renderer_base $renderer - * + * @throws \coding_exception + * @throws \dml_exception + * @throws \invalid_parameter_exception */ public function handle_view($renderer) { global $DB; @@ -110,6 +112,11 @@ class view_controller { * @param string $action triggered action code. * @param int $processid id of the process the action was triggered for. * @param int $stepid id of the step the action was triggered for. + * @throws \coding_exception + * @throws \dml_exception + * @throws \invalid_parameter_exception + * @throws \moodle_exception + * @throws \required_capability_exception */ public function handle_interaction($action, $processid, $stepid) { global $PAGE; @@ -129,6 +136,10 @@ class view_controller { * * @param int $triggerid id of the trigger whose workflow was requested. * @param int $courseid id of the course the workflow was requested for. + * @throws \coding_exception + * @throws \dml_exception + * @throws \moodle_exception + * @throws \required_capability_exception */ public function handle_trigger($triggerid, $courseid) { global $PAGE; diff --git a/db/install.php b/db/install.php deleted file mode 100644 index 34d36a23c86a7ec76ca79dbe6a03770ae9b87b00..0000000000000000000000000000000000000000 --- a/db/install.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see <http://www.gnu.org/licenses/>. - -/** - * Install script for lifecycle plugin - * - * @package tool_lifecycle - * @copyright 2017 Tobias Reischmann WWU - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -function xmldb_tool_lifecycle_install() { - -} \ No newline at end of file diff --git a/db/upgrade.php b/db/upgrade.php index 56832ca2d7fb3b80a31406abfdd9e63ae3d27b90..2d970f454de7516932a14848b2b9f9ff78b61091 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -24,6 +24,17 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Update script for tool_lifecycle. + * @param int $oldversion Version id of the previously installed version. + * @return bool + * @throws ddl_exception + * @throws ddl_field_missing_exception + * @throws ddl_table_missing_exception + * @throws dml_exception + * @throws downgrade_exception + * @throws upgrade_exception + */ function xmldb_tool_lifecycle_upgrade($oldversion) { global $DB; diff --git a/lib.php b/lib.php index 4a38e8f87db22a3769858cc8936d1e6a6ef94b99..4e5cabdc4566d7e7d3879fab741d97d1c40bc1eb 100644 --- a/lib.php +++ b/lib.php @@ -15,6 +15,7 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** + * Lib functions for tool_lifecycle. * @package tool_lifecycle * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -29,6 +30,8 @@ defined('MOODLE_INTERNAL') || die(); * @param stdClass $course The course to object for the tool * @param context $context The context of the course * @return void|null return null if we don't want to display the node. + * @throws coding_exception + * @throws moodle_exception */ function tool_lifecycle_extend_navigation_course($navigation, $course, $context) { global $PAGE; diff --git a/renderer.php b/renderer.php index b0f405c6b38116d05b4ded9c830f1dca18a1be40..278570011f8944c93ce9d553bd3f29073f0959e3 100644 --- a/renderer.php +++ b/renderer.php @@ -23,12 +23,17 @@ */ defined('MOODLE_INTERNAL') || die(); +/** + * Renderer for life cycle + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class tool_lifecycle_renderer extends plugin_renderer_base { /** * Write the page footer - * - * @return string */ public function footer() { global $OUTPUT; @@ -38,8 +43,7 @@ class tool_lifecycle_renderer extends plugin_renderer_base { /** * Write the page header * - * @param string optional page title. - * @return string + * @param string $title optional page title. */ public function header($title = null) { global $OUTPUT, $PAGE; @@ -55,6 +59,7 @@ class tool_lifecycle_renderer extends plugin_renderer_base { * Renders the workflow upload form including errors, which occured during upload. * @param \tool_lifecycle\form\form_upload_workflow $form * @param array $errors + * @throws coding_exception */ public function render_workflow_upload_form($form, $errors = array()) { $this->header(get_string('adminsettings_edit_workflow_definition_heading', 'tool_lifecycle')); diff --git a/step/createbackup/db/upgrade.php b/step/createbackup/db/upgrade.php index f6f7217006d0fcd6e91f415ed8f8f6538914410a..2884072d369625622c8eebdf1a581bb55c28f722 100644 --- a/step/createbackup/db/upgrade.php +++ b/step/createbackup/db/upgrade.php @@ -15,10 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Update script for lifecycles subplugin deletecourse + * Update script for lifecycles subplugin createbackup * - * @package tool_lifecycle_step - * @subpackage createbackup + * @package lifecyclestep_createbackup * @copyright 2019 WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -28,6 +27,15 @@ use tool_lifecycle\manager\step_manager; defined('MOODLE_INTERNAL') || die(); +/** + * Update script for lifecycles subplugin createbackup. + * @param int $oldversion Version id of the previously installed version. + * @throws coding_exception + * @throws dml_exception + * @throws downgrade_exception + * @throws moodle_exception + * @throws upgrade_exception + */ function xmldb_lifecyclestep_createbackup_upgrade($oldversion) { if ($oldversion < 2019052900) { diff --git a/step/createbackup/lang/de/lifecyclestep_createbackup.php b/step/createbackup/lang/de/lifecyclestep_createbackup.php index c2c09aa76d7cb1efff451d4dcebe3ad95be72d02..f767e9f0666fdbe4a8157da24dde1ca0788dfc85 100644 --- a/step/createbackup/lang/de/lifecyclestep_createbackup.php +++ b/step/createbackup/lang/de/lifecyclestep_createbackup.php @@ -17,8 +17,7 @@ /** * Lang strings for create backup step * - * @package tool_lifecycle_step - * @subpackage createbackup + * @package lifecyclestep_createbackup * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/createbackup/lang/en/lifecyclestep_createbackup.php b/step/createbackup/lang/en/lifecyclestep_createbackup.php index fc4830214bd74ebb46468aefacf3cf4751272aae..c8dbbb4c98994c9ed2a89c7b65939420357af497 100644 --- a/step/createbackup/lang/en/lifecyclestep_createbackup.php +++ b/step/createbackup/lang/en/lifecyclestep_createbackup.php @@ -17,8 +17,7 @@ /** * Lang strings for create backup step * - * @package tool_lifecycle_step - * @subpackage createbackup + * @package lifecyclestep_createbackup * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/createbackup/lib.php b/step/createbackup/lib.php index da7306d85c4cf53256b1b80da4704e74c1293a65..2e9a9a85e9ff322273765ae0a741cdaf96511f61 100644 --- a/step/createbackup/lib.php +++ b/step/createbackup/lib.php @@ -15,11 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the subplugintype step - * It has to be implemented by all subplugins. + * Step Subplugin for creating a course backup. * - * @package tool_lifecycle_step - * @subpackage createbackup + * @package lifecyclestep_createbackup * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -39,8 +37,16 @@ global $CFG; require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php'); require_once($CFG->dirroot . '/backup/controller/backup_controller.class.php'); +/** + * Step Subplugin for creating a course backup. + * + * @package lifecyclestep_createbackup + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class createbackup extends libbase { + /** @var int $numberofbackups Backups created so far in this php call. */ private static $numberofbackups = 0; /** @@ -53,6 +59,8 @@ class createbackup extends libbase { * @param int $instanceid of the step instance. * @param mixed $course to be processed. * @return step_response + * @throws \coding_exception + * @throws \dml_exception */ public function process_course($processid, $instanceid, $course) { if (self::$numberofbackups >= settings_manager::get_settings( @@ -66,20 +74,43 @@ class createbackup extends libbase { return step_response::waiting(); } + /** + * Simply call the process_course since it handles everything necessary for this plugin. + * @param int $processid + * @param int $instanceid + * @param mixed $course + * @return step_response + * @throws \coding_exception + * @throws \dml_exception + */ public function process_waiting_course($processid, $instanceid, $course) { return $this->process_course($processid, $instanceid, $course); } + /** + * The return value should be equivalent with the name of the subplugin folder. + * @return string technical name of the subplugin + */ public function get_subpluginname() { return 'createbackup'; } - + /** + * Defines which settings each instance of the subplugin offers for the user to define. + * @return instance_setting[] containing settings keys and PARAM_TYPES + */ public function instance_settings() { return array( new instance_setting('maximumbackupspercron', PARAM_INT), ); } + + /** + * This method can be overriden, to add form elements to the form_step_instance. + * It is called in definition(). + * @param \MoodleQuickForm $mform + * @throws \coding_exception + */ public function extend_add_instance_form_definition($mform) { $elementname = 'maximumbackupspercron'; $mform->addElement('text', $elementname, diff --git a/step/createbackup/version.php b/step/createbackup/version.php index 53e977c1fd2c2f95149929f22ac65f6c40422e64..6a5462252c48df1c621f10c29ed0e117ca36c76b 100644 --- a/step/createbackup/version.php +++ b/step/createbackup/version.php @@ -17,8 +17,7 @@ /** * Life Cycle Create Backup Step * - * @package tool_lifecycle_step - * @subpackage createbackup + * @package lifecyclestep_createbackup * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/deletecourse/db/upgrade.php b/step/deletecourse/db/upgrade.php index cb2b8b34a04a7b043b6d970e30f7a5e3de0ef6e7..b6dd64a5aa83174bedf9fac23eb8ab52d293cf2d 100644 --- a/step/deletecourse/db/upgrade.php +++ b/step/deletecourse/db/upgrade.php @@ -17,8 +17,7 @@ /** * Update script for lifecycles subplugin deletecourse * - * @package tool_lifecycle_step - * @subpackage deletecourse + * @package lifecyclestep_deletecourse * @copyright 2018 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -28,6 +27,19 @@ use tool_lifecycle\manager\step_manager; defined('MOODLE_INTERNAL') || die(); +/** + * Update script for lifecycles subplugin deletecourse + * + * @package lifecyclestep_deletecourse + * @copyright 2018 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @param int $oldversion Version id of the previously installed version. + * @throws coding_exception + * @throws dml_exception + * @throws downgrade_exception + * @throws moodle_exception + * @throws upgrade_exception + */ function xmldb_lifecyclestep_deletecourse_upgrade($oldversion) { if ($oldversion < 2018122300) { diff --git a/step/deletecourse/lang/de/lifecyclestep_deletecourse.php b/step/deletecourse/lang/de/lifecyclestep_deletecourse.php index 487926c4cc383a8928cde91384b77f85d601f0e7..7b38ae14f7f0f27abd3238bec3becc1234d9ffbb 100644 --- a/step/deletecourse/lang/de/lifecyclestep_deletecourse.php +++ b/step/deletecourse/lang/de/lifecyclestep_deletecourse.php @@ -17,8 +17,7 @@ /** * Lang strings for delete course step * - * @package tool_lifecycle_step - * @subpackage deletecourse + * @package lifecyclestep_deletecourse * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/deletecourse/lang/en/lifecyclestep_deletecourse.php b/step/deletecourse/lang/en/lifecyclestep_deletecourse.php index 458eaed6981487b2a40fd48cfbb80009b5f37264..82ffeb4ee5316e5c0678e80f483785578a692392 100644 --- a/step/deletecourse/lang/en/lifecyclestep_deletecourse.php +++ b/step/deletecourse/lang/en/lifecyclestep_deletecourse.php @@ -17,8 +17,7 @@ /** * Lang strings for delete course step * - * @package tool_lifecycle_step - * @subpackage deletecourse + * @package lifecyclestep_deletecourse * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/deletecourse/lib.php b/step/deletecourse/lib.php index 9520512a99a6b8f1606700b916a86d1e654dfaa6..a11f01452e99b27684e251a26629fcdb589de5c0 100644 --- a/step/deletecourse/lib.php +++ b/step/deletecourse/lib.php @@ -15,11 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the subplugintype step - * It has to be implemented by all subplugins. + * Step subplugin to delete a course. * - * @package tool_lifecycle_step - * @subpackage deletecourse + * @package lifecyclestep_deletecourse * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -33,8 +31,16 @@ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/../lib.php'); +/** + * Step subplugin to delete a course. + * + * @package lifecyclestep_deletecourse + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class deletecourse extends libbase { + /** @var int $numberofdeletions Deletions done so far in this php call. */ private static $numberofdeletions = 0; /** @@ -47,6 +53,8 @@ class deletecourse extends libbase { * @param int $instanceid of the step instance. * @param mixed $course to be processed. * @return step_response + * @throws \coding_exception + * @throws \dml_exception */ public function process_course($processid, $instanceid, $course) { if (self::$numberofdeletions >= settings_manager::get_settings( @@ -58,16 +66,30 @@ class deletecourse extends libbase { return step_response::proceed(); } + /** + * The return value should be equivalent with the name of the subplugin folder. + * @return string technical name of the subplugin + */ public function get_subpluginname() { return 'deletecourse'; } + /** + * Defines which settings each instance of the subplugin offers for the user to define. + * @return instance_setting[] containing settings keys and PARAM_TYPES + */ public function instance_settings() { return array( new instance_setting('maximumdeletionspercron', PARAM_INT), ); } + /** + * This method can be overriden, to add form elements to the form_step_instance. + * It is called in definition(). + * @param \MoodleQuickForm $mform + * @throws \coding_exception + */ public function extend_add_instance_form_definition($mform) { $elementname = 'maximumdeletionspercron'; $mform->addElement('text', $elementname, get_string('deletecourse_maximumdeletionspercron', 'lifecyclestep_deletecourse')); diff --git a/step/deletecourse/version.php b/step/deletecourse/version.php index 05dc24335d86fe0acdfcfc55eb8376a3a7b591d3..d22eb2777b1341e556c566500206b277cd2326ce 100644 --- a/step/deletecourse/version.php +++ b/step/deletecourse/version.php @@ -17,8 +17,7 @@ /** * Life Cycle Delete Course Step * - * @package tool_lifecycle_step - * @subpackage deletecourse + * @package lifecyclestep_deletecourse * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/duplicate/classes/form_duplicate.php b/step/duplicate/classes/form_duplicate.php index 412de6710b7fffb9ed5d88adb761785faa8b60eb..183328cfb5b6ffef8126a389cc521ac0701f2a4d 100644 --- a/step/duplicate/classes/form_duplicate.php +++ b/step/duplicate/classes/form_duplicate.php @@ -15,9 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Offers the possibility to enter a new coursename + * Offers the possibility to enter a new coursename. * - * @package tool_lifecycle + * @package lifecyclestep_duplicate * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -31,17 +31,24 @@ defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir . '/formslib.php'); /** - * Provides a form to modify a step instance + * Offers the possibility to enter a new coursename. + * + * @package lifecyclestep_duplicate + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class form_duplicate extends \moodleform { + /** @var int $processid Id of the process. */ private $processid; + /** @var int $stepid Id of the step instance. */ private $stepid; /** * Constructor - * @param \moodle_url $url. - * @param int $processid if of the process + * @param \moodle_url $url Url of the current page. + * @param int $processid Id of the process. + * @param int $stepid Id of the step instance. */ public function __construct($url, $processid, $stepid) { $this->processid = $processid; diff --git a/step/duplicate/db/access.php b/step/duplicate/db/access.php index 23efa53491178b0c9164d87305d59dccac6a700d..85169b974edb9a9b3f83f49ec4bdb702249f2bf9 100644 --- a/step/duplicate/db/access.php +++ b/step/duplicate/db/access.php @@ -16,8 +16,7 @@ /** * Capability definitions for the duplication step subplugin - * @package lifecycle_step - * @subpackage duplication + * @package lifecyclestep_duplicate * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/duplicate/interactionlib.php b/step/duplicate/interactionlib.php index 71d09bbc6d2b957a751c4ec7699eaa5464e28ec9..169c8e277effb716bf494a090915ccfca5d63c87 100644 --- a/step/duplicate/interactionlib.php +++ b/step/duplicate/interactionlib.php @@ -15,11 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the interactions of the subplugintype step - * It has to be implemented by all subplugins that want to use the interaction view. + * Interaction lib for querying course details from the user. * - * @package tool_lifecycle - * @subpackage step + * @package lifecyclestep_duplicate * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -37,9 +35,16 @@ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/../interactionlib.php'); require_once(__DIR__ . '/lib.php'); - +/** + * Interaction lib for querying course details from the user. + * + * @package lifecyclestep_duplicate + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class interactionduplicate extends interactionlibbase { + /** @var string Action string for triggering the duplication interaction form. */ const ACTION_DUPLICATE_FORM = 'duplicateform'; /** @@ -57,6 +62,8 @@ class interactionduplicate extends interactionlibbase { * 'alt' => a string text of the button * @param process $process process the action tools are requested for * @return array of action tools + * @throws \coding_exception + * @throws \dml_exception */ public function get_action_tools($process) { $step = step_manager::get_step_instance_by_workflow_index($process->workflowid, $process->stepindex); @@ -76,6 +83,8 @@ class interactionduplicate extends interactionlibbase { * Returns the status message for the given process. * @param process $process process the status message is requested for * @return string status message + * @throws \coding_exception + * @throws \dml_exception */ public function get_status_message($process) { $step = step_manager::get_step_instance_by_workflow_index($process->workflowid, $process->stepindex); @@ -97,6 +106,8 @@ class interactionduplicate extends interactionlibbase { * - stillprocessing: the step still wants to process the course and is responsible for rendering the site. * - noaction: the action is not defined for the step. * - rollback: the step has finished and respective controller class should rollback the process. + * @throws \coding_exception + * @throws \dml_exception */ public function handle_interaction($process, $step, $action = 'default') { global $PAGE, $DB; @@ -128,7 +139,7 @@ class interactionduplicate extends interactionlibbase { /** * Renders the duplication form including respective headers and footers. - * @param $mform \moodleform to be rendered. + * @param \moodleform $mform Form to be rendered. */ private function render_form($mform) { global $PAGE; @@ -143,8 +154,9 @@ class interactionduplicate extends interactionlibbase { * Returns the display name for the given action. * Used for the past actions table in view.php. * @param string $action Identifier of action - * @param string $userlink html-link with username as text that refers to the user profile. + * @param string $user Html-link with username as text that refers to the user profile. * @return string action display name + * @throws \coding_exception */ public function get_action_string($action, $user) { return get_string('action_new_course_data', 'lifecyclestep_duplicate', $user); diff --git a/step/duplicate/lang/de/lifecyclestep_duplicate.php b/step/duplicate/lang/de/lifecyclestep_duplicate.php index f3d9b0330160cdcddc5c7c94e66eab2e5fef03a3..448883c1cd1f5d6ecb490fc5c11d130a8a61be9f 100644 --- a/step/duplicate/lang/de/lifecyclestep_duplicate.php +++ b/step/duplicate/lang/de/lifecyclestep_duplicate.php @@ -17,8 +17,7 @@ /** * Lang strings for duplicate step * - * @package tool_lifecycle_step - * @subpackage duplicate + * @package lifecyclestep_duplicate * @copyright 2018 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/duplicate/lang/en/lifecyclestep_duplicate.php b/step/duplicate/lang/en/lifecyclestep_duplicate.php index 6637e89689b553cb7056fb1ee82ce340401c2100..cf90c5d6eac70910bb27f179fd475f5da8e3cce3 100644 --- a/step/duplicate/lang/en/lifecyclestep_duplicate.php +++ b/step/duplicate/lang/en/lifecyclestep_duplicate.php @@ -17,8 +17,7 @@ /** * Lang strings for duplicate step * - * @package tool_lifecycle_step - * @subpackage duplicate + * @package lifecyclestep_duplicate * @copyright 2018 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/duplicate/lib.php b/step/duplicate/lib.php index 609278b0b36f3e4102a29f71454d50d6b197c476..4a969b9bbec172a4f6cbe178ae6f6c3594ace1c9 100644 --- a/step/duplicate/lib.php +++ b/step/duplicate/lib.php @@ -15,11 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the subplugintype step - * It has to be implemented by all subplugins. + * Step subplugin for course duplication. * - * @package tool_lifecycle_step - * @subpackage email + * @package lifecyclestep_duplicate * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -36,9 +34,18 @@ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/../lib.php'); +/** + * Step subplugin for course duplication. + * + * @package lifecyclestep_duplicate + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class duplicate extends libbase { + /** @var string Constant course fullname. */ const PROC_DATA_COURSEFULLNAME = 'fullname'; + /** @var string Constant course shortname. */ const PROC_DATA_COURSESHORTNAME = 'shortname'; /** @@ -51,6 +58,7 @@ class duplicate extends libbase { * @param int $instanceid of the step instance. * @param mixed $course to be processed. * @return step_response + * @throws \dml_exception */ public function process_course($processid, $instanceid, $course) { $fullname = process_data_manager::get_process_data($processid, $instanceid, self::PROC_DATA_COURSEFULLNAME); @@ -85,15 +93,37 @@ class duplicate extends libbase { * @param int $instanceid of the step instance. * @param mixed $course to be processed. * @return step_response + * @throws \dml_exception */ public function process_waiting_course($processid, $instanceid, $course) { return $this->process_course($processid, $instanceid, $course); } + /** + * The return value should be equivalent with the name of the subplugin folder. + * @return string technical name of the subplugin + */ public function get_subpluginname() { return 'duplicate'; } + + /** + * Duplicates a course. + * @param int $courseid Id of the course. + * @param string $fullname Full name of the new course. + * @param string $shortname Short name of the new course. + * @param int $categoryid New category id. + * @param bool $visible New visibility state of the course. + * @param array $options Additional options for the new course. + * @throws \base_plan_exception + * @throws \base_setting_exception + * @throws \coding_exception + * @throws \dml_exception + * @throws \moodle_exception + * @throws \required_capability_exception + * @throws \restore_controller_exception + */ public function duplicate_course($courseid, $fullname, $shortname, $categoryid, $visible, $options) { global $USER, $DB, $CFG; require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php'); diff --git a/step/duplicate/version.php b/step/duplicate/version.php index 6d97c94c33d37eec3648ec5cd8d308dce0e45695..41bdba13c13bca630b3dd9c8f8d7fd1a58447ed2 100644 --- a/step/duplicate/version.php +++ b/step/duplicate/version.php @@ -15,10 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Life Cycle Email Step + * Life Cycle Duplicate Step * - * @package tool_lifecycle_step - * @subpackage email + * @package lifecyclestep_duplicate * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/email/db/access.php b/step/email/db/access.php index 94ddebbe0834b51b69733fec8782ac5bdbbbd8b0..7c33a54832cc98b89043ff9401584f938c84165d 100644 --- a/step/email/db/access.php +++ b/step/email/db/access.php @@ -16,8 +16,7 @@ /** * Capability definitions for the email step subplugin - * @package lifecycle_step - * @subpackage email + * @package lifecyclestep_email * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/email/interactionlib.php b/step/email/interactionlib.php index e6e96ec5ea3f652827db061691a9516202049dc2..f438bd95f7974d198c756ed44d3511773d8cafac 100644 --- a/step/email/interactionlib.php +++ b/step/email/interactionlib.php @@ -15,11 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the interactions of the subplugintype step - * It has to be implemented by all subplugins that want to use the interaction view. + * Implementation for the interactions of the email step. * - * @package tool_lifecycle - * @subpackage step + * @package lifecyclestep_email * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -39,9 +37,16 @@ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/../interactionlib.php'); require_once(__DIR__ . '/lib.php'); - +/** + * Implementation for the interactions of the email step. + * + * @package lifecyclestep_email + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class interactionemail extends interactionlibbase { + /** @var string Action string for triggering to keep a course. */ const ACTION_KEEP = 'keep'; /** @@ -59,6 +64,7 @@ class interactionemail extends interactionlibbase { * 'alt' => a string text of the button * @param process $process process the action tools are requested for * @return array of action tools + * @throws \coding_exception */ public function get_action_tools($process) { return array( @@ -72,6 +78,7 @@ class interactionemail extends interactionlibbase { * Returns the status message for the given process. * @param process $process process the status message is requested for * @return string status message + * @throws \coding_exception */ public function get_status_message($process) { return get_string('status_message_requiresattention', 'lifecyclestep_email'); @@ -97,7 +104,11 @@ class interactionemail extends interactionlibbase { /** * Returns the due date. - * @return null + * @param int $processid Id of the process. + * @param int $stepid Id of the step instance. + * @return string formatted date. + * @throws \coding_exception + * @throws \dml_exception */ public function get_due_date($processid, $stepid) { $process = process_manager::get_process_by_id($processid); @@ -123,8 +134,9 @@ class interactionemail extends interactionlibbase { * Returns the display name for the given action. * Used for the past actions table in view.php. * @param string $action Identifier of action - * @param string $userlink html-link with username as text that refers to the user profile. + * @param string $user html-link with username as text that refers to the user profile. * @return string action display name + * @throws \coding_exception */ public function get_action_string($action, $user) { return get_string('action_prevented_deletion', 'lifecyclestep_email', $user); diff --git a/step/email/lang/de/lifecyclestep_email.php b/step/email/lang/de/lifecyclestep_email.php index bf53c0460ad3438609dbb1379af3e369cc07ab30..2a6c2a269aa1ba773d5bcf6cc7a13ef3a41010ae 100644 --- a/step/email/lang/de/lifecyclestep_email.php +++ b/step/email/lang/de/lifecyclestep_email.php @@ -17,8 +17,7 @@ /** * Lang strings for email step * - * @package tool_lifecycle_step - * @subpackage email + * @package lifecyclestep_email * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/email/lang/en/lifecyclestep_email.php b/step/email/lang/en/lifecyclestep_email.php index ac523c67ef51d72be3ecf90c6eab77cc595ff966..529f0a926823c9d14cc809eb7b0c60934187dcbf 100644 --- a/step/email/lang/en/lifecyclestep_email.php +++ b/step/email/lang/en/lifecyclestep_email.php @@ -17,8 +17,7 @@ /** * Lang strings for email step * - * @package tool_lifecycle_step - * @subpackage email + * @package lifecyclestep_email * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/email/lib.php b/step/email/lib.php index 5a1201731b6b5f1e3c3ecea53551547e1f2f0418..7d9eb361352ccdf4a701fd424b4e06a79dc19460 100644 --- a/step/email/lib.php +++ b/step/email/lib.php @@ -15,16 +15,14 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the subplugintype step - * It has to be implemented by all subplugins. - * - * @package tool_lifecycle_step - * @subpackage email + * Step subplugin for sending out emails to the teacher. + * @package lifecyclestep_email * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace tool_lifecycle\step; +use core_user; use tool_lifecycle\manager\process_manager; use tool_lifecycle\manager\settings_manager; use tool_lifecycle\response\step_response; @@ -38,9 +36,14 @@ require_once(__DIR__ . '/../lib.php'); define('EMAIL_PROCDATA_KEY_KEEP', 'keep'); +/** + * Step subplugin for sending out emails to the teacher. + * @package lifecyclestep_email + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class email extends libbase { - /** * Processes the course and returns a repsonse. * The response tells either @@ -51,6 +54,8 @@ class email extends libbase { * @param int $instanceid of the step instance. * @param mixed $course to be processed. * @return step_response + * @throws \coding_exception + * @throws \dml_exception */ public function process_course($processid, $instanceid, $course) { global $DB; @@ -76,6 +81,8 @@ class email extends libbase { * @param int $instanceid of the step instance. * @param mixed $course to be processed. * @return step_response + * @throws \coding_exception + * @throws \dml_exception */ public function process_waiting_course($processid, $instanceid, $course) { // When time runs up and no one wants to keep the course, then proceed. @@ -89,6 +96,9 @@ class email extends libbase { return step_response::waiting(); } + /** + * Send emails to all teachers, but only one mail per teacher. + */ public function post_processing_bulk_operation() { global $DB, $PAGE; $stepinstances = step_manager::get_step_instances_by_subpluginname($this->get_subpluginname()); @@ -127,8 +137,12 @@ class email extends libbase { /** * Replaces certain placeholders within the mail template. * @param string[] $strings array of mail templates. - * @param mixed $user user object + * @param core_user $user User object. + * @param int $stepid Id of the step instance. + * @param array[] $mailentries Array consisting of course entries from the database. * @return string[] array of mail text. + * @throws \dml_exception + * @throws \moodle_exception */ private function replace_placeholders($strings, $user, $stepid, $mailentries) { global $CFG; @@ -182,6 +196,7 @@ class email extends libbase { * Parses a course for the non html format. * @param int $courseid id of the course * @return string + * @throws \dml_exception */ private function parse_course($courseid) { $course = get_course($courseid); @@ -193,12 +208,17 @@ class email extends libbase { * Parses a course for the html format. * @param int $courseid id of the course * @return array column of a course + * @throws \dml_exception */ private function parse_course_row_data($courseid) { $course = get_course($courseid); return array($course->fullname); } + /** + * Defines which settings each instance of the subplugin offers for the user to define. + * @return instance_setting[] containing settings keys and PARAM_TYPES + */ public function instance_settings() { return array( new instance_setting('responsetimeout', PARAM_INT), @@ -208,10 +228,20 @@ class email extends libbase { ); } + /** + * The return value should be equivalent with the name of the subplugin folder. + * @return string technical name of the subplugin + */ public function get_subpluginname() { return 'email'; } + /** + * This method can be overriden, to add form elements to the form_step_instance. + * It is called in definition(). + * @param \MoodleQuickForm $mform + * @throws \coding_exception + */ public function extend_add_instance_form_definition($mform) { $elementname = 'responsetimeout'; $mform->addElement('duration', $elementname, get_string('email_responsetimeout', 'lifecyclestep_email')); @@ -232,6 +262,12 @@ class email extends libbase { $mform->setType($elementname, PARAM_RAW); } + /** + * This method can be overriden, to set default values to the form_step_instance. + * It is called in definition_after_data(). + * @param \MoodleQuickForm $mform + * @param array $settings array containing the settings from the db. + */ public function extend_add_instance_form_definition_after_data($mform, $settings) { $mform->setDefault('contenthtml', array('text' => $settings['contenthtml'], 'format' => FORMAT_HTML)); } diff --git a/step/email/version.php b/step/email/version.php index 1dd4f3cea8e8c2a5351b7d0f38dcd70d8b979399..4de3b26229b9a7cad129f785909c71f232485d5e 100644 --- a/step/email/version.php +++ b/step/email/version.php @@ -17,8 +17,7 @@ /** * Life Cycle Email Step * - * @package tool_lifecycle_step - * @subpackage email + * @package lifecyclestep_email * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/step/interactionlib.php b/step/interactionlib.php index 5b2aef7465dc9e0d133a2011060544d5b931ebf0..038042e97c0b3c0661dc4530bf9aab401eb6170a 100644 --- a/step/interactionlib.php +++ b/step/interactionlib.php @@ -15,9 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the interactions of the subplugintype step - * It has to be implemented by all subplugins that want to use the interaction view. + * Interface for the interactions of the subplugintype step. * + * It has to be implemented by all subplugins that want to use the interaction view. * @package tool_lifecycle * @subpackage step * @copyright 2017 Tobias Reischmann WWU @@ -26,12 +26,22 @@ namespace tool_lifecycle\step; use core_user; +use MongoDB\BSON\Timestamp; use tool_lifecycle\entity\process; use tool_lifecycle\entity\step_subplugin; use tool_lifecycle\response\step_interactive_response; defined('MOODLE_INTERNAL') || die(); +/** + * Interface for the interactions of the subplugintype step. + * + * It has to be implemented by all subplugins that want to use the interaction view. + * @package tool_lifecycle + * @subpackage step + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ abstract class interactionlibbase { /** @@ -70,7 +80,7 @@ abstract class interactionlibbase { * Returns the display name for the given action. * Used for the past actions table in view.php. * @param string $action Identifier of action - * @param string $userlink html-link with username as text that refers to the user profile. + * @param string $user html-link with username as text that refers to the user profile. * @return string action display name */ public abstract function get_action_string($action, $user); @@ -90,7 +100,9 @@ abstract class interactionlibbase { /** * Returns the due date. - * @return null | timestamp + * @param int $processid Id of the process. + * @param int $stepid Id of the step instance. + * @return null | string formatted due date. */ public function get_due_date($processid, $stepid) { return null; diff --git a/step/lib.php b/step/lib.php index 8687bfe2189421d3beab4074ec8de5ca96e56f51..ae70a17f9d2254179a17ef8d6df6c1628b285d60 100644 --- a/step/lib.php +++ b/step/lib.php @@ -15,11 +15,10 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the subplugintype step - * It has to be implemented by all subplugins. + * Interface for the subplugintype step. * + * It has to be implemented by all subplugins. * @package tool_lifecycle - * @subpackage step * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -30,9 +29,16 @@ use tool_lifecycle\response\step_response; defined('MOODLE_INTERNAL') || die(); +/** + * Interface for the subplugintype step. + * + * It has to be implemented by all subplugins. + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ abstract class libbase { - /** * Processes the course and returns a repsonse. * The response tells either @@ -93,6 +99,7 @@ abstract class libbase { public abstract function get_subpluginname(); /** + * Defines which settings each instance of the subplugin offers for the user to define. * @return instance_setting[] containing settings keys and PARAM_TYPES */ public function instance_settings() { @@ -120,7 +127,10 @@ abstract class libbase { /** * Class representing a local settings object for a subplugin instance. - * @package tool_lifecycle\step + * + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class instance_setting { diff --git a/tests/active_workflow_is_manual_test.php b/tests/active_workflow_is_manual_test.php index 9737e7de4502d081436cc447f9656df2c6b2a006..27992979f3b7454feab1677fbc0d5975a6eb7ae3 100644 --- a/tests/active_workflow_is_manual_test.php +++ b/tests/active_workflow_is_manual_test.php @@ -14,6 +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/>. +/** + * Tests the field is manual after activating workflows. + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2018 WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/generator/lib.php'); @@ -32,13 +40,23 @@ use tool_lifecycle\entity\workflow; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tool_lifecycle_workflow_is_manual_testcase extends \advanced_testcase { + + /** Icon of the trigger. */ const MANUAL_TRIGGER1_ICON = 't/up'; + /** Action name of the trigger. */ const MANUAL_TRIGGER1_DISPLAYNAME = 'Up'; + /** Capability of the trigger. */ const MANUAL_TRIGGER1_CAPABILITY = 'moodle/course:manageactivities'; + /** @var workflow $manualworkflow Instance of the manual workflow */ private $manualworkflow; + /** @var workflow $automaticworkflow Instance of the automatic workflow */ private $automaticworkflow; + /** + * Setup the testcase. + * @throws coding_exception + */ public function setUp() { global $USER; $this->resetAfterTest(true); diff --git a/tests/active_workflow_sortindex_updown_test.php b/tests/active_workflow_sortindex_updown_test.php index cbf2d511a63c97fc79986a6e6292ece85d0e7ebf..85affabc19b3b34620edd4defd4a85ab38a3ca63 100644 --- a/tests/active_workflow_sortindex_updown_test.php +++ b/tests/active_workflow_sortindex_updown_test.php @@ -14,6 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Tests the different state changes of the workflow sortindex for up and down action. + * + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/generator/lib.php'); diff --git a/tests/backup_and_restore_workflow_test.php b/tests/backup_and_restore_workflow_test.php index b05e4d2482791f617ca633019fba0967640a7ae3..b006cce0ef5bb567e41cf7fdf702d1c005aa97de 100644 --- a/tests/backup_and_restore_workflow_test.php +++ b/tests/backup_and_restore_workflow_test.php @@ -14,6 +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/>. +/** + * Tests the field is manual after activating workflows. + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2018 WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/generator/lib.php'); @@ -41,8 +49,13 @@ class tool_lifecycle_backup_and_restore_workflow_testcase extends \advanced_test /** @var $workflow workflow */ private $workflow; + /** @var workflow[] $existingworkflows Array of workflows created in this test. */ private $existingworkflows = []; + /** + * Setup the testcase. + * @throws coding_exception + */ public function setUp() { $this->resetAfterTest(true); $generator = $this->getDataGenerator()->get_plugin_generator('tool_lifecycle'); diff --git a/tests/backup_manager_test.php b/tests/backup_manager_test.php index b05c5fc55c82ed4a523c1b1264be6efac9f7c91d..dadf053d36317c56527e940e5d08f5b61f922bd1 100644 --- a/tests/backup_manager_test.php +++ b/tests/backup_manager_test.php @@ -14,6 +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/>. +/** + * Tests the beckup manager. + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); use tool_lifecycle\manager\backup_manager; @@ -22,15 +30,18 @@ use tool_lifecycle\manager\backup_manager; * Tests the beckup manager. * @package tool_lifecycle * @category test - * @group tool_lifecycle_backup + * @group tool_lifecycle * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tool_lifecycle_backup_manager_testcase extends \advanced_testcase { - /** course */ + /** @var array $course Instance of the course under test. */ private $course; + /** + * Setup the testcase. + */ public function setUp() { $this->resetAfterTest(false); $this->course = $this->getDataGenerator()->create_course(); diff --git a/tests/behat/behat_tool_lifecycle.php b/tests/behat/behat_tool_lifecycle.php index a73b9d7934be8bc8d805cfef7b05916a07cde4d7..b742d30c876939739e9712b6ed38bc3e6e3f6c17 100644 --- a/tests/behat/behat_tool_lifecycle.php +++ b/tests/behat/behat_tool_lifecycle.php @@ -43,9 +43,9 @@ class behat_tool_lifecycle extends behat_base { * * @When /^I click on the tool "([^"]*)" in the "([^"]*)" row of the "([^"]*)" table$/ * - * @param $tool string identifier of the tool - * @param $rowname string identifier of the row - * @param $tablename string identifier of the table + * @param string $tool Identifier of the tool + * @param string $rowname Identifier of the row + * @param string $tablename Identifier of the table * @throws Exception */ public function click_on_the_tool_in_the_row_of_the_table($tool, $rowname, $tablename) { @@ -60,9 +60,9 @@ class behat_tool_lifecycle extends behat_base { * * @When /^I should see the tool "([^"]*)" in the "([^"]*)" row of the "([^"]*)" table$/ * - * @param $tool string identifier of the tool - * @param $rowname string identifier of the row - * @param $tablename string identifier of the table + * @param string $tool Identifier of the tool + * @param string $rowname Identifier of the row + * @param string $tablename Identifier of the table * @return string the selector of the searched tool * @throws Exception */ @@ -88,8 +88,8 @@ class behat_tool_lifecycle extends behat_base { * * @When /^I should see the tool "([^"]*)" in all rows of the "([^"]*)" table$/ * - * @param $tool string identifier of the tool - * @param $tablename string identifier of the table + * @param string $tool Identifier of the tool + * @param string $tablename Identifier of the table * @throws Exception */ public function i_should_see_the_tool_in_all_rows_of_the_table($tool, $tablename) { @@ -118,7 +118,7 @@ class behat_tool_lifecycle extends behat_base { * * @When /^I should not see the table "([^"]*)"$/ * - * @param $tablename string identifier of the table + * @param string $tablename Identifier of the table * @throws Exception */ public function i_should_not_see_the_table($tablename) { @@ -136,7 +136,8 @@ class behat_tool_lifecycle extends behat_base { * * @When /^I should see the row "([^"]*)" in the "([^"]*)" table$/ * - * @param $tablename string identifier of the table + * @param string $rowname Identifier of the row + * @param string $tablename Identifier of the table * @throws Exception */ public function i_should_see_the_row($rowname, $tablename) { @@ -155,7 +156,8 @@ class behat_tool_lifecycle extends behat_base { * * @When /^I should not see the row "([^"]*)" in the "([^"]*)" table$/ * - * @param $tablename string identifier of the table + * @param string $rowname Identifier of the row + * @param string $tablename Identifier of the table * @throws Exception */ public function i_should_not_see_the_row($rowname, $tablename) { @@ -174,9 +176,9 @@ class behat_tool_lifecycle extends behat_base { * * @When /^I should not see the tool "([^"]*)" in the "([^"]*)" row of the "([^"]*)" table$/ * - * @param $tool string identifier of the tool - * @param $rowname string identifier of the row - * @param $tablename string identifier of the table + * @param string $tool Identifier of the tool + * @param string $rowname Identifier of the row + * @param string $tablename Identifier of the table * @throws Exception */ public function i_should_not_see_the_tool_in_the_row_of_the_table($tool, $rowname, $tablename) { @@ -196,9 +198,9 @@ class behat_tool_lifecycle extends behat_base { /** * If Javascript is active, this function tries to click on an action dropdown, to reveal the underlying actions. - * @param $tool string identifier of the tool - * @param $rowname string identifier of the row - * @param $tablename string identifier of the table + * @param string $tool Identifier of the tool + * @param string $rowname Identifier of the row + * @param string $tablename Identifier of the table * @throws Exception */ protected function open_or_close_action_menu($tool, $rowname, $tablename) { @@ -216,7 +218,7 @@ class behat_tool_lifecycle extends behat_base { /** * Build the xpath to the table element with class tablename, throws exceptions if not present. - * @param $tablename string identifier of the table + * @param string $tablename Identifier of the table * @return string xpath of the table * @throws ExpectationException */ @@ -234,8 +236,8 @@ class behat_tool_lifecycle extends behat_base { /** * Build the xpath to the row element with class $rowname within class tablename, throws exceptions if not present. - * @param $rowname string identifier of the row - * @param $tablename string identifier of the table + * @param string $rowname Identifier of the row + * @param string $tablename Identifier of the table * @return string xpath of the table * @throws ExpectationException */ @@ -257,9 +259,9 @@ class behat_tool_lifecycle extends behat_base { /** * Build the xpath to the tool element and throws exceptions if either the table or the row are not present. - * @param $tool string identifier of the tool - * @param $rowname string identifier of the row - * @param $tablename string identifier of the table + * @param string $tool Identifier of the tool + * @param string $rowname Identifier of the row + * @param string $tablename Identifier of the table * @return string xpath of the tool * @throws ExpectationException */ @@ -290,9 +292,9 @@ class behat_tool_lifecycle extends behat_base { /** * Build the xpath to the action menu and throws exceptions if either the table or the row are not present. - * @param $tool string identifier of the tool - * @param $rowname string identifier of the row - * @param $tablename string identifier of the table + * @param string $tool Identifier of the tool + * @param string $rowname Identifier of the row + * @param string $tablename Identifier of the table * @return string xpath of the tool * @throws ExpectationException */ @@ -324,8 +326,8 @@ class behat_tool_lifecycle extends behat_base { * * @When /^I should not see the tool "([^"]*)" in any row of the "([^"]*)" table$/ * - * @param $tool string identifier of the tool - * @param $tablename string identifier of the table + * @param string $tool Identifier of the tool + * @param string $tablename Identifier of the table * @throws Exception */ public function i_should_not_see_the_tool_in_any_row_of_the_table($tool, $tablename) { diff --git a/tests/generator/lib.php b/tests/generator/lib.php index 408733afebf5da182e84f9f9b5398d3f36f699cc..254c12d688aa72b36157be952f3eb173ff30c911 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -14,6 +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/>. +/** + * tool_lifecycle test generator + * + * @package tool_lifecycle + * @category test + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); use tool_lifecycle\entity\process; @@ -27,7 +35,7 @@ use tool_lifecycle\manager\workflow_manager; use tool_lifecycle\settings_type; /** - * tool_lifecycle generator tests + * tool_lifecycle test generator * * @package tool_lifecycle * @category test @@ -36,6 +44,7 @@ use tool_lifecycle\settings_type; */ class tool_lifecycle_generator extends testing_module_generator { + /** @var array $defaultsteps Default steps configuration. */ private static $defaultsteps = [ "deletecourse" => [ "maximumdeletionspercron" => 10 @@ -50,6 +59,8 @@ class tool_lifecycle_generator extends testing_module_generator { "maximumbackupspercron" => 10 ], ]; + + /** @var array $defaulttrigger Default trigger configuration. */ private static $defaulttrigger = [ "startdatedelay" => [ "delay" => 10000 @@ -102,6 +113,7 @@ class tool_lifecycle_generator extends testing_module_generator { * Creates an artificial workflow without steps, which is triggered manually. * @param \stdClass $triggersettings settings of the manual trigger * @return workflow + * @throws moodle_exception */ public static function create_manual_workflow($triggersettings) { // Create Workflow. @@ -123,9 +135,9 @@ class tool_lifecycle_generator extends testing_module_generator { /** * Creates a step for a given workflow and stores it in the DB - * @param $instancename - * @param $subpluginname - * @param $workflowid + * @param string $instancename Name of the subplugin instance. + * @param string $subpluginname Name of the subplugin type. + * @param int $workflowid Id of the workflow. * @return step_subplugin created step */ public static function create_step($instancename, $subpluginname, $workflowid) { @@ -136,10 +148,10 @@ class tool_lifecycle_generator extends testing_module_generator { /** * Creates a trigger for a given workflow and stores it in the DB - * @param $instancename - * @param $subpluginname - * @param $workflowid - * @return step_subplugin created step + * @param string $instancename Name of the subplugin instance. + * @param string $subpluginname Name of the subplugin type. + * @param int $workflowid Id of the workflow. + * @return trigger_subplugin created step */ public static function create_trigger($instancename, $subpluginname, $workflowid) { $trigger = new trigger_subplugin($instancename, $subpluginname, $workflowid); @@ -149,6 +161,9 @@ class tool_lifecycle_generator extends testing_module_generator { /** * Creates an artificial workflow with three steps. + * @return workflow + * @throws coding_exception + * @throws moodle_exception */ public static function create_workflow_with_steps() { $workflow = self::create_workflow(); @@ -158,6 +173,13 @@ class tool_lifecycle_generator extends testing_module_generator { return $workflow; } + /** + * Create a process for a combination of course and workflow. + * @param int $courseid Id of the course. + * @param int $workflowid Id of the workflow. + * @return process + * @throws dml_exception + */ public static function create_process($courseid, $workflowid) { global $DB; diff --git a/tests/manual_trigger_tools_test.php b/tests/manual_trigger_tools_test.php index a0ded7f9af40ec851e066b7f4b2d7f9f8465b4f8..a23ebf4a0efafb47125c3bead422e333e3a3bf8b 100644 --- a/tests/manual_trigger_tools_test.php +++ b/tests/manual_trigger_tools_test.php @@ -14,9 +14,18 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Tests assembly of manual trigger tools. + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2018 Tobias Reischmann, Jan Dageforde WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); use tool_lifecycle\action; +use tool_lifecycle\entity\workflow; use tool_lifecycle\manager\workflow_manager; use tool_lifecycle\manager\trigger_manager; use tool_lifecycle\local\data\manual_trigger_tool; @@ -30,15 +39,29 @@ use tool_lifecycle\local\data\manual_trigger_tool; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tool_lifecycle_manual_trigger_tools_testcase extends \advanced_testcase { + /** Icon of the manual trigger 1. */ const MANUAL_TRIGGER1_ICON = 't/up'; + /** Display name of the manual trigger 1. */ const MANUAL_TRIGGER1_DISPLAYNAME = 'Up'; + /** Capability of the manual trigger 1. */ const MANUAL_TRIGGER1_CAPABILITY = 'moodle/course:manageactivities'; + + /** Icon of the manual trigger 2. */ const MANUAL_TRIGGER2_ICON = 't/down'; + /** Display name of the manual trigger 2. */ const MANUAL_TRIGGER2_DISPLAYNAME = 'Down'; + /** Capability of the manual trigger 2. */ const MANUAL_TRIGGER2_CAPABILITY = 'moodle/course:view'; + + /** @var workflow $workflow1 Instance of the first workflow. */ private $workflow1; + /** @var workflow $workflow1 Instance of the second workflow. */ private $workflow2; + /** + * Setup the testcase. + * @throws coding_exception + */ public function setUp() { global $USER; $this->resetAfterTest(true); @@ -97,8 +120,8 @@ class tool_lifecycle_manual_trigger_tools_testcase extends \advanced_testcase { /** * Test if a specific manual_trigger_tool exist within an array. - * @param $expectedtool manual_trigger_tool searched trigger_tool. - * @param $tools manual_trigger_tool[] haystack. + * @param manual_trigger_tool $expectedtool searched trigger_tool. + * @param manual_trigger_tool[] $tools haystack. */ private function assert_tool_exist($expectedtool, $tools) { $found = false; diff --git a/tests/manually_triggered_process_test.php b/tests/manually_triggered_process_test.php index 25aa9220eff6544f93bf0922bdd6eea3e279f5d6..96546cca0789081abf9ca04beef48b94b75d4233 100644 --- a/tests/manually_triggered_process_test.php +++ b/tests/manually_triggered_process_test.php @@ -14,12 +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/>. +/** + * Manually triggers a process and tests if process courses proceeds the process as expected. + * + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2018 WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/generator/lib.php'); require_once(__DIR__ . '/../lib.php'); use tool_lifecycle\action; +use tool_lifecycle\entity\trigger_subplugin; use tool_lifecycle\manager\settings_manager; use tool_lifecycle\manager\workflow_manager; use tool_lifecycle\manager\trigger_manager; @@ -37,13 +47,24 @@ use tool_lifecycle\settings_type; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tool_lifecycle_manually_triggered_process_testcase extends \advanced_testcase { + /** Icon of the manual trigger. */ const MANUAL_TRIGGER1_ICON = 't/up'; + /** Display name of the manual trigger. */ const MANUAL_TRIGGER1_DISPLAYNAME = 'Up'; + /** Capability of the manual trigger. */ const MANUAL_TRIGGER1_CAPABILITY = 'moodle/course:manageactivities'; + + /** @var trigger_subplugin[] $trigger Instances of the triggers under test. */ private $trigger; + /** @var array $course Instance of the course under test. */ private $course; + /** + * Setup the testcase. + * @throws coding_exception + * @throws moodle_exception + */ public function setUp() { global $USER; diff --git a/tests/persistence/persist_process_data_test.php b/tests/persistence/persist_process_data_test.php index dafd44e3e8d55d1e7d0aee39c1ae74739deb1c36..676a76ee6beb4db0076421fd586fbfb3553409f3 100644 --- a/tests/persistence/persist_process_data_test.php +++ b/tests/persistence/persist_process_data_test.php @@ -14,10 +14,19 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Tests creating storing and retrieving process data. + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/../../lib.php'); +use tool_lifecycle\entity\process; use \tool_lifecycle\manager\process_manager; use \tool_lifecycle\manager\process_data_manager; use \tool_lifecycle\manager\step_manager; @@ -32,12 +41,19 @@ use \tool_lifecycle\manager\step_manager; */ class tool_lifecycle_persist_process_data_testcase extends \advanced_testcase { - /** process*/ + /** @var process $process Instance of the process. */ private $process; + /** Key of the process data to be stored and retrieved. */ const KEY = 'key123'; + /** Value of the process data to be stored and retrieved. */ const VALUE = 'value123'; + /** + * Setup the testcase. + * @throws coding_exception + * @throws dml_exception + */ public function setUp() { $this->resetAfterTest(true); $generator = $this->getDataGenerator()->get_plugin_generator('tool_lifecycle'); diff --git a/tests/persistence/persist_process_test.php b/tests/persistence/persist_process_test.php index aa99b5aefcce8fa4d3c603ad4ec4c10f1c4916cd..f66d51e88d1d117517dd5e1fb62edb0400da6d65 100644 --- a/tests/persistence/persist_process_test.php +++ b/tests/persistence/persist_process_test.php @@ -14,10 +14,19 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Tests creating storing and retrieving a process object. + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/../../lib.php'); +use tool_lifecycle\entity\workflow; use tool_lifecycle\manager\delayed_courses_manager; use \tool_lifecycle\manager\process_manager; @@ -31,12 +40,16 @@ use \tool_lifecycle\manager\process_manager; */ class tool_lifecycle_persist_process_testcase extends \advanced_testcase { - /** workflow */ + /** @var workflow $workflow Instance of the workflow. */ private $workflow; - /** course */ + /** @var array $course Instance of the course. */ private $course; + /** + * Setup the testcase. + * @throws coding_exception + */ public function setUp() { $this->resetAfterTest(true); $generator = $this->getDataGenerator()->get_plugin_generator('tool_lifecycle'); @@ -73,7 +86,6 @@ class tool_lifecycle_persist_process_testcase extends \advanced_testcase { * Tests deletion of a process when rolledback. */ public function test_process_rollback() { - global $CFG; $process = process_manager::create_process($this->course->id, $this->workflow->id); delayed_courses_manager::set_course_delayed($process->courseid, get_config('tool_lifecycle', 'duration')); process_manager::rollback_process($process); diff --git a/tests/persistence/persist_step_test.php b/tests/persistence/persist_step_test.php index 36e17efefc1140ef01fb6110bc5928be31c801af..a6ffd246b5198b6adeb5368c82d49827e93adfc1 100644 --- a/tests/persistence/persist_step_test.php +++ b/tests/persistence/persist_step_test.php @@ -14,6 +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/>. +/** + * Tests creating storing and retrieving a step object. + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/../../lib.php'); @@ -32,14 +40,17 @@ use \tool_lifecycle\manager\step_manager; */ class tool_lifecycle_persist_step_testcase extends \advanced_testcase { - /** workflow */ + /** @var workflow $workflow Instance of the workflow. */ private $workflow; - const INSTANCENAME = 'myinstance'; - const STEPNAME = 'stepname'; + /** @var tool_lifecycle_generator $generator Instance of the test generator. */ private $generator; - + /** + * Setup the testcase. + * @throws coding_exception + * @throws moodle_exception + */ public function setUp() { $this->resetAfterTest(true); $this->generator = $this->getDataGenerator()->get_plugin_generator('tool_lifecycle'); diff --git a/tests/persistence/persist_workflow_test.php b/tests/persistence/persist_workflow_test.php index 86cef5934780be4ab3d671cbe21e2b31716385a7..7f86028bed093dcbc562fcfa8acf32dcbead7b32 100644 --- a/tests/persistence/persist_workflow_test.php +++ b/tests/persistence/persist_workflow_test.php @@ -14,6 +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/>. +/** + * Tests creating storing and retrieving a workflow object. + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/../../lib.php'); @@ -31,9 +39,12 @@ use \tool_lifecycle\manager\workflow_manager; */ class tool_lifecycle_persist_workflow_testcase extends \advanced_testcase { - /** workflow */ + /** @var workflow $workflow Instance of the workflow. */ private $workflow; + /** + * Setup the testcase. + */ public function setUp() { $this->resetAfterTest(true); $record = new stdClass(); diff --git a/tests/process_status_message_test.php b/tests/process_status_message_test.php index 726fbd28eeaa51a07ae8a26a6de23a7a1f8abd20..1b07f797cd54cdd27bf25e3f31de4c0d89b7c133 100644 --- a/tests/process_status_message_test.php +++ b/tests/process_status_message_test.php @@ -14,9 +14,18 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Tests assembly of manual trigger tools. + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2018 Tamara Gunkel, Jan Dageforde WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); use tool_lifecycle\action; +use tool_lifecycle\entity\workflow; use tool_lifecycle\manager\workflow_manager; /** @@ -28,13 +37,23 @@ use tool_lifecycle\manager\workflow_manager; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tool_lifecycle_process_status_message_testcase extends \advanced_testcase { + /** Icon of the manual trigger. */ const MANUAL_TRIGGER1_ICON = 't/up'; + /** Display name of the manual trigger. */ const MANUAL_TRIGGER1_DISPLAYNAME = 'Up'; + /** Capability of the manual trigger. */ const MANUAL_TRIGGER1_CAPABILITY = 'moodle/course:manageactivities'; + + /** @var workflow $workflow Workflow of this test. */ private $workflow; + /** @var tool_lifecycle_generator $generator Instance of the test generator. */ private $generator; + /** + * Setup the testcase. + * @throws coding_exception + */ public function setUp() { global $USER; diff --git a/tests/settings_manager_test.php b/tests/settings_manager_test.php index abe2ac1e85a3f27bcb21bb292db35e9dea5fcb34..d2eb7594d323f7f2af59a80980dd355d8d60b22c 100644 --- a/tests/settings_manager_test.php +++ b/tests/settings_manager_test.php @@ -14,9 +14,19 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Tests the settings manager. + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); use tool_lifecycle\entity\step_subplugin; +use tool_lifecycle\entity\trigger_subplugin; +use tool_lifecycle\entity\workflow; use tool_lifecycle\manager\step_manager; use tool_lifecycle\manager\settings_manager; use tool_lifecycle\manager\subplugin_manager; @@ -33,14 +43,22 @@ use tool_lifecycle\settings_type; */ class tool_lifecycle_settings_manager_testcase extends \advanced_testcase { - /** step_subplugin */ + /** @var step_subplugin $step Instance of the step plugin. */ private $step; + /** @var trigger_subplugin $trigger Instance of the trigger plugin. */ private $trigger; + /** @var workflow $workflow Instance of the workflow. */ private $workflow; + /** @var string constant value for the email. */ const EMAIL_VALUE = 'value'; + /** @var int constant value for start delay. */ const STARTDELAY_VALUE = 100; + /** + * Setup the testcase. + * @throws coding_exception + */ public function setUp() { $this->resetAfterTest(false); $generator = $this->getDataGenerator()->get_plugin_generator('tool_lifecycle'); diff --git a/tests/workflow_actions_testcase.php b/tests/workflow_actions_testcase.php index a6affc5d12dd66544ccbab53dcb1a71dc4957a06..e3a81b613f0563bd5a9216b71e5828d3f4273408 100644 --- a/tests/workflow_actions_testcase.php +++ b/tests/workflow_actions_testcase.php @@ -14,11 +14,20 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Setup for workflow actions tests. + * + * @package tool_lifecycle + * @category test + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/generator/lib.php'); require_once(__DIR__ . '/../lib.php'); +use tool_lifecycle\entity\workflow; use tool_lifecycle\manager\workflow_manager; /** @@ -26,15 +35,21 @@ use tool_lifecycle\manager\workflow_manager; * * @package tool_lifecycle * @category test - * @group tool_lifecycle * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class workflow_actions_testcase extends \advanced_testcase { + /** @var workflow $workflow1 Instance of the first workflow. */ protected $workflow1; + /** @var workflow $workflow2 Instance of the second workflow. */ protected $workflow2; + /** @var workflow $workflow3 Instance of the third workflow. */ protected $workflow3; + /** + * Setup the testcase. + * @throws coding_exception + */ public function setUp() { global $USER; // We do not need a sesskey check in theses tests. diff --git a/tests/workflow_activate_disable_duplicate_test.php b/tests/workflow_activate_disable_duplicate_test.php index 401a0538b2dfbbfedb1a51d0db80bbc9517f27d9..f63f2e99d7fa5a78c6c243f8e9b5025e3ce6fdf9 100644 --- a/tests/workflow_activate_disable_duplicate_test.php +++ b/tests/workflow_activate_disable_duplicate_test.php @@ -14,6 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Tests activating, disabling and duplicating workflows + * + * @package tool_lifecycle + * @category test + * @group tool_lifecycle + * @copyright 2018 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/generator/lib.php'); diff --git a/trigger/categories/lang/de/lifecycletrigger_categories.php b/trigger/categories/lang/de/lifecycletrigger_categories.php index 306f56c3a8ba2b913db11629a3c298c8eaff448e..4711e721d139f5258636ec01062c9a57999fe45b 100644 --- a/trigger/categories/lang/de/lifecycletrigger_categories.php +++ b/trigger/categories/lang/de/lifecycletrigger_categories.php @@ -15,10 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Lang strings for categories delay trigger + * Lang strings for categories trigger * - * @package tool_lifecycle_trigger - * @subpackage startdatedelay + * @package lifecycletrigger_categories * @copyright 2018 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/categories/lang/en/lifecycletrigger_categories.php b/trigger/categories/lang/en/lifecycletrigger_categories.php index 8236d9dd0596991790624a2f1023d8635eaae229..178e0364791555d8dedf7079b0658b46ec3caa98 100644 --- a/trigger/categories/lang/en/lifecycletrigger_categories.php +++ b/trigger/categories/lang/en/lifecycletrigger_categories.php @@ -15,10 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Lang strings for categories delay trigger + * Lang strings for categories trigger * - * @package tool_lifecycle_trigger - * @subpackage startdatedelay + * @package lifecycletrigger_categories * @copyright 2018 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/categories/lib.php b/trigger/categories/lib.php index 21fe0f450d073fc1126ac392439e132223a2e2d9..902231ae3a901c61eeb5da81fe314ddf8f43da25 100644 --- a/trigger/categories/lib.php +++ b/trigger/categories/lib.php @@ -15,11 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the subplugintype trigger - * It has to be implemented by all subplugins. + * Trigger subplugin to include or exclude courses of certain categories. * - * @package tool_lifecycle_trigger - * @subpackage categories + * @package lifecycletrigger_categories * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -36,14 +34,16 @@ require_once(__DIR__ . '/../../lib.php'); /** * Class which implements the basic methods necessary for a cleanyp courses trigger subplugin - * @package tool_lifecycle_trigger + * @package lifecycletrigger_categories + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class categories extends base_automatic { /** * Checks the course and returns a repsonse, which tells if the course should be further processed. - * @param $course object to be processed. - * @param $triggerid int id of the trigger instance. + * @param object $course Course to be processed. + * @param int $triggerid Id of the trigger instance. * @return trigger_response */ public function check_course($course, $triggerid) { @@ -51,6 +51,14 @@ class categories extends base_automatic { return trigger_response::trigger(); } + /** + * Return sql sniplet for including (or excluding) the courses belonging to specific categories + * and all their children. + * @param int $triggerid Id of the trigger. + * @return array A list containing the constructed sql fragment and an array of parameters. + * @throws \coding_exception + * @throws \dml_exception + */ public function get_course_recordset_where($triggerid) { global $DB, $CFG; $categories = settings_manager::get_settings($triggerid, settings_type::TRIGGER)['categories']; @@ -81,10 +89,18 @@ class categories extends base_automatic { return array($where, $inparams); } + /** + * The return value should be equivalent with the name of the subplugin folder. + * @return string technical name of the subplugin + */ public function get_subpluginname() { return 'categories'; } + /** + * Defines which settings each instance of the subplugin offers for the user to define. + * @return instance_setting[] containing settings keys and PARAM_TYPES + */ public function instance_settings() { return array( new instance_setting('categories', PARAM_SEQUENCE), @@ -92,6 +108,13 @@ class categories extends base_automatic { ); } + /** + * This method can be overriden, to add form elements to the form_step_instance. + * It is called in definition(). + * @param \MoodleQuickForm $mform + * @throws \coding_exception + * @throws \dml_exception + */ public function extend_add_instance_form_definition($mform) { global $DB; $categories = $DB->get_records('course_categories'); diff --git a/trigger/categories/tests/generator/lib.php b/trigger/categories/tests/generator/lib.php index 5d11fb20e7acf23fa752020ab62c254df38dea2b..6cc8b9f20f7c92036f5b88b802822e7bc2f20e80 100644 --- a/trigger/categories/tests/generator/lib.php +++ b/trigger/categories/tests/generator/lib.php @@ -14,6 +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/>. +/** + * lifecycletrigger_categories generator tests + * + * @package lifecycletrigger_categories + * @category test + * @copyright 2018 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); use tool_lifecycle\entity\trigger_subplugin; @@ -35,7 +43,9 @@ class tool_lifecycle_trigger_categories_generator extends testing_module_generat /** * Creates a trigger startdatedelay for an artificial workflow without steps. - * @return trigger_subplugin the created startdatedelay trigger. + * @param array $data Data which is used to fill the triggers with certain settings. + * @return trigger_subplugin The created startdatedelay trigger. + * @throws moodle_exception */ public static function create_trigger_with_workflow($data) { // Create Workflow. diff --git a/trigger/categories/tests/trigger_test.php b/trigger/categories/tests/trigger_test.php index 02e0e3d3b687a4ecbd61c3061de897cfebe6be7c..b841b1244e9fe31ffef620a7559ef44081bff296 100644 --- a/trigger/categories/tests/trigger_test.php +++ b/trigger/categories/tests/trigger_test.php @@ -14,8 +14,17 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Trigger test for categories trigger. + * + * @package lifecycletrigger_categories + * @group lifecycletrigger + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle\trigger; +use tool_lifecycle\entity\trigger_subplugin; use tool_lifecycle\processor; use tool_lifecycle\response\trigger_response; @@ -27,23 +36,30 @@ require_once(__DIR__ . '/generator/lib.php'); /** * Trigger test for categories trigger. * - * @package tool_lifecycle_trigger - * @category categories - * @group tool_lifecycle_trigger + * @package lifecycletrigger_categories + * @group lifecycletrigger * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tool_lifecycle_trigger_categories_testcase extends \advanced_testcase { + /** @var trigger_subplugin $excludetrigger Trigger instance that excludes a category. */ private $excludetrigger; + /** @var trigger_subplugin $includetrigger Trigger instance that includes a category. */ private $includetrigger; + /** @var \core_course_category $category A category. */ private $category; + /** @var \core_course_category $category A child category. */ private $childcategory; - /**@var processor Instance of the lifecycle processor */ + /** @var processor $processor Instance of the lifecycle processor */ private $processor; + /** + * Setup the testcase. + * @throws \moodle_exception + */ public function setUp() { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/trigger/categories/version.php b/trigger/categories/version.php index 33abaa75ed4a0bc141660f1f2d9c9cc8be92aee8..ac5c1e57602c69ec9f2a51c63be9e7afc8acf6f9 100644 --- a/trigger/categories/version.php +++ b/trigger/categories/version.php @@ -17,8 +17,7 @@ /** * Life Cycle Categories Trigger * - * @package tool_lifecycle_trigger - * @subpackage categories + * @package lifecycletrigger_categories * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/delayedcourses/db/install.php b/trigger/delayedcourses/db/install.php index 465ef53cceb6f143fbf9fdf4c852c26d97b9881e..fe8eb6195615beb54e9ac62431503ae901d9c1b2 100644 --- a/trigger/delayedcourses/db/install.php +++ b/trigger/delayedcourses/db/install.php @@ -17,8 +17,8 @@ /** * Install script for lifecycle subplugin * - * @package tool_lifecycle_trigger - * @subpackage delayedcourses + * @package lifecycletrigger_delayedcourses + * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -26,6 +26,9 @@ use tool_lifecycle\manager\trigger_manager; defined('MOODLE_INTERNAL') || die(); +/** + * Register delayed courses as initial workflow. + */ function xmldb_lifecycletrigger_delayedcourses_install() { trigger_manager::register_workflow('delayedcourses'); } \ No newline at end of file diff --git a/trigger/delayedcourses/lang/de/lifecycletrigger_delayedcourses.php b/trigger/delayedcourses/lang/de/lifecycletrigger_delayedcourses.php index 32cdc1c7a397ba54f01e0f6085f6412c79cf47a7..1dac873c8c889f9a3efc5f0eeda70f9ee99254d6 100644 --- a/trigger/delayedcourses/lang/de/lifecycletrigger_delayedcourses.php +++ b/trigger/delayedcourses/lang/de/lifecycletrigger_delayedcourses.php @@ -15,10 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Lang strings for site course trigger + * Lang strings for delayed course trigger * - * @package tool_lifecycle_trigger - * @subpackage delayedcourses + * @package lifecycletrigger_delayedcourses * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/delayedcourses/lang/en/lifecycletrigger_delayedcourses.php b/trigger/delayedcourses/lang/en/lifecycletrigger_delayedcourses.php index 088c10d13a8483e07113450d42027a372d6602fa..4a5dcdcfe56dd097397c578dd88b82c90f54604c 100644 --- a/trigger/delayedcourses/lang/en/lifecycletrigger_delayedcourses.php +++ b/trigger/delayedcourses/lang/en/lifecycletrigger_delayedcourses.php @@ -15,10 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Lang strings for site course trigger + * Lang strings for delayed course trigger * - * @package tool_lifecycle_trigger - * @subpackage delayedcourses + * @package lifecycletrigger_delayedcourses * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/delayedcourses/lib.php b/trigger/delayedcourses/lib.php index 29f5e9e228713caf52359e607fc65fee5be694f7..df7758459bdba3ffd8767aa08c6335590816752f 100644 --- a/trigger/delayedcourses/lib.php +++ b/trigger/delayedcourses/lib.php @@ -15,10 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the subplugintype trigger - * It has to be implemented by all subplugins. + * Trigger subplugin to exclude delayed courses. * - * @package tool_lifecycle + * @package lifecycletrigger_delayedcourses * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -32,25 +31,37 @@ require_once(__DIR__ . '/../lib.php'); /** * Class which implements the basic methods necessary for a life cycle trigger subplugin - * @package tool_lifecycle\trigger + * @package lifecycletrigger_delayedcourses + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class delayedcourses extends base_automatic { /** * Checks the course and returns a repsonse, which tells if the course should be further processed. - * @param $course object to be processed. - * @param $triggerid int id of the trigger instance. + * @param object $course Course to be processed. + * @param int $triggerid Id of the trigger instance. * @return trigger_response */ public function check_course($course, $triggerid) { return trigger_response::exclude(); } + /** + * Return sql which excludes delayed courses. + * @param int $triggerid Id of the trigger. + * @return array A list containing the constructed sql fragment and an array of parameters. + */ public function get_course_recordset_where($triggerid) { return delayed_courses_manager::get_course_delayed_wheresql(); } + + /** + * The return value should be equivalent with the name of the subplugin folder. + * @return string technical name of the subplugin + */ public function get_subpluginname() { return 'delayedcourses'; } diff --git a/trigger/delayedcourses/tests/generator/lib.php b/trigger/delayedcourses/tests/generator/lib.php index 1133d8c55b25a9f358fa1b863c727be6b9175e32..34c50e86f6f231ba8940c925125e52db9f81b65d 100644 --- a/trigger/delayedcourses/tests/generator/lib.php +++ b/trigger/delayedcourses/tests/generator/lib.php @@ -14,6 +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/>. +/** + * lifecycletrigger_delayedcourses generator tests + * + * @package lifecycletrigger_delayedcourses + * @category test + * @copyright 2018 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); use tool_lifecycle\entity\trigger_subplugin; diff --git a/trigger/delayedcourses/tests/trigger_test.php b/trigger/delayedcourses/tests/trigger_test.php index a8facbd17c8fdfa95621beae8de557edf07fc3e0..2ffaf2afaf0f38d058bcc6dd6d57bd11a5a3c12b 100644 --- a/trigger/delayedcourses/tests/trigger_test.php +++ b/trigger/delayedcourses/tests/trigger_test.php @@ -14,8 +14,17 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Trigger test for delayed courses trigger. + * + * @package lifecycletrigger_delayedcourses + * @group lifecycletrigger + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle\trigger; +use tool_lifecycle\entity\trigger_subplugin; use tool_lifecycle\entity\workflow; use tool_lifecycle\processor; use tool_lifecycle\manager\delayed_courses_manager; @@ -29,23 +38,23 @@ require_once(__DIR__ . '/generator/lib.php'); /** * Trigger test for delayed courses trigger. * - * @package tool_lifecycle_trigger - * @category delayedcourses - * @group tool_lifecycle_trigger + * @package lifecycletrigger_delayedcourses + * @group lifecycletrigger * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tool_lifecycle_trigger_delayedcourses_testcase extends \advanced_testcase { + /** @var trigger_subplugin $triggerinstance Instance of the delayedcourses trigger. */ private $triggerinstance; - /**@var processor Instance of the lifecycle processor */ + /** @var processor Instance of the lifecycle processor */ private $processor; - /**@var workflow Workflow delaying only processes for itself */ + /** @var workflow Workflow delaying only processes for itself */ private $workflow; - /**@var workflow Workflow delaying processes for all workflows */ + /** @var workflow Workflow delaying processes for all workflows */ private $workflowdealayingallworkflows; public function setUp() { diff --git a/trigger/delayedcourses/version.php b/trigger/delayedcourses/version.php index c9ff0a1e05d4e825f5628b6b8a0a47c1388f4aac..5b1fa5e9bf8a2782a7003df6b914c7074e06e8aa 100644 --- a/trigger/delayedcourses/version.php +++ b/trigger/delayedcourses/version.php @@ -15,9 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Life Cycle Site Course Trigger + * Life Cycle Delayed Course Trigger * - * @package tool_lifecycle_trigger + * @package lifecycletrigger_delayedcourses * @subpackage delayedcourses * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/trigger/lib.php b/trigger/lib.php index ef711d668f800e31a66871e17d0ec163bbe84190..1c68d0c42aecd844be1eb167a7959e577ccc3312 100644 --- a/trigger/lib.php +++ b/trigger/lib.php @@ -15,9 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the subplugintype trigger - * It has to be implemented by all subplugins. + * Interface for the subplugintype trigger. * + * It has to be implemented by all subplugins. * @package tool_lifecycle * @subpackage trigger * @copyright 2017 Tobias Reischmann WWU @@ -31,8 +31,11 @@ defined('MOODLE_INTERNAL') || die(); /** * This class bundles different functions necessary for every trigger of a workflow. + * * This class should not be extended directly. Please use base_manual or base_automatic. - * @package tool_lifecycle\trigger + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class base { @@ -43,6 +46,7 @@ abstract class base { public abstract function get_subpluginname(); /** + * Defines which settings each instance of the subplugin offers for the user to define. * @return instance_setting[] containing settings keys and PARAM_TYPES */ public function instance_settings() { @@ -68,8 +72,8 @@ abstract class base { /** * This method can be overriden, to add additional data validation to the instance form. - * @param $error - * @param $data + * @param array $error Array containing all errors. + * @param array $data Data passed from the moodle form to be validated */ public function extend_add_instance_form_validation(&$error, $data) { } @@ -95,6 +99,7 @@ abstract class base { /** * Returns the status message for the trigger. * @return string status message + * @throws \coding_exception */ public function get_status_message() { return get_string("workflow_started", "tool_lifecycle"); @@ -104,19 +109,26 @@ abstract class base { /** * This class represents an automatic trigger. + * * It is used when workflow should be started based on a specific logic. - * @package tool_lifecycle\trigger + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class base_automatic extends base { /** * Checks the course and returns a repsonse, which tells if the course should be further processed. - * @param $course object to be processed. - * @param $triggerid int id of the trigger instance. + * @param object $course Course to be processed. + * @param int $triggerid Id of the trigger instance. * @return trigger_response */ public abstract function check_course($course, $triggerid); + /** + * Defines if the trigger subplugin is started manually or automatically. + * @return bool + */ public function is_manual_trigger() { return false; } @@ -126,7 +138,8 @@ abstract class base_automatic extends base { * The return value has to consist of an array with two values. The first one includes the where sql statement, * which will be concatenated using an 'AND' to the recordset query (e.g. '{course}.id = $courseid'). * The second one is the set of parameters for the sql query, which will be merged with other param sets. - * @params $triggerid int id of the trigger. + * @param int $triggerid Id of the trigger. + * @return array A list containing the constructed sql fragment and an array of parameters. */ public function get_course_recordset_where($triggerid) { return array('', array()); @@ -135,18 +148,28 @@ abstract class base_automatic extends base { /** * This class represents a manual trigger. + * * It is used to enable user to manually start processes for workflows. - * @package tool_lifecycle\trigger + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class base_manual extends base { + /** + * Defines if the trigger subplugin is started manually or automatically. + * @return bool + */ public function is_manual_trigger() { return true; } } + /** * Class representing a local settings object for a subplugin instance. - * @package tool_lifecycle\trigger + * @package tool_lifecycle + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class instance_setting { diff --git a/trigger/manual/lang/de/lifecycletrigger_manual.php b/trigger/manual/lang/de/lifecycletrigger_manual.php index 09d0a9d7ea039caa4ad3817eda04845d79763b3a..efde6b1165d08996d6f027bb727580f0780b1807 100644 --- a/trigger/manual/lang/de/lifecycletrigger_manual.php +++ b/trigger/manual/lang/de/lifecycletrigger_manual.php @@ -17,8 +17,7 @@ /** * Lang strings for manual trigger * - * @package tool_lifecycle_trigger - * @subpackage manual + * @package lifecycletrigger_manual * @copyright 2018 WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/manual/lang/en/lifecycletrigger_manual.php b/trigger/manual/lang/en/lifecycletrigger_manual.php index cf11894fad487f93394f9af579270af78c9aeb3e..94b3c1185974d4916993db3080b2a0b76a9fb1c8 100644 --- a/trigger/manual/lang/en/lifecycletrigger_manual.php +++ b/trigger/manual/lang/en/lifecycletrigger_manual.php @@ -17,8 +17,7 @@ /** * Lang strings for manual trigger * - * @package tool_lifecycle_trigger - * @subpackage manual + * @package lifecycletrigger_manual * @copyright 2018 WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/manual/lib.php b/trigger/manual/lib.php index 836db66346aeefb8679fcc947cc81d8ff439deb6..b3bc945e886f45c602a6c1e9d8c05d919951360d 100644 --- a/trigger/manual/lib.php +++ b/trigger/manual/lib.php @@ -15,11 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the subplugintype trigger - * It has to be implemented by all subplugins. + * Trigger subplugin for manual triggers. * - * @package tool_lifecycle_trigger - * @subpackage manual + * @package lifecycletrigger_manual * @copyright 2018 WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -30,15 +28,22 @@ require_once(__DIR__ . '/../lib.php'); /** * Class which implements the basic methods necessary for a life cycle trigger subplugin - * @package tool_lifecycle_trigger + * @package lifecycletrigger_manual + * @copyright 2018 WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class manual extends base_manual { + /** + * The return value should be equivalent with the name of the subplugin folder. + * @return string technical name of the subplugin + */ public function get_subpluginname() { return 'manual'; } /** + * Defines which settings each instance of the subplugin offers for the user to define. * @return instance_setting[] containing settings keys and PARAM_TYPES */ public function instance_settings() { @@ -52,6 +57,7 @@ class manual extends base_manual { * This method can be overriden, to add form elements to the form_step_instance. * It is called in definition(). * @param \MoodleQuickForm $mform + * @throws \coding_exception */ public function extend_add_instance_form_definition($mform) { $elementname = 'icon'; @@ -84,8 +90,10 @@ class manual extends base_manual { /** * Make all fields required. - * @param $error - * @param $data + * @param array $error Array containing all errors. + * @param array $data Data passed from the moodle form to be validated. + * @return void the extended error array. + * @throws \coding_exception */ public function extend_add_instance_form_validation(&$error, $data) { parent::extend_add_instance_form_validation($error, $data); diff --git a/trigger/manual/version.php b/trigger/manual/version.php index c6f0f0a127655be820f5ff108b9f980c87036ac0..eba9484f26b7a18694cd338020498aa24471488d 100644 --- a/trigger/manual/version.php +++ b/trigger/manual/version.php @@ -17,8 +17,7 @@ /** * Life Cycle Manual Trigger * - * @package tool_lifecycle_trigger - * @subpackage manual + * @package lifecycletrigger_manual * @copyright 2018 WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/sitecourse/db/install.php b/trigger/sitecourse/db/install.php index b251a39dda13f791be63b67835837b2cbed5b19c..6f5600aa6384b40e2e6eb24639a7c7fdb4d73663 100644 --- a/trigger/sitecourse/db/install.php +++ b/trigger/sitecourse/db/install.php @@ -17,8 +17,7 @@ /** * Install script for lifecycle subplugin * - * @package tool_lifecycle_trigger - * @subpackage sitecourse + * @package lifecycletrigger_sitecourse * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -26,6 +25,9 @@ use tool_lifecycle\manager\trigger_manager; defined('MOODLE_INTERNAL') || die(); +/** + * Register site course trigger exclusion as initial workflow. + */ function xmldb_lifecycletrigger_sitecourse_install() { trigger_manager::register_workflow('sitecourse'); } \ No newline at end of file diff --git a/trigger/sitecourse/lang/de/lifecycletrigger_sitecourse.php b/trigger/sitecourse/lang/de/lifecycletrigger_sitecourse.php index ac70fe67be8e68a6c581331190043b4b0a473cbb..acd54b6dab51cd577a28a94c32b0858998b00b71 100644 --- a/trigger/sitecourse/lang/de/lifecycletrigger_sitecourse.php +++ b/trigger/sitecourse/lang/de/lifecycletrigger_sitecourse.php @@ -17,8 +17,7 @@ /** * Lang strings for site course trigger * - * @package tool_lifecycle_trigger - * @subpackage startdatedelay + * @package lifecycletrigger_sitecourse * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/sitecourse/lang/en/lifecycletrigger_sitecourse.php b/trigger/sitecourse/lang/en/lifecycletrigger_sitecourse.php index e5496ca9e5b0e1d53c3a7483f67c8412e9467b9d..330ef9f6ec34a3f4289fae7e6d3decb0c73eaf0f 100644 --- a/trigger/sitecourse/lang/en/lifecycletrigger_sitecourse.php +++ b/trigger/sitecourse/lang/en/lifecycletrigger_sitecourse.php @@ -17,8 +17,7 @@ /** * Lang strings for site course trigger * - * @package tool_lifecycle_trigger - * @subpackage startdatedelay + * @package lifecycletrigger_sitecourse * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/sitecourse/lib.php b/trigger/sitecourse/lib.php index d3bf4efc961354ad61b1555cddf287a7e6818f78..3dea124597e9d018ebdc007fce8223bf8d6ba360 100644 --- a/trigger/sitecourse/lib.php +++ b/trigger/sitecourse/lib.php @@ -15,10 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the subplugintype trigger - * It has to be implemented by all subplugins. + * Trigger subplugin that excludes the sitecourse. * - * @package tool_lifecycle + * @package lifecycletrigger_sitecourse * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -31,14 +30,16 @@ require_once(__DIR__ . '/../lib.php'); /** * Class which implements the basic methods necessary for a life cycle trigger subplugin - * @package tool_lifecycle\trigger + * @package lifecycletrigger_sitecourse + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class sitecourse extends base_automatic { /** * Checks the course and returns a repsonse, which tells if the course should be further processed. - * @param $course object to be processed. - * @param $triggerid int id of the trigger instance. + * @param object $course Course to be processed. + * @param int $triggerid Id of the trigger instance. * @return trigger_response */ public function check_course($course, $triggerid) { @@ -48,12 +49,23 @@ class sitecourse extends base_automatic { return trigger_response::next(); } + /** + * Sql that queries only the sitecourse. + * @param int $triggerid Id of the trigger. + * @return array A list containing the constructed sql fragment and an array of parameters. + * @throws \coding_exception + * @throws \dml_exception + */ public function get_course_recordset_where($triggerid) { global $DB; list($insql, $inparam) = $DB->get_in_or_equal(SITEID, SQL_PARAMS_NAMED); return array("{course}.id {$insql}", $inparam); } + /** + * The return value should be equivalent with the name of the subplugin folder. + * @return string technical name of the subplugin + */ public function get_subpluginname() { return 'sitecourse'; } diff --git a/trigger/sitecourse/tests/generator/lib.php b/trigger/sitecourse/tests/generator/lib.php index 584db79dc31ca600ce982b39f33d83a16550230d..94d01c2717de9aa665c593e9d1c124504918a999 100644 --- a/trigger/sitecourse/tests/generator/lib.php +++ b/trigger/sitecourse/tests/generator/lib.php @@ -14,6 +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/>. +/** + * lifecycletrigger_sitecourse generator tests + * + * @package lifecycletrigger_sitecourse + * @category test + * @copyright 2018 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); use tool_lifecycle\entity\trigger_subplugin; diff --git a/trigger/sitecourse/tests/trigger_test.php b/trigger/sitecourse/tests/trigger_test.php index 1fb30fa0c93d1ca97949a4a2f533e9ec42c9a721..66622f18fb05ca0205a36fdb4ae67001601952ee 100644 --- a/trigger/sitecourse/tests/trigger_test.php +++ b/trigger/sitecourse/tests/trigger_test.php @@ -14,8 +14,17 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Trigger test for course site trigger. + * + * @package lifecycletrigger_sitecourse + * @group lifecycletrigger + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle\trigger; +use tool_lifecycle\entity\trigger_subplugin; use tool_lifecycle\response\trigger_response; defined('MOODLE_INTERNAL') || die(); @@ -26,16 +35,20 @@ require_once(__DIR__ . '/generator/lib.php'); /** * Trigger test for course site trigger. * - * @package tool_lifecycle_trigger - * @category startdatedelay - * @group tool_lifecycle_trigger + * @package lifecycletrigger_sitecourse + * @group lifecycletrigger * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tool_lifecycle_trigger_sitecourse_testcase extends \advanced_testcase { + /** @var trigger_subplugin $triggerinstance Instance of the trigger. */ private $triggerinstance; + /** + * Setup the testcase. + * @throws coding_exception + */ public function setUp() { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/trigger/sitecourse/version.php b/trigger/sitecourse/version.php index d89e6c1c1b79aff3d757b10e2a0c7b0632189665..1e4fcac1658e3c44e9b4d69f05433eab06432abb 100644 --- a/trigger/sitecourse/version.php +++ b/trigger/sitecourse/version.php @@ -17,8 +17,7 @@ /** * Life Cycle Site Course Trigger * - * @package tool_lifecycle_trigger - * @subpackage sitecourse + * @package lifecycletrigger_sitecourse * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/specificdate/lang/de/lifecycletrigger_specificdate.php b/trigger/specificdate/lang/de/lifecycletrigger_specificdate.php index fc24f19583c6a5694f308ea30c230316200d990b..8e64a25aac0ebf79e53070b9b9e247b5d9bf7a37 100644 --- a/trigger/specificdate/lang/de/lifecycletrigger_specificdate.php +++ b/trigger/specificdate/lang/de/lifecycletrigger_specificdate.php @@ -15,10 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Lang strings for categories delay trigger + * Lang strings for specific date trigger * - * @package tool_lifecycle_trigger - * @subpackage startdatedelay + * @package lifecycletrigger_specificdate * @copyright 2018 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/specificdate/lang/en/lifecycletrigger_specificdate.php b/trigger/specificdate/lang/en/lifecycletrigger_specificdate.php index 1b4ffabf912bfc681ee0892bc84ef8fb5ac9e5e3..1529ac202ab7ff06356e76b522826d5017345e0a 100644 --- a/trigger/specificdate/lang/en/lifecycletrigger_specificdate.php +++ b/trigger/specificdate/lang/en/lifecycletrigger_specificdate.php @@ -15,10 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Lang strings for categories delay trigger + * Lang strings for specific date trigger * - * @package tool_lifecycle_trigger - * @subpackage startdatedelay + * @package lifecycletrigger_specificdate * @copyright 2018 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/specificdate/lib.php b/trigger/specificdate/lib.php index 6c362fac9188ce58e54b0c9c95b9c7b03ff38034..2782a49fe8516183f3823e07619cdabc921194e2 100644 --- a/trigger/specificdate/lib.php +++ b/trigger/specificdate/lib.php @@ -15,11 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the subplugintype trigger - * It has to be implemented by all subplugins. + * Trigger subplugin which triggers on specific dates only. * - * @package tool_lifecycle_trigger - * @subpackage specificdate + * @package lifecycletrigger_specificdate * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -37,14 +35,16 @@ require_once(__DIR__ . '/../../lib.php'); /** * Class which implements the basic methods necessary for a cleanyp courses trigger subplugin - * @package tool_lifecycle_trigger + * @package lifecycletrigger_specificdate + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class specificdate extends base_automatic { /** * Checks the course and returns a repsonse, which tells if the course should be further processed. - * @param $course object to be processed. - * @param $triggerid int id of the trigger instance. + * @param object $course Course to be processed. + * @param int $triggerid Id of the trigger instance. * @return trigger_response */ public function check_course($course, $triggerid) { @@ -52,6 +52,16 @@ class specificdate extends base_automatic { return trigger_response::trigger(); } + /** + * Returns true or false, depending on if the current date is one of the specified days, + * at which the trigger should run. + * @param int $triggerid Id of the trigger. + * @return array A list containing the constructed sql fragment and an array of parameters. + * @throws \coding_exception + * @throws \dml_exception + * @throws \moodle_exception + * @throws \Exception + */ public function get_course_recordset_where($triggerid) { $settings = settings_manager::get_settings($triggerid, settings_type::TRIGGER); $lastrun = getdate($settings['timelastrun']); @@ -93,7 +103,9 @@ class specificdate extends base_automatic { /** * Parses the dates settings to actual date objects. - * @param $datesraw string + * @param string $datesraw Raw data from the form representing dates. + * @return array + * @throws \moodle_exception */ private function parse_dates($datesraw) { $dates = preg_split('/\r\n|\r|\n/', $datesraw); @@ -111,10 +123,18 @@ class specificdate extends base_automatic { return $result; } + /** + * The return value should be equivalent with the name of the subplugin folder. + * @return string technical name of the subplugin + */ public function get_subpluginname() { return 'specificdate'; } + /** + * Defines which settings each instance of the subplugin offers for the user to define. + * @return instance_setting[] containing settings keys and PARAM_TYPES + */ public function instance_settings() { return array( new instance_setting('dates', PARAM_TEXT), @@ -122,15 +142,27 @@ class specificdate extends base_automatic { ); } + /** + * This method can be overriden, to add form elements to the form_step_instance. + * It is called in definition(). + * @param \MoodleQuickForm $mform + * @throws \coding_exception + */ public function extend_add_instance_form_definition($mform) { $mform->addElement('textarea', 'dates', get_string('dates', 'lifecycletrigger_specificdate'), get_string('dates_desc', 'lifecycletrigger_specificdate')); - $mform->setType('categories', PARAM_TEXT); + $mform->setType('dates', PARAM_TEXT); $mform->addElement('hidden', 'timelastrun'); $mform->setDefault('timelastrun', time()); $mform->setType('timelastrun', PARAM_INT); } + /** + * Validate parsable dates. + * @param array $error Array containing all errors. + * @param array $data Data passed from the moodle form to be validated. + * @throws \coding_exception + */ public function extend_add_instance_form_validation(&$error, $data) { $dates = preg_split('/\r\n|\r|\n/', $data['dates']); foreach ($dates as $date) { diff --git a/trigger/specificdate/version.php b/trigger/specificdate/version.php index 145de45be8066c8d5edb6151a72bd57fb0b4b585..a7f69e70cafaaf0d1bec92e91b36db5d55c1605e 100644 --- a/trigger/specificdate/version.php +++ b/trigger/specificdate/version.php @@ -17,8 +17,7 @@ /** * Life Cycle Specific Date Trigger * - * @package tool_lifecycle_trigger - * @subpackage specificdate + * @package lifecycletrigger_specificdate * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/startdatedelay/lang/de/lifecycletrigger_startdatedelay.php b/trigger/startdatedelay/lang/de/lifecycletrigger_startdatedelay.php index 153e7359530c8d2e3f461ae09343b130c343a4c2..7f92b7c8bde043dced9656728bf8ffa3631a6bad 100644 --- a/trigger/startdatedelay/lang/de/lifecycletrigger_startdatedelay.php +++ b/trigger/startdatedelay/lang/de/lifecycletrigger_startdatedelay.php @@ -17,8 +17,7 @@ /** * Lang strings for start date delay trigger * - * @package tool_lifecycle_trigger - * @subpackage startdatedelay + * @package lifecycletrigger_startdatedelay * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/startdatedelay/lang/en/lifecycletrigger_startdatedelay.php b/trigger/startdatedelay/lang/en/lifecycletrigger_startdatedelay.php index a5344f01d2e8612bebce35c9c0e2f024f84c7867..93d29d534db99d81277cffd4a7ce68981bf11abc 100644 --- a/trigger/startdatedelay/lang/en/lifecycletrigger_startdatedelay.php +++ b/trigger/startdatedelay/lang/en/lifecycletrigger_startdatedelay.php @@ -17,8 +17,7 @@ /** * Lang strings for start date delay trigger * - * @package tool_lifecycle_trigger - * @subpackage startdatedelay + * @package lifecycletrigger_startdatedelay * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/trigger/startdatedelay/lib.php b/trigger/startdatedelay/lib.php index cfa9e6b0f67fc93ce5d18b2f3ea9b01ae5fe71f5..4cfac5a0ff69572ecd1def650fd79ae26149a246 100644 --- a/trigger/startdatedelay/lib.php +++ b/trigger/startdatedelay/lib.php @@ -15,11 +15,9 @@ // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** - * Interface for the subplugintype trigger - * It has to be implemented by all subplugins. + * Subplugin for the start date delay. * - * @package tool_lifecycle_trigger - * @subpackage startdatedelay + * @package lifecycletrigger_startdatedelay * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -35,15 +33,16 @@ require_once(__DIR__ . '/../../lib.php'); /** * Class which implements the basic methods necessary for a cleanyp courses trigger subplugin - * @package tool_lifecycle_trigger + * @package lifecycletrigger_startdatedelay + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class startdatedelay extends base_automatic { - /** * Checks the course and returns a repsonse, which tells if the course should be further processed. - * @param $course object to be processed. - * @param $triggerid int id of the trigger instance. + * @param object $course Course to be processed. + * @param int $triggerid Id of the trigger instance. * @return trigger_response */ public function check_course($course, $triggerid) { @@ -51,6 +50,13 @@ class startdatedelay extends base_automatic { return trigger_response::trigger(); } + /** + * Add sql comparing the current date to the start date of a course in combination with the specified delay. + * @param int $triggerid Id of the trigger. + * @return array A list containing the constructed sql fragment and an array of parameters. + * @throws \coding_exception + * @throws \dml_exception + */ public function get_course_recordset_where($triggerid) { $delay = settings_manager::get_settings($triggerid, settings_type::TRIGGER)['delay']; $where = "{course}.startdate < :startdatedelay"; @@ -60,21 +66,39 @@ class startdatedelay extends base_automatic { return array($where, $params); } + /** + * The return value should be equivalent with the name of the subplugin folder. + * @return string technical name of the subplugin + */ public function get_subpluginname() { return 'startdatedelay'; } + /** + * Defines which settings each instance of the subplugin offers for the user to define. + * @return instance_setting[] containing settings keys and PARAM_TYPES + */ public function instance_settings() { return array( new instance_setting('delay', PARAM_INT) ); } + /** + * At the delay since the start date of a course. + * @param \MoodleQuickForm $mform + * @throws \coding_exception + */ public function extend_add_instance_form_definition($mform) { $mform->addElement('duration', 'delay', get_string('delay', 'lifecycletrigger_startdatedelay')); $mform->addHelpButton('delay', 'delay', 'lifecycletrigger_startdatedelay'); } + /** + * Reset the delay at the add instance form initializiation. + * @param \MoodleQuickForm $mform + * @param array $settings array containing the settings from the db. + */ public function extend_add_instance_form_definition_after_data($mform, $settings) { if (is_array($settings) && array_key_exists('delay', $settings)) { $default = $settings['delay']; diff --git a/trigger/startdatedelay/tests/generator/lib.php b/trigger/startdatedelay/tests/generator/lib.php index dd3bada2a8126e7dfa4ac9970d138d09be9867c1..aa4bde42ee325a68c7fc2721455297d6839cca57 100644 --- a/trigger/startdatedelay/tests/generator/lib.php +++ b/trigger/startdatedelay/tests/generator/lib.php @@ -14,6 +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/>. +/** + * lifecycletrigger_startdatedelay generator tests + * + * @package lifecycletrigger_startdatedelay + * @category test + * @copyright 2018 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ defined('MOODLE_INTERNAL') || die(); use tool_lifecycle\entity\trigger_subplugin; @@ -36,6 +44,7 @@ class tool_lifecycle_trigger_startdatedelay_generator extends testing_module_gen /** * Creates a trigger startdatedelay for an artificial workflow without steps. * @return trigger_subplugin the created startdatedelay trigger. + * @throws moodle_exception */ public static function create_trigger_with_workflow() { // Create Workflow. diff --git a/trigger/startdatedelay/tests/trigger_test.php b/trigger/startdatedelay/tests/trigger_test.php index 91d56468277660ef2b54ce8974e4202146ce4d42..434aa27c5a5400f7860b6f7a2688336ad2d0816b 100644 --- a/trigger/startdatedelay/tests/trigger_test.php +++ b/trigger/startdatedelay/tests/trigger_test.php @@ -14,8 +14,17 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +/** + * Trigger test for start date delay trigger. + * + * @package lifecycletrigger_startdatedelay + * @group lifecycletrigger + * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace tool_lifecycle\trigger; +use tool_lifecycle\entity\trigger_subplugin; use tool_lifecycle\processor; defined('MOODLE_INTERNAL') || die(); @@ -26,17 +35,17 @@ require_once(__DIR__ . '/generator/lib.php'); /** * Trigger test for start date delay trigger. * - * @package tool_lifecycle_trigger - * @category startdatedelay - * @group tool_lifecycle_trigger + * @package lifecycletrigger_startdatedelay + * @group lifecycletrigger * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tool_lifecycle_trigger_startdatedelay_testcase extends \advanced_testcase { + /** @var $triggerinstance trigger_subplugin Instance of the trigger. */ private $triggerinstance; - /**@var processor Instance of the lifecycle processor */ + /** @var $processor processor Instance of the lifecycle processor. */ private $processor; public function setUp() { diff --git a/trigger/startdatedelay/version.php b/trigger/startdatedelay/version.php index 9bd6252549ed74de592cb1bd60bb08da60dfc09c..c59c13cb2e4645c83d5edd3e0ba98aac9bf16c02 100644 --- a/trigger/startdatedelay/version.php +++ b/trigger/startdatedelay/version.php @@ -17,8 +17,7 @@ /** * Life Cycle Startdate Trigger * - * @package tool_lifecycle_trigger - * @subpackage startdatedelay + * @package lifecycletrigger_startdatedelay * @copyright 2017 Tobias Reischmann WWU * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/version.php b/version.php index e42e34f4891f46d9fed114c37bbf6fa55aa74f91..f39d537e6125732b4f85587beeaf0ba1503c56f9 100644 --- a/version.php +++ b/version.php @@ -19,6 +19,7 @@ * * @package tool_lifecycle * @copyright 2017 Tobias Reischmann WWU + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die;