Merge branch 'MDL-80289-402' of https://github.com/call-learning/moodle into MOODLE_402_STABLE
This commit is contained in:
@@ -193,10 +193,20 @@ EOF;
|
||||
* @return null|self
|
||||
*/
|
||||
public static function get_from_meetingid(string $meetingid): ?self {
|
||||
global $DB;
|
||||
// Here we try to manage cases where the meetingid was actually produced by the old plugin or we have actually
|
||||
// changed the identifiers for the instance.
|
||||
$matches = self::parse_meetingid($meetingid);
|
||||
$existinginstanceid = $DB->get_field('bigbluebuttonbn', 'id', ['meetingid' => $matches['meetingid']]);
|
||||
if (empty($existinginstanceid)) {
|
||||
debugging("The meeting id with ID ($meetingid) was not found in the bigbluebuttonbn table", DEBUG_DEVELOPER);
|
||||
$existinginstanceid = $matches['instanceid']; // We try to "guess" the meeting id from its instance id. We should
|
||||
// not really do that as this changes simply if we move the course elsewhere.
|
||||
debugging("Trying to get the instanceid from the meeting ID. This will soon be deprecated", DEBUG_DEVELOPER);
|
||||
}
|
||||
$instance = self::get_from_instanceid($existinginstanceid);
|
||||
|
||||
$instance = self::get_from_instanceid($matches['instanceid']);
|
||||
|
||||
// Check for the group if any.
|
||||
if ($instance && array_key_exists('groupid', $matches)) {
|
||||
$instance->set_group_id($matches['groupid']);
|
||||
}
|
||||
|
||||
@@ -157,6 +157,34 @@ class instance_test extends advanced_testcase {
|
||||
$this->assertEquals($cm->id, $instance->get_cm_id());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting Meeting ID from log as Log field (meetingid) is the full meeting id (with courseid, and bigbluebuttonid).
|
||||
*
|
||||
* @covers ::get_from_meetingid
|
||||
*/
|
||||
public function test_get_from_meetingid_from_log(): void {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
[
|
||||
'record' => $record,
|
||||
'course' => $course,
|
||||
'cm' => $cm,
|
||||
] = $this->get_test_instance();
|
||||
$instance = instance::get_from_cmid($cm->id);
|
||||
$instance->set_group_id(1);
|
||||
logger::log_meeting_joined_event($instance, 1);
|
||||
$logs = $DB->get_records('bigbluebuttonbn_logs',
|
||||
['courseid' => $course->id, 'bigbluebuttonbnid' => $instance->get_instance_id()], 'timecreated DESC');
|
||||
$log = end($logs);
|
||||
$retrievedinstance = instance::get_from_meetingid(
|
||||
$log->meetingid
|
||||
);
|
||||
|
||||
$this->assertEquals($cm->instance, $retrievedinstance->get_instance_id());
|
||||
$this->assertEquals($cm->id, $retrievedinstance->get_cm_id());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that invalid meetingids throw an appropriate exception.
|
||||
*
|
||||
|
||||
@@ -124,6 +124,7 @@ class upgrade_recordings_task_test extends advanced_testcase {
|
||||
foreach ($matchesarray as $matches) {
|
||||
$this->expectOutputRegex('/' . implode('.*', $matches) . '/s');
|
||||
}
|
||||
$this->resetDebugging(); // We might have debugging message that are sent by get_from_meetingid and can ignore them.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,6 +187,7 @@ class upgrade_recordings_task_test extends advanced_testcase {
|
||||
foreach ($matchesarray as $matches) {
|
||||
$this->expectOutputRegex('/' . implode('.*', $matches) . '/s');
|
||||
}
|
||||
$this->resetDebugging(); // We might have debugging message that are sent by get_from_meetingid and can ignore them.
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user