-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
300 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>. | ||
|
||
namespace tool_dynamic_cohorts\event; | ||
|
||
use core\event\base; | ||
|
||
/** | ||
* Event triggered when a rule created. | ||
* | ||
* @property-read array $other { | ||
* Extra information about event. | ||
* - string ruleid: new rule id. | ||
* } | ||
* | ||
* @package tool_dynamic_cohorts | ||
* @copyright 2024 Catalyst IT | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class rule_created extends base { | ||
|
||
/** | ||
* Initialise the rule data. | ||
*/ | ||
protected function init() { | ||
$this->data['edulevel'] = self::LEVEL_OTHER; | ||
$this->data['crud'] = 'u'; | ||
$this->context = \context_system::instance(); | ||
} | ||
|
||
/** | ||
* Return localised event name. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_name(): string { | ||
return get_string('event:rulecreated', 'tool_dynamic_cohorts'); | ||
} | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description(): string { | ||
return "User with id '{$this->userid}' created a dynamic cohort rule with id '{$this->other['ruleid']}'"; | ||
} | ||
|
||
/** | ||
* Validates the custom data. | ||
* | ||
* @throws \coding_exception if missing required data. | ||
*/ | ||
protected function validate_data() { | ||
parent::validate_data(); | ||
|
||
if (!isset($this->other['ruleid'])) { | ||
throw new \coding_exception('The \'ruleid\' value must be set in other.'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>. | ||
|
||
namespace tool_dynamic_cohorts\event; | ||
|
||
use core\event\base; | ||
|
||
/** | ||
* Event triggered when a rule deleted. | ||
* | ||
* @property-read array $other { | ||
* Extra information about event. | ||
* - string ruleid: deleted rule id. | ||
* } | ||
* | ||
* @package tool_dynamic_cohorts | ||
* @copyright 2024 Catalyst IT | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class rule_deleted extends base { | ||
|
||
/** | ||
* Initialise the rule data. | ||
*/ | ||
protected function init() { | ||
$this->data['edulevel'] = self::LEVEL_OTHER; | ||
$this->data['crud'] = 'u'; | ||
$this->context = \context_system::instance(); | ||
} | ||
|
||
/** | ||
* Return localised event name. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_name(): string { | ||
return get_string('event:ruledeleted', 'tool_dynamic_cohorts'); | ||
} | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description(): string { | ||
return "User with id '{$this->userid}' deleted a dynamic cohort rule with id '{$this->other['ruleid']}'"; | ||
} | ||
|
||
/** | ||
* Validates the custom data. | ||
* | ||
* @throws \coding_exception if missing required data. | ||
*/ | ||
protected function validate_data() { | ||
parent::validate_data(); | ||
|
||
if (!isset($this->other['ruleid'])) { | ||
throw new \coding_exception('The \'ruleid\' value must be set in other.'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>. | ||
|
||
namespace tool_dynamic_cohorts\event; | ||
|
||
use core\event\base; | ||
|
||
/** | ||
* Event triggered when a rule updated. | ||
* | ||
* @property-read array $other { | ||
* Extra information about event. | ||
* - string ruleid: updated rule id. | ||
* } | ||
* | ||
* @package tool_dynamic_cohorts | ||
* @copyright 2024 Catalyst IT | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class rule_updated extends base { | ||
|
||
/** | ||
* Initialise the rule data. | ||
*/ | ||
protected function init() { | ||
$this->data['edulevel'] = self::LEVEL_OTHER; | ||
$this->data['crud'] = 'u'; | ||
$this->context = \context_system::instance(); | ||
} | ||
|
||
/** | ||
* Return localised event name. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_name(): string { | ||
return get_string('event:ruleupdated', 'tool_dynamic_cohorts'); | ||
} | ||
|
||
/** | ||
* Returns description of what happened. | ||
* | ||
* @return string | ||
*/ | ||
public function get_description(): string { | ||
return "User with id '{$this->userid}' updated a dynamic cohort rule with id '{$this->other['ruleid']}'"; | ||
} | ||
|
||
/** | ||
* Validates the custom data. | ||
* | ||
* @throws \coding_exception if missing required data. | ||
*/ | ||
protected function validate_data() { | ||
parent::validate_data(); | ||
|
||
if (!isset($this->other['ruleid'])) { | ||
throw new \coding_exception('The \'ruleid\' value must be set in other.'); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters