Merge branch 'MDL-81932-404' of https://github.com/safatshahin/moodle into MOODLE_404_STABLE
This commit is contained in:
@@ -265,13 +265,13 @@ class api {
|
||||
$mform->insertElementBefore(
|
||||
$mform->createElement(
|
||||
'text',
|
||||
'communicationroomname',
|
||||
$provider . 'roomname',
|
||||
get_string('communicationroomname', 'communication'),
|
||||
'maxlength="100" size="20"'
|
||||
),
|
||||
'addcommunicationoptionshere'
|
||||
);
|
||||
$mform->setType('communicationroomname', PARAM_TEXT);
|
||||
$mform->setType($provider . 'roomname', PARAM_TEXT);
|
||||
|
||||
$mform->insertElementBefore(
|
||||
$mform->createElement(
|
||||
@@ -376,6 +376,9 @@ class api {
|
||||
* @return string
|
||||
*/
|
||||
public function get_room_name(): string {
|
||||
if (!$this->communication) {
|
||||
return '';
|
||||
}
|
||||
return $this->communication->get_room_name();
|
||||
}
|
||||
|
||||
@@ -387,7 +390,8 @@ class api {
|
||||
public function set_data(\stdClass $instance): void {
|
||||
if (!empty($instance->id) && $this->communication) {
|
||||
$instance->selectedcommunication = $this->communication->get_provider();
|
||||
$instance->communicationroomname = $this->communication->get_room_name();
|
||||
$roomnameidentifier = $this->get_provider() . 'roomname';
|
||||
$instance->$roomnameidentifier = $this->communication->get_room_name();
|
||||
|
||||
$this->communication->get_form_provider()->set_form_data($instance);
|
||||
}
|
||||
@@ -474,8 +478,6 @@ class api {
|
||||
// Now deactivate the previous provider.
|
||||
$this->update_room(
|
||||
active: processor::PROVIDER_INACTIVE,
|
||||
communicationroomname: $communicationroomname,
|
||||
avatar: $instanceimage,
|
||||
instance: $instance,
|
||||
queue: $queue,
|
||||
);
|
||||
|
||||
@@ -430,10 +430,14 @@ class helper {
|
||||
if (empty($provider)) {
|
||||
$provider = $coursecommunication->get_provider();
|
||||
}
|
||||
$roomnameidenfier = $provider . 'roomname';
|
||||
|
||||
// Determine the communication room name if none was provided and add it to the course data.
|
||||
if (empty($course->communicationroomname)) {
|
||||
$course->communicationroomname = $course->fullname ?? get_course($course->id)->fullname;
|
||||
if (empty($course->$roomnameidenfier)) {
|
||||
$course->$roomnameidenfier = $coursecommunication->get_room_name();
|
||||
if (empty($course->$roomnameidenfier)) {
|
||||
$course->$roomnameidenfier = $course->fullname ?? get_course($course->id)->fullname;
|
||||
}
|
||||
}
|
||||
|
||||
// List of enrolled users for course communication.
|
||||
@@ -465,7 +469,7 @@ class helper {
|
||||
$communication->configure_room_and_membership_by_provider(
|
||||
provider: $provider,
|
||||
instance: $course,
|
||||
communicationroomname: $course->communicationroomname,
|
||||
communicationroomname: $course->$roomnameidenfier,
|
||||
users: $enrolledusers,
|
||||
instanceimage: $courseimage,
|
||||
);
|
||||
@@ -486,7 +490,7 @@ class helper {
|
||||
$communication->configure_room_and_membership_by_provider(
|
||||
provider: $provider,
|
||||
instance: $course,
|
||||
communicationroomname: $course->communicationroomname,
|
||||
communicationroomname: $course->$roomnameidenfier,
|
||||
users: $enrolledusers,
|
||||
instanceimage: $courseimage,
|
||||
queue: false,
|
||||
@@ -533,8 +537,9 @@ class helper {
|
||||
context: $coursecontext,
|
||||
);
|
||||
|
||||
$roomnameidenfier = $provider . 'roomname';
|
||||
$communicationroomname = self::format_group_room_name(
|
||||
baseroomname: $course->communicationroomname,
|
||||
baseroomname: $course->$roomnameidenfier,
|
||||
groupname: $coursegroup->name,
|
||||
);
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ Feature: Communication custom link
|
||||
And I select "Custom link" from the "Provider" singleselect
|
||||
And I should see "Custom link URL"
|
||||
And I set the following fields to these values:
|
||||
| communicationroomname | Test URL |
|
||||
| customlinkurl | #wwwroot#/communication/provider/customlink/tests/behat/fixtures/custom_link_test_page.php |
|
||||
| communication_customlinkroomname | Test URL |
|
||||
| customlinkurl | #wwwroot#/communication/provider/customlink/tests/behat/fixtures/custom_link_test_page.php |
|
||||
And I press "Save changes"
|
||||
Then "Chat to course participants" "button" should be visible
|
||||
And I click on "Chat to course participants" "button"
|
||||
@@ -59,8 +59,8 @@ Feature: Communication custom link
|
||||
When I navigate to "Communication" in current page administration
|
||||
And I select "Custom link" from the "Provider" singleselect
|
||||
And I set the following fields to these values:
|
||||
| communicationroomname | Test URL |
|
||||
| customlinkurl | #wwwroot#/communication/provider/customlink/tests/behat/fixtures/custom_link_test_page.php |
|
||||
| communication_customlinkroomname | Test URL |
|
||||
| customlinkurl | #wwwroot#/communication/provider/customlink/tests/behat/fixtures/custom_link_test_page.php |
|
||||
And I press "Save changes"
|
||||
And "Chat to course participants" "button" should be visible
|
||||
And I run all adhoc tasks
|
||||
@@ -74,8 +74,8 @@ Feature: Communication custom link
|
||||
And I navigate to "Communication" in current page administration
|
||||
And I select "Custom link" from the "Provider" singleselect
|
||||
And I set the following fields to these values:
|
||||
| communicationroomname | Test URL |
|
||||
| customlinkurl | #wwwroot#/communication/provider/customlink/tests/behat/fixtures/custom_link_test_page.php |
|
||||
| communication_customlinkroomname | Test URL |
|
||||
| customlinkurl | #wwwroot#/communication/provider/customlink/tests/behat/fixtures/custom_link_test_page.php |
|
||||
And I press "Save changes"
|
||||
And "Chat to course participants" "button" should be visible
|
||||
And I run all adhoc tasks
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@communication @communication_matrix @javascript
|
||||
@communication @communication_matrix
|
||||
Feature: Communication matrix form field
|
||||
In order to create a new communication room in matrix
|
||||
As a teacher
|
||||
@@ -15,34 +15,20 @@ Feature: Communication matrix form field
|
||||
| user | course | role |
|
||||
| teacher1 | Test course | editingteacher |
|
||||
|
||||
Scenario: I can add room name for matrix room
|
||||
@javascript
|
||||
Scenario: I can add room name and topic for matrix room
|
||||
Given a Matrix mock server is configured
|
||||
And I log in as "teacher1"
|
||||
And I am on "Test course" course homepage
|
||||
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 field "id_selectedcommunication" to "Matrix"
|
||||
And I wait to be redirected
|
||||
And I should see "Room name"
|
||||
And I set the field "id_communicationroomname" to "Sampleroomname"
|
||||
And I press "Save changes"
|
||||
And I navigate to "Communication" in current page administration
|
||||
Then the field "id_communicationroomname" matches value "Sampleroomname"
|
||||
|
||||
Scenario: I can add room topic for matrix room
|
||||
Given a Matrix mock server is configured
|
||||
And I log in as "teacher1"
|
||||
And I am on "Test course" course homepage
|
||||
When I navigate to "Communication" in current page administration
|
||||
And I set the field "id_selectedcommunication" to "Matrix"
|
||||
And I set the following fields to these values:
|
||||
| selectedcommunication | communication_matrix |
|
||||
And I wait to be redirected
|
||||
And I set the following fields to these values:
|
||||
| communication_matrixroomname | Sampleroomname |
|
||||
| matrixroomtopic | Sampleroomtopic |
|
||||
And I should see "Room name"
|
||||
And I should see "Room topic"
|
||||
And I set the field "id_communicationroomname" to "Sampleroomname"
|
||||
And I set the field "id_matrixroomtopic" to "Sampleroomtopic"
|
||||
And I press "Save changes"
|
||||
And I navigate to "Communication" in current page administration
|
||||
Then the field "id_communicationroomname" matches value "Sampleroomname"
|
||||
And I press "Cancel"
|
||||
And I run all adhoc tasks
|
||||
And I navigate to "Communication" in current page administration
|
||||
And the field "id_matrixroomtopic" matches value "Sampleroomtopic"
|
||||
Then the field "Room name" matches value "Sampleroomname"
|
||||
And the field "Room topic" matches value "Sampleroomtopic"
|
||||
|
||||
@@ -69,8 +69,10 @@ class api_test extends \advanced_testcase {
|
||||
// Set the data.
|
||||
$communication->set_data($course);
|
||||
|
||||
$roomnameidenfier = $communication->get_provider() . 'roomname';
|
||||
|
||||
// Test the set data.
|
||||
$this->assertEquals($roomname, $course->communicationroomname);
|
||||
$this->assertEquals($roomname, $course->$roomnameidenfier);
|
||||
$this->assertEquals($provider, $course->selectedcommunication);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,5 +38,72 @@ Feature: Access the communication configuration page
|
||||
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
|
||||
Then I should see "Room name"
|
||||
And I should see "Room topic"
|
||||
|
||||
@javascript
|
||||
Scenario: Changing the communication provider in the form fetches the correct data
|
||||
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:
|
||||
| selectedcommunication | communication_customlink |
|
||||
And I wait to be redirected
|
||||
And I should see "Room name"
|
||||
And I should not see "Room topic"
|
||||
And I should see "Custom link URL"
|
||||
And I set the following fields to these values:
|
||||
| communication_customlinkroomname | Custom link room |
|
||||
| customlinkurl | https://moodle.org |
|
||||
And I click on "Save changes" "button"
|
||||
And I navigate to "Communication" in current page administration
|
||||
And the field "Room name" matches value "Custom link room"
|
||||
And the field "Custom link URL" matches value "https://moodle.org"
|
||||
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 the field "Room name" matches value "Matrix room"
|
||||
And the field "Room topic" matches value "Matrix topic"
|
||||
And I should not see "Custom link URL"
|
||||
And I set the following fields to these values:
|
||||
| selectedcommunication | communication_customlink |
|
||||
And I wait to be redirected
|
||||
And I should see "Room name"
|
||||
And I should see "Custom link URL"
|
||||
And the field "Room name" matches value "Custom link room"
|
||||
And the field "Custom link URL" matches value "https://moodle.org"
|
||||
And I should not see "Room topic"
|
||||
And I set the following fields to these values:
|
||||
| selectedcommunication | communication_matrix |
|
||||
And I wait to be redirected
|
||||
And I click on "Save changes" "button"
|
||||
And I am on "Test course" course homepage with editing mode on
|
||||
And I navigate to "Settings" in current page administration
|
||||
And I set the following fields to these values:
|
||||
| Group mode | Separate groups |
|
||||
And I press "Save and display"
|
||||
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"
|
||||
And I press "Cancel"
|
||||
And I navigate to "Settings" in current page administration
|
||||
And I set the following fields to these values:
|
||||
| Group mode | Visible groups |
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user