Code Duplication    Length = 7-8 lines in 2 locations

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

@@ 4734-4740 (lines=7) @@
4731
                            // Only one coach is added.
4732
                            if ($onlyAddFirstCoachOrTeacher == true) {
4733
4734
                                foreach ($course_coaches as $course_coach) {
4735
                                    $coach_id = UserManager::get_user_id_from_username($course_coach);
4736
                                    if ($coach_id !== false) {
4737
                                        $teacherToAdd = $coach_id;
4738
                                        break;
4739
                                    }
4740
                                }
4741
4742
                                // Un subscribe everyone that's not in the list.
4743
                                $teacherList = CourseManager::get_teacher_list_from_course_code($course_code);
@@ 4839-4846 (lines=8) @@
4836
                            // All coaches are added.
4837
                            if ($removeAllTeachersFromCourse) {
4838
                                $teacherToAdd = null;
4839
                                foreach ($course_coaches as $course_coach) {
4840
                                    $coach_id = UserManager::get_user_id_from_username(
4841
                                        $course_coach
4842
                                    );
4843
                                    if ($coach_id !== false) {
4844
                                        $teacherToAdd[] = $coach_id;
4845
                                    }
4846
                                }
4847
4848
                                if (!empty($teacherToAdd)) {
4849
                                    // Deleting all course teachers and adding the only coach as teacher.