From 87dee7620ebc34a614ac596e5b2ce3ba476b009d Mon Sep 17 00:00:00 2001 From: "Shamiso.Jaravaza" <33659194+ssj365@users.noreply.github.com> Date: Fri, 30 Aug 2024 20:27:20 -0600 Subject: [PATCH] MDL-82520 mod_bigbluebuttonbn: Show presentation * Added setting to show/hide presentation file on activity page * Created capability to check if user should always see presentation --- .upgradenotes/MDL-82520-2024083002382133.yml | 5 ++ .../backup_bigbluebuttonbn_stepslib.php | 2 +- .../classes/external/meeting_info.php | 1 + mod/bigbluebuttonbn/classes/instance.php | 16 ++++++ mod/bigbluebuttonbn/classes/local/config.php | 4 ++ mod/bigbluebuttonbn/classes/meeting.php | 1 + .../classes/output/view_page.php | 2 + mod/bigbluebuttonbn/classes/settings.php | 22 ++++++++ mod/bigbluebuttonbn/db/access.php | 11 ++++ mod/bigbluebuttonbn/db/install.xml | 3 +- mod/bigbluebuttonbn/db/upgrade.php | 15 ++++++ .../lang/en/bigbluebuttonbn.php | 7 +++ mod/bigbluebuttonbn/mod_form.php | 29 +++++++---- .../templates/room_view.mustache | 20 +++---- .../tests/behat/view_presentation.feature | 52 +++++++++++++++++++ mod/bigbluebuttonbn/version.php | 2 +- 16 files changed, 171 insertions(+), 21 deletions(-) create mode 100644 .upgradenotes/MDL-82520-2024083002382133.yml create mode 100644 mod/bigbluebuttonbn/tests/behat/view_presentation.feature diff --git a/.upgradenotes/MDL-82520-2024083002382133.yml b/.upgradenotes/MDL-82520-2024083002382133.yml new file mode 100644 index 00000000000..c34cf0bea14 --- /dev/null +++ b/.upgradenotes/MDL-82520-2024083002382133.yml @@ -0,0 +1,5 @@ +issueNumber: MDL-82520 +notes: + mod_bigbluebuttonbn: + - message: Added new meeting_info value to show presentation file on BBB activity page + type: improved diff --git a/mod/bigbluebuttonbn/backup/moodle2/backup_bigbluebuttonbn_stepslib.php b/mod/bigbluebuttonbn/backup/moodle2/backup_bigbluebuttonbn_stepslib.php index 3be1678c89e..6877eef6fb4 100644 --- a/mod/bigbluebuttonbn/backup/moodle2/backup_bigbluebuttonbn_stepslib.php +++ b/mod/bigbluebuttonbn/backup/moodle2/backup_bigbluebuttonbn_stepslib.php @@ -52,7 +52,7 @@ class backup_bigbluebuttonbn_activity_structure_step extends backup_activity_str 'clienttype', 'muteonstart', 'completionattendance', 'completionengagementchats', 'completionengagementtalks', 'completionengagementraisehand', 'completionengagementpollvotes', 'completionengagementemojis', - 'guestallowed', 'mustapproveuser']); + 'guestallowed', 'mustapproveuser', 'showpresentation']); $logs = new backup_nested_element('logs'); diff --git a/mod/bigbluebuttonbn/classes/external/meeting_info.php b/mod/bigbluebuttonbn/classes/external/meeting_info.php index d48b1f97fc6..c796183d0d2 100644 --- a/mod/bigbluebuttonbn/classes/external/meeting_info.php +++ b/mod/bigbluebuttonbn/classes/external/meeting_info.php @@ -140,6 +140,7 @@ class meeting_info extends external_api { 'guestaccessenabled' => new external_value(PARAM_BOOL, 'Guest access enabled', VALUE_OPTIONAL), 'guestjoinurl' => new external_value(PARAM_URL, 'Guest URL', VALUE_OPTIONAL), 'guestpassword' => new external_value(PARAM_RAW, 'Guest join password', VALUE_OPTIONAL), + 'showpresentations' => new external_value(PARAM_BOOL, 'Show presentation file', VALUE_OPTIONAL), 'features' => new external_multiple_structure( new external_single_structure([ 'name' => new external_value(PARAM_ALPHA, 'Feature name.'), diff --git a/mod/bigbluebuttonbn/classes/instance.php b/mod/bigbluebuttonbn/classes/instance.php index 5f13e8e8809..51c66425a9f 100644 --- a/mod/bigbluebuttonbn/classes/instance.php +++ b/mod/bigbluebuttonbn/classes/instance.php @@ -1001,6 +1001,22 @@ EOF; } } + /** + * Whether to show the preuploaded presentation on the activity page. + * + * @return bool + */ + public function should_show_presentation(): bool { + // Users with the correct capability should always be able to see presentation file. + if (has_capability('mod/bigbluebuttonbn:seepresentation', $this->get_context())) { + return true; + } + if (get_config('mod_bigbluebuttonbn', 'showpresentation_editable')) { + return (bool) $this->get_instance_var('showpresentation'); + } + return (bool) get_config('mod_bigbluebuttonbn', 'showpresentation_default'); + } + /** * Whether the current time is before the scheduled start time. * diff --git a/mod/bigbluebuttonbn/classes/local/config.php b/mod/bigbluebuttonbn/classes/local/config.php index 9f47b5fdcc7..98c7d4114fc 100644 --- a/mod/bigbluebuttonbn/classes/local/config.php +++ b/mod/bigbluebuttonbn/classes/local/config.php @@ -123,6 +123,8 @@ class config { 'default_dpa_accepted' => false, 'poll_interval' => bigbluebutton_proxy::DEFAULT_POLL_INTERVAL, 'checksum_algorithm' => self::DEFAULT_CHECKSUM_ALGORITHM, + 'showpresentation_default' => true, + 'showpresentation_editable' => false, ]; } @@ -251,6 +253,8 @@ class config { 'welcome_editable' => self::get('welcome_editable'), 'poll_interval' => self::get('poll_interval'), 'guestaccess_enabled' => self::get('guestaccess_enabled'), + 'showpresentation_editable' => self::get('showpresentation_editable'), + 'showpresentation_default' => self::get('showpresentation_default'), ]; } diff --git a/mod/bigbluebuttonbn/classes/meeting.php b/mod/bigbluebuttonbn/classes/meeting.php index 095a09d8a20..be05c23caff 100644 --- a/mod/bigbluebuttonbn/classes/meeting.php +++ b/mod/bigbluebuttonbn/classes/meeting.php @@ -283,6 +283,7 @@ class meeting { $presentation = $instance->get_presentation(); // This is for internal use. if (!empty($presentation)) { $meetinginfo->presentations[] = $presentation; + $meetinginfo->showpresentations = $instance->should_show_presentation(); } $meetinginfo->attendees = []; if (!empty($info['attendees'])) { diff --git a/mod/bigbluebuttonbn/classes/output/view_page.php b/mod/bigbluebuttonbn/classes/output/view_page.php index d2662d03ade..40654ea66e3 100644 --- a/mod/bigbluebuttonbn/classes/output/view_page.php +++ b/mod/bigbluebuttonbn/classes/output/view_page.php @@ -86,8 +86,10 @@ class view_page implements renderable, templatable { } if ($this->instance->is_feature_enabled('showroom')) { + $showpresentation = $this->instance->should_show_presentation(); $roomdata = meeting::get_meeting_info_for_instance($this->instance); $roomdata->haspresentations = false; + $roomdata->showpresentations = $showpresentation; if (!empty($roomdata->presentations)) { $roomdata->haspresentations = true; } diff --git a/mod/bigbluebuttonbn/classes/settings.php b/mod/bigbluebuttonbn/classes/settings.php index e874d9b1bbc..87019e718a7 100644 --- a/mod/bigbluebuttonbn/classes/settings.php +++ b/mod/bigbluebuttonbn/classes/settings.php @@ -715,6 +715,28 @@ class settings { ); $preuploadsettings->add($filemanager); + $item = new admin_setting_configcheckbox( + 'mod_bigbluebuttonbn/showpresentation_default', + get_string('config_showpresentation_default', 'bigbluebuttonbn'), + get_string('config_showpresentation_default_description', 'bigbluebuttonbn'), + 1 + ); + $this->add_conditional_element( + 'showpresentation_default', + $item, + $preuploadsettings + ); + $item = new admin_setting_configcheckbox( + 'mod_bigbluebuttonbn/showpresentation_editable', + get_string('config_showpresentation_editable', 'bigbluebuttonbn'), + get_string('config_showpresentation_editable_description', 'bigbluebuttonbn'), + 0 + ); + $this->add_conditional_element( + 'showpresentation_editable', + $item, + $preuploadsettings + ); } $this->admin->add($this->parent, $preuploadsettings); } diff --git a/mod/bigbluebuttonbn/db/access.php b/mod/bigbluebuttonbn/db/access.php index 5e59ba1ed89..b2102708103 100644 --- a/mod/bigbluebuttonbn/db/access.php +++ b/mod/bigbluebuttonbn/db/access.php @@ -168,4 +168,15 @@ $capabilities = [ 'editingteacher' => CAP_ALLOW, ], ], + + // Ability to always see presentation files. + 'mod/bigbluebuttonbn:seepresentation' => [ + 'captype' => 'read', + 'contextlevel' => CONTEXT_MODULE, + 'archetypes' => [ + 'manager' => CAP_ALLOW, + 'teacher' => CAP_ALLOW, + 'editingteacher' => CAP_ALLOW, + ], + ], ]; diff --git a/mod/bigbluebuttonbn/db/install.xml b/mod/bigbluebuttonbn/db/install.xml index d7aeeb4e5ee..239b99e97ed 100644 --- a/mod/bigbluebuttonbn/db/install.xml +++ b/mod/bigbluebuttonbn/db/install.xml @@ -1,5 +1,5 @@ - @@ -50,6 +50,7 @@ + diff --git a/mod/bigbluebuttonbn/db/upgrade.php b/mod/bigbluebuttonbn/db/upgrade.php index 7d107c75029..7cd7592f997 100644 --- a/mod/bigbluebuttonbn/db/upgrade.php +++ b/mod/bigbluebuttonbn/db/upgrade.php @@ -76,6 +76,21 @@ function xmldb_bigbluebuttonbn_upgrade($oldversion = 0) { // Automatically generated Moodle v4.4.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2024071900) { + + // Define field showpresentation to be added to bigbluebuttonbn. + $table = new xmldb_table('bigbluebuttonbn'); + $field = new xmldb_field('showpresentation', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'guestpassword'); + + // Conditionally launch add field showpresentation. + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // Bigbluebuttonbn savepoint reached. + upgrade_mod_savepoint(true, 2024071900, 'bigbluebuttonbn'); + } + return true; } diff --git a/mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php b/mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php index c36263f3851..43a2f690068 100644 --- a/mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php +++ b/mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php @@ -43,6 +43,7 @@ $string['bigbluebuttonbn:protectrecordings'] = 'Protect recordings'; $string['bigbluebuttonbn:unprotectrecordings'] = 'Unprotect recordings'; $string['bigbluebuttonbn:deleterecordings'] = 'Delete recordings'; $string['bigbluebuttonbn:importrecordings'] = 'Import recordings'; +$string['bigbluebuttonbn:seepresentation'] = 'Always see presentation file on activity page'; $string['bigbluebuttonbn:viewallrecordingformats'] = 'View all recording formats'; $string['bigbluebuttonbn'] = 'BigBlueButton'; $string['cannotperformaction'] = 'Cannot perform action {$a} on this recording'; @@ -214,6 +215,11 @@ $string['config_preuploadpresentation_editable_description'] = 'Preupload presen $string['config_presentation_default'] = 'Default presentation file'; $string['config_presentation_default_description'] = 'A file may be provided for use in all rooms.'; +$string['config_showpresentation_default'] = 'Show presentation file on activity page'; +$string['config_showpresentation_default_description'] = 'Allow students to access the preuploaded presentation file prior to the session on the activity page'; +$string['config_showpresentation_editable'] = 'Show presentation file editable'; +$string['config_showpresentation_editable_description'] = 'Show presentation file feature is editable in the UI when the room or conference is added or updated.'; + $string['config_participant'] = 'Participants'; $string['config_participant_description'] = 'These settings define the default role for participants.'; $string['config_participant_moderator_default'] = 'Moderator'; @@ -396,6 +402,7 @@ $string['mod_form_field_participant_list_action_add'] = 'Add'; $string['mod_form_field_participant_list_action_remove'] = 'Remove'; $string['mod_form_field_participant_bbb_role_moderator'] = 'Moderator'; $string['mod_form_field_participant_bbb_role_viewer'] = 'Viewer'; +$string['mod_form_field_showpresentation'] = 'Show presentation file on activity page'; $string['mod_form_field_instanceprofiles'] = 'Instance type'; $string['mod_form_field_instanceprofiles_help'] = 'If a session is to be recorded, select \'Room with recordings\', otherwise \'Room only\'. After a session is recorded, if there are to be no more sessions, select \'Recordings only\'.'; $string['mod_form_field_muteonstart'] = 'Mute on start'; diff --git a/mod/bigbluebuttonbn/mod_form.php b/mod/bigbluebuttonbn/mod_form.php index 83d09dbd512..807c94f0094 100644 --- a/mod/bigbluebuttonbn/mod_form.php +++ b/mod/bigbluebuttonbn/mod_form.php @@ -598,19 +598,30 @@ 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_editable']) { + $bigbluebuttonbn = get_config('mod_bigbluebuttonbn'); + if ($cfg['preuploadpresentation_editable'] || $bigbluebuttonbn->showpresentation_editable) { $mform->addElement('header', 'preuploadpresentation', get_string('mod_form_block_presentation', 'bigbluebuttonbn')); $mform->setExpanded('preuploadpresentation'); - $filemanageroptions = []; - $filemanageroptions['accepted_types'] = '*'; - $filemanageroptions['maxbytes'] = 0; - $filemanageroptions['subdirs'] = 0; - $filemanageroptions['maxfiles'] = 1; - $filemanageroptions['mainfile'] = true; - $mform->addElement('filemanager', 'presentation', get_string('selectfiles'), - null, $filemanageroptions); + if ($cfg['preuploadpresentation_editable']) { + $filemanageroptions = []; + $filemanageroptions['accepted_types'] = '*'; + $filemanageroptions['maxbytes'] = 0; + $filemanageroptions['subdirs'] = 0; + $filemanageroptions['maxfiles'] = 1; + $filemanageroptions['mainfile'] = true; + $mform->addElement('filemanager', 'presentation', get_string('selectfiles'), + null, $filemanageroptions); + } + if ($bigbluebuttonbn->showpresentation_editable) { + $mform->addElement('advcheckbox', 'showpresentation', + get_string('mod_form_field_showpresentation', 'bigbluebuttonbn')); + $mform->setDefault('showpresentation', $bigbluebuttonbn->showpresentation_default); + } else { + $mform->addElement('hidden', 'showpresentation', 0); + } } + $mform->setType('showpresentation', PARAM_BOOL); } /** diff --git a/mod/bigbluebuttonbn/templates/room_view.mustache b/mod/bigbluebuttonbn/templates/room_view.mustache index 5e6876e7be0..6437b03ae90 100644 --- a/mod/bigbluebuttonbn/templates/room_view.mustache +++ b/mod/bigbluebuttonbn/templates/room_view.mustache @@ -78,15 +78,17 @@
{{#haspresentations}} -
{{#str}}view_section_title_presentation, mod_bigbluebuttonbn{{/str}}
-
- {{#presentations}} - - {{#pix}}{{iconname}},core, {{icondesc}}{{/pix}} - {{name}} - - {{/presentations}} -
+ {{#showpresentations}} +
{{#str}}view_section_title_presentation, mod_bigbluebuttonbn{{/str}}
+
+ {{#presentations}} + + {{#pix}}{{iconname}},core, {{icondesc}}{{/pix}} + {{name}} + + {{/presentations}} +
+ {{/showpresentations}} {{/haspresentations}}
diff --git a/mod/bigbluebuttonbn/tests/behat/view_presentation.feature b/mod/bigbluebuttonbn/tests/behat/view_presentation.feature new file mode 100644 index 00000000000..54392e29268 --- /dev/null +++ b/mod/bigbluebuttonbn/tests/behat/view_presentation.feature @@ -0,0 +1,52 @@ +@mod @mod_bigbluebuttonbn @javascript @_file_upload +Feature: Test visibility of presentation on activity page + In order to ensure that presentation files are not visible to students when they shouldn't be + As a teacher + I set the visibility of presentation files in the BigBlueButtonBN activity + Background: + Given I enable "bigbluebuttonbn" "mod" plugin + And the following course exists: + | name | Test course | + | shortname | C1 | + And the following "users" exist: + | username | firstname | lastname | email | + | traverst | Terry | Travers | t.travers@example.com | + | uraverst | Uerry | Uravers | u.uravers@example.com | + And the following "course enrolments" exist: + | user | course | role | + | traverst | C1 | student | + | uraverst | C1 | teacher | + And the following config values are set as admin: + | bigbluebuttonbn_preuploadpresentation_editable | 1 | + + Scenario Outline: Check that presentation file can only be viewed when teachers allow it + Given the following "activity" exists: + | course | C1 | + | activity | bigbluebuttonbn | + | name | Room recordings | + | moderators | role:teacher | + | showpresentation | | + And the following config values are set as admin: + | config | value | plugin | + | showpresentation_default | | mod_bigbluebuttonbn | + | showpresentation_editable | | mod_bigbluebuttonbn | + And I am on the "Room recordings" "bigbluebuttonbn activity editing" page logged in as "admin" + And I expand all fieldsets + And I upload "mod/bigbluebuttonbn/tests/fixtures/bbpresentation.pptx" file to "Select files" filemanager + And I press "Save and display" + When I am on the "Room recordings" Activity page logged in as + Then I "Presentation file" + And I "bbpresentation.pptx" + + Examples: + | user | value | showfile_editable | showfile_default | existence | + | traverst | 1 | 1 | 1 | should see | + | uraverst | 1 | 1 | 1 | should see | + | traverst | 1 | 1 | 0 | should see | + | uraverst | 1 | 1 | 0 | should see | + | traverst | 0 | 0 | 1 | should see | + | uraverst | 0 | 0 | 1 | should see | + | traverst | 0 | 0 | 0 | should not see | + | uraverst | 0 | 0 | 0 | should see | + | traverst | 0 | 1 | 1 | should not see | + | uraverst | 0 | 1 | 1 | should see | diff --git a/mod/bigbluebuttonbn/version.php b/mod/bigbluebuttonbn/version.php index 547c15d734a..313074ab83a 100644 --- a/mod/bigbluebuttonbn/version.php +++ b/mod/bigbluebuttonbn/version.php @@ -27,6 +27,6 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2024042200; +$plugin->version = 2024071900; $plugin->requires = 2024041600; $plugin->component = 'mod_bigbluebuttonbn';