Code Duplication    Length = 7-8 lines in 2 locations

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

@@ 4871-4877 (lines=7) @@
4868
                                    $logger->addInfo("onlyAddFirstCoachOrTeacher : true");
4869
                                }
4870
4871
                                foreach ($course_coaches as $course_coach) {
4872
                                    $coach_id = UserManager::get_user_id_from_username($course_coach);
4873
                                    if ($coach_id !== false) {
4874
                                        $teacherToAdd = $coach_id;
4875
                                        break;
4876
                                    }
4877
                                }
4878
4879
                                // Un subscribe everyone that's not in the list.
4880
                                $teacherList = CourseManager::get_teacher_list_from_course_code($course_code);
@@ 5002-5009 (lines=8) @@
4999
                                    $logger->addInfo("removeAllTeachersFromCourse true");
5000
                                }
5001
                                $teacherToAdd = null;
5002
                                foreach ($course_coaches as $course_coach) {
5003
                                    $coach_id = UserManager::get_user_id_from_username(
5004
                                        $course_coach
5005
                                    );
5006
                                    if ($coach_id !== false) {
5007
                                        $teacherToAdd[] = $coach_id;
5008
                                    }
5009
                                }
5010
5011
                                if (!empty($teacherToAdd)) {
5012
                                    // Deleting all course teachers and adding the only coach as teacher.