mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-73228 mod_bigbluebuttonbn: Close all meetings when deleting
* When a BigblueButtonBN activity is deleted, we need to also close all running meetings (including group meetings)
This commit is contained in:
parent
952d9e9f18
commit
cb7d2bf2f1
@ -56,7 +56,9 @@ if ($id) {
|
||||
}
|
||||
|
||||
if (!$instance) {
|
||||
throw new moodle_exception('view_error_url_missing_parameters', plugin::COMPONENT);
|
||||
$courseid = optional_param('courseid', 1, PARAM_INT);
|
||||
\core\notification::error(get_string('general_error_not_found', 'mod_bigbluebuttonbn', $id));
|
||||
redirect(new moodle_url('/course/view.php', ['id' => $courseid]));
|
||||
}
|
||||
|
||||
$cm = $instance->get_cm();
|
||||
|
@ -999,6 +999,8 @@ EOF;
|
||||
return new moodle_url('/mod/bigbluebuttonbn/bbb_view.php', [
|
||||
'action' => 'logout',
|
||||
'id' => $this->cm->id,
|
||||
'courseid' => $this->cm->course // Used to find the course if ever the activity is deleted
|
||||
// while the meeting is running.
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ $string['general_error_unable_connect'] = 'Unable to connect. Please check the u
|
||||
Details : {$a}';
|
||||
$string['general_error_no_answer'] = 'Empty response. Please check the url of the BigBlueButton server AND check to see if the BigBlueButton server is running.';
|
||||
$string['general_error_not_allowed_to_create_instances'] = 'User is not allowed to create any type of instance.';
|
||||
$string['general_error_not_found'] = 'Entity not found : {$a}.';
|
||||
$string['general_error_not_found'] = 'Cannot find the BigBlueButton activity ({$a}).';
|
||||
$string['general_error_cannot_create_meeting'] = 'Cannot create session.';
|
||||
$string['general_error_cannot_get_recordings'] = 'Cannot get recordings.';
|
||||
$string['index_confirm_end'] = 'Do you want to end the session?';
|
||||
|
@ -159,20 +159,32 @@ function bigbluebuttonbn_delete_instance($id) {
|
||||
try {
|
||||
$meeting = new meeting($instance);
|
||||
$meeting->end_meeting();
|
||||
$groups = groups_get_course_group($instance->get_course());
|
||||
if ($groups) {
|
||||
foreach ($groups as $group) {
|
||||
$instance->set_group_id($group->id);
|
||||
$meeting = new meeting($instance);
|
||||
$meeting->end_meeting();
|
||||
}
|
||||
}
|
||||
} catch (moodle_exception $e) {
|
||||
// Do not log any issue when testing.
|
||||
if (!(defined('PHPUNIT_TEST') && PHPUNIT_TEST) && !defined('BEHAT_SITE_RUNNING')) {
|
||||
debugging($e->getMessage(), DEBUG_NORMAL, $e->getTrace());
|
||||
}
|
||||
}
|
||||
// Get all possible groups (course and course module).
|
||||
$groupids = [];
|
||||
if (groups_get_activity_groupmode($instance->get_cm())) {
|
||||
$coursegroups = groups_get_activity_allowed_groups($instance->get_cm());
|
||||
$groupids = array_map(
|
||||
function($gp) {
|
||||
return $gp->id;
|
||||
},
|
||||
$coursegroups);
|
||||
}
|
||||
// End all meetings for all groups.
|
||||
foreach ($groupids as $groupid) {
|
||||
try {
|
||||
$instance->set_group_id($groupid);
|
||||
$meeting = new meeting($instance);
|
||||
$meeting->end_meeting();
|
||||
} catch (moodle_exception $e) {
|
||||
debugging($e->getMessage() . ' for group ' . $groupid, DEBUG_NORMAL, $e->getTrace());
|
||||
}
|
||||
}
|
||||
|
||||
$result = true;
|
||||
|
||||
|
@ -100,6 +100,79 @@ class lib_test extends \advanced_testcase {
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check delete instance
|
||||
*
|
||||
* @covers ::bigbluebuttonbn_delete_instance
|
||||
*/
|
||||
public function test_bigbluebuttonbn_delete_instance_with_running_meeting() {
|
||||
$this->resetAfterTest();
|
||||
$this->initialise_mock_server();
|
||||
list($bbactivitycontext, $bbactivitycm, $bbactivity) = $this->create_instance();
|
||||
$bbbgenerator = $this->getDataGenerator()->get_plugin_generator('mod_bigbluebuttonbn');
|
||||
$instance = instance::get_from_instanceid($bbactivity->id);
|
||||
// Run the meeting.
|
||||
$bbbgenerator->create_meeting([
|
||||
'instanceid' => $instance->get_instance_id(),
|
||||
'groupid' => $instance->get_group_id(),
|
||||
]);
|
||||
$meeting = new meeting($instance);
|
||||
$meeting->update_cache();
|
||||
$this->assertTrue($meeting->is_running());
|
||||
$result = bigbluebuttonbn_delete_instance($bbactivity->id);
|
||||
$this->assertTrue($result);
|
||||
$meeting->update_cache();
|
||||
$this->assertFalse($meeting->is_running());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check delete instance
|
||||
*
|
||||
* @covers ::bigbluebuttonbn_delete_instance
|
||||
*/
|
||||
public function test_bigbluebuttonbn_delete_instance_with_running_group_meetings() {
|
||||
$this->resetAfterTest();
|
||||
$this->initialise_mock_server();
|
||||
$datagenerator = $this->getDataGenerator();
|
||||
list($bbactivitycontext, $bbactivitycm, $bbactivity) = $this->create_instance();
|
||||
$course = $this->get_course();
|
||||
set_coursemodule_groupmode($bbactivitycm->id, VISIBLEGROUPS);
|
||||
|
||||
$groups = [];
|
||||
foreach (['G1', 'G2'] as $gname) {
|
||||
$groups[] = $datagenerator->create_group(['courseid' => $course->id, 'name' => $gname]);
|
||||
}
|
||||
// Just create a user in one of the group so we check we don't just end meetings for this user...
|
||||
$user = $datagenerator->create_and_enrol($this->get_course());
|
||||
$groupids = array_map(function($g) {
|
||||
return $g->id;
|
||||
}, $groups);
|
||||
$datagenerator->create_group_member(['userid' => $user->id, 'groupid' => $groupids[0]]);
|
||||
$this->setUser($user);
|
||||
|
||||
$groupids[] = 0; // Add no group (id=0) - as an item so it is covered in the loop.
|
||||
$bbbgenerator = $datagenerator->get_plugin_generator('mod_bigbluebuttonbn');
|
||||
$globalinstance = instance::get_from_instanceid($bbactivity->id);
|
||||
$meetings = [];
|
||||
foreach ($groupids as $groupid) {
|
||||
$instance = instance::get_group_instance_from_instance($globalinstance, $groupid);
|
||||
// Run the meetings.
|
||||
$bbbgenerator->create_meeting([
|
||||
'instanceid' => $instance->get_instance_id(),
|
||||
'groupid' => $instance->get_group_id(),
|
||||
]);
|
||||
$meeting = new meeting($instance);
|
||||
$meeting->update_cache();
|
||||
$this->assertTrue($meeting->is_running());
|
||||
$meetings[] = $meeting;
|
||||
}
|
||||
$result = bigbluebuttonbn_delete_instance($bbactivity->id);
|
||||
$this->assertTrue($result);
|
||||
foreach ($meetings as $meeting) {
|
||||
$meeting->update_cache();
|
||||
$this->assertFalse($meeting->is_running());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check user outline page
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user