Code Duplication    Length = 7-8 lines in 2 locations

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

@@ 4988-4994 (lines=7) @@
4985
                                    $logger->addInfo("onlyAddFirstCoachOrTeacher : true");
4986
                                }
4987
4988
                                foreach ($course_coaches as $course_coach) {
4989
                                    $coach_id = UserManager::get_user_id_from_username($course_coach);
4990
                                    if ($coach_id !== false) {
4991
                                        $teacherToAdd = $coach_id;
4992
                                        break;
4993
                                    }
4994
                                }
4995
4996
                                // Un subscribe everyone that's not in the list.
4997
                                $teacherList = CourseManager::get_teacher_list_from_course_code($course_code);
@@ 5119-5126 (lines=8) @@
5116
                                    $logger->addInfo("removeAllTeachersFromCourse true");
5117
                                }
5118
                                $teacherToAdd = null;
5119
                                foreach ($course_coaches as $course_coach) {
5120
                                    $coach_id = UserManager::get_user_id_from_username(
5121
                                        $course_coach
5122
                                    );
5123
                                    if ($coach_id !== false) {
5124
                                        $teacherToAdd[] = $coach_id;
5125
                                    }
5126
                                }
5127
5128
                                if (!empty($teacherToAdd)) {
5129
                                    // Deleting all course teachers and adding the only coach as teacher.