Improving UI and queries see BT#7297

1.9.x
Julio Montoya 12 years ago
parent 3109abfd7b
commit 9a43f31d2a
  1. 24
      main/inc/lib/sessionmanager.lib.php
  2. 52
      main/mySpace/index.php
  3. 48
      main/mySpace/student.php
  4. 485
      main/mySpace/teachers.php
  5. 1
      main/mySpace/users.php

@ -3540,7 +3540,12 @@ class SessionManager
case 'drh':
// Classic DRH
if (empty($studentIdList)) {
$studentListSql = UserManager::get_users_followed_by_drh($userId, $filterByStatus, true, false);
$studentListSql = UserManager::get_users_followed_by_drh(
$userId,
$filterByStatus,
true,
false
);
$studentIdList = array_keys($studentListSql);
$studentListSql = "'".implode("','", $studentIdList)."'";
} else {
@ -3595,7 +3600,7 @@ class SessionManager
if (!empty($lastConnectionDate)) {
$loginTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql .= " INNER JOIN $loginTable l ON (l.login_user_id = u.user_id) ";
//$sql .= " INNER JOIN $loginTable l ON (l.login_user_id = u.user_id) ";
}
$where = " WHERE access_url_id = $urlId
@ -3609,7 +3614,7 @@ class SessionManager
if (!empty($lastConnectionDate)) {
$lastConnectionDate = Database::escape_string($lastConnectionDate);
$where .= " AND l.login_date <= '$lastConnectionDate' ";
//$where .= " AND l.login_date <= '$lastConnectionDate' ";
}
$sql .= $where;
@ -3640,7 +3645,6 @@ class SessionManager
}
$sql .= $limitCondition;
$result = Database::query($sql);
$result = Database::store_result($result);
@ -3797,6 +3801,7 @@ class SessionManager
* @param string $lastConnectionDate
* @param array $sessionIdList
* @param array $studentIdList
* @param int $userStatus STUDENT|COURSEMANAGER constants
* @return array|int
*/
public static function getCountUserTracking(
@ -3811,7 +3816,6 @@ class SessionManager
if (api_is_drh()) {
if (api_drh_can_access_all_session_content()) {
$count = self::getAllUsersFromCoursesFromAllSessionFromStatus(
'drh_all',
$userId,
@ -3844,7 +3848,6 @@ class SessionManager
array(),
array(),
$userStatus
);
}
} else {
@ -3893,6 +3896,7 @@ class SessionManager
$sessionIdList[] = $session['id'];
}
}
$sessionIdList = array_map('intval', $sessionIdList);
$sessionToString = implode("', '", $sessionIdList);
@ -3901,7 +3905,7 @@ class SessionManager
$courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
// Select the teachers.
$sql = "SELECT cu.user_id FROM $course c
$sql = "SELECT DISTINCT(cu.user_id) FROM $course c
INNER JOIN $sessionCourse src ON c.code = src.course_code
INNER JOIN $courseUser cu ON (cu.course_code = c.code)
WHERE src.id_session IN ('$sessionToString') AND cu.status = 1";
@ -3919,7 +3923,7 @@ class SessionManager
}
}
if (!empty($teacherResult)) {
if (!empty($teacherListId)) {
$tableUser = Database::get_main_table(TABLE_MAIN_USER);
$select = "SELECT DISTINCT u.* ";
@ -3931,7 +3935,7 @@ class SessionManager
if (!empty($lastConnectionDate)) {
$tableLogin = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql .= " INNER JOIN $tableLogin l ON (l.login_user_id = u.user_id) ";
//$sql .= " INNER JOIN $tableLogin l ON (l.login_user_id = u.user_id) ";
}
$active = intval($active);
$teacherListId = implode("','", $teacherListId);
@ -3939,7 +3943,7 @@ class SessionManager
if (!empty($lastConnectionDate)) {
$lastConnectionDate = Database::escape_string($lastConnectionDate);
$where .= " AND l.login_date <= '$lastConnectionDate' ";
//$where .= " AND l.login_date <= '$lastConnectionDate' ";
}
$sql .= $where;

@ -157,8 +157,8 @@ echo '</div>';
$userId = api_get_user_id();
$stats = Tracking::getStats($userId);
$students = $stats['teachers'];
$teachers = $stats['students'];
$students = $stats['students'];
$teachers = $stats['teachers'];
$courses = $stats['courses'];
$sessions = $stats['sessions'];
@ -194,7 +194,6 @@ if (!empty($students)) {
$avg_total_progress = $progress / $nb_students;
// average assignments
$nb_assignments = $countAssignments / $nb_students;
$avg_courses_per_student = $count_courses / $nb_students;
}
@ -242,24 +241,43 @@ echo Display::page_subheader(get_lang('Overview'));
echo '<div class="report_section">
<table class="table table-bordered">
<tr>
<td>'.get_lang('FollowedStudents').'</td>
<td>'.Display::url(
get_lang('FollowedStudents'),
api_get_path(WEB_CODE_PATH).'mySpace/student.php'
).'</td>
<td align="right">'.$nb_students.'</td>
</tr>
<tr>
<td>'.get_lang('FollowedTeachers').'</td>
<td>'.Display::url(
get_lang('FollowedTeachers'),
api_get_path(WEB_CODE_PATH).'mySpace/teachers.php'
).
'</td>
<td align="right">'.$numberTeachers.'</td>
</tr>
<tr>
<td>'.get_lang('FollowedUsers').'</td>
<td>'.Display::url(
get_lang('FollowedUsers'),
api_get_path(WEB_CODE_PATH).'mySpace/users.php'
).
'</td>
<td align="right">'.($nb_students+$numberTeachers).$linkAddUser.'</td>
</tr>
<tr>
<td>'.get_lang('FollowedCourses').'</td>
<td>'.Display::url(
get_lang('FollowedCourses'),
api_get_path(WEB_CODE_PATH).'mySpace/courses.php'
).
'</td>
<td align="right">'.$count_courses.$linkAddCourse.'</td>
</tr>
<tr>
<td>'.get_lang('FollowedSessions').'</td>
<td align="right">'.$count_sessions.$linkAddSession.'</td>
<td>'.Display::url(
get_lang('FollowedSessions'),
api_get_path(WEB_CODE_PATH).'mySpace/session.php'
).
'</td>
<td align="right">'.$count_sessions.$linkAddSession.'</td>
</tr>
</table>';
echo '</div>';
@ -281,7 +299,7 @@ if ($export_csv) {
$lastConnectionDate = api_get_utc_datetime(strtotime('15 days ago'));
$countActiveUsers = SessionManager::getCountUserTracking(null, 1, null, array(), array());
$countInactiveUsers = SessionManager::getCountUserTracking(null, 0, null, $sessionIdList, $studentIds);
///$countInactiveUsers = SessionManager::getCountUserTracking(null, 0, null, $sessionIdList, $studentIds);
$countSleepingTeachers = SessionManager::getTeacherTracking(
api_get_user_id(),
1,
@ -303,10 +321,9 @@ if ($export_csv) {
$form->addElement('button', 'submit', get_lang('Search'));
$form->display();
// html part
echo '<div class="report_section">
<table class="table table-bordered">
<tr>
/*
<tr>
<td>'.Display::url(
get_lang('ActiveUsers'),
api_get_path(WEB_CODE_PATH).'mySpace/users.php?active=1').'</td>
@ -324,6 +341,13 @@ if ($export_csv) {
<td>'.Display::url(get_lang('SleepingStudents'), api_get_path(WEB_CODE_PATH).'mySpace/student.php?sleeping_days=15').'</td>
<td align="right">'.$countSleepingStudents.'</td>
</tr>
*/
// html part
echo '<div class="report_section">
<table class="table table-bordered">
<tr>
<td>'.get_lang('AverageCoursePerStudent').'</td>
<td align="right">'.(is_null($avg_courses_per_student) ? '' : round($avg_courses_per_student, 2)).'</td>

@ -16,7 +16,7 @@ require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
$active = isset($_GET['active']) ? intval($_GET['active']) : null;
$active = isset($_GET['active']) ? intval($_GET['active']) : 1;
api_block_anonymous_users();
@ -32,16 +32,25 @@ if (isset($_GET["user_id"]) && $_GET["user_id"]!="" && isset($_GET["type"]) && $
$interbreadcrumb[] = array ("url" => "coaches.php", "name" => get_lang('Tutors'));
}
function get_count_users($keyword = null, $active = null)
function get_count_users()
{
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
$active = isset($_GET['active']) ? intval($_GET['active']) : 1;
$sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null;
$lastConnectionDate = null;
if (!empty($sleepingDays)) {
$lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago'));
}
return SessionManager::getCountUserTracking($keyword, $active, $lastConnectionDate);
$count = SessionManager::getCountUserTracking(
$keyword,
$active,
$lastConnectionDate,
null,
null,
STUDENT
);
return $count;
}
function get_users($from, $number_of_items, $column, $direction)
@ -54,7 +63,6 @@ function get_users($from, $number_of_items, $column, $direction)
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();
$column = 'u.user_id';
@ -71,7 +79,10 @@ function get_users($from, $number_of_items, $column, $direction)
$direction,
$keyword,
$active,
$lastConnectionDate
$lastConnectionDate,
null,
null,
STUDENT
);
} else {
$students = UserManager::get_users_followed_by_drh(
@ -85,7 +96,10 @@ function get_users($from, $number_of_items, $column, $direction)
$column,
$direction,
$active,
$lastConnectionDate
$lastConnectionDate,
null,
null,
STUDENT
);
}
} else {
@ -100,7 +114,10 @@ function get_users($from, $number_of_items, $column, $direction)
$direction,
$keyword,
$active,
$lastConnectionDate
$lastConnectionDate,
null,
null,
STUDENT
);
} else {
$students = UserManager::get_users_followed_by_drh(
@ -114,7 +131,10 @@ function get_users($from, $number_of_items, $column, $direction)
$column,
$direction,
$active,
$lastConnectionDate
$lastConnectionDate,
null,
null,
STUDENT
);
}
}
@ -258,14 +278,16 @@ if ($export_csv) {
}
$form = new FormValidator('search_user', 'get', api_get_path(WEB_CODE_PATH).'mySpace/student.php');
$form->addElement('text', 'keyword', get_lang('User'));
$form->addElement('text', 'keyword', get_lang('Keyword'));
$form->addElement('select', 'active', get_lang('Status'), array(1 => get_lang('Active'), 0 => get_lang('Inactive')));
//$form->addElement('select', 'sleeping_days', get_lang('InactiveDays'), array('', 1 => 1, 5 => 5, 15 => 15, 30 => 30, 60 => 60, 90 => 90, 120 => 120));
$form->addElement('button', 'submit', get_lang('Search'));
$form->setDefaults($params);
// send the csv file if asked
$content = $table->get_table_data();
if ($export_csv) {
// send the csv file if asked
$content = $table->get_table_data();
foreach ($content as &$row) {
unset($row[4]);
}

@ -1,280 +1,315 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Teachers report
* Teacher report
* @package chamilo.reporting
*/
/**
* Code
*/
ob_start();
// names of the language file that needs to be included.
$language_file = array('registration', 'index', 'trad4all', 'tracking', 'admin');
// name of the language file that needs to be included
$language_file = array ('registration', 'index', 'tracking', 'admin');
$cidReset = true;
require_once '../inc/global.inc.php';
require_once 'myspace.lib.php';
$userId = api_get_user_id();
$this_section = SECTION_TRACKING;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
$nameTools = get_lang('Teachers');
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
$active = isset($_GET['active']) ? intval($_GET['active']) : 1;
api_block_anonymous_users();
$this_section = SECTION_TRACKING;
$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
Display :: display_header($nameTools);
if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && !isset($_GET["type"])) {
$interbreadcrumb[] = array ("url" => "teachers.php", "name" => get_lang('Teachers'));
}
$sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null;
$active = isset($_GET['active']) ? intval($_GET['active']) : 1;
if (isset($_GET["user_id"]) && $_GET["user_id"]!="" && isset($_GET["type"]) && $_GET["type"] == "coach") {
$interbreadcrumb[] = array ("url" => "coaches.php", "name" => get_lang('Tutors'));
}
$formateurs = array();
if (api_is_drh() || api_is_platform_admin()) {
// Followed teachers by drh
/*if (api_drh_can_access_all_session_content()) {
$sessions = SessionManager::get_sessions_followed_by_drh($userId);
if (!empty($sessions)) {
$formateurs = array();
foreach ($sessions as $session) {
$coursesFromSession = SessionManager::get_course_list_by_session_id($session['id']);
foreach ($coursesFromSession as $course) {
$teachers = CourseManager::get_teacher_list_from_course_code($course['code']);
foreach ($teachers as $teacher) {
if (isset($formateurs[$teacher['user_id']])) {
continue;
}
$formateurs[$teacher['user_id']] = $teacher;
}
}
}
}
} else {
$formateurs = UserManager::get_users_followed_by_drh($userId, COURSEMANAGER);
}*/
function get_count_users()
{
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
$active = isset($_GET['active']) ? intval($_GET['active']) : 1;
$sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null;
$lastConnectionDate = null;
if (!empty($sleepingDays)) {
$lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago'));
}
$formateurs = SessionManager::getTeacherTracking($userId, $active, $lastConnectionDate);
$menu_items = array(
Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH)."auth/my_progress.php" ),
Display::url(Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), "index.php?view=drh_students&amp;display=yourstudents"),
Display::url(Display::return_icon('teacher_na.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), '#'),
Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), 'course.php'),
Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php')
return SessionManager::getCountUserTracking(
$keyword,
$active,
$lastConnectionDate,
null,
null,
COURSEMANAGER
);
echo '<div class="actions">';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {
foreach ($menu_items as $key => $item) {
echo $item;
}
}
if (count($formateurs) > 0) {
echo '<span style="float:right">';
echo Display::url(Display::return_icon('printer.png', get_lang('Print'), array(), ICON_SIZE_MEDIUM), 'javascript: void(0);', array('onclick'=>'javascript: window.print();'));
echo Display::url(Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), array(), ICON_SIZE_MEDIUM), api_get_self().'?export=xls');
echo '</span>';
}
echo '</div>';
echo Display::page_subheader(get_lang('YourTeachers'));
if (!empty($lastConnectionDate)) {
echo Display::page_subheader2(get_lang('SleepingTeachers').' '.api_get_local_time($lastConnectionDate));
}
}
if (!api_is_drh()) {
api_display_tool_title($nameTools);
}
function get_users($from, $number_of_items, $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;
/** MAIN PART */
$lastConnectionDate = null;
if (!empty($sleepingDays)) {
$lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago'));
}
if (isset($_POST['export'])) {
$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();
if (!api_is_drh() && !api_is_platform_admin()) {
$order_clause = $sort_by_first_name ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
if (isset($_GET["teacher_id"]) && $_GET["teacher_id"] != 0) {
$teacher_id = intval($_GET["teacher_id"]);
$sql_formateurs = "SELECT user_id,lastname,firstname,email
FROM $tbl_user
WHERE user_id='$teacher_id'".$order_clause;
$coach_id = api_get_user_id();
$column = 'u.user_id';
if (api_is_drh()) {
if (api_drh_can_access_all_session_content()) {
$students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
'drh_all',
api_get_user_id(),
false,
$from,
$number_of_items,
$column,
$direction,
$keyword,
$active,
$lastConnectionDate,
null,
null,
COURSEMANAGER
);
} else {
$students = UserManager::get_users_followed_by_drh(
api_get_user_id(),
null,
false,
false,
false,
$from,
$number_of_items,
$column,
$direction,
$active,
$lastConnectionDate,
null,
null,
COURSEMANAGER
);
}
} else {
$sql_formateurs = "SELECT user_id,lastname,firstname,email
FROM $tbl_user
WHERE status = 1".$order_clause;
}
$result_formateurs = Database::query($sql_formateurs);
if (Database::num_rows($result_formateurs) > 0) {
while ($row_formateurs = Database::fetch_array($result_formateurs)) {
$formateurs[] = $row_formateurs;
if (api_is_platform_admin()) {
$students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
'admin',
api_get_user_id(),
false,
$from,
$number_of_items,
$column,
$direction,
$keyword,
$active,
$lastConnectionDate,
null,
null,
COURSEMANAGER
);
} else {
$students = UserManager::get_users_followed_by_drh(
api_get_user_id(),
null,
false,
false,
false,
$from,
$number_of_items,
$column,
$direction,
$active,
$lastConnectionDate,
null,
null,
COURSEMANAGER
);
}
}
}
$time_filter = 'last_7_days';
$time_label = sprintf(get_lang('TimeSpentLastXDays'), 7);
$form = new FormValidator('time_filter');
$form->addElement('datepickerdate', 'start_date', get_lang('StartDate'), array('form_name'=>'exercise_admin'));
$form->addElement('datepickerdate', 'end_date', get_lang('EndDate'), array('form_name'=>'exercise_admin'));
$form->addRule('start_date', get_lang('InvalidDate'), 'date');
$form->addRule('end_date', get_lang('InvalidDate'), 'date');
$form->addRule(array ('start_date', 'end_date'), get_lang('StartDateShouldBeBeforeEndDate'), 'date_compare', 'lte');
$defaults = array();
$defaults['start_date'] = date('Y-m-d 12:00:00', strtotime("-7 days"));
$defaults['end_date'] = date('Y-m-d 12:00:00', time());
$start_date = $end_date = null;
if ($form->validate()) {
$values = $form->exportValues();
$start_date = $defaults['start_date'] = $values['start_date'];
$end_date = $defaults['end_date'] = $values['end_date'];
$time_filter = 'custom';
$time_label = sprintf(get_lang('TimeSpentBetweenXAndY'), $start_date, $end_date);
}
$form->setDefaults($defaults);
$form->addelement('style_submit_button', 'submit', get_lang('Filter'));
$form->display();
if ($is_western_name_order) {
echo '<table class="data_table">
<tr>
<th>'.get_lang('FirstName').'</th>
<th>'.get_lang('LastName').'</th>
<th>'.$time_label.'</th>
<th>'.get_lang('Email').'</th>
<th>'.get_lang('LastConnexion').'</th>
<th>'.get_lang('AdminCourses').'</th>
<th>'.get_lang('Students').'</th>
</tr>';
} else {
echo '<table class="data_table">
<tr>
<th>'.get_lang('LastName').'</th>
<th>'.get_lang('FirstName').'</th>
<th>'.$time_label.'</th>
<th>'.get_lang('Email').'</th>
<th>'.get_lang('LastConnexion').'</th>
<th>'.get_lang('AdminCourses').'</th>
<th>'.get_lang('Students').'</th>
</tr>';
}
$all_datas = array();
if ($is_western_name_order) {
$header[] = get_lang('FirstName');
$header[] = get_lang('LastName');
} else {
$header[] = get_lang('LastName');
$header[] = get_lang('FirstName');
}
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']);
}
$header[] = $time_label;
$header[] = get_lang('Email');
$data = array();
if (!empty($formateurs) && count($formateurs) > 0) {
$i = 1;
foreach ($formateurs as $formateur) {
$user_id = $formateur["user_id"];
$lastname = $formateur["lastname"];
$firstname = $formateur["firstname"];
$email = $formateur["email"];
if ($i % 2 == 0) {
$css_class = "row_odd";
if ($i % 20 == 0 && $i != 0) {
if ($is_western_name_order) {
echo '<tr>
<th>'.get_lang('FirstName').'</th>
<th>'.get_lang('LastName').'</th>
<th>'.get_lang('Email').'</th>
<th>'.get_lang('LastConnexion').'</th>
<th>'.get_lang('AdminCourses').'</th>
<th>'.get_lang('Students').'</th>
</tr>';
} else {
echo '<tr>
<th>'.get_lang('LastName').'</th>
<th>'.get_lang('FirstName').'</th>
<th>'.get_lang('Email').'</th>
<th>'.get_lang('LastConnexion').'</th>
<th>'.get_lang('AdminCourses').'</th>
<th>'.get_lang('Students').'</th>
</tr>';
$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) {
if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
$avg_time_spent += Tracking :: get_time_spent_on_the_course($student_id, $course_code, $_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 {
$css_class = "row_even";
$avg_time_spent = null;
$avg_student_score = null;
$avg_student_progress = null;
}
$i++;
$row = array();
if ($is_western_name_order) {
$data[$user_id]["firstname"] = $firstname;
$data[$user_id]["lastname"] = $lastname;
$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 {
$data[$user_id]["lastname"] = $lastname;
$data[$user_id]["firstname"] = $firstname;
$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;
}
$time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($user_id, $time_filter, $start_date, $end_date));
$data[$user_id]["timespentlastweek"] = $time_on_platform;
$data[$user_id]["email"] = $email;
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();
}
$timestamp = Tracking::get_last_connection_date($user_id, false, true);
$sort_by_first_name = api_sort_by_first_name();
$actions .= '<div class="actions">';
$lastConnection = api_get_local_time($timestamp);
if (api_is_drh()) {
$menu_items = array(
Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH)."auth/my_progress.php" ),
Display::url(Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), 'student.php'),
Display::url(Display::return_icon('teacher_na.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), 'teachers.php'),
Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), 'course.php'),
Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php')
);
if ($is_western_name_order) {
echo '<tr class="'.$css_class.'">
<td>'.$firstname.'</td>
<td>'.$lastname.'</td>
<td align="right">'.$time_on_platform.'</td>
<td align="right"><a href="mailto:'.$email.'">'.$email.'</a></td>
<td align="right">'.$lastConnection.'</td>
<td align="right">
<a href="course.php?user_id='.$user_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>
</td>
<td align="right">
<a href="student.php?user_id='.$user_id.'&amp;display=yourstudents">
<img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>
</td>
</tr>';
} else {
echo '<tr class="'.$css_class.'"><td>'.$lastname.'</td>
<td>'.$firstname.'</td><td align="right">'.$time_on_platform.'</td>
<td align="right"><a href="mailto:'.$email.'">'.$email.'</a></td>
<td align="right"><a href="course.php?user_id='.$user_id.'">
<img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>
</td>
<td align="right"><a href="student.php?user_id='.$user_id.'&amp;display=yourstudents">
<img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>
</td>
</tr>';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {
foreach ($menu_items as $key => $item) {
$actions .= $item;
}
}
}
$actions .= '<span style="float:right">';
$actions .= Display::url(Display::return_icon('printer.png', get_lang('Print'), array(), ICON_SIZE_MEDIUM), 'javascript: void(0);', array('onclick'=>'javascript: window.print();'));
$actions .= Display::url(Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), array(), ICON_SIZE_MEDIUM), api_get_self().'?export=csv&keyword='.$keyword);
$actions .= '</span>';
$actions .= '</div>';
$table = new SortableTable(
'tracking_teachers',
'get_count_users',
'get_users',
($is_western_name_order xor $sort_by_first_name) ? 1 : 0,
10
);
$params = array(
'keyword' => $keyword,
'active' => $active
);
$table->set_additional_parameters($params);
if ($is_western_name_order) {
$table->set_header(0, get_lang('FirstName'), false);
$table->set_header(1, get_lang('LastName'), false);
} else {
// No results
echo '<tr><td colspan="6">'.get_lang("NoResults").'</td></tr>';
$table->set_header(0, get_lang('LastName'), false);
$table->set_header(1, get_lang('FirstName'), false);
}
echo '</table>';
if (isset($_POST['export']) || (api_is_drh() && isset($_GET['export']))) {
MySpace::export_csv($header, $data, 'teachers.csv');
$table->set_header(2, get_lang('FirstLogin'), false);
$table->set_header(3, get_lang('LastConnexion'), false);
$table->set_header(4, get_lang('Details'), false);
if ($export_csv) {
if ($is_western_name_order) {
$csv_header[] = array (
get_lang('FirstName', ''),
get_lang('LastName', ''),
get_lang('FirstLogin', ''),
get_lang('LastConnexion', '')
);
} else {
$csv_header[] = array (
get_lang('LastName', ''),
get_lang('FirstName', ''),
get_lang('FirstLogin', ''),
get_lang('LastConnexion', '')
);
}
}
if (!api_is_drh()) {
echo "<form method='post' action='teachers.php'><input type='submit' name='export' value='".get_lang('exportExcel')."'/><form>";
$form = new FormValidator('search_user', 'get', api_get_path(WEB_CODE_PATH).'mySpace/teachers.php');
$form->addElement('text', 'keyword', get_lang('Keyword'));
$form->addElement('select', 'active', get_lang('Status'), array(1 => get_lang('Active'), 0 => get_lang('Inactive')));
//$form->addElement('select', 'sleeping_days', get_lang('InactiveDays'), array('', 1 => 1, 5 => 5, 15 => 15, 30 => 30, 60 => 60, 90 => 90, 120 => 120));
$form->addElement('button', 'submit', get_lang('Search'));
$form->setDefaults($params);
if ($export_csv) {
// send the csv file if asked
$content = $table->return_table();
foreach ($content as &$row) {
unset($row[4]);
}
$csv_content = array_merge($csv_header, $content);
ob_end_clean();
Export :: export_table_csv($csv_content, 'reporting_teacher_list');
exit;
} else {
Display::display_header($nameTools);
echo $actions;
$page_title = get_lang('Teachers');
echo Display::page_subheader($page_title);
if (isset($active)) {
if ($active) {
$activeLabel = get_lang('ActiveUsers');
} else {
$activeLabel = get_lang('InactiveUsers');
}
echo Display::page_subheader2($activeLabel);
}
$form->display();
$table->display();
}
Display::display_footer();
Display :: display_footer();

@ -87,7 +87,6 @@ function get_users($from, $number_of_items, $column, $direction)
$active,
$lastConnectionDate
);
}
} else {
if (api_is_platform_admin()) {

Loading…
Cancel
Save