diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index e89bfb6507..bc3250cfbd 100644 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -154,9 +154,7 @@ if (isset ($_GET['details'])) { api_block_anonymous_users(); - - -if (!api_is_allowed_to_create_course() && !api_is_session_admin()) { +if (!api_is_allowed_to_create_course() && !api_is_session_admin() && !api_is_drh()) { api_not_allowed(true); } @@ -217,30 +215,12 @@ if ($check) { $info_user = UserManager::get_user_info_by_id($student_id); $courses_in_session = array(); - -/*if (!isset ($_GET['id_coach'])) { - $sessions_coached_by_user = Tracking::get_sessions_coached_by_user($_user['user_id']); -foreach ($sessions_coached_by_user as $session_coached_by_user) { -$sid = intval($session_coached_by_user['id']); -$courses_followed_by_coach = Tracking :: get_courses_followed_by_coach($_user['user_id'], $sid); -$courses_in_session[$sid] = $courses_followed_by_coach; -} -} else { -$sessions_coached_by_user = Tracking::get_sessions_coached_by_user(intval($_GET['id_coach'])); -foreach ($sessions_coached_by_user as $session_coached_by_user) { -$sid = intval($session_coached_by_user['id']); -$courses_followed_by_coach = Tracking :: get_courses_followed_by_coach(intval($_GET['id_coach']), $sid); -$courses_in_session[$sid] = $courses_followed_by_coach; -} -}*/ - $courses = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id()); $courses_in_session_by_coach = array(); $sessions_coached_by_user = Tracking::get_sessions_coached_by_user(api_get_user_id()); //RRHH or session admin -if (api_is_session_admin()) { - +if (api_is_session_admin() || api_is_drh()) { $session_by_session_admin = SessionManager::get_sessions_followed_by_drh(api_get_user_id()); if (!empty($session_by_session_admin)) { foreach ($session_by_session_admin as $session_coached_by_user) { diff --git a/main/mySpace/student.php b/main/mySpace/student.php old mode 100755 new mode 100644 index 1f0aeb713c..a56a2fecdf --- a/main/mySpace/student.php +++ b/main/mySpace/student.php @@ -83,8 +83,7 @@ function rsort_users($a, $b) /* MAIN CODE */ //if ($isCoach || api_is_platform_admin() || api_is_drh()) { -if (api_is_allowed_to_create_course() || api_is_drh()) { - +if (api_is_allowed_to_create_course() || api_is_drh()) { if ($export_csv) { $is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT); } else { @@ -92,38 +91,7 @@ if (api_is_allowed_to_create_course() || api_is_drh()) { } $sort_by_first_name = api_sort_by_first_name(); - if (api_is_drh()) { - - $title = get_lang('YourStudents'); - if (!isset($_GET['id_session'])) { - - if (isset($_GET['user_id'])) { - $user_id = intval($_GET['user_id']); - $user_info = api_get_user_info($user_id); - $title = api_get_person_name($user_info['firstname'], $user_info['lastname']).' : '.get_lang('Students'); - $courses_by_teacher = CourseManager::get_course_list_of_user_as_course_admin($user_id); - $students_by_course = array(); - if (!empty($courses_by_teacher)) { - foreach ($courses_by_teacher as $course) { - $students_by_course = array_keys(CourseManager::get_student_list_from_course_code($course['course_code'])); - if (count($students_by_course) > 0) { - foreach ($students_by_course as $student_by_course) { - $students[] = $student_by_course; - } - } - } - } - $students = array_unique($students); - } else { - $students = array_keys(UserManager::get_users_followed_by_drh(api_get_user_id() , STUDENT)); - } - - $courses_of_the_platform = CourseManager :: get_real_course_list(); - foreach ($courses_of_the_platform as $course) { - $courses[$course['code']] = $course['code']; - } - } - + if (api_is_drh()) { $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',32),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" ); $menu_items[] = Display::return_icon('user_na.png', get_lang('Students'), array(), 32); $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), 32), 'teachers.php'); @@ -137,13 +105,12 @@ if (api_is_allowed_to_create_course() || api_is_drh()) { echo $item; } } - if (count($students) > 0) { - + //if (count($students) > 0) { // echo ''; echo Display::url(Display::return_icon('printer.png', get_lang('Print'), array(), 32), 'javascript: void(0);', array('onclick'=>'javascript: window.print();')); - echo Display::url(Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), array(), 32), api_get_self().'?export=xls'); + echo Display::url(Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), array(), 32), api_get_self().'?export=csv'); echo ''; - } + //} echo ''; echo '

'.$title.'

'; } else { @@ -159,24 +126,57 @@ if (api_is_allowed_to_create_course() || api_is_drh()) { } else { $coach_id = api_get_user_id(); } - - if (!isset($_GET['id_session'])) { - //Getting courses - $courses = CourseManager::get_course_list_as_coach($coach_id, false); - if (isset($courses[0])) { - $courses = $courses[0]; + if (api_is_drh()) { + $title = get_lang('YourStudents'); + if (!isset($_GET['id_session'])) { + + if (isset($_GET['user_id'])) { + $user_id = intval($_GET['user_id']); + $user_info = api_get_user_info($user_id); + $title = api_get_person_name($user_info['firstname'], $user_info['lastname']).' : '.get_lang('Students'); + $courses_by_teacher = CourseManager::get_course_list_of_user_as_course_admin($user_id); + $students_by_course = array(); + if (!empty($courses_by_teacher)) { + foreach ($courses_by_teacher as $course) { + $students_by_course = array_keys(CourseManager::get_student_list_from_course_code($course['course_code'])); + if (count($students_by_course) > 0) { + foreach ($students_by_course as $student_by_course) { + $students[] = $student_by_course; + } + } + } + } + if (!empty($students)) { + $students = array_unique($students); + } + } else { + $students = array_keys(UserManager::get_users_followed_by_drh(api_get_user_id() , STUDENT)); + } + + $courses_of_the_platform = CourseManager :: get_real_course_list(); + foreach ($courses_of_the_platform as $course) { + $courses[$course['code']] = $course['code']; + } } - - //Getting students - $students = CourseManager::get_user_list_from_courses_as_coach($coach_id); - } else { - $students = Tracking :: get_student_followed_by_coach_in_a_session($_GET['id_session'], $coach_id); + if (!isset($_GET['id_session'])) { + //Getting courses + $courses = CourseManager::get_course_list_as_coach($coach_id, false); + if (isset($courses[0])) { + $courses = $courses[0]; + } + //Getting students + + $students = CourseManager::get_user_list_from_courses_as_coach($coach_id); + + } else { + $students = Tracking :: get_student_followed_by_coach_in_a_session($_GET['id_session'], $coach_id); + } } $tracking_column = isset($_GET['tracking_column']) ? $_GET['tracking_column'] : ($is_western_name_order xor $sort_by_first_name) ? 1 : 0; $tracking_direction = isset($_GET['tracking_direction']) ? $_GET['tracking_direction'] : DESC; - + if (count($students) > 0) { $table = new SortableTable('tracking_student', 'count_student_coached', null, ($is_western_name_order xor $sort_by_first_name) ? 1 : 0); if ($is_western_name_order) { @@ -223,7 +223,8 @@ if (api_is_allowed_to_create_course() || api_is_drh()) { } } - $all_datas = array(); + $all_datas = array(); + foreach ($students as $student_id) { $student_data = UserManager :: get_user_info_by_id($student_id); if (isset($_GET['id_session'])) {