-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #251 from learnweb/fix/teachers_can_delete_groups
Fix/teachers can delete groups
- Loading branch information
Showing
13 changed files
with
349 additions
and
65 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Event observer for ratingallocate. | ||
* | ||
* @package mod_ratingallocate | ||
* @copyright 2023 I Hoppe | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace mod_ratingallocate; | ||
use coding_exception; | ||
use dml_exception; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
class ratingallocate_observer { | ||
|
||
/** | ||
* Triggered if group_deleted event is triggered. | ||
* | ||
* @param \core\event\group_deleted $event | ||
* @return void | ||
* @throws coding_exception | ||
* @throws dml_exception | ||
*/ | ||
public static function ch_gengroups_delete (\core\event\group_deleted $event) { | ||
global $DB; | ||
|
||
$eventdata = $event->get_record_snapshot('groups', $event->objectid); | ||
if ($DB->record_exists( | ||
'ratingallocate_ch_gengroups', | ||
['groupid' => $eventdata->id])) { | ||
|
||
// Delete the group from ratingallocate_ch_gengroups table. | ||
$DB->delete_records( | ||
'ratingallocate_ch_gengroups', | ||
['groupid' => $eventdata->id] | ||
); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Triggered if grouping_deleted event is triggered. | ||
* | ||
* @param \core\event\grouping_deleted $event | ||
* @return void | ||
* @throws coding_exception | ||
* @throws dml_exception | ||
*/ | ||
public static function ra_groupings_delete (\core\event\grouping_deleted $event) { | ||
global $DB; | ||
|
||
$eventdata = $event->get_record_snapshot('groupings', $event->objectid); | ||
if ($DB->record_exists( | ||
'ratingallocate_groupings', | ||
['groupingid' => $eventdata->id])) { | ||
|
||
// Delete the grouping from the ratingallocate_groupings table. | ||
$DB->delete_records( | ||
'ratingallocate_groupings', | ||
['groupingid' => $eventdata->id] | ||
); | ||
|
||
} | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Definition of ratingallocate event observers. | ||
* | ||
* The observers defined in this file are notified when respective events are triggered. | ||
* | ||
* @package mod_ratingallocate | ||
* @category event | ||
* @copyright 2023 I Hoppe | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* | ||
*/ | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
|
||
$handlers = array(); | ||
|
||
// List of observers for group_deleted and grouping_deleted. | ||
|
||
$observers = array( | ||
array( | ||
'eventname' => '\core\event\group_deleted', | ||
'callback' => 'mod_ratingallocate\ratingallocate_observer::ch_gengroups_delete', | ||
), | ||
array( | ||
'eventname' => '\core\event\grouping_deleted', | ||
'callback' => 'mod_ratingallocate\ratingallocate_observer::ra_groupings_delete' | ||
) | ||
); |
Oops, something went wrong.