Skip to content

Commit

Permalink
MDL-82520 mod_bigbluebuttonbn: Show presentation
Browse files Browse the repository at this point in the history
* Added setting to show/hide presentation file on activity page
  • Loading branch information
ssj365 committed Jul 22, 2024
1 parent 554a790 commit 785d8f5
Show file tree
Hide file tree
Showing 14 changed files with 146 additions and 21 deletions.
1 change: 1 addition & 0 deletions mod/bigbluebuttonbn/classes/external/meeting_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public static function execute_returns(): external_single_structure {
'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.'),
Expand Down
12 changes: 12 additions & 0 deletions mod/bigbluebuttonbn/classes/instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,18 @@ protected function do_get_presentation_with_nonce(bool $withnonce): ?array {
}
}

/**
* Whether to show the preuploaded presentation on the activity page.
*
* @return bool
*/
public function should_show_presentation(): bool {
if (config::get('showpresentation_editable')) {
return (bool) $this->get_instance_var('showpresentation');
}
return config::get('showpresentation_default');
}

/**
* Whether the current time is before the scheduled start time.
*
Expand Down
4 changes: 4 additions & 0 deletions mod/bigbluebuttonbn/classes/local/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ protected static function defaultvalues(): array {
'default_dpa_accepted' => false,
'poll_interval' => bigbluebutton_proxy::DEFAULT_POLL_INTERVAL,
'checksum_algorithm' => self::DEFAULT_CHECKSUM_ALGORITHM,
'showpresentation_default' => true,
'showpresentation_editable' => false,
];
}

Expand Down Expand Up @@ -251,6 +253,8 @@ public static function get_options(): array {
'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'),
];
}

Expand Down
2 changes: 2 additions & 0 deletions mod/bigbluebuttonbn/classes/meeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ protected function do_get_meeting_info(bool $updatecache = false): stdClass {
$presentation = $instance->get_presentation(); // This is for internal use.
if (!empty($presentation)) {
$meetinginfo->presentations[] = $presentation;
// Moderators should always be able to see presentation file.
$meetinginfo->showpresentations = $instance->should_show_presentation() || $instance->is_moderator();
}
$meetinginfo->attendees = [];
if (!empty($info['attendees'])) {
Expand Down
3 changes: 3 additions & 0 deletions mod/bigbluebuttonbn/classes/output/view_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ public function export_for_template(renderer_base $output): stdClass {
}

if ($this->instance->is_feature_enabled('showroom')) {
$showpresentation = $this->instance->should_show_presentation() ||
$this->instance->is_moderator();
$roomdata = meeting::get_meeting_info_for_instance($this->instance);
$roomdata->haspresentations = false;
$roomdata->showpresentations = $showpresentation;
if (!empty($roomdata->presentations)) {
$roomdata->haspresentations = true;
}
Expand Down
4 changes: 3 additions & 1 deletion mod/bigbluebuttonbn/classes/setting_validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ public static function section_static_voice_bridge_shown() {
*/
public static function section_preupload_presentation_shown() {
global $CFG;
return (!isset($CFG->bigbluebuttonbn['preuploadpresentation_editable']));
return (!isset($CFG->bigbluebuttonbn['preuploadpresentation_editable']) ||
!isset($CFG->bigbluebuttonbn['showpresentation_default']) ||
!isset($CFG->bigbluebuttonbn['showpresentation_editable']));
}

/**
Expand Down
22 changes: 22 additions & 0 deletions mod/bigbluebuttonbn/classes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,28 @@ protected function add_preupload_settings(): void {
);

$preuploadsettings->add($filemanager);
$item = new admin_setting_configcheckbox(
'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(
'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);
}
Expand Down
3 changes: 2 additions & 1 deletion mod/bigbluebuttonbn/db/install.xml
Original file line number Diff line number Diff line change
@@ -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"
>
Expand Down Expand Up @@ -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"/>
Expand Down
15 changes: 15 additions & 0 deletions mod/bigbluebuttonbn/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@
$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';
Expand Down Expand Up @@ -396,6 +401,7 @@
$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';
Expand Down
28 changes: 19 additions & 9 deletions mod/bigbluebuttonbn/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,19 +598,29 @@ private function bigbluebuttonbn_mform_add_block_room(MoodleQuickForm &$mform, a
* @return void
*/
private function bigbluebuttonbn_mform_add_block_preuploads(MoodleQuickForm &$mform, array $cfg): void {
if ($cfg['preuploadpresentation_editable']) {
if ($cfg['preuploadpresentation_editable'] || $cfg['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 ($cfg['showpresentation_editable']) {
$mform->addElement('advcheckbox', 'showpresentation',
get_string('mod_form_field_showpresentation', 'bigbluebuttonbn'));
$mform->setDefault('showpresentation', 1);
} else {
$mform->addElement('hidden', 'showpresentation', 0);
}
}
$mform->setType('showpresentation', PARAM_BOOL);
}

/**
Expand Down
20 changes: 11 additions & 9 deletions mod/bigbluebuttonbn/templates/room_view.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
45 changes: 45 additions & 0 deletions mod/bigbluebuttonbn/tests/behat/view_presentation.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@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_showpresentation_editable | 1 |
| bigbluebuttonbn_preuploadpresentation_editable | 1 |

Scenario Outline: Check that presentation file can only be viewed when teachers allow it
When the following "activity" exists:
| course | C1 |
| activity | bigbluebuttonbn |
| name | Room recordings |
| moderators | role:teacher |
| showpresentation | <value> |
When 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"
And 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 | existence |
| traverst | 1 | should see |
| uraverst | 1 | should see |
| traverst | 0 | should not see |
| uraverst | 0 | should see |


2 changes: 1 addition & 1 deletion mod/bigbluebuttonbn/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
defined('MOODLE_INTERNAL') || die;


$plugin->version = 2024042200;
$plugin->version = 2024071900;
$plugin->requires = 2024041600;
$plugin->component = 'mod_bigbluebuttonbn';

0 comments on commit 785d8f5

Please sign in to comment.