Code Duplication    Length = 7-8 lines in 2 locations

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

@@ 4772-4778 (lines=7) @@
4769
                                    $logger->addInfo("onlyAddFirstCoachOrTeacher : true");
4770
                                }
4771
4772
                                foreach ($course_coaches as $course_coach) {
4773
                                    $coach_id = UserManager::get_user_id_from_username($course_coach);
4774
                                    if ($coach_id !== false) {
4775
                                        $teacherToAdd = $coach_id;
4776
                                        break;
4777
                                    }
4778
                                }
4779
4780
                                // Un subscribe everyone that's not in the list.
4781
                                $teacherList = CourseManager::get_teacher_list_from_course_code($course_code);
@@ 4896-4903 (lines=8) @@
4893
                                    $logger->addInfo("removeAllTeachersFromCourse true");
4894
                                }
4895
                                $teacherToAdd = null;
4896
                                foreach ($course_coaches as $course_coach) {
4897
                                    $coach_id = UserManager::get_user_id_from_username(
4898
                                        $course_coach
4899
                                    );
4900
                                    if ($coach_id !== false) {
4901
                                        $teacherToAdd[] = $coach_id;
4902
                                    }
4903
                                }
4904
4905
                                if (!empty($teacherToAdd)) {
4906
                                    // Deleting all course teachers and adding the only coach as teacher.