Code Duplication    Length = 7-8 lines in 2 locations

main/inc/lib/sessionmanager.lib.php 2 locations

@@ 4781-4787 (lines=7) @@
4778
                                    $logger->addInfo("onlyAddFirstCoachOrTeacher : true");
4779
                                }
4780
4781
                                foreach ($course_coaches as $course_coach) {
4782
                                    $coach_id = UserManager::get_user_id_from_username($course_coach);
4783
                                    if ($coach_id !== false) {
4784
                                        $teacherToAdd = $coach_id;
4785
                                        break;
4786
                                    }
4787
                                }
4788
4789
                                // Un subscribe everyone that's not in the list.
4790
                                $teacherList = CourseManager::get_teacher_list_from_course_code($course_code);
@@ 4910-4917 (lines=8) @@
4907
                                    $logger->addInfo("removeAllTeachersFromCourse true");
4908
                                }
4909
                                $teacherToAdd = null;
4910
                                foreach ($course_coaches as $course_coach) {
4911
                                    $coach_id = UserManager::get_user_id_from_username(
4912
                                        $course_coach
4913
                                    );
4914
                                    if ($coach_id !== false) {
4915
                                        $teacherToAdd[] = $coach_id;
4916
                                    }
4917
                                }
4918
4919
                                if (!empty($teacherToAdd)) {
4920
                                    // Deleting all course teachers and adding the only coach as teacher.