This commit is contained in:
Huong Nguyen 2024-09-05 14:56:22 +07:00
commit d13985c2b8
No known key found for this signature in database
GPG Key ID: 40D88AB693A3E72A
16 changed files with 171 additions and 21 deletions

View File

@ -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

View File

@ -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');

View File

@ -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.'),

View File

@ -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.
*

View File

@ -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'),
];
}

View File

@ -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'])) {

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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,
],
],
];

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/bigbluebuttonbn/db" VERSION="20230213" COMMENT="XMLDB file for Moodle mod/bigbluebuttonbn"
<XMLDB PATH="mod/bigbluebuttonbn/db" VERSION="20240719" COMMENT="XMLDB file for Moodle mod/bigbluebuttonbn"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
@ -50,6 +50,7 @@
<FIELD NAME="mustapproveuser" TYPE="int" LENGTH="2" NOTNULL="false" DEFAULT="1" SEQUENCE="false"/>
<FIELD NAME="guestlinkuid" TYPE="char" LENGTH="1024" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="guestpassword" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="showpresentation" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>

View File

@ -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;
}

View File

@ -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';

View File

@ -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);
}
/**

View File

@ -78,15 +78,17 @@
<div id="bigbluebuttonbn-room-view-control-panel" data-bbb-id="{{bigbluebuttonbnid}}" class="mt-2">
{{#haspresentations}}
<h5>{{#str}}view_section_title_presentation, mod_bigbluebuttonbn{{/str}}</h5>
<div class="list-group list-group-flush">
{{#presentations}}
<a href="{{url}}" target="_blank" class="list-group-item list-group-item-action">
{{#pix}}{{iconname}},core, {{icondesc}}{{/pix}}
{{name}}
</a>
{{/presentations}}
</div>
{{#showpresentations}}
<h5>{{#str}}view_section_title_presentation, mod_bigbluebuttonbn{{/str}}</h5>
<div class="list-group list-group-flush">
{{#presentations}}
<a href="{{url}}" target="_blank" class="list-group-item list-group-item-action">
{{#pix}}{{iconname}},core, {{icondesc}}{{/pix}}
{{name}}
</a>
{{/presentations}}
</div>
{{/showpresentations}}
{{/haspresentations}}
</div>
</div>

View File

@ -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 | <value> |
And the following config values are set as admin:
| config | value | plugin |
| showpresentation_default | <showfile_default> | mod_bigbluebuttonbn |
| showpresentation_editable | <showfile_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 <user>
Then I <existence> "Presentation file"
And I <existence> "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 |

View File

@ -27,6 +27,6 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2024042200;
$plugin->version = 2024071900;
$plugin->requires = 2024041600;
$plugin->component = 'mod_bigbluebuttonbn';