Skip to content

Commit

Permalink
Merge branch 'MDL-81595-main' of https://github.com/safatshahin/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
HuongNV13 committed Apr 19, 2024
2 parents 56ea31a + f070a16 commit c021a83
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
12 changes: 9 additions & 3 deletions communication/classes/api.php
Expand Up @@ -427,13 +427,15 @@ public function get_provider(): string {
* @param string $communicationroomname The communication room name
* @param array $users The user ids to add to the room
* @param null|\stored_file $instanceimage The stored file for the avatar
* @param bool $queue Queue the task for the provider room or not
*/
public function configure_room_and_membership_by_provider(
string $provider,
stdClass $instance,
string $communicationroomname,
array $users,
?\stored_file $instanceimage = null,
bool $queue = true,
): void {
// If the current provider is inactive and the new provider is also none, then nothing to do.
if (
Expand All @@ -456,6 +458,7 @@ public function configure_room_and_membership_by_provider(
communicationroomname: $communicationroomname,
avatar: $instanceimage,
instance: $instance,
queue: $queue,
);
return;
}
Expand All @@ -474,6 +477,7 @@ public function configure_room_and_membership_by_provider(
communicationroomname: $communicationroomname,
avatar: $instanceimage,
instance: $instance,
queue: $queue,
);
}

Expand All @@ -492,23 +496,25 @@ public function configure_room_and_membership_by_provider(
communicationroomname: $communicationroomname,
avatar: $instanceimage,
instance: $instance,
queue: $queue,
);
$queue = false;
$queueusertask = false;
} else {
// Otherwise update the room.
$this->update_room(
active: processor::PROVIDER_ACTIVE,
communicationroomname: $communicationroomname,
avatar: $instanceimage,
instance: $instance,
queue: $queue,
);
$queue = true;
$queueusertask = true;
}

// Now add the members.
$this->add_members_to_room(
userids: $users,
queue: $queue,
queue: $queueusertask,
);

}
Expand Down
35 changes: 13 additions & 22 deletions communication/classes/helper.php
Expand Up @@ -480,30 +480,21 @@ public static function update_course_communication_instance(
$communication = self::load_by_course(
courseid: $course->id,
context: $coursecontext,
provider: $provider === processor::PROVIDER_NONE ? null : $provider,
);

if ($communication->get_processor() === null) {
// If a course communication instance is not created, create one.
$communication->create_and_configure_room(
communicationroomname: $course->communicationroomname,
avatar: $courseimage,
instance: $course,
queue: false,
);
} else {
$communication->remove_all_members_from_room();
// Now update the course communication instance with the latest changes.
// We are not making room for this instance as it is a group mode enabled course.
// If provider is none, then we will make the room inactive, otherwise always active in group mode.
$communication->update_room(
active: $provider === processor::PROVIDER_NONE ? processor::PROVIDER_INACTIVE : processor::PROVIDER_ACTIVE,
communicationroomname: $course->communicationroomname,
avatar: $courseimage,
instance: $course,
queue: false,
);
}
// Now handle the course communication according to the provider.
$communication->configure_room_and_membership_by_provider(
provider: $provider,
instance: $course,
communicationroomname: $course->communicationroomname,
users: $enrolledusers,
instanceimage: $courseimage,
queue: false,
);

// As the course is in group mode, make sure no users are in the course room.
$communication->reload();
$communication->remove_all_members_from_room();
}
}

Expand Down

0 comments on commit c021a83

Please sign in to comment.