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. 48
      main/mySpace/index.php
  3. 44
      main/mySpace/student.php
  4. 457
      main/mySpace/teachers.php
  5. 1
      main/mySpace/users.php

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

@ -157,8 +157,8 @@ echo '</div>';
$userId = api_get_user_id(); $userId = api_get_user_id();
$stats = Tracking::getStats($userId); $stats = Tracking::getStats($userId);
$students = $stats['teachers']; $students = $stats['students'];
$teachers = $stats['students']; $teachers = $stats['teachers'];
$courses = $stats['courses']; $courses = $stats['courses'];
$sessions = $stats['sessions']; $sessions = $stats['sessions'];
@ -194,7 +194,6 @@ if (!empty($students)) {
$avg_total_progress = $progress / $nb_students; $avg_total_progress = $progress / $nb_students;
// average assignments // average assignments
$nb_assignments = $countAssignments / $nb_students; $nb_assignments = $countAssignments / $nb_students;
$avg_courses_per_student = $count_courses / $nb_students; $avg_courses_per_student = $count_courses / $nb_students;
} }
@ -242,23 +241,42 @@ echo Display::page_subheader(get_lang('Overview'));
echo '<div class="report_section"> echo '<div class="report_section">
<table class="table table-bordered"> <table class="table table-bordered">
<tr> <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> <td align="right">'.$nb_students.'</td>
</tr> </tr>
<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> <td align="right">'.$numberTeachers.'</td>
</tr> </tr>
<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> <td align="right">'.($nb_students+$numberTeachers).$linkAddUser.'</td>
</tr> </tr>
<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> <td align="right">'.$count_courses.$linkAddCourse.'</td>
</tr> </tr>
<tr> <tr>
<td>'.get_lang('FollowedSessions').'</td> <td>'.Display::url(
get_lang('FollowedSessions'),
api_get_path(WEB_CODE_PATH).'mySpace/session.php'
).
'</td>
<td align="right">'.$count_sessions.$linkAddSession.'</td> <td align="right">'.$count_sessions.$linkAddSession.'</td>
</tr> </tr>
</table>'; </table>';
@ -281,7 +299,7 @@ if ($export_csv) {
$lastConnectionDate = api_get_utc_datetime(strtotime('15 days ago')); $lastConnectionDate = api_get_utc_datetime(strtotime('15 days ago'));
$countActiveUsers = SessionManager::getCountUserTracking(null, 1, null, array(), array()); $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( $countSleepingTeachers = SessionManager::getTeacherTracking(
api_get_user_id(), api_get_user_id(),
1, 1,
@ -303,9 +321,8 @@ if ($export_csv) {
$form->addElement('button', 'submit', get_lang('Search')); $form->addElement('button', 'submit', get_lang('Search'));
$form->display(); $form->display();
// html part /*
echo '<div class="report_section">
<table class="table table-bordered">
<tr> <tr>
<td>'.Display::url( <td>'.Display::url(
get_lang('ActiveUsers'), get_lang('ActiveUsers'),
@ -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>'.Display::url(get_lang('SleepingStudents'), api_get_path(WEB_CODE_PATH).'mySpace/student.php?sleeping_days=15').'</td>
<td align="right">'.$countSleepingStudents.'</td> <td align="right">'.$countSleepingStudents.'</td>
</tr> </tr>
*/
// html part
echo '<div class="report_section">
<table class="table table-bordered">
<tr> <tr>
<td>'.get_lang('AverageCoursePerStudent').'</td> <td>'.get_lang('AverageCoursePerStudent').'</td>
<td align="right">'.(is_null($avg_courses_per_student) ? '' : round($avg_courses_per_student, 2)).'</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; $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null; $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(); 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')); $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; $sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null;
$lastConnectionDate = null; $lastConnectionDate = null;
if (!empty($sleepingDays)) { if (!empty($sleepingDays)) {
$lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago')); $lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago'));
} }
$count = SessionManager::getCountUserTracking(
return SessionManager::getCountUserTracking($keyword, $active, $lastConnectionDate); $keyword,
$active,
$lastConnectionDate,
null,
null,
STUDENT
);
return $count;
} }
function get_users($from, $number_of_items, $column, $direction) 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)) { if (!empty($sleepingDays)) {
$lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago')); $lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago'));
} }
$is_western_name_order = api_is_western_name_order(); $is_western_name_order = api_is_western_name_order();
$coach_id = api_get_user_id(); $coach_id = api_get_user_id();
$column = 'u.user_id'; $column = 'u.user_id';
@ -71,7 +79,10 @@ function get_users($from, $number_of_items, $column, $direction)
$direction, $direction,
$keyword, $keyword,
$active, $active,
$lastConnectionDate $lastConnectionDate,
null,
null,
STUDENT
); );
} else { } else {
$students = UserManager::get_users_followed_by_drh( $students = UserManager::get_users_followed_by_drh(
@ -85,7 +96,10 @@ function get_users($from, $number_of_items, $column, $direction)
$column, $column,
$direction, $direction,
$active, $active,
$lastConnectionDate $lastConnectionDate,
null,
null,
STUDENT
); );
} }
} else { } else {
@ -100,7 +114,10 @@ function get_users($from, $number_of_items, $column, $direction)
$direction, $direction,
$keyword, $keyword,
$active, $active,
$lastConnectionDate $lastConnectionDate,
null,
null,
STUDENT
); );
} else { } else {
$students = UserManager::get_users_followed_by_drh( $students = UserManager::get_users_followed_by_drh(
@ -114,7 +131,10 @@ function get_users($from, $number_of_items, $column, $direction)
$column, $column,
$direction, $direction,
$active, $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 = 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->addElement('button', 'submit', get_lang('Search'));
$form->setDefaults($params); $form->setDefaults($params);
if ($export_csv) {
// send the csv file if asked // send the csv file if asked
$content = $table->get_table_data(); $content = $table->get_table_data();
if ($export_csv) {
foreach ($content as &$row) { foreach ($content as &$row) {
unset($row[4]); unset($row[4]);
} }

@ -1,280 +1,315 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Teachers report * Teacher report
* @package chamilo.reporting * @package chamilo.reporting
*/ */
/** /**
* Code * Code
*/ */
ob_start(); // name of the language file that needs to be included
$language_file = array ('registration', 'index', 'tracking', 'admin');
// names of the language file that needs to be included.
$language_file = array('registration', 'index', 'trad4all', 'tracking', 'admin');
$cidReset = true; $cidReset = true;
require_once '../inc/global.inc.php';
require_once 'myspace.lib.php';
$userId = api_get_user_id(); require_once '../inc/global.inc.php';
$this_section = SECTION_TRACKING; 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(); api_block_anonymous_users();
$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
Display :: display_header($nameTools); $this_section = SECTION_TRACKING;
$sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null; $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
$active = isset($_GET['active']) ? intval($_GET['active']) : 1;
$formateurs = array(); if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && !isset($_GET["type"])) {
if (api_is_drh() || api_is_platform_admin()) { $interbreadcrumb[] = array ("url" => "teachers.php", "name" => get_lang('Teachers'));
// 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;
}
}
} }
if (isset($_GET["user_id"]) && $_GET["user_id"]!="" && isset($_GET["type"]) && $_GET["type"] == "coach") {
$interbreadcrumb[] = array ("url" => "coaches.php", "name" => get_lang('Tutors'));
} }
} 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; $lastConnectionDate = null;
if (!empty($sleepingDays)) { if (!empty($sleepingDays)) {
$lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago')); $lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago'));
} }
$formateurs = SessionManager::getTeacherTracking($userId, $active, $lastConnectionDate);
$menu_items = array( return SessionManager::getCountUserTracking(
Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH)."auth/my_progress.php" ), $keyword,
Display::url(Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), "index.php?view=drh_students&amp;display=yourstudents"), $active,
Display::url(Display::return_icon('teacher_na.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), '#'), $lastConnectionDate,
Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), 'course.php'), null,
Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php') 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">'; function get_users($from, $number_of_items, $column, $direction)
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'); $active = isset($_GET['active']) ? $_GET['active'] : 1;
echo '</span>'; $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'));
} }
echo '</div>';
echo Display::page_subheader(get_lang('YourTeachers'));
if (!empty($lastConnectionDate)) { $is_western_name_order = api_is_western_name_order();
echo Display::page_subheader2(get_lang('SleepingTeachers').' '.api_get_local_time($lastConnectionDate)); $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 {
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
);
} }
if (!api_is_drh()) {
api_display_tool_title($nameTools);
} }
/** MAIN PART */ $all_datas = array();
if (isset($_POST['export'])) { foreach ($students as $student_data) {
$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT); $student_id = $student_data['user_id'];
} else { if (isset($_GET['id_session'])) {
$is_western_name_order = api_is_western_name_order(); $courses = Tracking :: get_course_list_in_session_from_student($student_id, $_GET['id_session']);
} }
$sort_by_first_name = api_sort_by_first_name();
if (!api_is_drh() && !api_is_platform_admin()) { $avg_time_spent = $avg_student_score = $avg_student_progress = $total_assignments = $total_messages = 0;
$order_clause = $sort_by_first_name ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname'; $nb_courses_student = 0;
if (isset($_GET["teacher_id"]) && $_GET["teacher_id"] != 0) { if (!empty($courses)) {
$teacher_id = intval($_GET["teacher_id"]); foreach ($courses as $course_code) {
$sql_formateurs = "SELECT user_id,lastname,firstname,email if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
FROM $tbl_user $avg_time_spent += Tracking :: get_time_spent_on_the_course($student_id, $course_code, $_GET['id_session']);
WHERE user_id='$teacher_id'".$order_clause; $my_average = Tracking :: get_avg_student_score($student_id, $course_code);
} else { if (is_numeric($my_average)) {
$sql_formateurs = "SELECT user_id,lastname,firstname,email $avg_student_score += $my_average;
FROM $tbl_user
WHERE status = 1".$order_clause;
} }
$avg_student_progress += Tracking :: get_avg_student_progress($student_id, $course_code);
$result_formateurs = Database::query($sql_formateurs); $total_assignments += Tracking :: count_student_assignments($student_id, $course_code);
if (Database::num_rows($result_formateurs) > 0) { $total_messages += Tracking :: count_student_messages($student_id, $course_code);
while ($row_formateurs = Database::fetch_array($result_formateurs)) { $nb_courses_student++;
$formateurs[] = $row_formateurs;
} }
} }
} }
$time_filter = 'last_7_days'; if ($nb_courses_student > 0) {
$time_label = sprintf(get_lang('TimeSpentLastXDays'), 7); $avg_time_spent = $avg_time_spent / $nb_courses_student;
$form = new FormValidator('time_filter'); $avg_student_score = $avg_student_score / $nb_courses_student;
$form->addElement('datepickerdate', 'start_date', get_lang('StartDate'), array('form_name'=>'exercise_admin')); $avg_student_progress = $avg_student_progress / $nb_courses_student;
$form->addElement('datepickerdate', 'end_date', get_lang('EndDate'), array('form_name'=>'exercise_admin')); } else {
$form->addRule('start_date', get_lang('InvalidDate'), 'date'); $avg_time_spent = null;
$form->addRule('end_date', get_lang('InvalidDate'), 'date'); $avg_student_score = null;
$form->addRule(array ('start_date', 'end_date'), get_lang('StartDateShouldBeBeforeEndDate'), 'date_compare', 'lte'); $avg_student_progress = null;
$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();
$row = array();
if ($is_western_name_order) { if ($is_western_name_order) {
echo '<table class="data_table"> $row[] = $student_data['firstname'];
<tr> $row[] = $student_data['lastname'];
<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 { } else {
echo '<table class="data_table"> $row[] = $student_data['lastname'];
<tr> $row[] = $student_data['firstname'];
<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>';
} }
$string_date = Tracking :: get_last_connection_date($student_id, true);
if ($is_western_name_order) { $first_date = Tracking :: get_first_connection_date($student_id);
$header[] = get_lang('FirstName'); $row[] = $first_date;
$header[] = get_lang('LastName'); $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 { } else {
$header[] = get_lang('LastName'); $detailsLink = '<a href="myStudents.php?student='.$student_id.'">
$header[] = get_lang('FirstName'); <img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
}
$row[] = $detailsLink;
$all_datas[] = $row;
}
return $all_datas;
} }
$header[] = $time_label; if ($export_csv) {
$header[] = get_lang('Email'); $is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
} else {
$is_western_name_order = api_is_western_name_order();
}
$data = array(); $sort_by_first_name = api_sort_by_first_name();
$actions .= '<div class="actions">';
if (!empty($formateurs) && count($formateurs) > 0) { if (api_is_drh()) {
$i = 1; $menu_items = array(
foreach ($formateurs as $formateur) { Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH)."auth/my_progress.php" ),
$user_id = $formateur["user_id"]; Display::url(Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), 'student.php'),
$lastname = $formateur["lastname"]; Display::url(Display::return_icon('teacher_na.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), 'teachers.php'),
$firstname = $formateur["firstname"]; Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), 'course.php'),
$email = $formateur["email"]; Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php')
);
if ($i % 2 == 0) { $nb_menu_items = count($menu_items);
$css_class = "row_odd"; if ($nb_menu_items > 1) {
if ($i % 20 == 0 && $i != 0) { foreach ($menu_items as $key => $item) {
if ($is_western_name_order) { $actions .= $item;
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>';
} }
} }
} else {
$css_class = "row_even";
} }
$i++;
$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) { if ($is_western_name_order) {
$data[$user_id]["firstname"] = $firstname; $table->set_header(0, get_lang('FirstName'), false);
$data[$user_id]["lastname"] = $lastname; $table->set_header(1, get_lang('LastName'), false);
} else { } else {
$data[$user_id]["lastname"] = $lastname; $table->set_header(0, get_lang('LastName'), false);
$data[$user_id]["firstname"] = $firstname; $table->set_header(1, get_lang('FirstName'), false);
} }
$time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($user_id, $time_filter, $start_date, $end_date)); $table->set_header(2, get_lang('FirstLogin'), false);
$data[$user_id]["timespentlastweek"] = $time_on_platform; $table->set_header(3, get_lang('LastConnexion'), false);
$data[$user_id]["email"] = $email; $table->set_header(4, get_lang('Details'), false);
$timestamp = Tracking::get_last_connection_date($user_id, false, true);
$lastConnection = api_get_local_time($timestamp);
if ($export_csv) {
if ($is_western_name_order) { if ($is_western_name_order) {
echo '<tr class="'.$css_class.'"> $csv_header[] = array (
<td>'.$firstname.'</td> get_lang('FirstName', ''),
<td>'.$lastname.'</td> get_lang('LastName', ''),
<td align="right">'.$time_on_platform.'</td> get_lang('FirstLogin', ''),
<td align="right"><a href="mailto:'.$email.'">'.$email.'</a></td> get_lang('LastConnexion', '')
<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 { } else {
echo '<tr class="'.$css_class.'"><td>'.$lastname.'</td> $csv_header[] = array (
<td>'.$firstname.'</td><td align="right">'.$time_on_platform.'</td> get_lang('LastName', ''),
<td align="right"><a href="mailto:'.$email.'">'.$email.'</a></td> get_lang('FirstName', ''),
<td align="right"><a href="course.php?user_id='.$user_id.'"> get_lang('FirstLogin', ''),
<img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a> get_lang('LastConnexion', '')
</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>';
} }
} }
$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 { } else {
// No results $activeLabel = get_lang('InactiveUsers');
echo '<tr><td colspan="6">'.get_lang("NoResults").'</td></tr>';
} }
echo '</table>'; echo Display::page_subheader2($activeLabel);
if (isset($_POST['export']) || (api_is_drh() && isset($_GET['export']))) {
MySpace::export_csv($header, $data, 'teachers.csv');
} }
$form->display();
if (!api_is_drh()) { $table->display();
echo "<form method='post' action='teachers.php'><input type='submit' name='export' value='".get_lang('exportExcel')."'/><form>";
} }
Display :: display_footer(); Display :: display_footer();

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

Loading…
Cancel
Save