MDL-74325 mod_bigbluebuttonbn: Fix presentation setting

This commit is contained in:
Shamiso.Jaravaza 2022-04-01 17:12:49 -02:30
parent 7ce003b666
commit 4483261625
7 changed files with 42 additions and 39 deletions

View File

@ -64,7 +64,7 @@ class config {
'waitformoderator_cache_ttl' => '60',
'userlimit_default' => '0',
'userlimit_editable' => false,
'preuploadpresentation_enabled' => false,
'preuploadpresentation_editable' => false,
'recordingready_enabled' => false,
'recordingstatus_enabled' => false,
'meetingevents_enabled' => false,
@ -175,7 +175,7 @@ class config {
'waitformoderator_editable' => self::get('waitformoderator_editable'),
'userlimit_default' => self::get('userlimit_default'),
'userlimit_editable' => self::get('userlimit_editable'),
'preuploadpresentation_enabled' => self::get('preuploadpresentation_enabled'),
'preuploadpresentation_editable' => self::get('preuploadpresentation_editable'),
'recordings_enabled' => self::get('recordings_enabled'),
'meetingevents_enabled' => self::get('meetingevents_enabled'),
'recordings_deleted_default' => self::get('recordings_deleted_default'),

View File

@ -140,36 +140,37 @@ class files {
global $CFG;
$fs = get_file_storage();
$files = [];
if (empty($presentation)) {
if ($CFG->bigbluebuttonbn_preuploadpresentation_enabled) {
// Item has not presentation but presentation is enabled..
// Check if exist some file by default in general mod setting ("presentationdefault").
$files = $fs->get_area_files(
context_system::instance()->id,
'mod_bigbluebuttonbn',
'presentationdefault',
0,
"filename",
false
);
$id = null; // This is the general presentation/default so we will generate
// an id as if the activity was null.
$defaultpresentation = $fs->get_area_files(
context_system::instance()->id,
'mod_bigbluebuttonbn',
'presentationdefault',
0,
"filename",
false
);
$activitypresentation = $files = $fs->get_area_files(
$context->id,
'mod_bigbluebuttonbn',
'presentation',
false,
'itemid, filepath, filename',
false
);
// Presentation upload logic based on config settings.
if (empty($defaultpresentation)) {
if (empty($activitypresentation) || !\mod_bigbluebuttonbn\local\config::get('preuploadpresentation_editable')) {
return null;
}
$files = $activitypresentation;
} else {
$files = $fs->get_area_files(
$context->id,
'mod_bigbluebuttonbn',
'presentation',
false,
'itemid, filepath, filename',
false
);
if (empty($activitypresentation) || !\mod_bigbluebuttonbn\local\config::get('preuploadpresentation_editable')) {
$files = $defaultpresentation;
$id = null;
} else {
$files = $activitypresentation;
}
}
if (count($files) == 0) {
return null; // No presentation.
}
$pnoncevalue = 0;
if ($withnonce) {
$nonceid = 0;

View File

@ -114,7 +114,7 @@ class setting_validator {
*/
public static function section_preupload_presentation_shown() {
global $CFG;
return (!isset($CFG->bigbluebuttonbn['preuploadpresentation_enabled']));
return (!isset($CFG->bigbluebuttonbn['preuploadpresentation_editable']));
}
/**

View File

@ -593,13 +593,13 @@ class settings {
$preuploadsettings->add($item);
$item = new admin_setting_configcheckbox(
'bigbluebuttonbn_preuploadpresentation_enabled',
get_string('config_preuploadpresentation_enabled', 'bigbluebuttonbn'),
get_string('config_preuploadpresentation_enabled_description', 'bigbluebuttonbn'),
'bigbluebuttonbn_preuploadpresentation_editable',
get_string('config_preuploadpresentation_editable', 'bigbluebuttonbn'),
get_string('config_preuploadpresentation_editable_description', 'bigbluebuttonbn'),
0
);
$this->add_conditional_element(
'preuploadpresentation_enabled',
'preuploadpresentation_editable',
$item,
$preuploadsettings
);

View File

@ -199,8 +199,8 @@ $string['config_voicebridge_editable_description'] = 'A conference voice bridge
$string['config_preuploadpresentation'] = 'Pre-upload presentation';
$string['config_preuploadpresentation_description'] = 'These settings enable or disable options in the UI and also define default values for these options. The feature works only if the Moodle server is accessible to BigBlueButton.';
$string['config_preuploadpresentation_enabled'] = 'Pre-upload presentation';
$string['config_preuploadpresentation_enabled_description'] = 'If enabled, an option is provided in the BigBlueButton activity settings to upload presentation files ready for use in the room.';
$string['config_preuploadpresentation_editable'] = 'Pre-uploading presentation editable';
$string['config_preuploadpresentation_editable_description'] = 'Preupload presentation feature is editable in the UI when the room or conference is added or updated.';
$string['config_presentation_default'] = 'Default presentation file';
$string['config_presentation_default_description'] = 'A file may be provided for use in all rooms.';

View File

@ -553,7 +553,7 @@ class mod_bigbluebuttonbn_mod_form extends moodleform_mod {
* @return void
*/
private function bigbluebuttonbn_mform_add_block_preuploads(MoodleQuickForm &$mform, array $cfg): void {
if ($cfg['preuploadpresentation_enabled']) {
if ($cfg['preuploadpresentation_editable']) {
$mform->addElement('header', 'preuploadpresentation',
get_string('mod_form_block_presentation', 'bigbluebuttonbn'));
$mform->setExpanded('preuploadpresentation');

View File

@ -106,7 +106,7 @@ class files_test extends \advanced_testcase {
list($user, $bbactivity) = $this->create_user_and_activity($CFG->dirroot . self::PRESENTATION_FILEPATH);
$this->setUser($user);
$CFG->bigbluebuttonbn_preuploadpresentation_editable = true;
$instance = instance::get_from_instanceid($bbactivity->id);
$presentation = $instance->get_presentation_for_bigbluebutton_upload();
$fulldirset = explode('/', $presentation['url']);
@ -135,7 +135,7 @@ class files_test extends \advanced_testcase {
list($user, $bbactivity) = $this->create_user_and_activity($CFG->dirroot . self::PRESENTATION_FILEPATH);
$this->setUser($user);
$CFG->bigbluebuttonbn_preuploadpresentation_editable = true;
$instance = instance::get_from_instanceid($bbactivity->id);
$presentation = $instance->get_presentation();
$fulldirset = explode('/', $presentation['url']);
@ -155,11 +155,13 @@ class files_test extends \advanced_testcase {
* Get filename test
*/
public function test_pluginfile_filename() {
global $CFG;
$this->resetAfterTest();
list($user, $bbactivity, $bbactivitycm, $bbactivitycontext) = $this->create_user_and_activity();
$this->setUser($user);
$this->create_sample_file(self::PRESENTATION_FILENAME, $bbactivitycontext->id);
$CFG->bigbluebuttonbn_preuploadpresentation_editable = true;
$presentationdef = files::get_presentation($bbactivitycontext, self::PRESENTATION_FILENAME, $bbactivity->id, true);
$pathparts = explode('/', $presentationdef['url']);
$filename = array_pop($pathparts);