From f7b2f362181f30bbefb6de6ce68ad8c6abe253d3 Mon Sep 17 00:00:00 2001 From: Safat Date: Thu, 18 May 2023 11:49:57 +1000 Subject: [PATCH] MDL-76704 core_course: Add settings to control selected provider --- admin/settings/courses.php | 12 ++++++++ course/edit_form.php | 17 +++++++++-- .../course_communication_defaults.feature | 28 +++++++++++++++++++ lang/en/course.php | 1 + version.php | 2 +- 5 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 course/tests/behat/course_communication_defaults.feature diff --git a/admin/settings/courses.php b/admin/settings/courses.php index c77469f4b504f..ac91d531d5c0b 100644 --- a/admin/settings/courses.php +++ b/admin/settings/courses.php @@ -214,6 +214,18 @@ $temp->add(new admin_setting_configselect('moodlecourse/groupmode', new lang_string('groupmode'), '', key($choices),$choices)); $temp->add(new admin_setting_configselect('moodlecourse/groupmodeforce', new lang_string('force'), new lang_string('coursehelpforce'), 0,array(0 => new lang_string('no'), 1 => new lang_string('yes')))); + // Communication. + $temp->add(new admin_setting_heading('communication', + new lang_string('communication', 'core_communication'), '')); + + list($communicationproviders, $defaulprovider) = \core_communication\api:: + get_enabled_providers_and_default('communication_matrix'); + + $temp->add(new admin_setting_configselect('moodlecourse/coursecommunicationprovider', + new lang_string('seleccommunicationprovider', 'communication'), + new lang_string('coursecommunication_desc', 'course'), + $defaulprovider, $communicationproviders)); + $ADMIN->add('courses', $temp); // Download course content. diff --git a/course/edit_form.php b/course/edit_form.php index aabffa53b2b2a..d0b50f3ab7952 100644 --- a/course/edit_form.php +++ b/course/edit_form.php @@ -389,11 +389,24 @@ function definition() { // Add communication plugins to the form. if (core_communication\api::is_available()) { + + $instanceconfig = core_communication\processor::PROVIDER_NONE; + // For new courses. + if (empty($course->id)) { + $instanceid = 0; + if (!empty($courseconfig->coursecommunicationprovider)) { + $instanceconfig = $courseconfig->coursecommunicationprovider; + } + } else { + // For existing courses. + $instanceid = $course->id; + } + $communication = \core_communication\api::load_by_instance( 'core_course', 'coursecommunication', - empty($course->id) ? 0 : $course->id); - $communication->form_definition($mform); + $instanceid); + $communication->form_definition($mform, $instanceconfig); $communication->set_data($course); } diff --git a/course/tests/behat/course_communication_defaults.feature b/course/tests/behat/course_communication_defaults.feature new file mode 100644 index 0000000000000..c7fc5982fb2f5 --- /dev/null +++ b/course/tests/behat/course_communication_defaults.feature @@ -0,0 +1,28 @@ +@core @core_course +Feature: Course communication + In order to create a new communication room in for course + As an admin + I should have matrix plugin enabled by default + I should not have any plugins enabled by default for existing courses + + Background: + Given the following "courses" exist: + | fullname | shortname | + | Test course | C | + And I enable communication experimental feature + And I log in as "admin" + + Scenario: I should have matrix plugin by default for new courses + Given I go to the courses management page + And I should see the "Categories" management page + And I click on category "Category 1" in the management interface + And I should see the "Course categories and courses" management page + And I follow "Create new course" + When I click on "Communication" "link" + Then the field "Communication service" matches value "Matrix" + + Scenario: I should have communication disabled by default for existing courses + Given I am on "Test course" course homepage + When I navigate to "Settings" in current page administration + And I click on "Communication" "link" + Then the field "Communication service" matches value "None" diff --git a/lang/en/course.php b/lang/en/course.php index e01ce31d12434..4255e127636dc 100644 --- a/lang/en/course.php +++ b/lang/en/course.php @@ -66,6 +66,7 @@ $string['completionrequirements'] = 'Completion requirements for {$a}'; $string['courseaccess'] = 'Course access'; $string['coursealreadyfinished'] = 'Course already finished'; +$string['coursecommunication_desc'] = 'The default communication service for the new courses. All the existing courses will not have any provider selected by default.'; $string['coursecontentnotification'] = 'Send content change notification'; $string['coursecontentnotifnew'] = '{$a->coursename} new content'; $string['coursecontentnotifnewbody'] = '

{$a->moduletypename} {$a->modulename} is new in the course {$a->coursename}.

Change your notification preferences

'; diff --git a/version.php b/version.php index f742bc263343d..4574cb5114352 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2023061600.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2023061600.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '4.3dev (Build: 20230616)'; // Human-friendly version name