Skip to content

Commit

Permalink
MDL-76704 core_course: Add settings to control selected provider
Browse files Browse the repository at this point in the history
  • Loading branch information
safatshahin committed Jun 21, 2023
1 parent 3f48306 commit f7b2f36
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
12 changes: 12 additions & 0 deletions admin/settings/courses.php
Expand Up @@ -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.
Expand Down
17 changes: 15 additions & 2 deletions course/edit_form.php
Expand Up @@ -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);
}

Expand Down
28 changes: 28 additions & 0 deletions 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"
1 change: 1 addition & 0 deletions lang/en/course.php
Expand Up @@ -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'] = '<p>{$a->moduletypename} <a href="{$a->link}">{$a->modulename}</a> is new in the course <a href="{$a->courselink}">{$a->coursename}</a>.</p><p><a href="{$a->notificationpreferenceslink}">Change your notification preferences</a></p>';
Expand Down
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -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
Expand Down

0 comments on commit f7b2f36

Please sign in to comment.