Skip to content

Commit

Permalink
MDL-73279 mod_bigbluebuttonbn: Remove notify change option in settings
Browse files Browse the repository at this point in the history
* As 'Send content change notification' is standard in all activities in Moodle 4.0
 we should be removing 'Notify this change to users enrolled'
* Fix and adjust tests
  • Loading branch information
laurentdavid committed Feb 1, 2022
1 parent 4f9a539 commit 4d72663
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 324 deletions.
2 changes: 0 additions & 2 deletions mod/bigbluebuttonbn/classes/local/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ protected static function defaultvalues() {
'userlimit_default' => '0',
'userlimit_editable' => false,
'preuploadpresentation_enabled' => false,
'sendnotifications_enabled' => false,
'recordingready_enabled' => false,
'recordingstatus_enabled' => false,
'meetingevents_enabled' => false,
Expand Down Expand Up @@ -182,7 +181,6 @@ public static function get_options() {
'userlimit_default' => self::get('userlimit_default'),
'userlimit_editable' => self::get('userlimit_editable'),
'preuploadpresentation_enabled' => self::get('preuploadpresentation_enabled'),
'sendnotifications_enabled' => self::get('sendnotifications_enabled'),
'recordings_enabled' => self::get('recordings_enabled'),
'meetingevents_enabled' => self::get('meetingevents_enabled'),
'recordings_deleted_default' => self::get('recordings_deleted_default'),
Expand Down
22 changes: 0 additions & 22 deletions mod/bigbluebuttonbn/classes/local/helpers/mod_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use mod_bigbluebuttonbn\instance;
use mod_bigbluebuttonbn\logger;
use mod_bigbluebuttonbn\plugin;
use mod_bigbluebuttonbn\task\send_instance_update_notification;
use stdClass;

/**
Expand Down Expand Up @@ -143,31 +142,10 @@ protected static function process_pre_save_common(stdClass $bigbluebuttonbn): vo
* @param stdClass $bigbluebuttonbn BigBlueButtonBN form data
**/
public static function process_post_save(stdClass $bigbluebuttonbn): void {
if (isset($bigbluebuttonbn->notification) && $bigbluebuttonbn->notification) {
self::process_post_save_notification($bigbluebuttonbn);
}
self::process_post_save_event($bigbluebuttonbn);
self::process_post_save_completion($bigbluebuttonbn);
}

/**
* Generates a message on insert/update which is sent to all users enrolled.
*
* @param stdClass $bigbluebuttonbn BigBlueButtonBN form data
**/
protected static function process_post_save_notification(stdClass $bigbluebuttonbn): void {
$task = new send_instance_update_notification();
$task->set_instance_id($bigbluebuttonbn->id);

if (isset($bigbluebuttonbn->add) && !empty($bigbluebuttonbn->add)) {
$task->set_update_type(send_instance_update_notification::TYPE_CREATED);
} else {
$task->set_update_type(send_instance_update_notification::TYPE_UPDATED);
}

\core\task\manager::queue_adhoc_task($task);
}

/**
* Generates an event after a bigbluebuttonbn insert/update.
*
Expand Down
10 changes: 0 additions & 10 deletions mod/bigbluebuttonbn/classes/setting_validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,6 @@ public static function section_moderator_default_shown() {
return (!isset($CFG->bigbluebuttonbn['participant_moderator_default']));
}

/**
* Validate if send notification section will be shown.
*
* @return bool
*/
public static function section_send_notifications_shown() {
global $CFG;
return (!isset($CFG->bigbluebuttonbn['sendnotifications_enabled']));
}

/**
* Validate if settings extended section will be shown.
*
Expand Down
35 changes: 0 additions & 35 deletions mod/bigbluebuttonbn/classes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public function add_all_settings(): void {
$this->add_preupload_settings();
$this->add_userlimit_settings();
$this->add_participants_settings();
$this->add_notifications_settings();
$this->add_muteonstart_settings();
$this->add_locksettings_settings();
// Renders settings for extended capabilities.
Expand Down Expand Up @@ -712,40 +711,6 @@ protected function add_participants_settings(): void {
$this->admin->add($this->section, $participantsettings);
}

/**
* Helper function renders notification settings if the feature is enabled.
*/
protected function add_notifications_settings(): void {
// Configuration for "send notifications" feature.
$notificationssettings = new admin_settingpage(
"{$this->sectionnameprefix}_notifications",
get_string('config_sendnotifications', 'bigbluebuttonbn'),
'moodle/site:config',
!((boolean) setting_validator::section_send_notifications_shown()) && ($this->moduleenabled)
);

if ($this->admin->fulltree) {
$item = new admin_setting_heading(
'bigbluebuttonbn_config_sendnotifications',
'',
get_string('config_sendnotifications_description', 'bigbluebuttonbn')
);
$notificationssettings->add($item);
$item = new admin_setting_configcheckbox(
'bigbluebuttonbn_sendnotifications_enabled',
get_string('config_sendnotifications_enabled', 'bigbluebuttonbn'),
get_string('config_sendnotifications_enabled_description', 'bigbluebuttonbn'),
1
);
$this->add_conditional_element(
'sendnotifications_enabled',
$item,
$notificationssettings
);
}
$this->admin->add($this->section, $notificationssettings);
}

/**
* Helper function renders general settings if the feature is enabled.
*/
Expand Down
124 changes: 0 additions & 124 deletions mod/bigbluebuttonbn/classes/task/send_instance_update_notification.php

This file was deleted.

10 changes: 0 additions & 10 deletions mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,6 @@
$string['config_scheduled_pre_opening'] = 'Accessible before opening time (minutes)';
$string['config_scheduled_pre_opening_description'] = 'The time in minutes for the session to be acceessible before the schedules opening time is due.';

$string['config_sendnotifications'] = 'Configuration for "Send notifications" feature';
$string['config_sendnotifications_description'] = 'These settings enable or disable options in the UI and also define default values for these options.';
$string['config_sendnotifications_enabled'] = 'Send notifications enabled';
$string['config_sendnotifications_enabled_description'] = 'If enabled the UI for editing the activity includes an option for sending a notification to enrolled user when the activity is added or updated.';

$string['config_extended_capabilities'] = 'Configuration for extended capabilities';
$string['config_extended_capabilities_description'] = 'Configuration for extended capabilities when the BigBlueButton server offers them.';
$string['config_uidelegation_enabled'] = 'UI delegation is enabled';
Expand Down Expand Up @@ -364,11 +359,6 @@
$string['mod_form_field_instanceprofiles'] = 'Instance type';
$string['mod_form_field_instanceprofiles_help'] = 'Select the type for this BigBlueButton instance.';
$string['mod_form_field_muteonstart'] = 'Mute on start';
$string['mod_form_field_notification'] = 'Notify this change to users enrolled';
$string['mod_form_field_notification_help'] = 'Send a notification to all users enrolled to let them know that this activity has been added or updated';
$string['mod_form_field_notification_created_help'] = 'Send a notification to all users enrolled to let them know that this activity has been created';
$string['mod_form_field_notification_modified_help'] = 'Send a notification to all users enrolled to let them know that this activity has been updated';
$string['mod_form_field_notification_msg_at'] = 'at';
$string['mod_form_field_recordings_html'] = 'Show the table in plain html';
$string['mod_form_field_recordings_deleted'] = 'Include recordings from deleted activities';
$string['mod_form_field_recordings_imported'] = 'Show only imported links';
Expand Down
6 changes: 0 additions & 6 deletions mod/bigbluebuttonbn/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,6 @@ private function bigbluebuttonbn_mform_add_block_general(MoodleQuickForm &$mform
$this->standard_intro_elements(get_string('mod_form_field_intro', 'bigbluebuttonbn'));
$mform->setAdvanced('introeditor');
$mform->setAdvanced('showdescription');
if ($cfg['sendnotifications_enabled']) {
$field = ['type' => 'checkbox', 'name' => 'notification', 'data_type' => PARAM_INT,
'description_key' => 'mod_form_field_notification'];
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'],
$field['description_key'], 0);
}
}

/**
Expand Down
38 changes: 29 additions & 9 deletions mod/bigbluebuttonbn/tests/local/helpers/mod_helper_trait_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,18 @@ public function test_process_post_save() {
$generator->enrol_user($teacher->id, $this->get_course()->id);

// Mark the form to trigger notification.
$bbformdata->notification = true;
$bbformdata->coursecontentnotification = true;
$bbformdata->update = false;
$messagesink = $this->redirectMessages();
mod_helper::process_post_save($bbformdata);
edit_module_post_actions($bbformdata, $this->course);
// Now run cron.
ob_start();
$this->runAdhocTasks();
ob_get_clean(); // Suppress output as it can fail the test.
$this->assertEquals(1, $messagesink->count());
$firstmessage = $messagesink->get_messages()[0];
$this->assertStringContainsString('is new in', $firstmessage->smallmessage);
}

/**
Expand All @@ -135,19 +139,21 @@ public function test_process_post_save_with_add() {
$this->create_instance(null, ['type' => instance::TYPE_RECORDING_ONLY]);
$bbformdata = $this->get_form_data_from_instance($bbactivity);

$bbformdata->add = "1";

$bbformdata->update = false;
$messagesink = $this->redirectMessages();
// Enrol users in a course so he will receive the message.
$teacher = $generator->create_user(['role' => 'editingteacher']);
$generator->enrol_user($teacher->id, $this->get_course()->id);
$bbformdata->notification = true;
$bbformdata->coursecontentnotification = true;
mod_helper::process_post_save($bbformdata);
edit_module_post_actions($bbformdata, $this->course);
// Now run cron.
ob_start();
$this->runAdhocTasks();
ob_get_clean(); // Suppress output as it can fail the test.
$this->assertEquals(1, $messagesink->count());
$firstmessage = $messagesink->get_messages()[0];
$this->assertStringContainsString('is new in', $firstmessage->smallmessage);
}

/**
Expand All @@ -170,20 +176,34 @@ public function test_process_post_save_twice_with_completion() {
$bbformdata->openingtime = time() - 1000;
$bbformdata->closing = time() + 1000;
// Enrol users in a course so he will receive the message.
$teacher = $generator->create_user(['role' => 'editingteacher']);
$generator->enrol_user($teacher->id, $this->get_course()->id);

$teacher = $generator->create_user();
$generator->enrol_user($teacher->id, $this->get_course()->id, 'editingteacher');
$this->setUser($teacher);
// Mark the form to trigger notification.
$bbformdata->notification = true;
$bbformdata->coursecontentnotification = true;
$bbformdata->update = false;
$messagesink = $this->redirectMessages();
mod_helper::process_post_save($bbformdata);
edit_module_post_actions($bbformdata, $this->course);
// Now run cron.
ob_start();
$this->runAdhocTasks();
ob_get_clean(); // Suppress output as it can fail the test.
$this->assertEquals(1, $messagesink->count());
// Do it a again, so we check we still have one event of type EVENT_MEETING_START.
$firstmessage = $messagesink->get_messages()[0];
$this->assertStringContainsString('is new in', $firstmessage->smallmessage);
$messagesink->clear();
// Do it a again, so we check we still have one event.
mod_helper::process_post_save($bbformdata);
// Mark the form to trigger notification.
$bbformdata->update = true;
edit_module_post_actions($bbformdata, $this->course);
// Now run cron.
ob_start();
$this->runAdhocTasks();
ob_get_clean(); // Suppress output as it can fail the test.
$this->assertEquals(1, $messagesink->count());
$firstmessage = $messagesink->get_messages()[0];
$this->assertStringContainsString('has been changed', $firstmessage->smallmessage);
}
}
Loading

0 comments on commit 4d72663

Please sign in to comment.