Skip to content

Commit

Permalink
Merge branch 'MDL-83143-main' of https://github.com/safatshahin/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Oct 17, 2024
2 parents db8da82 + fcf941c commit 7ebe8cc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
18 changes: 9 additions & 9 deletions communication/classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,13 @@ public static function update_course_communication_instance(
if (empty($provider)) {
$provider = $coursecommunication->get_provider();
}
$roomnameidenfier = $provider . 'roomname';
$roomnameidentifier = $provider . 'roomname';

// Determine the communication room name if none was provided and add it to the course data.
if (empty($course->$roomnameidenfier)) {
$course->$roomnameidenfier = $coursecommunication->get_room_name();
if (empty($course->$roomnameidenfier)) {
$course->$roomnameidenfier = $course->fullname ?? get_course($course->id)->fullname;
if (empty($course->$roomnameidentifier)) {
$course->$roomnameidentifier = $coursecommunication->get_room_name();
if (empty($course->$roomnameidentifier)) {
$course->$roomnameidentifier = $course->fullname ?? get_course($course->id)->fullname;
}
}

Expand Down Expand Up @@ -470,7 +470,7 @@ public static function update_course_communication_instance(
$communication->configure_room_and_membership_by_provider(
provider: $provider,
instance: $course,
communicationroomname: $course->$roomnameidenfier,
communicationroomname: $course->$roomnameidentifier,
users: $enrolledusers,
instanceimage: $courseimage,
);
Expand All @@ -491,7 +491,7 @@ public static function update_course_communication_instance(
$communication->configure_room_and_membership_by_provider(
provider: $provider,
instance: $course,
communicationroomname: $course->$roomnameidenfier,
communicationroomname: $course->$roomnameidentifier,
users: $enrolledusers,
instanceimage: $courseimage,
queue: false,
Expand Down Expand Up @@ -542,9 +542,9 @@ public static function update_group_communication_instances_for_course(
context: $coursecontext,
);

$roomnameidenfier = $provider . 'roomname';
$roomnameidentifier = $provider . 'roomname';
$communicationroomname = self::format_group_room_name(
baseroomname: $course->$roomnameidenfier,
baseroomname: $course->$roomnameidentifier,
groupname: $coursegroup->name,
);

Expand Down
4 changes: 2 additions & 2 deletions communication/tests/api_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public function test_set_data(): void {
// Set the data.
$communication->set_data($course);

$roomnameidenfier = $communication->get_provider() . 'roomname';
$roomnameidentifier = $communication->get_provider() . 'roomname';

// Test the set data.
$this->assertEquals($roomname, $course->$roomnameidenfier);
$this->assertEquals($roomname, $course->$roomnameidentifier);
$this->assertEquals($provider, $course->selectedcommunication);
}

Expand Down
23 changes: 23 additions & 0 deletions communication/tests/behat/communication_configuration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,26 @@ Feature: Access the communication configuration page
And I navigate to "Communication" in current page administration
And the field "Room name" matches value "Matrix room"
And the field "Room topic" matches value "Matrix topic"

@javascript
Scenario: Emptying the room name field always sets course name as default
Given a Matrix mock server is configured
And I am on the "Test course" "Course" page logged in as "teacher1"
When I navigate to "Communication" in current page administration
And I set the following fields to these values:
| selectedcommunication | communication_matrix |
And I wait to be redirected
And I should see "Room name"
And I should see "Room topic"
And I set the following fields to these values:
| communication_matrixroomname | Matrix room |
| matrixroomtopic | Matrix topic |
And I click on "Save changes" "button"
And I navigate to "Communication" in current page administration
Then the field "Room name" matches value "Matrix room"
And the field "Room topic" matches value "Matrix topic"
And I set the following fields to these values:
| communication_matrixroomname | |
And I click on "Save changes" "button"
And I navigate to "Communication" in current page administration
And the field "Room name" matches value "Test course"
6 changes: 6 additions & 0 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4801,6 +4801,12 @@ function course_get_communication_instance_data(int $courseid): array {
*/
function course_update_communication_instance_data(stdClass $data): void {
$data->id = $data->instanceid; // For correct use in update_course.
// If the room name is set to empty, then set it course name.
$provider = $data->selectedcommunication ?? null;
$roomnameidentifier = $provider . 'roomname';
if ($provider && empty($data->$roomnameidentifier)) {
$data->$roomnameidentifier = $data->fullname ?? get_course($data->id)->fullname;
}
core_communication\helper::update_course_communication_instance(
course: $data,
changesincoursecat: false,
Expand Down

0 comments on commit 7ebe8cc

Please sign in to comment.