Merge branch 'MDL-80318-master' of https://github.com/jleyva/moodle

This commit is contained in:
Shamim Rezaie 2023-12-21 01:13:20 +11:00
commit 494064288c
2 changed files with 16 additions and 3 deletions

View File

@ -3349,9 +3349,11 @@ class core_course_external extends external_api {
instancetype: 'coursecommunication',
instanceid: $course->id
);
$coursesdata[$course->id]['communicationroomname'] = \core_external\util::format_string($communication->get_room_name(), $context);
// This will be usually an URL, however, it is better to consider that can be anything a plugin might return, this is why we will use PARAM_RAW.
$coursesdata[$course->id]['communicationroomurl'] = $communication->get_communication_room_url();
if ($communication->get_provider()) {
$coursesdata[$course->id]['communicationroomname'] = \core_external\util::format_string($communication->get_room_name(), $context);
// This will be usually an URL, however, it is better to consider that can be anything a plugin might return, this is why we will use PARAM_RAW.
$coursesdata[$course->id]['communicationroomurl'] = $communication->get_communication_room_url();
}
}
}

View File

@ -3094,6 +3094,17 @@ class externallib_test extends externallib_advanced_testcase {
$course = reset($result['courses']);
$this->assertEquals($roomname, $course['communicationroomname']);
$this->assertEquals($telegramlink, $course['communicationroomurl']);
// Course without comm tools.
$course = $this->getDataGenerator()->create_course();
$result = external_api::clean_returnvalue(
core_course_external::get_courses_by_field_returns(),
core_course_external::get_courses_by_field('id', $course->id)
);
$course = reset($result['courses']);
$this->assertNotContains('communicationroomname', $course);
$this->assertNotContains('communicationroomurl', $course);
}
public function test_get_courses_by_field_invalid_field() {