if ($start_date != '') $sql .= " access_date >= '$start_date' "; if ($end_date != '') { $sql = ($start_date == '') ? $sql : ($sql . " AND "); $sql .= " access_date <= '$end_date' "; } } $result = Database::query($sql); $table_result = new SortableTable(); $table_result->set_header(0, get_lang('User'), false); $table_result->set_header(1, get_lang('Fullname'), false); $table_result->set_header(2, get_lang('Date'), false); $table_result->set_header(3, get_lang('Course'), false); $table_result->set_header(4, get_lang('Tool'), false); while ($row = Database::fetch_assoc($result)) { $row = array( $row['username'], $row['fullname'], $row['access_date'], $row['course'], get_lang($tools[$row['tool']]['name']) ); $table_result->addRow($row); } $table_result->display(); } else { show_form(); } Display::display_footer();
public static function display_tracking_coach_overview($export_csv) { global $charset; if ($export_csv) { $is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT); } else { $is_western_name_order = api_is_western_name_order(); } $sort_by_first_name = api_sort_by_first_name(); $tracking_column = isset($_GET['tracking_list_coaches_column']) ? $_GET['tracking_list_coaches_column'] : ($is_western_name_order xor $sort_by_first_name) ? 1 : 0; $tracking_direction = isset($_GET['tracking_list_coaches_direction']) && in_array(strtoupper($_GET['tracking_list_coaches_direction']), array('ASC', 'DESC', 'ASCENDING', 'DESCENDING', '0', '1')) ? $_GET['tracking_list_coaches_direction'] : 'DESC'; // Prepare array for column order - when impossible, use some of user names. if ($is_western_name_order) { $order = array(0 => 'firstname', 1 => 'lastname', 2 => $sort_by_first_name ? 'firstname' : 'lastname', 3 => 'login_date', 4 => $sort_by_first_name ? 'firstname' : 'lastname', 5 => $sort_by_first_name ? 'firstname' : 'lastname'); } else { $order = array(0 => 'lastname', 1 => 'firstname', 2 => $sort_by_first_name ? 'firstname' : 'lastname', 3 => 'login_date', 4 => $sort_by_first_name ? 'firstname' : 'lastname', 5 => $sort_by_first_name ? 'firstname' : 'lastname'); } $table = new SortableTable('tracking_list_coaches_myspace', array('MySpace', 'count_coaches'), null, ($is_western_name_order xor $sort_by_first_name) ? 1 : 0); $parameters['view'] = 'admin'; $table->set_additional_parameters($parameters); if ($is_western_name_order) { $table->set_header(0, get_lang('FirstName'), true); $table->set_header(1, get_lang('LastName'), true); } else { $table->set_header(0, get_lang('LastName'), true); $table->set_header(1, get_lang('FirstName'), true); } $table->set_header(2, get_lang('TimeSpentOnThePlatform'), false); $table->set_header(3, get_lang('LastConnexion'), false); $table->set_header(4, get_lang('NbStudents'), false); $table->set_header(5, get_lang('CountCours'), false); $table->set_header(6, get_lang('NumberOfSessions'), false); $table->set_header(7, get_lang('Sessions'), false); if ($is_western_name_order) { $csv_header[] = array(get_lang('FirstName', ''), get_lang('LastName', ''), get_lang('TimeSpentOnThePlatform', ''), get_lang('LastConnexion', ''), get_lang('NbStudents', ''), get_lang('CountCours', ''), get_lang('NumberOfSessions', '')); } else { $csv_header[] = array(get_lang('LastName', ''), get_lang('FirstName', ''), get_lang('TimeSpentOnThePlatform', ''), get_lang('LastConnexion', ''), get_lang('NbStudents', ''), get_lang('CountCours', ''), get_lang('NumberOfSessions', '')); } $tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_sessions = Database::get_main_table(TABLE_MAIN_SESSION); $sqlCoachs = "SELECT DISTINCT\n scu.user_id as id_coach,\n u.id as user_id,\n lastname,\n firstname,\n MAX(login_date) as login_date\n FROM {$tbl_user} u, {$tbl_session_course_user} scu, {$tbl_track_login}\n WHERE\n scu.user_id = u.id AND scu.status=2 AND login_user_id=u.id\n GROUP BY user_id "; if (api_is_multiple_url_enabled()) { $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $sqlCoachs = "SELECT DISTINCT\n scu.user_id as id_coach,\n u.id as user_id,\n lastname,\n firstname,\n MAX(login_date) as login_date\n FROM {$tbl_user} u,\n {$tbl_session_course_user} scu,\n {$tbl_track_login} ,\n {$tbl_session_rel_access_url} session_rel_url\n WHERE\n scu.user_id = u.id AND\n scu.status = 2 AND\n login_user_id = u.id AND\n access_url_id = {$access_url_id} AND\n session_rel_url.session_id = scu.session_id\n GROUP BY u.id"; } } if (!empty($order[$tracking_column])) { $sqlCoachs .= "ORDER BY " . $order[$tracking_column] . " " . $tracking_direction; } $result_coaches = Database::query($sqlCoachs); $total_no_coaches = Database::num_rows($result_coaches); $global_coaches = array(); while ($coach = Database::fetch_array($result_coaches)) { $global_coaches[$coach['user_id']] = $coach; } $sql_session_coach = 'SELECT session.id_coach, u.id as user_id, lastname, firstname, MAX(login_date) as login_date FROM ' . $tbl_user . ' u ,' . $tbl_sessions . ' as session,' . $tbl_track_login . ' WHERE id_coach = u.id AND login_user_id = u.id GROUP BY u.id ORDER BY login_date ' . $tracking_direction; if (api_is_multiple_url_enabled()) { $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $sql_session_coach = 'SELECT session.id_coach, u.id as user_id, lastname, firstname, MAX(login_date) as login_date FROM ' . $tbl_user . ' u ,' . $tbl_sessions . ' as session, ' . $tbl_track_login . ' , ' . $tbl_session_rel_access_url . ' as session_rel_url WHERE id_coach = u.id AND login_user_id = u.id AND access_url_id = ' . $access_url_id . ' AND session_rel_url.session_id = session.id GROUP BY u.id ORDER BY login_date ' . $tracking_direction; } } $result_sessions_coach = Database::query($sql_session_coach); $total_no_coaches += Database::num_rows($result_sessions_coach); while ($coach = Database::fetch_array($result_sessions_coach)) { $global_coaches[$coach['user_id']] = $coach; } $all_datas = array(); foreach ($global_coaches as $id_coach => $coaches) { $time_on_platform = api_time_to_hms(Tracking::get_time_spent_on_the_platform($coaches['user_id'])); $last_connection = Tracking::get_last_connection_date($coaches['user_id']); $nb_students = count(Tracking::get_student_followed_by_coach($coaches['user_id'])); $nb_courses = count(Tracking::get_courses_followed_by_coach($coaches['user_id'])); $nb_sessions = count(Tracking::get_sessions_coached_by_user($coaches['user_id'])); $table_row = array(); if ($is_western_name_order) { $table_row[] = $coaches['firstname']; $table_row[] = $coaches['lastname']; } else { $table_row[] = $coaches['lastname']; $table_row[] = $coaches['firstname']; } $table_row[] = $time_on_platform; $table_row[] = $last_connection; $table_row[] = $nb_students; $table_row[] = $nb_courses; $table_row[] = $nb_sessions; $table_row[] = '<a href="session.php?id_coach=' . $coaches['user_id'] . '"><img src="' . api_get_path(WEB_IMG_PATH) . 'icons/22/2rightarrow.png" border="0" /></a>'; $all_datas[] = $table_row; if ($is_western_name_order) { $csv_content[] = array(api_html_entity_decode($coaches['firstname'], ENT_QUOTES), api_html_entity_decode($coaches['lastname'], ENT_QUOTES), $time_on_platform, $last_connection, $nb_students, $nb_courses, $nb_sessions); } else { $csv_content[] = array(api_html_entity_decode($coaches['lastname'], ENT_QUOTES), api_html_entity_decode($coaches['firstname'], ENT_QUOTES), $time_on_platform, $last_connection, $nb_students, $nb_courses, $nb_sessions); } } if ($tracking_column != 3) { if ($tracking_direction == 'DESC') { usort($all_datas, array('MySpace', 'rsort_users')); } else { usort($all_datas, array('MySpace', 'sort_users')); } } if ($export_csv && $tracking_column != 3) { usort($csv_content, 'sort_users'); } if ($export_csv) { $csv_content = array_merge($csv_header, $csv_content); } foreach ($all_datas as $row) { $table->addRow($row, 'align="right"'); } $table->display(); }
$messages_in_course = null; $assignments_in_course = null; } $tematic_advance_progress = 0; $thematic = new Thematic($course); $tematic_advance = $thematic->get_total_average_of_thematic_advances($course_code, $id_session); if (!empty($tematic_advance)) { $tematic_advance_csv = $tematic_advance_progress . '%'; $tematic_advance_progress = '<a title="' . get_lang('GoToThematicAdvance') . '" href="' . api_get_path(WEB_CODE_PATH) . 'course_progress/index.php?cidReq=' . $course_code . '&id_session=' . $id_session . '">' . $tematic_advance . '%</a>'; } else { $tematic_advance_progress = '-'; } $table_row = array(); $table_row[] = $course['title']; $table_row[] = $nb_students_in_course; $table_row[] = is_null($avg_time_spent_in_course) ? '-' : $avg_time_spent_in_course; $table_row[] = $tematic_advance_progress; $table_row[] = is_null($avg_progress_in_course) ? '-' : $avg_progress_in_course . '%'; $table_row[] = is_null($avg_score_in_course) ? '-' : $avg_score_in_course; $table_row[] = is_null($messages_in_course) ? '-' : $messages_in_course; $table_row[] = is_null($assignments_in_course) ? '-' : $assignments_in_course; $table_row[] = '<a href="../tracking/courseLog.php?cidReq=' . $course_code . '&id_session=' . $id_session . '"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>'; $csv_content[] = array($course['title'], $nb_students_in_course, $avg_time_spent_in_course, $tematic_advance_csv, is_null($avg_progress_in_course) ? null : $avg_progress_in_course . '%', is_null($avg_score_in_course) ? null : $avg_score_in_course, $messages_in_course, $assignments_in_course); $table->addRow($table_row, 'align="right"'); } // $csv_content = array_merge($csv_header, $csv_content); // Before this statement you are allowed to sort (in different way) the array $csv_content. } //$table -> setColAttributes(0); //$table -> setColAttributes(7); $table->display(); Display::display_footer();
$row[] = '<a href="student.php?id_session=' . $session['id'] . '&id_coach=' . intval($_GET['id_coach']) . '"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>'; } else { $row[] = '<a href="course.php?id_session=' . $session['id'] . '"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>'; } $all_data[] = $row; } if (!isset($tracking_column)) { $tracking_column = 0; } if ($_GET['tracking_direction'] == 'DESC') { usort($all_data, 'rsort_sessions'); } else { usort($all_data, 'sort_sessions'); } if ($export_csv) { usort($csv_content, 'sort_sessions'); } foreach ($all_data as $row) { $table->addRow($row); } //$table -> setColAttributes(2, array('align' => 'center')); $table->display(); if ($export_csv) { ob_end_clean(); Export::export_table_csv($csv_content, 'reporting_student_list'); exit; } } else { echo get_lang('NoSession'); } Display::display_footer();