function create_backup_is_admin($_cid) { $this_section = SECTION_COURSES; if (isset($_GET['session']) && $_GET['session']) { $archive_path = api_get_path(SYS_ARCHIVE_PATH); $_cid = true; $is_courseAdmin = true; } else { $archive_path = api_get_path(SYS_ARCHIVE_PATH); } $archive_file = $_GET['archive']; $archive_file = str_replace(array('..', '/', '\\'), '', $archive_file); list($extension) = getextension($archive_file); if (empty($extension) || !file_exists($archive_path . $archive_file)) { return false; } $extension = strtolower($extension); $content_type = ''; if (in_array($extension, array('xml', 'csv')) && (api_is_platform_admin(true) || api_is_drh())) { $content_type = 'application/force-download'; // TODO: The following unclear condition is commented ant is to be checked. A replacement has been proposed. //} elseif (strtolower($extension) == 'zip' || ('html' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin))) { } elseif ($extension == 'zip' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin)) { // $content_type = 'application/force-download'; } if (empty($content_type)) { return false; } return true; }
public static function redirect() { global $param; $param = isset($param) ? $param : ''; $redirect_url = ''; /* //If session request url is setted, we go there if (!empty($_SESSION['request_uri'])) { $req = $_SESSION['request_uri']; unset($_SESSION['request_uri']); header('location: '.$req); exit(); } */ if (api_is_student() && !api_get_setting('student_page_after_login') == '') { $redirect_url = html_entity_decode(api_get_setting('student_page_after_login')); if ($redirect_url[0] == "/") { $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; } } if (api_is_teacher() && !api_get_setting('teacher_page_after_login') == '') { $redirect_url = html_entity_decode(api_get_setting('teacher_page_after_login')); if ($redirect_url[0] == "/") { $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; } } if (api_is_drh() && !api_get_setting('drh_page_after_login') == '') { $redirect_url = html_entity_decode(api_get_setting('drh_page_after_login')); if ($redirect_url[0] == "/") { $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; } } if (api_is_session_admin() && !api_get_setting('sessionadmin_page_after_login') == '') { $redirect_url = html_entity_decode(api_get_setting('sessionadmin_page_after_login')); if ($redirect_url[0] == "/") { $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; } } if (!empty($redirect_url)) { header('Location: ' . $redirect_url . $param); exit; } // Custom pages if (CustomPages::enabled()) { CustomPages::display(CustomPages::INDEX_LOGGED); } header('location: ' . api_get_path(WEB_PATH) . api_get_setting('page_after_login') . $param); exit; }
/** * @param int $userId * * @return array */ public static function getStats($userId) { if (api_is_drh() && api_drh_can_access_all_session_content()) { $studentList = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', $userId, false, null, null, null, null, null, null, null, array(), array(), STUDENT); $students = array(); foreach ($studentList as $studentData) { $students[] = $studentData['user_id']; } $teacherList = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', $userId, false, null, null, null, null, null, null, null, array(), array(), COURSEMANAGER); $teachers = array(); foreach ($teacherList as $teacherData) { $teachers[] = $teacherData['user_id']; } $humanResources = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', $userId, false, null, null, null, null, null, null, null, array(), array(), DRH); $humanResourcesList = array(); foreach ($humanResources as $item) { $humanResourcesList[] = $item['user_id']; } $platformCourses = SessionManager::getAllCoursesFollowedByUser($userId, null, null, null, null, null); //$platformCourses = SessionManager::getAllCoursesFromAllSessionFromDrh($userId); $courses = array(); foreach ($platformCourses as $course) { $courses[$course['code']] = $course['code']; } $sessions = SessionManager::get_sessions_followed_by_drh($userId); } else { $studentList = UserManager::getUsersFollowedByUser($userId, STUDENT, false, false, false, null, null, null, null, null, null, COURSEMANAGER); $students = array(); foreach ($studentList as $studentData) { $students[] = $studentData['user_id']; } $teacherList = UserManager::getUsersFollowedByUser($userId, COURSEMANAGER, false, false, false, null, null, null, null, null, null, COURSEMANAGER); $teachers = array(); foreach ($teacherList as $teacherData) { $teachers[] = $teacherData['user_id']; } $humanResources = UserManager::getUsersFollowedByUser($userId, DRH, false, false, false, null, null, null, null, null, null, COURSEMANAGER); $humanResourcesList = array(); foreach ($humanResources as $item) { $humanResourcesList[] = $item['user_id']; } $platformCourses = CourseManager::getCoursesFollowedByUser($userId, COURSEMANAGER); foreach ($platformCourses as $course) { $courses[$course['code']] = $course['code']; } $sessions = SessionManager::getSessionsFollowedByUser($userId, COURSEMANAGER); } return array('drh' => $humanResourcesList, 'teachers' => $teachers, 'students' => $students, 'courses' => $courses, 'sessions' => $sessions); }
<?php /* See license terms in /license.txt */ //require_once '../../main/inc/global.inc.php'; //Add the JS needed to use the jqgrid $htmlHeadXtra[] = api_get_jqgrid_js(); $allowed = api_is_platform_admin() || api_is_drh(); if (!$allowed) { api_not_allowed(true); } Display::display_header(); //jqgrid will use this URL to do the selects $url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_user_list_plugin_widescale'; //The order is important you need to check the the $column variable in the model.ajax.php file $columns = array(get_lang('Username'), get_lang('Firstname'), get_lang('Lastname'), get_lang('Password')); //Column config $column_model = array(array('name' => 'username', 'index' => 'username', 'width' => '100', 'align' => 'left'), array('name' => 'firstname', 'index' => 'firstname', 'width' => '100', 'align' => 'left'), array('name' => 'lastname', 'index' => 'lastname', 'width' => '100', 'align' => 'left'), array('name' => 'exam_password', 'index' => 'exam_password', 'width' => '100', 'align' => 'left', 'sortable' => 'false')); //Autowidth $extra_params['autowidth'] = 'true'; //height auto $extra_params['height'] = 'auto'; //With this function we can add actions to the jgrid (edit, delete, etc) /* $action_links = 'function action_formatter(cellvalue, options, rowObject) { return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'. ' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=copy&id=\'+options.rowId+\'">'.Display::return_icon('copy.png',get_lang('Copy'),'',ICON_SIZE_SMALL).'</a>'. ' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'. '\'; }';*/ $action_links = null; $room = UserManager::get_extra_user_data_by_field(api_get_user_id(), 'exam_room');
} // When loading a chamilo page do not include the hot courses and news if (!isset($_REQUEST['include'])) { if (api_get_setting('show_hot_courses') == 'true') { $hot_courses = $controller->return_hot_courses(); } $announcements_block = $controller->return_announcements(); } $controller->tpl->assign('hot_courses', $hot_courses); $controller->tpl->assign('announcements_block', $announcements_block); $controller->tpl->assign('home_page_block', $controller->return_home_page()); $controller->tpl->assign('navigation_course_links', $controller->return_navigation_links()); $controller->tpl->assign('notice_block', $controller->return_notice()); $controller->tpl->assign('main_navigation_block', $controller->return_navigation_links()); $controller->tpl->assign('help_block', $controller->return_help()); if (api_is_platform_admin() || api_is_drh()) { $controller->tpl->assign('skills_block', $controller->return_skills_links()); } if (api_is_anonymous()) { $controller->tpl->setLoginBodyClass(); } // direct login to course if (isset($_GET['firstpage'])) { api_set_firstpage_parameter($_GET['firstpage']); // if we are already logged, go directly to course if (api_user_is_login()) { echo "<script type='text/javascript'>self.location.href='index.php?firstpage=" . Security::remove_XSS($_GET['firstpage']) . "'</script>"; } } else { api_delete_firstpage_parameter(); }
// Access restrictions. $is_allowedToTrack = api_is_platform_admin() || api_is_allowed_to_create_course() || api_is_session_admin() || api_is_drh() || api_is_course_tutor() || api_is_course_admin(); if (!$is_allowedToTrack) { api_not_allowed(true); exit; } // If the user is a HR director (drh) if (api_is_drh()) { // Blocking course for drh if (api_drh_can_access_all_session_content()) { // If the drh has been configured to be allowed to see all session content, give him access to the session courses $coursesFromSession = SessionManager::getAllCoursesFollowedByUser(api_get_user_id(), null); if (!empty($coursesFromSession)) { $coursesFromSession = array_keys($coursesFromSession); } $coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id()); if (!empty($coursesFollowedList)) { $coursesFollowedList = array_keys($coursesFollowedList); } if (!in_array($courseCode, $coursesFollowedList)) { if (!in_array($courseCode, $coursesFromSession)) { api_not_allowed();
*/ $pathopen = isset($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null; // Including the global initialization file require_once '../inc/global.inc.php'; $current_course_tool = TOOL_TRACKING; $course_info = api_get_course_info(); $from_myspace = false; $from = isset($_GET['from']) ? $_GET['from'] : null; if ($from == 'myspace') { $from_myspace = true; $this_section = "session_my_space"; } else { $this_section = SECTION_COURSES; } // Access restrictions. $is_allowedToTrack = api_is_platform_admin() || api_is_allowed_to_create_course() || api_is_session_admin() || api_is_drh() || api_is_course_tutor(); if (!$is_allowedToTrack) { api_not_allowed(); exit; } // Including additional libraries. require_once api_get_path(SYS_CODE_PATH) . 'resourcelinker/resourcelinker.inc.php'; // Starting the output buffering when we are exporting the information. $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false; $session_id = intval($_REQUEST['id_session']); if ($export_csv) { ob_start(); } if (empty($session_id)) { $session_id = api_get_session_id(); }
/** * It's used to print attendance sheet * @param string action * @param int attendance id */ public function attendance_sheet_export_to_pdf($action, $attendance_id, $student_id = 0, $course_id = '') { $attendance = new Attendance(); $courseInfo = CourseManager::get_course_information($course_id); $attendance->set_course_id($courseInfo['code']); $data_array = array(); $data_array['attendance_id'] = $attendance_id; $data_array['users_in_course'] = $attendance->get_users_rel_course($attendance_id); $filter_type = 'today'; if (!empty($_REQUEST['filter'])) { $filter_type = $_REQUEST['filter']; } $my_calendar_id = null; if (is_numeric($filter_type)) { $my_calendar_id = $filter_type; $filter_type = 'calendar_id'; } $data_array['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id, $filter_type, $my_calendar_id); if (api_is_allowed_to_edit(null, true) || api_is_drh()) { $data_array['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id); } else { if (!empty($student_id)) { $user_id = intval($student_id); } else { $user_id = api_get_user_id(); } $data_array['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id, $user_id); $data_array['faults'] = $attendance->get_faults_of_user($user_id, $attendance_id); $data_array['user_id'] = $user_id; } $data_array['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id($attendance_id); //Set headers pdf $courseCategory = CourseManager::get_course_category($courseInfo['category_code']); $teacherInfo = CourseManager::get_teacher_list_from_course_code($courseInfo['real_id']); $teacherName = null; foreach ($teacherInfo as $dados) { if ($teacherName != null) { $teacherName = $teacherName . " / "; } $teacherName .= $dados['firstname'] . " " . $dados['lastname']; } // Get data table - Marco - ordenacao fixa - just fullname $data_table = array(); $head_table = array('#', get_lang('Name')); foreach ($data_array['attendant_calendar'] as $class_day) { //$head_table[] = api_format_date($class_day['date_time'], DATE_FORMAT_SHORT).' <br />'.api_format_date($class_day['date_time'], TIME_NO_SEC_FORMAT); $head_table[] = api_format_date($class_day['date_time'], DATE_FORMAT_NUMBER_NO_YEAR); } $data_table[] = $head_table; $dataClass = array(); $max_dates_per_page = 10; $data_attendant_calendar = $data_array['attendant_calendar']; $data_users_presence = $data_array['users_presence']; $count = 1; if (!empty($data_array['users_in_course'])) { foreach ($data_array['users_in_course'] as $user) { $cols = 1; $result = array(); $result['count'] = $count; $result['full_name'] = api_get_person_name($user['firstname'], $user['lastname']); foreach ($data_array['attendant_calendar'] as $class_day) { if ($class_day['done_attendance'] == 1) { if ($data_users_presence[$user['user_id']][$class_day['id']]['presence'] == 1) { $result[$class_day['id']] = get_lang('UserAttendedSymbol'); } else { $result[$class_day['id']] = get_lang('UserNotAttendedSymbol'); } } else { $result[$class_day['id']] = " "; } $cols++; } $count++; $data_table[] = $result; } } $max_cols_per_page = 12; //10 dates + 2 name and number $max_dates_per_page = $max_dates_per_page_original = $max_cols_per_page - 2; //10 $rows = count($data_table); if ($cols > $max_cols_per_page) { $number_tables = round(($cols - 2) / $max_dates_per_page); $headers = $data_table[0]; $all = array(); $tables = array(); $changed = 1; for ($i = 0; $i <= $rows; $i++) { $row = $data_table[$i]; $key = 1; $max_dates_per_page = 10; $item = $data_table[$i]; $count_j = 0; if (!empty($item)) { foreach ($item as $value) { if ($count_j >= $max_dates_per_page) { $key++; $max_dates_per_page = $max_dates_per_page_original * $key; //magic hack $tables[$key][$i][] = $tables[1][$i][0]; $tables[$key][$i][] = $tables[1][$i][1]; } $tables[$key][$i][] = $value; $count_j++; } } } $content = null; if (!empty($tables)) { foreach ($tables as $sub_table) { $content .= Export::convert_array_to_html($sub_table) . '<br /><br />'; } } } else { $content .= Export::convert_array_to_html($data_table, array('header_attributes' => array('align' => 'center'))); } $params = array('filename' => get_lang('Attendance') . '-' . api_get_local_time(), 'pdf_title' => $courseInfo['title'], 'course_code' => $courseInfo['code'], 'add_signatures' => true, 'orientation' => 'landscape', 'pdf_teachers' => $teacherName, 'pdf_course_category' => $courseCategory['name'], 'format' => 'A4-L', 'orientation' => 'L'); Export::export_html_to_pdf($content, $params); exit; }
/** * Gives a list of courses for the given user in the given session * @param integer $user_id * @param integer $session_id * @return array list of statuses (session_id-course_code => status) */ public static function get_courses_list_by_session($user_id, $session_id) { // Database Table Definitions $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $user_id = intval($user_id); $session_id = intval($session_id); //we filter the courses from the URL $join_access_url = $where_access_url = ''; if (api_get_multiple_access_url()) { $urlId = api_get_current_access_url_id(); if ($urlId != -1) { $tbl_url_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); $join_access_url = " , {$tbl_url_session} url_rel_session "; $where_access_url = " AND access_url_id = {$urlId} AND url_rel_session.session_id = {$session_id} "; } } $personal_course_list = array(); $courses = array(); /* This query is very similar to the query below, but it will check the session_rel_course_user table if there are courses registered to our user or not */ $sql = "SELECT DISTINCT\n c.visibility,\n c.id as real_id\n FROM {$tbl_session_course_user} as scu\n INNER JOIN {$tbl_session_course} sc\n ON (scu.session_id = sc.session_id AND scu.c_id = sc.c_id)\n INNER JOIN {$tableCourse} as c\n ON (scu.c_id = c.id)\n {$join_access_url}\n WHERE\n scu.user_id = {$user_id} AND\n scu.session_id = {$session_id}\n {$where_access_url}\n ORDER BY sc.position ASC"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { while ($result_row = Database::fetch_array($result, 'ASSOC')) { $result_row['status'] = 5; if (!in_array($result_row['real_id'], $courses)) { $personal_course_list[] = $result_row; $courses[] = $result_row['real_id']; } } } if (api_is_allowed_to_create_course()) { $sql = "SELECT DISTINCT\n c.visibility, c.id as real_id\n FROM {$tbl_session_course_user} as scu\n INNER JOIN {$tbl_session} as s\n ON (scu.session_id = s.id)\n INNER JOIN {$tbl_session_course} sc\n ON (scu.session_id = sc.session_id AND scu.c_id = sc.c_id)\n INNER JOIN {$tableCourse} as c\n ON (scu.c_id = c.id)\n {$join_access_url}\n WHERE\n s.id = {$session_id} AND\n (\n (scu.user_id={$user_id} AND scu.status=2) OR\n s.id_coach = {$user_id}\n )\n {$where_access_url}\n ORDER BY sc.position ASC"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { while ($result_row = Database::fetch_array($result, 'ASSOC')) { $result_row['status'] = 2; if (!in_array($result_row['real_id'], $courses)) { $personal_course_list[] = $result_row; $courses[] = $result_row['real_id']; } } } } if (api_is_drh()) { $session_list = SessionManager::get_sessions_followed_by_drh($user_id); $session_list = array_keys($session_list); if (in_array($session_id, $session_list)) { $course_list = SessionManager::get_course_list_by_session_id($session_id); if (!empty($course_list)) { foreach ($course_list as $course) { $personal_course_list[] = $course; } } } } else { //check if user is general coach for this session $s = api_get_session_info($session_id); if ($s['id_coach'] == $user_id) { $course_list = SessionManager::get_course_list_by_session_id($session_id); if (!empty($course_list)) { foreach ($course_list as $course) { if (!in_array($course['id'], $courses)) { $personal_course_list[] = $course; } } } } } return $personal_course_list; }
<param name="movie" value="../plugin/hotspot/hotspot_solution.swf?modifyAnswers=' . $questionId . '&exe_id=' . $id . '&from_db=1" /> </object> </td> </tr> </table>'; } } } if ($show_results) { if ($answerType != HOT_SPOT) { echo '</table>'; } } $comnt = null; if ($show_results) { if ($is_allowedToEdit && $locked == false && !api_is_drh() && !api_is_student_boss() && $isCoachAllowedToEdit) { $isFeedbackAllowed = true; } else { if (!$isCoachAllowedToEdit && $allowCoachFeedbackExercises) { $isFeedbackAllowed = true; } } $marksname = ''; if ($isFeedbackAllowed) { $name = "fckdiv" . $questionId; $marksname = "marksName" . $questionId; if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { $url_name = get_lang('EditCommentsAndMarks'); } else { if ($action == 'edit') { $url_name = get_lang('EditIndividualComment');
$total_score_text .= '</div>'; } } if (!empty($category_list) && ($show_results || $show_only_total_score)) { //Adding total $category_list['total'] = array('score' => $my_total_score_temp, 'total' => $totalWeighting); echo Testcategory::get_stats_table_by_attempt($objExercise->id, $category_list); } echo $total_score_text; echo $exercise_content; echo $total_score_text; if (is_array($arrid) && is_array($arrmarks)) { $strids = implode(",", $arrid); $marksid = implode(",", $arrmarks); } if ($is_allowedToEdit && $locked == false && !api_is_drh()) { if (in_array($origin, array('tracking_course', 'user_course', 'correct_exercise_in_lp'))) { echo ' <form name="myform" id="myform" action="exercise_report.php?exerciseId=' . $exercise_id . '&filter=2&comments=update&exeid=' . $id . '&origin=' . $origin . '&details=true&course=' . Security::remove_XSS($_GET['cidReq']) . $fromlink . '" method="post">'; echo '<input type = "hidden" name="lp_item_id" value="' . $learnpath_id . '">'; echo '<input type = "hidden" name="lp_item_view_id" value="' . $lp_item_view_id . '">'; echo '<input type = "hidden" name="student_id" value="' . $student_id . '">'; echo '<input type = "hidden" name="total_score" value="' . $totalScore . '"> '; echo '<input type = "hidden" name="my_exe_exo_id" value="' . $exercise_id . '"> '; } else { echo ' <form name="myform" id="myform" action="exercise_report.php?exerciseId=' . $exercise_id . '&filter=1&comments=update&exeid=' . $id . '" method="post">'; } if ($origin != 'learnpath' && $origin != 'student_progress') { echo '<label><input type= "checkbox" name="send_notification"> ' . get_lang('SendEmail') . '</label>'; ?> <button type="submit" class="btn btn-primary" value="<?php echo get_lang('Ok');
/** * It's used for listing courses with categories, * render to courses_categories view * @param string action * @param string Category code (optional) */ public function courses_categories($action, $category_code = null, $message = '', $error = '', $content = null) { $data = array(); $browse_course_categories = $this->model->browse_course_categories(); if ($action == 'display_random_courses') { $data['browse_courses_in_category'] = $this->model->browse_courses_in_category(null, 10); } else { if (!isset($category_code)) { $category_code = $browse_course_categories[0][1]['code']; // by default first category } $data['browse_courses_in_category'] = $this->model->browse_courses_in_category($category_code); } $data['search_form'] = $this->getSearchForm(); $data['browse_course_categories'] = $browse_course_categories; $data['code'] = Security::remove_XSS($category_code); // getting all the courses to which the user is subscribed to $curr_user_id = api_get_user_id(); $user_courses = $this->model->get_courses_of_user($curr_user_id); $user_coursecodes = array(); // we need only the course codes as these will be used to match against the courses of the category if ($user_courses != '') { foreach ($user_courses as $key => $value) { $user_coursecodes[] = $value['code']; } } if (api_is_drh()) { $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id()); foreach ($courses as $course) { $user_coursecodes[] = $course['code']; } } $data['user_coursecodes'] = $user_coursecodes; $data['action'] = $action; $data['message'] = $message; $data['content'] = $content; $data['error'] = $error; // render to the view $this->view->set_data($data); $this->view->set_layout('layout'); $this->view->set_template('courses_categories'); $this->view->render(); }
/** * Checks if user can login as another user * * @param int $loginAsUserId the user id to log in * @param int $userId my user id * @return bool */ function api_can_login_as($loginAsUserId, $userId = null) { if (empty($userId)) { $userId = api_get_user_id(); } if ($loginAsUserId == $userId) { return false; } if (empty($loginAsUserId)) { return false; } if ($loginAsUserId != strval(intval($loginAsUserId))) { return false; } // Check if the user to login is an admin if (api_is_platform_admin_by_id($loginAsUserId)) { // Only super admins can login to admin accounts if (!api_global_admin_can_edit_admin($loginAsUserId)) { return false; } } $userInfo = api_get_user_info($userId); $isDrh = function () use($loginAsUserId) { if (api_is_drh()) { if (api_drh_can_access_all_session_content()) { $users = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', api_get_user_id()); $userList = array(); foreach ($users as $user) { $userList[] = $user['user_id']; } if (in_array($loginAsUserId, $userList)) { return true; } } else { if (api_is_drh() && UserManager::is_user_followed_by_drh($loginAsUserId, api_get_user_id())) { return true; } } } return false; }; return api_is_platform_admin() || api_is_session_admin() && $userInfo['status'] == 5 || $isDrh(); }
/** * Get the attendaces to display on the current page (fill the sortable-table) * @param int offset of first user to recover * @param int Number of users to get * @param int Column to sort on * @param string Order (ASC,DESC) * @see SortableTable#get_table_data($from) */ static function get_attendance_data($from = 0, $number_of_items = 20, $column = 1, $direction = 'desc') { $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); $course_id = api_get_course_int_id(); $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id); $column = intval($column); $from = intval($from); $number_of_items = intval($number_of_items); if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'ASC'; } $att = new Attendance(); $att->set_session_id($session_id); $att->set_course_int_id($course_id); $active_plus = 'att.active = 1'; if (api_is_platform_admin()) { $active_plus = ' 1 = 1 '; } $sql = "SELECT\n att.id,\n att.name,\n att.description,\n att.attendance_qualify_max,\n att.locked,\n att.active,\n att.session_id\n\t\t\t\tFROM {$tbl_attendance} att\n\t\t\t\tWHERE c_id = {$course_id} AND {$active_plus} {$condition_session}\n\t\t\t\tORDER BY {$column} {$direction}\n LIMIT {$from}, {$number_of_items} "; $res = Database::query($sql); $attendances = array(); $param_gradebook = ''; if (isset($_SESSION['gradebook'])) { $param_gradebook = '&gradebook=' . $_SESSION['gradebook']; } $user_info = api_get_user_info(); while ($attendance = Database::fetch_array($res, 'ASSOC')) { $id = $attendance['id']; $student_param = ''; if (api_is_drh() && $_GET['student_id']) { $student_param = '&student_id=' . Security::remove_XSS($_GET['student_id']); } $session_star = ''; if (api_get_session_id() == $attendance['session_id']) { $session_star = api_get_session_image(api_get_session_id(), $user_info['status']); } if ($attendance['active'] == 0) { $attendance['name'] = "<del>" . $attendance['name'] . "</del>"; } if ($attendance['locked'] == 1) { if (api_is_allowed_to_edit(null, true)) { //Link to edit $attendance['name'] = '<a href="index.php?' . api_get_cidreq() . '&action=attendance_sheet_list&attendance_id=' . $id . $param_gradebook . $student_param . '">' . $attendance['name'] . '</a>' . $session_star; } else { //Link to view $attendance['name'] = '<a href="index.php?' . api_get_cidreq() . '&action=attendance_sheet_list_no_edit&attendance_id=' . $id . $param_gradebook . $student_param . '">' . $attendance['name'] . '</a>' . $session_star; } } else { $attendance['name'] = '<a href="index.php?' . api_get_cidreq() . '&action=attendance_sheet_list&attendance_id=' . $id . $param_gradebook . $student_param . '">' . $attendance['name'] . '</a>' . $session_star; } //description $attendance['description'] = '<center>' . $attendance['description'] . '</center>'; if (api_is_allowed_to_edit(null, true)) { $actions = ''; $actions .= '<center>'; if (api_is_platform_admin()) { $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_edit&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a> '; if ($attendance['locked'] == 0) { // $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=attendance_delete&attendance_id='.$id.$param_gradebook.'">'.Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>'; } if ($attendance['active'] == 1) { $actions .= '<a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToDelete') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; } else { $actions .= '<a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToRestore') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=attendance_restore&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('invisible.png', get_lang('Restore'), array(), ICON_SIZE_SMALL) . '</a>'; } } else { $is_locked_attendance = self::is_locked_attendance($attendance['id']); if ($is_locked_attendance) { $actions .= Display::return_icon('edit_na.png', get_lang('Edit')) . ' '; $actions .= Display::return_icon('delete_na.png', get_lang('Delete')); } else { $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_edit&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a> '; $actions .= '<a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToDelete') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; } } // display lock/unlock icon $is_done_all_calendar = $att->is_all_attendance_calendar_done($id); if ($is_done_all_calendar) { $locked = $attendance['attendance_qualify_max']; if ($locked == 0) { if (api_is_platform_admin()) { $message_alert = get_lang('AreYouSureToLockTheAttendance'); } else { $message_alert = get_lang('UnlockMessageInformation'); } $actions .= ' <a onclick="javascript:if(!confirm(\'' . $message_alert . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=lock_attendance&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('unlock.png', get_lang('LockAttendance')) . '</a>'; } else { if (api_is_platform_admin()) { $actions .= ' <a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToUnlockTheAttendance') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=unlock_attendance&attendance_id=' . $id . $param_gradebook . '">' . Display::return_icon('lock.png', get_lang('UnlockAttendance')) . '</a>'; } else { $actions .= ' ' . Display::return_icon('locked_na.png', get_lang('LockedAttendance')); } } } $actions .= '</center>'; $attendance['actions'] = $actions; $attendances[] = $attendance; } else { $attendances[] = $attendance; } } return $attendances; }
/** * Get appropriate links visible for the user * @param int $stud_id student id (default: all students) * @param boolean $recursive process subcategories (default: no recursion) */ public function get_links($stud_id = null, $recursive = false, $course_code = '') { $links = array(); if (empty($course_code)) { $course_code = api_get_course_id(); } // no links in root or course independent categories if ($this->id == 0) { } elseif (isset($stud_id)) { // 1 student $stud_id $links = LinkFactory::load(null, null, null, null, empty($this->course_code) ? null : $course_code, $this->id, api_is_allowed_to_edit() ? null : 1); } elseif (api_is_allowed_to_edit() || api_is_drh() || api_is_session_admin()) { // all students -> only for course/platform admin $links = LinkFactory::load(null, null, null, null, empty($this->course_code) ? null : $this->course_code, $this->id, null); } if ($recursive) { $subcats = $this->get_subcategories($stud_id, $course_code); if (!empty($subcats)) { foreach ($subcats as $subcat) { $sublinks = $subcat->get_links($stud_id, false, $course_code); $links = array_merge($links, $sublinks); } } } return $links; }
function get_users($from, $limit, $column, $direction) { $active = isset($_GET['active']) ? $_GET['active'] : 1; $keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null; $sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null; $lastConnectionDate = null; if (!empty($sleepingDays)) { $lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays . ' days ago')); } $is_western_name_order = api_is_western_name_order(); $coach_id = api_get_user_id(); $drhLoaded = false; if (api_is_drh()) { $column = 'u.user_id'; if (api_drh_can_access_all_session_content()) { $students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', api_get_user_id(), false, $from, $limit, $column, $direction, $keyword, $active, $lastConnectionDate, null, null, api_is_student_boss() ? null : STUDENT); $drhLoaded = true; } } if ($drhLoaded == false) { $students = UserManager::getUsersFollowedByUser(api_get_user_id(), api_is_student_boss() ? null : STUDENT, false, false, false, $from, $limit, $column, $direction, $active, $lastConnectionDate, api_is_student_boss() ? STUDENT_BOSS : COURSEMANAGER, $keyword); } $all_datas = array(); foreach ($students as $student_data) { $student_id = $student_data['user_id']; if (isset($_GET['id_session'])) { $courses = Tracking::get_course_list_in_session_from_student($student_id, $_GET['id_session']); } $avg_time_spent = $avg_student_score = $avg_student_progress = $total_assignments = $total_messages = 0; $nb_courses_student = 0; if (!empty($courses)) { foreach ($courses as $course_code) { $courseInfo = api_get_course_info($course_code); $courseId = $courseInfo['real_id']; if (CourseManager::is_user_subscribed_in_course($student_id, $course_code, true)) { $avg_time_spent += Tracking::get_time_spent_on_the_course($student_id, $courseId, $_GET['id_session']); $my_average = Tracking::get_avg_student_score($student_id, $course_code); if (is_numeric($my_average)) { $avg_student_score += $my_average; } $avg_student_progress += Tracking::get_avg_student_progress($student_id, $course_code); $total_assignments += Tracking::count_student_assignments($student_id, $course_code); $total_messages += Tracking::count_student_messages($student_id, $course_code); $nb_courses_student++; } } } if ($nb_courses_student > 0) { $avg_time_spent = $avg_time_spent / $nb_courses_student; $avg_student_score = $avg_student_score / $nb_courses_student; $avg_student_progress = $avg_student_progress / $nb_courses_student; } else { $avg_time_spent = null; $avg_student_score = null; $avg_student_progress = null; } $row = array(); if ($is_western_name_order) { $row[] = $student_data['firstname']; $row[] = $student_data['lastname']; } else { $row[] = $student_data['lastname']; $row[] = $student_data['firstname']; } $string_date = Tracking::get_last_connection_date($student_id, true); $first_date = Tracking::get_first_connection_date($student_id); $row[] = $first_date; $row[] = $string_date; if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) { $detailsLink = '<a href="myStudents.php?student=' . $student_id . '&id_coach=' . $coach_id . '&id_session=' . $_GET['id_session'] . '"> <img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>'; } else { $detailsLink = '<a href="myStudents.php?student=' . $student_id . '"> <img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>'; } $row[] = $detailsLink; $all_datas[] = $row; } return $all_datas; }
</script>'; // interbreadcrumbs if (!empty($_GET['gradebook']) && $_GET['gradebook'] == 'view') { $_SESSION['gradebook'] = Security::remove_XSS($_GET['gradebook']); $gradebook = $_SESSION['gradebook']; } elseif (empty($_GET['gradebook'])) { unset($_SESSION['gradebook']); $gradebook = ''; } $param_gradebook = ''; if (isset($_SESSION['gradebook'])) { $param_gradebook = '&gradebook=' . $gradebook; } $student_param = ''; $student_id = null; if (api_is_drh() && isset($_GET['student_id'])) { $student_id = intval($_GET['student_id']); $student_param = '&student_id=' . $student_id; $student_info = api_get_user_info($student_id); $student_name = api_get_person_name($student_info['firstname'], $student_info['lastname']); $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . $student_id, 'name' => $student_name); } if (!empty($gradebook)) { $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'gradebook/index.php', 'name' => get_lang('ToolGradebook')); } $interbreadcrumb[] = array('url' => 'index.php?' . api_get_cidreq() . '&action=attendance_list' . $param_gradebook . $student_param, 'name' => get_lang('ToolAttendance')); if ($action == 'attendance_add') { $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('CreateANewAttendance')); } if ($action == 'attendance_edit') { $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Edit'));
$count_sessions = count($sessions); } if ($count_courses || $count_sessions) { // If we are in course. if (empty($session_id)) { if ($count_courses) { $title = '<img src="' . api_get_path(WEB_IMG_PATH) . 'course.gif"> ' . get_lang('Courses') . ' (' . $count_courses . ') '; } } else { //If we are in Course Session $session_name = api_get_session_name($session_id); $title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL) . ' ' . $session_name; $menu_items[] = '<a href="' . api_get_self() . '?view=teacher">' . get_lang('TeacherInterface') . '</a>'; } } if ((api_is_allowed_to_create_course() || api_is_drh()) && in_array($view, array('teacher', 'drh'))) { //Courses if ($count_courses) { echo Display::page_subheader($title); $data = MySpace::get_course_data(null, null, null, null, $courses, $csv_content, $charset); $table = new SortableTable('courses_my_space', 'get_number_of_courses'); $parameters['view'] = 'teacher'; $parameters['class'] = 'data_table'; $table->set_additional_parameters($parameters); $table->set_header(0, get_lang('CourseTitle'), false); $table->set_header(1, get_lang('NbStudents'), false); $table->set_header(2, get_lang('AvgTimeSpentInTheCourse') . ' ' . Display::return_icon('info3.gif', get_lang('TimeOfActiveByTraining'), array('align' => 'absmiddle', 'hspace' => '3px')), false); $table->set_header(3, get_lang('AvgStudentsProgress') . ' ' . Display::return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false); $table->set_header(4, get_lang('AvgCourseScore') . ' ' . Display::return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false); $table->set_header(5, get_lang('AvgExercisesScore') . ' ' . Display::return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false); $table->set_header(6, get_lang('AvgMessages'), false);
/** * Get the attendaces to display on the current page (fill the sortable-table) * @param int offset of first user to recover * @param int Number of users to get * @param int Column to sort on * @param string Order (ASC,DESC) * @see SortableTable#get_table_data($from) */ public static function get_attendance_data($from, $number_of_items, $column, $direction) { $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); $course_id = api_get_course_int_id(); $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id); $column = intval($column); $from = intval($from); $number_of_items = intval($number_of_items); if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'ASC'; } $active_plus = ''; if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true' || !api_is_allowed_to_edit(null, true)) { $active_plus = ' AND att.active = 1'; } $sql = "SELECT\n att.id AS col0,\n att.name AS col1,\n att.description AS col2,\n att.attendance_qualify_max AS col3,\n att.locked AS col4,\n att.active AS col5,\n att.session_id\n\t\t\t\tFROM {$tbl_attendance} att\n\t\t\t\tWHERE\n\t\t\t\t\tatt.active <> 2 AND\n\t\t\t\t\tc_id = {$course_id} {$active_plus} {$condition_session}\n\t\t\t\tORDER BY col{$column} {$direction}\n\t\t\t\tLIMIT {$from},{$number_of_items} "; $res = Database::query($sql); $attendances = array(); $user_info = api_get_user_info(); $allowDelete = api_get_setting('attendance.allow_delete_attendance'); while ($attendance = Database::fetch_row($res)) { $student_param = ''; if (api_is_drh() && $_GET['student_id']) { $student_param = '&student_id=' . intval($_GET['student_id']); } $session_star = ''; if (api_get_session_id() == $attendance[6]) { $session_star = api_get_session_image(api_get_session_id(), $user_info['status']); } if ($attendance[5] == 1) { $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(api_get_user_id(), api_get_course_info()); if (api_is_allowed_to_edit(null, true) || $isDrhOfCourse) { // Link to edit $attendance[1] = '<a href="index.php?' . api_get_cidreq() . '&action=attendance_sheet_list&attendance_id=' . $attendance[0] . $student_param . '">' . $attendance[1] . '</a>' . $session_star; } else { // Link to view $attendance[1] = '<a href="index.php?' . api_get_cidreq() . '&action=attendance_sheet_list_no_edit&attendance_id=' . $attendance[0] . $student_param . '">' . $attendance[1] . '</a>' . $session_star; } } else { $attendance[1] = '<a class="muted" href="index.php?' . api_get_cidreq() . '&action=attendance_sheet_list&attendance_id=' . $attendance[0] . $student_param . '">' . $attendance[1] . '</a>' . $session_star; } if ($attendance[5] == 1) { $attendance[3] = '<center>' . $attendance[3] . '</center>'; } else { $attendance[3] = '<center><span class="muted">' . $attendance[3] . '</span></center>'; } $attendance[3] = '<center>' . $attendance[3] . '</center>'; if (api_is_allowed_to_edit(null, true)) { $actions = ''; $actions .= '<center>'; if (api_is_platform_admin()) { $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_edit&attendance_id=' . $attendance[0] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a> '; // Visible if ($attendance[5] == 1) { $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_set_invisible&attendance_id=' . $attendance[0] . '">' . Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL) . '</a>'; } else { $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_set_visible&attendance_id=' . $attendance[0] . '">' . Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL) . '</a>'; $attendance[2] = '<span class="muted">' . $attendance[2] . '</span>'; } if ($allowDelete === 'true') { $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0] . '">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; } } else { $is_locked_attendance = self::is_locked_attendance($attendance[0]); if ($is_locked_attendance) { $actions .= Display::return_icon('edit_na.png', get_lang('Edit')) . ' '; $actions .= Display::return_icon('visible.png', get_lang('Hide')); } else { $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_edit&attendance_id=' . $attendance[0] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a> '; if ($attendance[5] == 1) { $actions .= ' <a href="index.php?' . api_get_cidreq() . '&action=attendance_set_invisible&attendance_id=' . $attendance[0] . '">' . Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL) . '</a>'; } else { $actions .= ' <a href="index.php?' . api_get_cidreq() . '&action=attendance_set_visible&attendance_id=' . $attendance[0] . '">' . Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL) . '</a>'; $attendance[2] = '<span class="muted">' . $attendance[2] . '</span>'; } if ($allowDelete === 'true') { $actions .= ' <a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0] . '">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; } } } // display lock/unlock icon $is_done_all_calendar = self::is_all_attendance_calendar_done($attendance[0]); if ($is_done_all_calendar) { $locked = $attendance[4]; if ($locked == 0) { if (api_is_platform_admin()) { $message_alert = get_lang('AreYouSureToLockTheAttendance'); } else { $message_alert = get_lang('UnlockMessageInformation'); } $actions .= ' <a onclick="javascript:if(!confirm(\'' . $message_alert . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=lock_attendance&attendance_id=' . $attendance[0] . '">' . Display::return_icon('unlock.png', get_lang('LockAttendance')) . '</a>'; } else { if (api_is_platform_admin()) { $actions .= ' <a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToUnlockTheAttendance') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=unlock_attendance&attendance_id=' . $attendance[0] . '">' . Display::return_icon('locked.png', get_lang('UnlockAttendance')) . '</a>'; } else { $actions .= ' ' . Display::return_icon('locked_na.png', get_lang('LockedAttendance')); } } } $actions .= '</center>'; $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3], $actions); } else { $attendance[0] = ' '; $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3]); } } return $attendances; }
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_user_course = Database::get_main_table(TABLE_MAIN_COURSE_USER); if (isset($_GET['action'])) { if ($_GET['action'] == 'show_message') { Display::display_normal_message(stripslashes($_GET['message']), false); } if ($_GET['action'] == 'error_message') { Display::display_error_message(stripslashes($_GET['message']), false); } } if ($show_import_icon) { echo "<div align=\"right\">"; echo '<a href="user_import.php?id_session=' . $id_session . '&action=export&type=xml">' . Display::return_icon('excel.gif', get_lang('ImportUserListXMLCSV')) . ' ' . get_lang('ImportUserListXMLCSV') . '</a>'; echo "</div><br />"; } if (!api_is_drh() && !api_is_session_admin() && !api_is_platform_admin()) { $courses = Tracking::get_courses_followed_by_coach($_user['user_id'], $id_session); $a_courses = array_keys($courses); } $nb_courses = count($a_courses); $table = new SortableTable('tracking_list_course', 'count_courses'); $table->set_header(0, get_lang('CourseTitle'), false); $table->set_header(1, get_lang('NbStudents'), false); $table->set_header(2, get_lang('TimeSpentInTheCourse') . Display::return_icon('info3.gif', get_lang('TimeOfActiveByTraining'), array('align' => 'absmiddle', 'hspace' => '3px')), false); $table->set_header(3, get_lang('ThematicAdvance'), false); $table->set_header(4, get_lang('AvgStudentsProgress') . Display::return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false); $table->set_header(5, get_lang('AvgCourseScore') . Display::return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false); //$table -> set_header(5, get_lang('AvgExercisesScore'), false);// no code for this? $table->set_header(6, get_lang('AvgMessages'), false); $table->set_header(7, get_lang('AvgAssignments'), false); $table->set_header(8, get_lang('Details'), false);
<?php /* For licensing terms, see /license.txt */ // including necessary libraries $language_file = array('admin', 'registration'); $cidReset = true; //require_once '../inc/global.inc.php'; $libpath = api_get_path(LIBRARY_PATH); require_once $libpath . 'fileManage.lib.php'; require_once $libpath . 'fileUpload.lib.php'; // user permissions api_block_anonymous_users(); if (!api_is_platform_admin()) { if (!api_is_drh()) { api_not_allowed(true); } } else { api_protect_admin_script(); } // Database table definitions $table_admin = Database::get_main_table(TABLE_MAIN_ADMIN); $table_user = Database::get_main_table(TABLE_MAIN_USER); $database = Database::get_main_database(); $userId = isset($_REQUEST['user_id']) ? intval($_REQUEST['user_id']) : ''; $userInfo = api_get_user_info($userId); if (empty($userInfo)) { api_not_allowed(true); } $userIsFollowed = UserManager::is_user_followed_by_drh($userId, api_get_user_id()); if (api_drh_can_access_all_session_content()) { $students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', api_get_user_id(), false, 0, null, null, 'desc', null, null, null, null, null, STUDENT);
/** * @param int $userId * @param array $courseInfo * @return bool */ public static function isUserSubscribedInCourseAsDrh($userId, $courseInfo) { $userId = intval($userId); if (!api_is_drh()) { return false; } if (empty($courseInfo) || empty($userId)) { return false; } $courseId = intval($courseInfo['real_id']); $table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $sql = "SELECT * FROM {$table}\n WHERE\n user_id = {$userId} AND\n relation_type = " . COURSE_RELATION_TYPE_RRHH . " AND\n c_id = {$courseId}"; $result = Database::fetch_array(Database::query($sql)); if (!empty($result)) { // The user has been registered in this course. return true; } }
/** * Get list of groups for current course. * @param int $category The id of the category from which the groups are * requested * @param string $course_code Default is current course * @return array An array with all information about the groups. */ public static function get_group_list($category = null, $course_code = null) { $my_user_id = api_get_user_id(); $course_info = api_get_course_info($course_code); $course_id = $course_info['real_id']; $table_group_user = Database::get_course_table(TABLE_GROUP_USER); $table_group = Database::get_course_table(TABLE_GROUP); //condition for the session $session_id = api_get_session_id(); $my_status_of_user_in_course = CourseManager::get_user_in_course_status($my_user_id, $course_info['code']); $is_student_in_session = false; if (is_null($my_status_of_user_in_course) || $my_status_of_user_in_course == '') { if ($session_id > 0) { $is_student_in_session = true; } } // COURSEMANAGER or STUDENT if ($my_status_of_user_in_course == COURSEMANAGER || api_is_allowed_to_edit(null, true) || api_is_drh()) { $can_see_groups = 1; $sql = "SELECT g.iid,\n g.name,\n g.description,\n g.category_id,\n g.max_student maximum_number_of_members,\n g.secret_directory,\n g.self_registration_allowed,\n g.self_unregistration_allowed,\n g.session_id\n FROM {$table_group} g "; } elseif ($my_status_of_user_in_course == STUDENT || $is_student_in_session === true || $_SESSION['studentview'] == 'studentview') { $can_see_groups = 1; $sql = "SELECT g.iid,\n g.name,\n g.description,\n g.category_id,\n g.max_student maximum_number_of_members,\n g.secret_directory,\n g.self_registration_allowed,\n g.self_unregistration_allowed,\n g.session_id,\n ug.user_id is_member\n FROM {$table_group} g\n LEFT JOIN {$table_group_user} ug\n ON (ug.group_id = g.iid AND ug.user_id = '" . api_get_user_id() . "' AND ug.c_id = {$course_id} AND g.c_id = {$course_id})"; } $sql .= " WHERE 1=1 "; if ($category != null) { $sql .= " AND g.category_id = '" . Database::escape_string($category) . "' "; $session_condition = api_get_session_condition($session_id); if (!empty($session_condition)) { $sql .= $session_condition; } } else { $session_condition = api_get_session_condition($session_id, true); } $sql .= " AND g.c_id = {$course_id} "; if (!empty($session_condition)) { $sql .= $session_condition; } $sql .= " GROUP BY g.iid ORDER BY UPPER(g.name)"; if ($can_see_groups == 1) { $groupList = Database::query($sql); } else { return array(); } $groups = array(); while ($thisGroup = Database::fetch_array($groupList)) { $thisGroup['id'] = $thisGroup['iid']; $thisGroup['is_member'] = self::is_subscribed($my_user_id, $thisGroup['id']); $thisGroup['number_of_members'] = count(self::get_subscribed_users($thisGroup['id'])); if ($thisGroup['session_id'] != 0) { $sql = 'SELECT name FROM ' . Database::get_main_table(TABLE_MAIN_SESSION) . ' WHERE id=' . $thisGroup['session_id']; $rs_session = Database::query($sql); if (Database::num_rows($rs_session) > 0) { $thisGroup['session_name'] = Database::result($rs_session, 0, 0); } } $groups[] = $thisGroup; } return $groups; }
/** * @param int $user_id * @param string $filter current|history * @param int $page * @return bool|null|string */ public function returnSessions($user_id, $filter, $page) { if (empty($user_id)) { return false; } $app = $this->app; $loadHistory = isset($filter) && $filter == 'history' ? true : false; $app['session_menu'] = function ($app) use($loadHistory) { $menu = $app['knp_menu.factory']->createItem('root', array('childrenAttributes' => array('class' => 'nav nav-tabs', 'currentClass' => 'active'))); $current = $menu->addChild(get_lang('Current'), array('route' => 'userportal', 'routeParameters' => array('filter' => 'current', 'type' => 'sessions'))); $history = $menu->addChild(get_lang('HistoryTrainingSession'), array('route' => 'userportal', 'routeParameters' => array('filter' => 'history', 'type' => 'sessions'))); //@todo use URIVoter if ($loadHistory) { $history->setCurrent(true); } else { $current->setCurrent(true); } return $menu; }; //@todo move this in template $app['knp_menu.menus'] = array('actions_menu' => 'session_menu'); $start = ($page - 1) * $this->maxPerPage; if ($loadHistory) { // Load sessions in category in *history*. $nbResults = (int) UserManager::get_sessions_by_category($user_id, true, true, true, null, null, 'no_category'); $session_categories = UserManager::get_sessions_by_category($user_id, true, false, true, $start, $this->maxPerPage, 'no_category'); } else { // Load sessions in category. $nbResults = (int) UserManager::get_sessions_by_category($user_id, false, true, false, null, null, 'no_category'); $session_categories = UserManager::get_sessions_by_category($user_id, false, false, false, $start, $this->maxPerPage, 'no_category'); } $html = null; // Showing history title if ($loadHistory) { // $html .= Display::page_subheader(get_lang('HistoryTrainingSession')); if (empty($session_categories)) { $html .= get_lang('YouDoNotHaveAnySessionInItsHistory'); } } $load_directories_preview = api_get_setting('show_documents_preview') == 'true' ? true : false; $sessions_with_no_category = $html; if (isset($session_categories) && !empty($session_categories)) { foreach ($session_categories as $session_category) { $session_category_id = $session_category['session_category']['id']; // Sessions does not belong to a session category if ($session_category_id == 0) { // Independent sessions if (isset($session_category['sessions'])) { foreach ($session_category['sessions'] as $session) { $session_id = $session['session_id']; // Don't show empty sessions. if (count($session['courses']) < 1) { continue; } $html_courses_session = ''; $count_courses_session = 0; foreach ($session['courses'] as $course) { //Read only and accessible if (api_get_setting('hide_courses_in_sessions') == 'false') { $html_courses_session .= CourseManager::get_logged_user_course_html($course, $session_id, $load_directories_preview); } $count_courses_session++; } if ($count_courses_session > 0) { $params = array(); $params['icon'] = Display::return_icon('window_list.png', $session['session_name'], array('id' => 'session_img_' . $session_id), ICON_SIZE_LARGE); $params['is_session'] = true; //Default session name $session_link = $session['session_name']; $params['link'] = null; if (api_get_setting('session_page_enabled') == 'true' && !api_is_drh()) { //session name with link $session_link = Display::tag('a', $session['session_name'], array('href' => api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . $session_id)); $params['link'] = api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . $session_id; } $params['title'] = $session_link; $moved_status = SessionManager::get_session_change_user_reason($session['moved_status']); $moved_status = isset($moved_status) && !empty($moved_status) ? ' (' . $moved_status . ')' : null; $params['subtitle'] = isset($session['coach_info']) ? $session['coach_info']['complete_name'] : null . $moved_status; $params['dates'] = $session['date_message']; $params['right_actions'] = ''; if (api_is_platform_admin()) { $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'admin/resume_session.php?id_session=' . $session_id . '">'; $params['right_actions'] .= Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>'; } if (api_get_setting('hide_courses_in_sessions') == 'false') { // $params['extra'] .= $html_courses_session; } $sessions_with_no_category .= CourseManager::course_item_parent(CourseManager::course_item_html($params, true), $html_courses_session); } } } } } $adapter = new FixedAdapter($nbResults, array()); $pagerfanta = new Pagerfanta($adapter); $pagerfanta->setMaxPerPage($this->maxPerPage); // 10 by default $pagerfanta->setCurrentPage($page); // 1 by default $this->app['pagerfanta.view.router.name'] = 'userportal'; $this->app['pagerfanta.view.router.params'] = array('filter' => $filter, 'type' => 'sessions', 'page' => $page); $this->app['template']->assign('pagination', $pagerfanta); } return $sessions_with_no_category; }
*/ //require_once '../inc/global.inc.php'; // Setting the tabs $this_section = SECTION_COURSES; $htmlHeadXtra[] = api_get_jqgrid_js(); // Access control api_protect_course_script(true, false, true); // including additional libraries require_once 'hotpotatoes.lib.php'; $_course = api_get_course_info(); // document path $documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . "/document"; $origin = isset($origin) ? $origin : null; $path = isset($_GET['path']) ? Security::remove_XSS($_GET['path']) : null; /* Constants and variables */ $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_drh() || api_is_student_boss(); $is_tutor = api_is_allowed_to_edit(true); $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); $TBL_TRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); $TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING); $TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW); $allowCoachFeedbackExercises = api_get_setting('exercise.allow_coach_feedback_exercises') === 'true'; $course_id = api_get_course_int_id(); $exercise_id = isset($_REQUEST['exerciseId']) ? intval($_REQUEST['exerciseId']) : null; $filter_user = isset($_REQUEST['filter_by_user']) ? intval($_REQUEST['filter_by_user']) : null; $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE); if (empty($exercise_id)) { api_not_allowed(true); } if (!$is_allowedToEdit && !$allowCoachFeedbackExercises) {
<?php /* For licensing terms, see /license.txt */ /** * Show the skills report * @author Angel Fernando Quiroz Campos <*****@*****.**> * @package chamilo.social.skill */ //require_once '../inc/global.inc.php'; $isStudent = api_is_student(); $isStudentBoss = api_is_student_boss(); $isDRH = api_is_drh(); if (!$isStudent && !$isStudentBoss && !$isDRH) { header('Location: ' . api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'); exit; } $userId = api_get_user_id(); $skillTable = Database::get_main_table(TABLE_MAIN_SKILL); $skillRelUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER); $courseTable = Database::get_main_table(TABLE_MAIN_COURSE); $tableRows = array(); //$tpl = new Template(get_lang('Skills')); $tpl = \Chamilo\CoreBundle\Framework\Container::getTwig(); $tplPath = null; $tpl->addGlobal('allowSkillsTool', api_get_setting('skill.allow_skills_tool') == 'true'); $tpl->addGlobal('allowDrhSkillsManagement', api_get_setting('skill.allow_hr_skills_management') == 'true'); if ($isStudent) { $sql = "SELECT s.name, sru.acquired_skill_at, c.title, c.directory\n FROM {$skillTable} s\n INNER JOIN {$skillRelUserTable} sru\n ON s.id = sru.skill_id\n INNER JOIN {$courseTable} c\n ON sru.course_id = c.id\n WHERE sru.user_id = {$userId}"; $result = Database::query($sql); while ($resultData = Database::fetch_assoc($result)) { $tableRow = array('skillName' => $resultData['name'], 'achievedAt' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER), 'courseImage' => Display::return_icon('course.png', null, null, ICON_SIZE_MEDIUM, null, true), 'courseName' => $resultData['title']);
if ($view == "0010000") { $nameTools = get_lang('ToolsAccess'); } if ($view == "0001000") { $nameTools = get_lang('LinksAccess'); } if ($view == "0000100") { $nameTools = get_lang('DocumentsAccess'); } if ($view == "00000010") { $nameTools = get_lang('ScormAccess'); } $interbreadcrumb[] = array("url" => api_get_self() . "?view=0000000", "name" => get_lang('ToolName')); include api_get_path(LIBRARY_PATH) . "statsUtils.lib.inc.php"; include "../resourcelinker/resourcelinker.inc.php"; $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || api_is_drh(); /* MAIN CODE */ $title[0] = get_lang('StatsOfCourse') . " : " . $_course['official_code']; $courseInfo = api_get_course_info($_course['official_code']); $courseId = $courseInfo['real_id']; // check if uid is prof of this group if ($is_allowedToTrack) { // show all : view must be equal to the sum of all view values (1024+512+...+64) // show none : less than the tiniest value /* echo "<div> [<a href='".api_get_self()."?view=1111111'>".get_lang('ShowAll')."</a>] [<a href='".api_get_self()."?view=0000000'>".get_lang('ShowNone')."</a>] </div><br> "; */ if (!isset($view)) { $view = "0000000";
/** * Gets the exam'data results * @todo this function should be moved in a library + no global calls * @param int $from * @param int $number_of_items * @param int $column * @param string $direction * @param int $exercise_id * @param null $extra_where_conditions * @param bool $get_count * @return array */ public static function get_exam_results_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false) { //@todo replace all this globals global $documentPath, $filter; $course_id = api_get_course_int_id(); $sessionId = api_get_session_id(); $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit(true) || api_is_drh() || api_is_student_boss(); $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_GROUP_REL_USER = Database::get_course_table(TABLE_GROUP_USER); $TBL_GROUP = Database::get_course_table(TABLE_GROUP); $TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); $TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING); $session_id_and = ' AND te.session_id = ' . $sessionId . ' '; $exercise_id = intval($exercise_id); $exercise_where = ''; if (!empty($exercise_id)) { $exercise_where .= ' AND te.exe_exo_id = ' . $exercise_id . ' '; } $hotpotatoe_where = ''; if (!empty($_GET['path'])) { $hotpotatoe_path = Database::escape_string($_GET['path']); $hotpotatoe_where .= ' AND exe_name = "' . $hotpotatoe_path . '" '; } // sql for chamilo-type tests for teacher / tutor view $sql_inner_join_tbl_track_exercices = "\n (\n SELECT DISTINCT ttte.*, if(tr.exe_id,1, 0) as revised\n FROM {$TBL_TRACK_EXERCICES} ttte LEFT JOIN {$TBL_TRACK_ATTEMPT_RECORDING} tr\n ON (ttte.exe_id = tr.exe_id)\n WHERE\n c_id = {$course_id} AND\n exe_exo_id = {$exercise_id} AND\n ttte.session_id = " . $sessionId . "\n )"; if ($is_allowedToEdit) { //@todo fix to work with COURSE_RELATION_TYPE_RRHH in both queries // Hack in order to filter groups $sql_inner_join_tbl_user = ''; if (strpos($extra_where_conditions, 'group_id')) { $sql_inner_join_tbl_user = "******" . $course_id . ")\n INNER JOIN {$TBL_GROUP} g\n ON (gru.group_id = g.id AND g.c_id=" . $course_id . ")\n )"; } if (strpos($extra_where_conditions, 'group_all')) { $extra_where_conditions = str_replace("AND ( group_id = 'group_all' )", '', $extra_where_conditions); $extra_where_conditions = str_replace("AND group_id = 'group_all'", '', $extra_where_conditions); $extra_where_conditions = str_replace("group_id = 'group_all' AND", '', $extra_where_conditions); $sql_inner_join_tbl_user = "******"; $sql_inner_join_tbl_user = null; } if (strpos($extra_where_conditions, 'group_none')) { $extra_where_conditions = str_replace("AND ( group_id = 'group_none' )", "AND ( group_id is null )", $extra_where_conditions); $extra_where_conditions = str_replace("AND group_id = 'group_none'", "AND ( group_id is null )", $extra_where_conditions); $sql_inner_join_tbl_user = "******" . $course_id . " )\n LEFT OUTER JOIN {$TBL_GROUP} g\n ON (gru.group_id = g.id AND g.c_id = " . $course_id . ")\n )"; } // All $is_empty_sql_inner_join_tbl_user = false; if (empty($sql_inner_join_tbl_user)) { $is_empty_sql_inner_join_tbl_user = true; $sql_inner_join_tbl_user = "******" . api_get_users_status_ignored_in_reports('string') . ")\n )"; } $sqlFromOption = " , {$TBL_GROUP_REL_USER} AS gru "; $sqlWhereOption = " AND gru.c_id = " . $course_id . " AND gru.user_id = user.user_id "; $first_and_last_name = api_is_western_name_order() ? "firstname, lastname" : "lastname, firstname"; if ($get_count) { $sql_select = "SELECT count(te.exe_id) "; } else { $sql_select = "SELECT DISTINCT\n user_id,\n {$first_and_last_name},\n official_code,\n ce.title,\n username,\n te.exe_result,\n te.exe_weighting,\n te.exe_date,\n te.exe_id,\n email as exemail,\n te.start_date,\n steps_counter,\n exe_user_id,\n te.exe_duration,\n propagate_neg,\n revised,\n group_name,\n group_id,\n orig_lp_id,\n te.user_ip"; } $sql = " {$sql_select}\n FROM {$TBL_EXERCICES} AS ce\n INNER JOIN {$sql_inner_join_tbl_track_exercices} AS te\n ON (te.exe_exo_id = ce.id)\n INNER JOIN {$sql_inner_join_tbl_user} AS user\n ON (user.user_id = exe_user_id)\n WHERE\n te.status != 'incomplete' AND\n te.c_id = " . $course_id . " {$session_id_and} AND\n ce.active <>-1 AND ce.c_id = " . $course_id . "\n {$exercise_where}\n {$extra_where_conditions}\n "; // sql for hotpotatoes tests for teacher / tutor view if ($get_count) { $hpsql_select = "SELECT count(username)"; } else { $hpsql_select = "SELECT\n {$first_and_last_name} ,\n username,\n official_code,\n tth.exe_name,\n tth.exe_result ,\n tth.exe_weighting,\n tth.exe_date"; } $hpsql = " {$hpsql_select}\n FROM\n {$TBL_TRACK_HOTPOTATOES} tth,\n {$TBL_USER} user\n {$sqlFromOption}\n WHERE\n user.user_id=tth.exe_user_id\n AND tth.c_id = " . $course_id . "\n {$hotpotatoe_where}\n {$sqlWhereOption}\n AND user.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ")\n ORDER BY\n tth.c_id ASC,\n tth.exe_date DESC"; } if ($get_count) { $resx = Database::query($sql); $rowx = Database::fetch_row($resx, 'ASSOC'); return $rowx[0]; } $teacher_list = CourseManager::getTeacherListFromCourse(api_get_course_int_id()); $teacher_id_list = array(); if (!empty($teacher_list)) { foreach ($teacher_list as $teacher) { $teacher_id_list[] = $teacher['user_id']; } } $list_info = array(); // Simple exercises if (empty($hotpotatoe_where)) { $column = !empty($column) ? Database::escape_string($column) : null; $from = intval($from); $number_of_items = intval($number_of_items); if (!empty($column)) { $sql .= " ORDER BY {$column} {$direction} "; } $sql .= " LIMIT {$from}, {$number_of_items}"; $results = array(); $resx = Database::query($sql); while ($rowx = Database::fetch_array($resx, 'ASSOC')) { $results[] = $rowx; } $group_list = GroupManager::get_group_list(); $clean_group_list = array(); if (!empty($group_list)) { foreach ($group_list as $group) { $clean_group_list[$group['id']] = $group['name']; } } $lp_list_obj = new LearnpathList(api_get_user_id()); $lp_list = $lp_list_obj->get_flat_list(); if (is_array($results)) { $users_array_id = array(); $from_gradebook = false; if (isset($_GET['gradebook']) && $_GET['gradebook'] == 'view') { $from_gradebook = true; } $sizeof = count($results); $user_list_id = array(); $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE); // Looping results for ($i = 0; $i < $sizeof; $i++) { $revised = $results[$i]['revised']; if ($from_gradebook && $is_allowedToEdit) { if (in_array($results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'], $users_array_id)) { continue; } $users_array_id[] = $results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname']; } $lp_obj = isset($results[$i]['orig_lp_id']) && isset($lp_list[$results[$i]['orig_lp_id']]) ? $lp_list[$results[$i]['orig_lp_id']] : null; $lp_name = null; if ($lp_obj) { $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $results[$i]['orig_lp_id']; $lp_name = Display::url($lp_obj['lp_name'], $url, array('target' => '_blank')); } //Add all groups by user $group_name_list = null; if ($is_empty_sql_inner_join_tbl_user) { $group_list = GroupManager::get_group_ids(api_get_course_int_id(), $results[$i]['user_id']); foreach ($group_list as $id) { $group_name_list .= $clean_group_list[$id] . '<br/>'; } $results[$i]['group_name'] = $group_name_list; } $results[$i]['exe_duration'] = !empty($results[$i]['exe_duration']) ? round($results[$i]['exe_duration'] / 60) : 0; $user_list_id[] = $results[$i]['exe_user_id']; $id = $results[$i]['exe_id']; $dt = api_convert_and_format_date($results[$i]['exe_weighting']); // we filter the results if we have the permission to if (isset($results[$i]['results_disabled'])) { $result_disabled = intval($results[$i]['results_disabled']); } else { $result_disabled = 0; } if ($result_disabled == 0) { $my_res = $results[$i]['exe_result']; $my_total = $results[$i]['exe_weighting']; $results[$i]['start_date'] = api_get_local_time($results[$i]['start_date']); $results[$i]['exe_date'] = api_get_local_time($results[$i]['exe_date']); if (!$results[$i]['propagate_neg'] && $my_res < 0) { $my_res = 0; } $score = self::show_score($my_res, $my_total); $actions = ''; if ($is_allowedToEdit) { if (isset($teacher_id_list)) { if (in_array($results[$i]['exe_user_id'], $teacher_id_list)) { $actions .= Display::return_icon('teachers.gif', get_lang('Teacher')); } } if ($revised) { $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=edit&id={$id}'>" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL); $actions .= ' '; } else { $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=qualify&id={$id}'>" . Display::return_icon('quiz.gif', get_lang('Qualify')); $actions .= ' '; } $actions .= "</a>"; if ($filter == 2) { $actions .= ' <a href="exercise_history.php?' . api_get_cidreq() . '&exe_id=' . $id . '">' . Display::return_icon('history.gif', get_lang('ViewHistoryChange')) . '</a>'; } //Admin can always delete the attempt if (($locked == false || api_is_platform_admin()) && !api_is_student_boss()) { $ip = TrackingUserLog::get_ip_from_user_event($results[$i]['exe_user_id'], date('Y-m-d h:i:s'), false); $actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip=' . $ip . '" target="_blank">'; $actions .= Display::return_icon('info.png', $ip, ['title' => $ip]); $actions .= '</a>'; $delete_link = '<a href="exercise_report.php?' . api_get_cidreq() . '&filter_by_user='******'filter_by_user']) . '&filter=' . $filter . '&exerciseId=' . $exercise_id . '&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $results[$i]['username'], $dt) . '\')) return false;">' . Display::return_icon('delete.png', get_lang('Delete')) . '</a>'; $delete_link = utf8_encode($delete_link); if (api_is_drh() && !api_is_platform_admin()) { $delete_link = null; } $actions .= $delete_link . ' '; } } else { $attempt_url = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?' . api_get_cidreq() . '&id=' . $results[$i]['exe_id'] . '&id_session=' . $sessionId; $attempt_link = Display::url(get_lang('Show'), $attempt_url, ['class' => 'ajax btn btn-default', 'data-title' => get_lang('Show')]); $actions .= $attempt_link; } if ($revised) { $revised = Display::label(get_lang('Validated'), 'success'); } else { $revised = Display::label(get_lang('NotValidated'), 'info'); } if ($is_allowedToEdit) { $results[$i]['status'] = $revised; $results[$i]['score'] = $score; $results[$i]['lp'] = $lp_name; $results[$i]['actions'] = $actions; $list_info[] = $results[$i]; } else { $results[$i]['status'] = $revised; $results[$i]['score'] = $score; $results[$i]['actions'] = $actions; $list_info[] = $results[$i]; } } } } } else { $hpresults = StatsUtils::getManyResultsXCol($hpsql, 6); // Print HotPotatoes test results. if (is_array($hpresults)) { for ($i = 0; $i < sizeof($hpresults); $i++) { $hp_title = GetQuizName($hpresults[$i][3], $documentPath); if ($hp_title == '') { $hp_title = basename($hpresults[$i][3]); } $hp_date = api_get_local_time($hpresults[$i][6], null, date_default_timezone_get()); $hp_result = round($hpresults[$i][4] / ($hpresults[$i][5] != 0 ? $hpresults[$i][5] : 1) * 100, 2) . '% (' . $hpresults[$i][4] . ' / ' . $hpresults[$i][5] . ')'; if ($is_allowedToEdit) { $list_info[] = array($hpresults[$i][0], $hpresults[$i][1], $hpresults[$i][2], '', $hp_title, '-', $hp_date, $hp_result, '-'); } else { $list_info[] = array($hp_title, '-', $hp_date, $hp_result, '-'); } } } } return $list_info; }
$this_section = SECTION_TRACKING; api_block_anonymous_users(); $htmlHeadXtra[] = api_get_jqgrid_js(); $interbreadcrumb[] = array("url" => "index.php", "name" => get_lang('MySpace')); Display::display_header(get_lang('Sessions')); $export_csv = false; if (isset($_GET['export']) && $_GET['export'] == 'csv') { $export_csv = true; } /* MAIN CODE */ if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') { $id_coach = intval($_GET['id_coach']); } else { $id_coach = api_get_user_id(); } if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) { $a_sessions = SessionManager::get_sessions_followed_by_drh(api_get_user_id()); if (!api_is_session_admin()) { $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "auth/my_progress.php"); $menu_items[] = Display::url(Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), "index.php?view=drh_students&display=yourstudents"); $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), 'teachers.php'); $menu_items[] = Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), 'course.php'); $menu_items[] = Display::url(Display::return_icon('session_na.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), '#'); } $actionsLeft = ''; $nb_menu_items = count($menu_items); if ($nb_menu_items > 1) { foreach ($menu_items as $key => $item) { $actionsLeft .= $item; } }
/** * @param int $filter * @param string $view * @return string */ public function displayActions($view, $filter = 0) { $courseInfo = api_get_course_info(); $actionsLeft = ''; $actionsLeft .= "<a href='" . api_get_path(WEB_CODE_PATH) . "calendar/agenda_js.php?type={$this->type}'>" . Display::return_icon('calendar.png', get_lang('Calendar'), '', ICON_SIZE_MEDIUM) . "</a>"; $courseCondition = ''; if (!empty($courseInfo)) { $courseCondition = api_get_cidreq(); } $actionsLeft .= "<a href='" . api_get_path(WEB_CODE_PATH) . "calendar/agenda_list.php?type={$this->type}&" . $courseCondition . "'>" . Display::return_icon('week.png', get_lang('AgendaList'), '', ICON_SIZE_MEDIUM) . "</a>"; $form = ''; if (api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous() && api_is_allowed_to_session_edit(false, true) || GroupManager::user_has_access(api_get_user_id(), api_get_group_id(), GroupManager::GROUP_TOOL_CALENDAR) && GroupManager::is_tutor_of_group(api_get_user_id(), api_get_group_id())) { $actionsLeft .= Display::url(Display::return_icon('new_event.png', get_lang('AgendaAdd'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?" . api_get_cidreq() . "&action=add&type=" . $this->type); $actionsLeft .= Display::url(Display::return_icon('import_calendar.png', get_lang('ICalFileImport'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?" . api_get_cidreq() . "&action=importical&type=" . $this->type); if ($this->type == 'course') { if (!isset($_GET['action'])) { $form = new FormValidator('form-search', 'post', '', '', array(), FormValidator::LAYOUT_INLINE); $attributes = array('multiple' => false, 'id' => 'select_form_id_search'); $selectedValues = $this->parseAgendaFilter($filter); $this->showToForm($form, $selectedValues, $attributes); $form = $form->returnForm(); } } } if (api_is_platform_admin() || api_is_teacher() || api_is_student_boss() || api_is_drh() || api_is_session_admin() || api_is_coach()) { if ($this->type == 'personal') { $form = null; if (!isset($_GET['action'])) { $form = new FormValidator('form-search', 'get', api_get_self() . '?type=personal&', '', array(), FormValidator::LAYOUT_INLINE); $sessions = SessionManager::get_sessions_by_user(api_get_user_id()); $form->addHidden('type', 'personal'); $sessions = array_column($sessions, 'session_name', 'session_id'); $sessions = ['0' => get_lang('SelectAnOption')] + $sessions; $form->addSelect('session_id', get_lang('Session'), $sessions, ['id' => 'session_id', 'onchange' => 'submit();']); //$form->addButtonFilter(get_lang('Filter')); //$renderer = $form->defaultRenderer(); //$renderer->setCustomElementTemplate('<div class="col-md-6">{element}</div>'); $form->addButtonReset(get_lang('Reset')); $form = $form->returnForm(); } } } $actionsRight = ''; if ($view == 'calendar') { $actionsRight .= $form; } $toolbar = Display::toolbarAction('toolbar-agenda', array(0 => $actionsLeft, 1 => $actionsRight), 2, false); return $toolbar; }