Merge branch 'MDL-74782-master' of https://github.com/ssj365/moodle

This commit is contained in:
Ilya Tregubov 2022-09-07 15:48:56 +04:00
commit 295e6fee8f
3 changed files with 67 additions and 0 deletions

View File

@ -766,6 +766,18 @@ EOF;
return $this->is_feature_enabled('importrecordings');
}
/**
* Get recordings_imported from instancedata.
*
* @return bool
*/
public function get_recordings_imported(): bool {
if (config::get('recordings_imported_editable')) {
return (bool) $this->get_instance_var('recordings_imported');
}
return config::get('recordings_imported_default');
}
/**
* Whether this instance is recorded from the start.
*

View File

@ -296,6 +296,10 @@ class recording_data {
if ($rec->get('imported')) {
return true;
}
// When show imported recordings only is enabled, exclude all other recordings.
if ($instance->get_recordings_imported() && !$rec->get('imported')) {
return false;
}
// Administrators and moderators are always allowed.
if ($instance->is_admin() || $instance->is_moderator()) {
return true;

View File

@ -314,6 +314,57 @@ class get_recordings_test extends \externallib_advanced_testcase {
}
}
/**
* Check we can see only imported recordings in a recordings only instance when "Show only imported links" enabled.
* @covers \mod_bigbluebuttonbn\external\get_recordings::execute
*/
public function test_get_imported_recordings_only() {
$this->resetAfterTest();
set_config('bigbluebuttonbn_importrecordings_enabled', 1);
$dataset = [
'type' => instance::TYPE_ALL,
'groups' => null,
'users' => [['username' => 's1', 'role' => 'student']],
'recordingsdata' => [
[['name' => 'Recording1']],
[['name' => 'Recording2']]
],
];
$activityid = $this->create_from_dataset($dataset);
$instance = instance::get_from_instanceid($activityid);
// Now create a recording only activity.
$plugingenerator = $this->getDataGenerator()->get_plugin_generator('mod_bigbluebuttonbn');
// Now create a new activity and import the first record.
$newactivity = $plugingenerator->create_instance([
'course' => $instance->get_course_id(),
'type' => instance::TYPE_RECORDING_ONLY,
'name' => 'Example 2'
]);
$plugingenerator->create_meeting([
'instanceid' => $newactivity->id,
]); // We need to have a meeting created in order to import recordings.
$newinstance = instance::get_from_instanceid($newactivity->id);
$recordings = $instance->get_recordings();
foreach ($recordings as $recording) {
if ($recording->get('name') == 'Recording1') {
$recording->create_imported_recording($newinstance);
}
}
$user = \core_user::get_user_by_username('s1');
$this->setUser($user);
$getrecordings = $this->get_recordings($newinstance->get_instance_id());
$data = json_decode($getrecordings['tabledata']['data']);
// Check that all recordings including the imported recording appear.
$this->assertCount(3, $data);
// Set the flags to enable "Show only imported links".
set_config('bigbluebuttonbn_recordings_imported_default', 1);
set_config('bigbluebuttonbn_recordings_imported_editable', 0);
$getrecordings = $this->get_recordings($newinstance->get_instance_id());
$data = json_decode($getrecordings['tabledata']['data']);
$this->assertCount(1, $data);
}
/**
* Check if recording are visible/invisible depending on the group.
*