added filter by session id for reporting about courses, sessions and users - partial BT#570

skala
Cristian Fasanando 15 years ago
parent 5a24416d01
commit 5a9642a033
  1. 49
      main/gradebook/lib/be/category.class.php
  2. 17
      main/inc/lib/attendance.lib.php
  3. 43
      main/inc/lib/events.lib.inc.php
  4. 854
      main/inc/lib/tracking.lib.php
  5. 4
      main/inc/local.inc.php
  6. 6
      main/mySpace/access_details.php
  7. 143
      main/mySpace/index.php
  8. 656
      main/mySpace/myStudents.php
  9. 74
      main/mySpace/myspace.lib.php
  10. 3
      main/mySpace/student.php
  11. 11
      main/newscorm/learnpathList.class.php
  12. 107
      main/tracking/courseLog.php
  13. 4
      main/tracking/courseLogCSV.php

@ -211,8 +211,11 @@ class Category implements GradebookItem
$sql .= ' visible = '.$visible; $sql .= ' visible = '.$visible;
$paramcount ++; $paramcount ++;
} }
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$allcat = Category::create_category_objects_from_sql_result($result); $allcat = Category::create_category_objects_from_sql_result($result);
}
return $allcat; return $allcat;
} }
@ -451,20 +454,25 @@ class Category implements GradebookItem
* @return array (score sum, weight sum) * @return array (score sum, weight sum)
* or null if no scores available * or null if no scores available
*/ */
public function calc_score ($stud_id = null) { public function calc_score ($stud_id = null, $course_code = '', $session_id = null) {
// get appropriate subcategories, evaluations and links // get appropriate subcategories, evaluations and links
if (!empty($course_code)) {
$cats = $this->get_subcategories($stud_id, $course_code, $session_id);
$evals = $this->get_evaluations($stud_id, false, $course_code);
$links = $this->get_links($stud_id, false, $course_code);
} else {
$cats = $this->get_subcategories($stud_id); $cats = $this->get_subcategories($stud_id);
$evals = $this->get_evaluations($stud_id); $evals = $this->get_evaluations($stud_id);
$links = $this->get_links($stud_id); $links = $this->get_links($stud_id);
}
// calculate score // calculate score
$rescount = 0; $rescount = 0;
$ressum = 0; $ressum = 0;
$weightsum = 0; $weightsum = 0;
if (!empty($cats)) {
foreach ($cats as $cat) { foreach ($cats as $cat) {
$catres = $cat->calc_score ($stud_id); // recursive call $catres = $cat->calc_score ($stud_id); // recursive call
if (isset($catres) && $cat->get_weight() != 0) { if (isset($catres) && $cat->get_weight() != 0) {
@ -474,7 +482,9 @@ class Category implements GradebookItem
$ressum += (($catres[0]/$catres[1]) * $catweight); $ressum += (($catres[0]/$catres[1]) * $catweight);
} }
} }
}
if (!empty($evals)) {
foreach ($evals as $eval) { foreach ($evals as $eval) {
$evalres = $eval->calc_score ($stud_id); $evalres = $eval->calc_score ($stud_id);
if (isset($evalres) && $eval->get_weight() != 0) { if (isset($evalres) && $eval->get_weight() != 0) {
@ -484,6 +494,9 @@ class Category implements GradebookItem
$ressum += (($evalres[0]/$evalres[1]) * $evalweight); $ressum += (($evalres[0]/$evalres[1]) * $evalweight);
} }
} }
}
if (!empty($links)) {
foreach ($links as $link) { foreach ($links as $link) {
$linkres = $link->calc_score ($stud_id); $linkres = $link->calc_score ($stud_id);
if (isset($linkres) && $link->get_weight() != 0) { if (isset($linkres) && $link->get_weight() != 0) {
@ -494,6 +507,7 @@ class Category implements GradebookItem
$ressum += (($linkres[0]/$link_res_denom) * $linkweight); $ressum += (($linkres[0]/$link_res_denom) * $linkweight);
} }
} }
}
if ($rescount == 0) { if ($rescount == 0) {
return null; return null;
@ -926,11 +940,13 @@ class Category implements GradebookItem
$crsindcats = Category::load(null,$creator,'0',$cat_id, $crsindcats = Category::load(null,$creator,'0',$cat_id,
api_is_allowed_to_create_course() ? null : 1); api_is_allowed_to_create_course() ? null : 1);
if (!empty($crsindcats)) {
foreach ($crsindcats as $crsindcat) { foreach ($crsindcats as $crsindcat) {
if ($crsindcat->has_evaluations_with_results_for_student($stud_id)) { if ($crsindcat->has_evaluations_with_results_for_student($stud_id)) {
$cats[] = $crsindcat; $cats[] = $crsindcat;
} }
}
} }
return $cats; return $cats;
} }
@ -992,17 +1008,20 @@ class Category implements GradebookItem
* @param int $stud_id student id (default: all students) * @param int $stud_id student id (default: all students)
* @param boolean $recursive process subcategories (default: no recursion) * @param boolean $recursive process subcategories (default: no recursion)
*/ */
public function get_evaluations ($stud_id = null, $recursive = false) { public function get_evaluations ($stud_id = null, $recursive = false, $course_code = '') {
$evals = array(); $evals = array();
if (empty($course_code)) {
$course_code = api_get_course_id();
}
// 1 student // 1 student
if (isset($stud_id)) { if (isset($stud_id)) {
// special case: this is the root // special case: this is the root
if ($this->id == 0) { if ($this->id == 0) {
$evals = Evaluation::get_evaluations_with_result_for_student(0,$stud_id); $evals = Evaluation::get_evaluations_with_result_for_student(0,$stud_id);
} else { } else {
//added api_get_course_id() $evals = Evaluation::load(null,null,$course_code,$this->id,
$evals = Evaluation::load(null,null,api_get_course_id(),$this->id,
api_is_allowed_to_create_course() ? null : 1); api_is_allowed_to_create_course() ? null : 1);
} }
} else {// all students } else {// all students
@ -1014,7 +1033,7 @@ class Category implements GradebookItem
} }
// inside a course // inside a course
elseif (isset($this->course_code) && !empty($this->course_code)) { elseif (isset($this->course_code) && !empty($this->course_code)) {
$evals = Evaluation::load(null, null, api_get_course_id(), $this->id, null); $evals = Evaluation::load(null, null, $course_code, $this->id, null);
}else { // course independent }else { // course independent
$evals = Evaluation::load(null, api_get_user_id(), null, $this->id, null); $evals = Evaluation::load(null, api_get_user_id(), null, $this->id, null);
@ -1024,19 +1043,21 @@ class Category implements GradebookItem
//platform admin //platform admin
elseif (api_is_platform_admin()) { elseif (api_is_platform_admin()) {
$evals = Evaluation::load(null, null, api_get_course_id(), $this->id, null); $evals = Evaluation::load(null, null, $course_code, $this->id, null);
} }
} }
if ($recursive) { if ($recursive) {
$subcats = $this->get_subcategories($stud_id); $subcats = $this->get_subcategories($stud_id);
if (!empty($subcats)) {
foreach ($subcats as $subcat) { foreach ($subcats as $subcat) {
$subevals = $subcat->get_evaluations($stud_id, true); $subevals = $subcat->get_evaluations($stud_id, true);
//$this->debugprint($subevals); //$this->debugprint($subevals);
$evals = array_merge($evals, $subevals); $evals = array_merge($evals, $subevals);
} }
} }
}
return $evals; return $evals;
} }
@ -1046,16 +1067,20 @@ class Category implements GradebookItem
* @param int $stud_id student id (default: all students) * @param int $stud_id student id (default: all students)
* @param boolean $recursive process subcategories (default: no recursion) * @param boolean $recursive process subcategories (default: no recursion)
*/ */
public function get_links ($stud_id = null, $recursive = false) { public function get_links ($stud_id = null, $recursive = false, $course_code = '') {
$links = array(); $links = array();
if (empty($course_code)) {
$course_code = api_get_course_id();
}
// no links in root or course independent categories // no links in root or course independent categories
if ($this->id == 0) { if ($this->id == 0) {
; ;
} }
// 1 student $stud_id // 1 student $stud_id
elseif (isset($stud_id)) { elseif (isset($stud_id)) {
$links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:api_get_course_id(),$this->id, $links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:$course_code,$this->id,
api_is_allowed_to_create_course() ? null : 1); api_is_allowed_to_create_course() ? null : 1);
} }
// all students -> only for course/platform admin // all students -> only for course/platform admin
@ -1065,11 +1090,13 @@ class Category implements GradebookItem
if ($recursive) { if ($recursive) {
$subcats = $this->get_subcategories($stud_id); $subcats = $this->get_subcategories($stud_id);
if (!empty($subcats)) {
foreach ($subcats as $subcat) { foreach ($subcats as $subcat) {
$sublinks = $subcat->get_links($stud_id, false); $sublinks = $subcat->get_links($stud_id, false);
$links = array_merge($links, $sublinks); $links = array_merge($links, $sublinks);
} }
} }
}
return $links; return $links;
} }

@ -46,18 +46,24 @@ class Attendance
* @param int session id (optional) * @param int session id (optional)
* @return array attendances list * @return array attendances list
*/ */
function get_attendances_list($course_code = '', $session_id = 0) { function get_attendances_list($course_code = '', $session_id = null) {
// initializing database table and variables // initializing database table and variables
$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
$session_id = intval($session_id);
$data = array(); $data = array();
if (!empty($course_code)) { if (!empty($course_code)) {
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE, $course_info['dbName']); $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE, $course_info['dbName']);
} }
$condition_session = '';
if (isset($session_id)) {
$session_id = intval($session_id);
$condition_session = ' WHERE session_id = '.$session_id;
}
// get attendance data // get attendance data
$sql = "SELECT * FROM $tbl_attendance WHERE session_id='$session_id'"; $sql = "SELECT * FROM $tbl_attendance $condition_session ";
$rs = Database::query($sql); $rs = Database::query($sql);
if (Database::num_rows($rs) > 0){ if (Database::num_rows($rs) > 0){
while ($row = Database::fetch_array($rs)) { while ($row = Database::fetch_array($rs)) {
@ -519,9 +525,10 @@ class Attendance
/** /**
* Get results of faults average by course * Get results of faults average by course
* @param int user id * @param int user id
* @param int Session id (optional)
* @return array results containing number of faults, total done attendance, porcent of faults and color depend on result (red, orange) * @return array results containing number of faults, total done attendance, porcent of faults and color depend on result (red, orange)
*/ */
public function get_faults_average_by_course($user_id, $course_code) { public function get_faults_average_by_course($user_id, $course_code, $session_id = null) {
// Database tables and variables // Database tables and variables
@ -530,7 +537,7 @@ class Attendance
$user_id = intval($user_id); $user_id = intval($user_id);
$results = array(); $results = array();
$total_faults = $total_weight = $porcent = 0; $total_faults = $total_weight = $porcent = 0;
$attendances_by_course = $this->get_attendances_list($course_code); $attendances_by_course = $this->get_attendances_list($course_code, $session_id);
foreach ($attendances_by_course as $attendance) { foreach ($attendances_by_course as $attendance) {
// get total faults and total weight // get total faults and total weight

@ -148,11 +148,13 @@ function event_access_course()
$sql = "INSERT INTO ".$TABLETRACK_ACCESS." $sql = "INSERT INTO ".$TABLETRACK_ACCESS."
(access_user_id, (access_user_id,
access_cours_code, access_cours_code,
access_date) access_date,
access_session_id)
VALUES VALUES
(".$user_id.", (".$user_id.",
'".$_cid."', '".$_cid."',
FROM_UNIXTIME(".$reallyNow."))"; FROM_UNIXTIME(".$reallyNow."),
'".$id_session."')";
$res = Database::query($sql); $res = Database::query($sql);
// added for "what's new" notification // added for "what's new" notification
$sql = " UPDATE $TABLETRACK_LASTACCESS $sql = " UPDATE $TABLETRACK_LASTACCESS
@ -261,30 +263,28 @@ function event_access_tool($tool, $id_session=0)
*/ */
function event_download($doc_url) function event_download($doc_url)
{ {
global $_configuration; global $_configuration, $_user, $_cid;
global $_user;
global $_cid; $tbl_stats_downloads = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
global $TABLETRACK_DOWNLOADS;
// if tracking is disabled record nothing // if tracking is disabled record nothing
if (!$_configuration['tracking_enabled']) if (!$_configuration['tracking_enabled']) {
{
return 0; return 0;
} }
$reallyNow = time(); $reallyNow = time();
if ($_user['user_id']) if ($_user['user_id']) {
{
$user_id = "'".$_user['user_id']."'"; $user_id = "'".$_user['user_id']."'";
} else { } else {
$user_id = "0"; $user_id = "0";
} }
$sql = "INSERT INTO ".$TABLETRACK_DOWNLOADS." $sql = "INSERT INTO $tbl_stats_downloads
( (
down_user_id, down_user_id,
down_cours_id, down_cours_id,
down_doc_path, down_doc_path,
down_date down_date,
down_session_id
) )
VALUES VALUES
@ -292,7 +292,8 @@ function event_download($doc_url)
".$user_id.", ".$user_id.",
'".$_cid."', '".$_cid."',
'".htmlspecialchars($doc_url, ENT_QUOTES)."', '".htmlspecialchars($doc_url, ENT_QUOTES)."',
FROM_UNIXTIME(".$reallyNow.") FROM_UNIXTIME(".$reallyNow."),
'".api_get_session_id()."'
)"; )";
$res = Database::query($sql); $res = Database::query($sql);
return 1; return 1;
@ -326,13 +327,15 @@ function event_upload($doc_id)
( upload_user_id, ( upload_user_id,
upload_cours_id, upload_cours_id,
upload_work_id, upload_work_id,
upload_date upload_date,
updload_session_id
) )
VALUES ( VALUES (
".$user_id.", ".$user_id.",
'".$_cid."', '".$_cid."',
'".$doc_id."', '".$doc_id."',
FROM_UNIXTIME(".$reallyNow.") FROM_UNIXTIME(".$reallyNow."),
'".api_get_session_id()."'
)"; )";
$res = Database::query($sql); $res = Database::query($sql);
return 1; return 1;
@ -346,9 +349,7 @@ function event_upload($doc_id)
*/ */
function event_link($link_id) function event_link($link_id)
{ {
global $_configuration; global $_configuration, $_user, $_cid;
global $_user;
global $_cid;
global $TABLETRACK_LINKS; global $TABLETRACK_LINKS;
// if tracking is disabled record nothing // if tracking is disabled record nothing
@ -368,14 +369,16 @@ function event_link($link_id)
( links_user_id, ( links_user_id,
links_cours_id, links_cours_id,
links_link_id, links_link_id,
links_date links_date,
links_session_id
) )
VALUES VALUES
( (
".$user_id.", ".$user_id.",
'".$_cid."', '".$_cid."',
'".Database::escape_string($link_id)."', '".Database::escape_string($link_id)."',
FROM_UNIXTIME(".$reallyNow.") FROM_UNIXTIME(".$reallyNow."),
'".api_get_session_id()."'
)"; )";
$res = Database::query($sql); $res = Database::query($sql);
return 1; return 1;

File diff suppressed because it is too large Load Diff

@ -810,8 +810,8 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
//We add a new record in the course tracking table //We add a new record in the course tracking table
$course_tracking_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); $course_tracking_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$time = api_get_datetime(); $time = api_get_datetime();
$sql="INSERT INTO $course_tracking_table(course_code, user_id, login_course_date, logout_course_date, counter)" . $sql="INSERT INTO $course_tracking_table(course_code, user_id, login_course_date, logout_course_date, counter, session_id)" .
"VALUES('".$_course['sysCode']."', '".$_user['user_id']."', '$time', '$time', '1')"; "VALUES('".$_course['sysCode']."', '".$_user['user_id']."', '$time', '$time', '1', ".intval($_SESSION['id_session']).")";
Database::query($sql); Database::query($sql);
} }

@ -31,10 +31,12 @@ $this_section = "session_my_space";
/* MAIN */ /* MAIN */
$user_id = Security::remove_XSS($_REQUEST['student']); $user_id = intval($_REQUEST['student']);
$course_code = Security::remove_XSS($_REQUEST['course']); $course_code = Security::remove_XSS($_REQUEST['course']);
$session_id = intval($_GET['id_session']);
$connections = MySpace::get_connections_to_course($user_id, $course_code, $session_id);
$connections = MySpace::get_connections_to_course($user_id, $course_code);
if (api_is_xml_http_request()) { if (api_is_xml_http_request()) {
$type = Security::remove_XSS($_GET['type']); $type = Security::remove_XSS($_GET['type']);
$main_year = $main_month_year = $main_day = array(); $main_year = $main_month_year = $main_day = array();

@ -74,6 +74,28 @@ function rsort_users($a, $b) {
return api_strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']]))); return api_strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
} }
function count_sessions_coached() {
global $nb_sessions;
return $nb_sessions;
}
function sort_sessions($a, $b) {
global $tracking_column;
if ($a[$tracking_column] > $b[$tracking_column]) {
return 1;
} else {
return -1;
}
}
function rsort_sessions($a, $b) {
global $tracking_column;
if ($b[$tracking_column] > $a[$tracking_column]) {
return 1;
} else {
return -1;
}
}
/************************** /**************************
* MAIN CODE * MAIN CODE
@ -81,47 +103,47 @@ function rsort_users($a, $b) {
$is_coach = api_is_coach(); $is_coach = api_is_coach();
$is_platform_admin = api_is_platform_admin(); $is_platform_admin = api_is_platform_admin();
$is_drh = api_is_drh();
$view = isset($_GET['view']) ? $_GET['view'] : 'teacher'; // get views
$views = array('admin', 'teacher', 'coach', 'drh');
$view = 'teacher';
if (isset($_GET['view']) && in_array($_GET['view'], $views)) {
$view = $_GET['view'];
}
$menu_items = array(); $menu_items = array();
$nb_teacher_courses = 0;
global $_configuration; global $_configuration;
// interbreadcrumbs
if (api_is_allowed_to_create_course()) { if (api_is_allowed_to_create_course()) {
$sql_nb_cours = "SELECT course_rel_user.course_code, course.title
FROM $tbl_course_user as course_rel_user
INNER JOIN $tbl_course as course
ON course.code = course_rel_user.course_code
WHERE course_rel_user.user_id='".$_user['user_id']."' AND course_rel_user.status='1'
ORDER BY course.title";
if ($_configuration['multiple_access_urls'] == true) { $session_id = intval($_GET['session_id']);
$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); if (!empty($session_id)) {
$access_url_id = api_get_current_access_url_id(); $courses = Tracking::get_courses_followed_by_coach($_user['user_id'], $session_id);
if ($access_url_id != -1) { } else {
$sql_nb_cours = " SELECT course_rel_user.course_code, course.title $courses = CourseManager::get_course_list_of_user_as_course_admin($_user['user_id']);
FROM $tbl_course_user as course_rel_user
INNER JOIN $tbl_course as course
ON course.code = course_rel_user.course_code
INNER JOIN $tbl_course_rel_access_url course_rel_url
ON (course_rel_url.course_code= course.code)
WHERE access_url_id = $access_url_id AND course_rel_user.user_id='".$_user['user_id']."' AND course_rel_user.status='1'
ORDER BY course.title";
}
} }
$result_nb_cours = Database::query($sql_nb_cours);
$courses = Database::store_result($result_nb_cours);
$nb_teacher_courses = count($courses); $nb_teacher_courses = count($courses);
$sessions = Tracking::get_sessions_coached_by_user($_user['user_id']);
$nb_sessions = count($sessions);
if ($nb_teacher_courses) { if ($nb_teacher_courses) {
if (!$is_coach && !$is_platform_admin) { if (!$is_coach && !$is_platform_admin) {
$view = 'teacher'; $view = 'teacher';
} }
if ($view == 'teacher') {
if ($view == 'teacher' && empty($session_id)) {
$menu_items[] = get_lang('TeacherInterface'); $menu_items[] = get_lang('TeacherInterface');
$title = get_lang('YourCourseList'); $title = get_lang('YourCourseList');
} else { } else {
if (!empty($session_id)) {
$session_name = api_get_session_name($session_id);
$title = ucfirst($session_name);
}
$menu_items[] = '<a href="'.api_get_self().'?view=teacher">'.get_lang('TeacherInterface').'</a>'; $menu_items[] = '<a href="'.api_get_self().'?view=teacher">'.get_lang('TeacherInterface').'</a>';
} }
} }
@ -140,7 +162,7 @@ if ($is_coach) {
} }
if ($is_platform_admin) { if ($is_platform_admin) {
if (!$is_coach && $nb_teacher_courses == 0) { if ((!$is_coach || !$is_drh) && $nb_teacher_courses == 0) {
$view = 'admin'; $view = 'admin';
} }
if ($view == 'admin') { if ($view == 'admin') {
@ -151,14 +173,15 @@ if ($is_platform_admin) {
} }
} }
if (api_is_drh()) { if ($is_drh) {
$view = 'drh_students'; $view = 'drh';
$menu_items[] = get_lang('Students'); $menu_items[] = get_lang('Students');
$menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>'; $menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>';
$menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>'; $menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>';
$menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>'; $menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>';
} }
// actions menu
echo '<div class="actions-title" style ="font-size:10pt;">'; echo '<div class="actions-title" style ="font-size:10pt;">';
$nb_menu_items = count($menu_items); $nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) { if ($nb_menu_items > 1) {
@ -179,7 +202,7 @@ if ($view == 'admin') {
echo '</div>'; echo '</div>';
echo '<h4>'.$title.'</h4>'; echo '<h4>'.$title.'</h4>';
if (api_is_drh() && $view == 'drh_students') { if ($is_drh && $view == 'drh') {
// get data for human resources manager // get data for human resources manager
$students = array_keys(UserManager::get_users_followed_by_drh($_user['user_id'], STUDENT)); $students = array_keys(UserManager::get_users_followed_by_drh($_user['user_id'], STUDENT));
$courses_of_the_platform = CourseManager :: get_real_course_list(); $courses_of_the_platform = CourseManager :: get_real_course_list();
@ -193,7 +216,7 @@ if ($is_coach && $view == 'coach') {
$courses = Tracking :: get_courses_followed_by_coach($_user['user_id']); $courses = Tracking :: get_courses_followed_by_coach($_user['user_id']);
} }
if ($view == 'coach' || $view == 'drh_students') { if ($view == 'coach' || $view == 'drh') {
$nb_students = count($students); $nb_students = count($students);
$total_time_spent = 0; $total_time_spent = 0;
@ -205,15 +228,8 @@ if ($view == 'coach' || $view == 'drh_students') {
foreach ($students as $student_id) { foreach ($students as $student_id) {
// inactive students // inactive students
$last_connection_date = Tracking :: get_last_connection_date($student_id, true, true); $last_connection_date = Tracking :: get_last_connection_date($student_id, true, true);
if ($last_connection_date != false) { if ($last_connection_date !== false) {
/* if (time() - (3600 * 24 * 7) > $last_connection_date) {
list($last_connection_date, $last_connection_hour) = explode(' ', $last_connection_date);
$last_connection_date = explode('-', $last_connection_date);
$last_connection_hour = explode(':', $last_connection_hour);
$last_connection_hour[0];
$last_connection_time = mktime($last_connection_hour[0], $last_connection_hour[1], $last_connection_hour[2], $last_connection_date[1], $last_connection_date[2], $last_connection_date[0]);
*/
if (time() - (3600 * 24 * 7) > $last_connection_time) {
$nb_inactive_students++; $nb_inactive_students++;
} }
} else { } else {
@ -480,6 +496,57 @@ if (api_is_allowed_to_create_course() && $view == 'teacher') {
); );
$table->display(); $table->display();
} }
// display sessions
if ($nb_sessions > 0 && !isset($_GET['session_id'])) {
echo '<h4>'.get_lang('Sessions').'</h4>';
$table = new SortableTable('tracking_sessions', 'count_sessions_coached');
$table->set_header(0, get_lang('Title'));
$table->set_header(1, get_lang('Date'));
$table->set_header(2, get_lang('NbCoursesPerSession'));
$table->set_header(3, get_lang('Details'), false);
$all_data = array();
foreach ($sessions as $session) {
$count_courses_in_session = count(Tracking::get_courses_followed_by_coach($_user['user_id'], $session['id']));
$row = array();
$row[] = $session['name'];
if ($session['date_start'] != '0000-00-00' && $session['date_end'] != '0000-00-00') {
$row[] = get_lang('From').' '.format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($session['date_start'])).' '.get_lang('To').' '.format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($session['date_end']));
} else {
$row[] = ' - ';
}
$row[] = $count_courses_in_session;
$row[] = '<a href="'.api_get_self().'?session_id='.$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(1, array('align' => 'center'));
$table -> setColAttributes(2, array('align' => 'center'));
$table -> setColAttributes(3, array('align' => 'center'));
$table -> display();
}
} }
if ($is_platform_admin && $view == 'admin') { if ($is_platform_admin && $view == 'admin') {

@ -17,7 +17,13 @@ require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php'; require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php'; require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
require_once api_get_path(SYS_CODE_PATH).'mySpace/myspace.lib.php'; require_once api_get_path(SYS_CODE_PATH).'mySpace/myspace.lib.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/linkfactory.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php';
require_once api_get_path(LIBRARY_PATH).'attendance.lib.php'; require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
$htmlHeadXtra[] = '<script type="text/javascript"> $htmlHeadXtra[] = '<script type="text/javascript">
@ -45,7 +51,6 @@ if (isset ($_GET['from']) && $_GET['from'] == 'myspace') {
} }
$nameTools = get_lang("StudentDetails"); $nameTools = get_lang("StudentDetails");
//$nameTools = SECTION_PLATFORM_ADMIN;
$cidReset = true; $cidReset = true;
$get_course_code = Security :: remove_XSS($_GET['course']); $get_course_code = Security :: remove_XSS($_GET['course']);
if (isset ($_GET['details'])) { if (isset ($_GET['details'])) {
@ -160,25 +165,6 @@ if (!api_is_allowed_to_edit() && !api_is_coach() && !api_is_drh() && $_user['sta
Display :: display_header($nameTools); Display :: display_header($nameTools);
/*
* ======================================================================================
* FUNCTIONS
* ======================================================================================
*/
/* Possible Deprecated
function is_teacher($course_code) {
global $_user;
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$sql = "SELECT 1 FROM $tbl_course_user WHERE user_id='" . $_user["user_id"] . "' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." AND course_code='" . Database :: escape_string($course_code) . "' AND status='1'";
$result = Database::query($sql);
if (Database :: result($result) != 1) {
return true;
} else {
return false;
}
}
*/
/* /*
*=============================================================================== *===============================================================================
* MAIN CODE * MAIN CODE
@ -194,9 +180,6 @@ $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_exercices_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); $tbl_stats_exercices_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
//$tbl_course_lp_view = Database :: get_course_table(TABLE_LP_VIEW);
//$tbl_course_lp_view_item = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
//$tbl_course_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
$tbl_course_lp_view = 'lp_view'; $tbl_course_lp_view = 'lp_view';
$tbl_course_lp_view_item = 'lp_item_view'; $tbl_course_lp_view_item = 'lp_item_view';
@ -208,12 +191,13 @@ $course_quiz_rel_question = 'quiz_rel_question';
$course_quiz_answer = 'quiz_answer'; $course_quiz_answer = 'quiz_answer';
$course_student_publication = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); $course_student_publication = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
if (isset ($_GET["user_id"]) && $_GET["user_id"] != "") { if (isset($_GET['user_id']) && $_GET['user_id'] != "") {
$user_id = intval($_GET['user_id']); $user_id = intval($_GET['user_id']);
} else { } else {
$user_id = $_user['user_id']; $user_id = $_user['user_id'];
} }
$session_id = intval($_GET['id_session']);
if (!empty ($_GET['student'])) { if (!empty ($_GET['student'])) {
$student_id = intval($_GET['student']); $student_id = intval($_GET['student']);
@ -237,7 +221,7 @@ if (!empty ($_GET['student'])) {
} }
echo $send_mail; echo $send_mail;
if (!empty ($_GET['student']) && !empty ($_GET['course'])) { //only show link to connection details if course and student were defined in the URL if (!empty ($_GET['student']) && !empty ($_GET['course'])) { //only show link to connection details if course and student were defined in the URL
echo '<a href="access_details.php?student=' . Security :: remove_XSS($_GET['student']) . '&course=' . Security :: remove_XSS($_GET['course']) . '&amp;origin=' . Security :: remove_XSS($_GET['origin']) . '&amp;cidReq=' . Security :: remove_XSS($_GET['course']) . '">' . Display :: return_icon('statistics.gif', get_lang('AccessDetails')) . ' ' . get_lang('AccessDetails') . '</a>'; echo '<a href="access_details.php?student=' . Security :: remove_XSS($_GET['student']) . '&course=' . Security :: remove_XSS($_GET['course']) . '&amp;origin=' . Security :: remove_XSS($_GET['origin']) . '&amp;cidReq='.Security::remove_XSS($_GET['course']).'&amp;id_session='.$session_id.'">' . Display :: return_icon('statistics.gif', get_lang('AccessDetails')) . ' ' . get_lang('AccessDetails') . '</a>';
} }
echo '</div>'; echo '</div>';
@ -253,34 +237,24 @@ if (!empty ($_GET['student'])) {
} }
} }
// get average of score and average of progress by student
$avg_student_progress = $avg_student_score = $nb_courses = 0; $avg_student_progress = $avg_student_score = $nb_courses = 0;
$sql = 'SELECT course_code FROM ' . $tbl_course_user . ' WHERE relation_type<>'.COURSE_RELATION_TYPE_RRHH.' AND user_id=' . Database :: escape_string($info_user['user_id']);
$rs = Database::query($sql);
$courses = array ();
while ($row = Database :: fetch_array($rs)) {
$courses[$row['course_code']] = $row['course_code'];
}
// get the list of sessions where the user is subscribed as student
$sql = 'SELECT DISTINCT course_code FROM ' . Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . ' WHERE id_user=' . intval($info_user['user_id']);
$rs = Database::query($sql);
while ($row = Database :: fetch_array($rs)) {
$courses[$row['course_code']] = $row['course_code'];
}
$course_id = Security :: remove_XSS($_GET['course']); $course_id = Security :: remove_XSS($_GET['course']);
if (!CourseManager :: is_user_subscribed_in_course($info_user['user_id'], $course_id, true)) { if (!CourseManager :: is_user_subscribed_in_course($info_user['user_id'], $course_id, true)) {
unset ($courses[$key]); unset ($courses[$key]);
} else { } else {
$nb_courses++; $nb_courses++;
$avg_student_progress = Tracking :: get_avg_student_progress($info_user['user_id'], $course_id); $avg_student_progress = Tracking::get_avg_student_progress($info_user['user_id'], $course_id, array(), $session_id);
//the score inside the Reporting table //the score inside the Reporting table
$avg_student_score = Tracking :: get_average_test_scorm_and_lp($info_user['user_id'], $course_id); $avg_student_score = Tracking::get_avg_student_score($info_user['user_id'], $course_id, array(), $session_id);
} }
$avg_student_progress = round($avg_student_progress, 2); $avg_student_progress = round($avg_student_progress, 2);
$avg_student_score = round($avg_student_score, 2); $avg_student_score = round($avg_student_score, 2);
// time spent on the course
$time_spent_on_the_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($info_user['user_id'], $course_id, $session_id));
// get information about connections on the platform by student
$first_connection_date = Tracking :: get_first_connection_date($info_user['user_id']); $first_connection_date = Tracking :: get_first_connection_date($info_user['user_id']);
if ($first_connection_date == '') { if ($first_connection_date == '') {
$first_connection_date = get_lang('NoConnexion'); $first_connection_date = get_lang('NoConnexion');
@ -291,7 +265,6 @@ if (!empty ($_GET['student'])) {
$last_connection_date = get_lang('NoConnexion'); $last_connection_date = get_lang('NoConnexion');
} }
$time_spent_on_the_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($info_user['user_id'], $course_id));
// cvs informations // cvs informations
$csv_content[] = array ( $csv_content[] = array (
get_lang('Informations', '') get_lang('Informations', '')
@ -356,14 +329,11 @@ if (!empty ($_GET['student'])) {
<td width="40%" valign="top"> <td width="40%" valign="top">
<table width="100%" class="data_table"> <table width="100%" class="data_table">
<tr> <tr>
<th> <th><?php echo get_lang('Information'); ?></th>
<?php echo get_lang('Information'); ?>
</th>
</tr> </tr>
<tr> <tr>
<td> <td>
<?php <?php
echo get_lang('Name') . ' : '; echo get_lang('Name') . ' : ';
echo $info_user['name']; echo $info_user['name'];
?> ?>
@ -372,7 +342,6 @@ if (!empty ($_GET['student'])) {
<tr> <tr>
<td> <td>
<?php <?php
echo get_lang('Email') . ' : '; echo get_lang('Email') . ' : ';
if (!empty ($info_user['email'])) { if (!empty ($info_user['email'])) {
echo '<a href="mailto:' . $info_user['email'] . '">' . $info_user['email'] . '</a>'; echo '<a href="mailto:' . $info_user['email'] . '">' . $info_user['email'] . '</a>';
@ -385,9 +354,7 @@ if (!empty ($_GET['student'])) {
<tr> <tr>
<td> <td>
<?php <?php
echo get_lang('Tel') . ' : '; echo get_lang('Tel') . ' : ';
if (!empty ($info_user['phone'])) { if (!empty ($info_user['phone'])) {
echo $info_user['phone']; echo $info_user['phone'];
} else { } else {
@ -399,9 +366,7 @@ if (!empty ($_GET['student'])) {
<tr> <tr>
<td> <td>
<?php <?php
echo get_lang('OfficialCode') . ' : '; echo get_lang('OfficialCode') . ' : ';
if (!empty ($info_user['official_code'])) { if (!empty ($info_user['official_code'])) {
echo $info_user['official_code']; echo $info_user['official_code'];
} else { } else {
@ -413,7 +378,6 @@ if (!empty ($_GET['student'])) {
<tr> <tr>
<td> <td>
<?php <?php
echo get_lang('OnLine') . ' : '; echo get_lang('OnLine') . ' : ';
echo $online; echo $online;
?> ?>
@ -443,162 +407,84 @@ if ($timezone !== null) {
</table> </table>
</td> </td>
<td class="borderLeft" width="35%" valign="top"> <td class="borderLeft" width="35%" valign="top">
<table width="100%" class="data_table"> <table width="100%" class="data_table">
<tr> <tr>
<th colspan="2"> <th colspan="2"><?php echo get_lang('Tracking'); ?></th>
<?php echo get_lang('Tracking'); ?>
</th>
</tr> </tr>
<tr> <tr><td align="right"><?php echo get_lang('FirstLogin') ?></td>
<td align="right"> <td align="left"><?php echo $first_connection_date ?></td>
<?php echo get_lang('FirstLogin') ?>
</td>
<td align="left">
<?php echo $first_connection_date ?>
</td>
</tr> </tr>
<tr> <tr>
<td align="right"> <td align="right"><?php echo get_lang('LatestLogin') ?></td>
<?php echo get_lang('LatestLogin') ?> <td align="left"><?php echo $last_connection_date ?></td>
</td>
<td align="left">
<?php echo $last_connection_date ?>
</td>
</tr> </tr>
<?php if (isset($_GET['details']) && $_GET['details'] == 'true') {?>
<tr> <tr>
<td align="right"> <td align="right"><?php echo get_lang('TimeSpentInTheCourse') ?></td>
<?php echo get_lang('TimeSpentInTheCourse') ?> <td align="left"><?php echo $time_spent_on_the_course ?></td>
</td>
<td align="left">
<?php echo $time_spent_on_the_course ?>
</td>
</tr> </tr>
<tr> <tr>
<td align="right"> <td align="right">
<?php <?php
echo get_lang('Progress'); echo get_lang('Progress');
Display :: display_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), array ( Display :: display_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px'));
'align' => 'absmiddle',
'hspace' => '3px'
));
?> ?>
</td> </td>
<td align="left"> <td align="left"><?php echo $avg_student_progress.'%' ?></td>
<?php echo $avg_student_progress.'%' ?>
</td>
</tr> </tr>
<tr> <tr>
<td align="right"> <td align="right">
<?php <?php
echo get_lang('Score'); echo get_lang('Score');
Display :: display_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ( Display :: display_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px'));
'align' => 'absmiddle',
'hspace' => '3px'
));
?> ?>
</td> </td>
<td align="left"> <td align="left"><?php echo $avg_student_score.'%' ?></td>
<?php echo $avg_student_score.'%' ?>
</td>
</tr> </tr>
<?php } ?>
</table> </table>
</td> </td>
</tr> </tr>
</table> </table>
<?php
if (!empty ($_GET['details'])) { ?>
<table class="data_table"> <table class="data_table">
<tr> <tr>
<td colspan="5" style="border-width: 0px;">&nbsp;</td> <td colspan="5" style="border-width: 0px;">&nbsp;</td>
</tr> </tr>
<?php
if (!empty ($_GET['details'])) {
$course_code_info = Security :: remove_XSS($_GET['course']);
$info_course = CourseManager :: get_course_information($course_code_info);
<?php
$course_code = $_GET['course'];
$info_course = CourseManager :: get_course_information($course_code);
$coachs_name = '';
$session_name = '';
$nb_login = Tracking :: count_login_per_student($info_user['user_id'], $_GET['course']);
//get coach and session_name if there is one and if session_mode is activated //get coach and session_name if there is one and if session_mode is activated
if (api_get_setting('use_session_mode') == 'true') { if (api_get_setting('use_session_mode') == 'true' && $session_id > 0) {
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$sql = 'SELECT id_session
FROM ' . $tbl_session_course_user . ' session_course_user
WHERE session_course_user.id_user = ' . intval($info_user['user_id']) . '
AND session_course_user.course_code = "' . Database :: escape_string($course_code_info) . '"
ORDER BY id_session DESC';
$rs = Database::query($sql);
$num_row = Database :: num_rows($rs);
if ($num_row > 0) {
$le_session_id = intval(Database :: result($rs, 0, 0));
if ($le_session_id > 0) {
// get session name and coach of the session
$sql = 'SELECT name, id_coach FROM ' . $tbl_session . '
WHERE id=' . $le_session_id;
$rs = Database::query($sql);
$session_name = Database :: result($rs, 0, 'name');
$session_coach_id = intval(Database :: result($rs, 0, 'id_coach'));
// get coach of the course in the session
$sql = 'SELECT id_user FROM ' . $tbl_session_course_user . '
WHERE id_session=' . $le_session_id . '
AND course_code = "' . Database :: escape_string($_GET['course']) . '" AND status=2';
/*
$sql = 'SELECT id_coach FROM ' . $tbl_session_course . '
WHERE id_session=' . $le_session_id . '
AND course_code = "' . Database :: escape_string($_GET['course']) . '"';
*/
$rs = Database::query($sql);
//$session_course_coach_id = intval(Database :: result($rs, 0, 0));
$course_coachs = array();
while ($row_coachs = Database::fetch_array($rs)) {
$course_coachs[] = $row_coachs['id_user'];
}
$session_info = api_get_session_info($session_id);
$course_coachs = api_get_coachs_from_course($session_id,$course_code);
$nb_login = '';
if (!empty($course_coachs)) { if (!empty($course_coachs)) {
$info_tutor_name = array(); $info_tutor_name = array();
foreach ($course_coachs as $course_coach) { foreach ($course_coachs as $course_coach) {
$coach_infos = UserManager :: get_user_info_by_id($course_coach); $info_tutor_name[] = api_get_person_name($course_coach['firstname'], $course_coach['lastname']);
$info_tutor_name[] = api_get_person_name($coach_infos['firstname'], $coach_infos['lastname']);
} }
$info_course['tutor_name'] = implode(",",$info_tutor_name); $info_course['tutor_name'] = implode(",",$info_tutor_name);
} elseif ($session_coach_id != 0) {
$session_coach_id = intval($session_info['id_coach']);
$coach_info = UserManager::get_user_info_by_id($session_coach_id);
$info_course['tutor_name'] = api_get_person_name($coach_info['firstname'], $coach_info['lastname']);
} }
$coachs_name = $info_course['tutor_name'];
/*if ($session_course_coach_id != 0) { $session_name = $session_info['name'];
$coach_infos = UserManager :: get_user_info_by_id($session_course_coach_id);
$info_course['tutor_name'] = api_get_person_name($coach_infos['firstname'], $coach_infos['lastname']);
}*/
elseif ($session_coach_id != 0) {
$coach_infos = UserManager :: get_user_info_by_id($session_coach_id);
$info_course['tutor_name'] = api_get_person_name($coach_infos['firstname'], $coach_infos['lastname']);
}
}
}
} // end if(api_get_setting('use_session_mode')=='true') } // end if(api_get_setting('use_session_mode')=='true')
$date_start = ''; $table_title = $info_course['title'].($nb_login?'&nbsp;|&nbsp;'.get_lang('CountToolAccess').' : '.$nb_login:'').($session_name?'&nbsp;|&nbsp;'.get_lang('Session').' : '.ucfirst($session_name):'').($coachs_name?'&nbsp;|&nbsp;'.get_lang('Tutor').' : '.stripslashes($coachs_name):'');
if (!empty ($info_course['date_start'])) {
$date_start = explode('-', $info_course['date_start']);
$date_start = $date_start[2] . '/' . $date_start[1] . '/' . $date_start[0];
}
$date_end = '';
if (!empty ($info_course['date_end'])) {
$date_end = explode('-', $info_course['date_end']);
$date_end = $date_end[2] . '/' . $date_end[1] . '/' . $date_end[0];
}
$dateSession = get_lang('From') . ' ' . $date_start . ' ' . get_lang('To') . ' ' . $date_end;
$nb_login = Tracking :: count_login_per_student($info_user['user_id'], $_GET['course']);
$table_title = $info_course['title'] . '&nbsp;|&nbsp;' . get_lang('CountToolAccess') . ' : ' . $nb_login . '&nbsp; | &nbsp;' . get_lang('Tutor') . ' : ' . stripslashes($info_course['tutor_name']) . ((!empty ($session_name)) ? ' | ' . get_lang('Session') . ' : ' . $session_name : '');
$csv_content[] = array (); $csv_content[] = array ();
$csv_content[] = array (str_replace('&nbsp;', '', $table_title)); $csv_content[] = array (str_replace('&nbsp;', '', $table_title));
@ -670,19 +556,10 @@ if ($timezone !== null) {
); );
$t_lp = Database :: get_course_table(TABLE_LP_MAIN, $info_course['db_name']); $t_lp = Database :: get_course_table(TABLE_LP_MAIN, $info_course['db_name']);
$t_lpi = Database :: get_course_table(TABLE_LP_ITEM, $info_course['db_name']);
$t_lpv = Database :: get_course_table(TABLE_LP_VIEW, $info_course['db_name']);
$t_lpiv = Database :: get_course_table(TABLE_LP_ITEM_VIEW, $info_course['db_name']);
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$tbl_quiz_questions = Database :: get_course_table(TABLE_QUIZ_QUESTION, $info_course['db_name']); $tbl_quiz_questions = Database :: get_course_table(TABLE_QUIZ_QUESTION, $info_course['db_name']);
$sql_learnpath = " SELECT lp.name,lp.id // csv export headers
FROM $t_lp AS lp ORDER BY lp.name ASC";
$result_learnpath = Database::query($sql_learnpath);
$csv_content[] = array (); $csv_content[] = array ();
$csv_content[] = array ( $csv_content[] = array (
get_lang('Learnpath', ''), get_lang('Learnpath', ''),
@ -692,65 +569,42 @@ if ($timezone !== null) {
get_lang('LastConnexion', '') get_lang('LastConnexion', '')
); );
if (Database :: num_rows($result_learnpath) > 0) { $sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp WHERE lp.session_id = $session_id ORDER BY lp.name ASC";
$rs_lp = Database::query($sql_lp);
if (Database :: num_rows($rs_lp) > 0) {
$i = 0; $i = 0;
while ($learnpath = Database :: fetch_array($result_learnpath)) { while ($learnpath = Database :: fetch_array($rs_lp)) {
$lp_id = intval($learnpath['id']);
$lp_name = $learnpath['name'];
$any_result = false; $any_result = false;
$progress = learnpath :: get_db_progress($learnpath['id'], $student_id, '%', $info_course['db_name'], true);
if ($progress === null) {
$progress = '0%';
} else {
$any_result = true;
}
// calculates time // Get progress in lp
$sql = 'SELECT SUM(total_time) $progress = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id));
FROM ' . $t_lpiv . ' AS item_view
INNER JOIN ' . $t_lpv . ' AS view
ON item_view.lp_view_id = view.id
AND view.lp_id = ' . $learnpath['id'] . '
AND view.user_id = ' . intval($_GET['student']);
$rs = Database::query($sql);
$total_time = 0;
if (Database :: num_rows($rs) > 0) {
$total_time = Database :: result($rs, 0, 0);
if ($total_time > 0)
$any_result = true;
}
// calculates last connection time
$sql = 'SELECT MAX(start_time)
FROM ' . $t_lpiv . ' AS item_view
INNER JOIN ' . $t_lpv . ' AS view
ON item_view.lp_view_id = view.id
AND view.lp_id = ' . $learnpath['id'] . '
AND view.user_id = ' . intval($_GET['student']);
$rs = Database::query($sql);
$start_time = null;
if (Database :: num_rows($rs) > 0) {
$start_time = Database :: result($rs, 0, 0);
if ($start_time > 0)
$any_result = true;
}
//QUIZZ IN LP if ($progress === null) $progress = '0%';
$score = Tracking :: get_avg_student_score(intval($_GET['student']), Database :: escape_string($_GET['course']), array ( else $any_result = true;
$learnpath['id']
));
if (empty ($score)) { // Get time in lp
//$score = 0; $total_time = Tracking::get_time_spent_in_lp($student_id, $course_code, array($lp_id));
} if (!empty($total_time)) $any_result = true;
if ($i % 2 == 0) {
$css_class = "row_odd"; // Get last connection time in lp
} else { $start_time = Tracking::get_last_connection_time_in_lp($student_id, $course_code, $lp_id);
$css_class = "row_even"; if (!empty($total_time)) $any_result = true;
}
// Quizz in lp
$score = Tracking :: get_avg_student_score($student_id, $course_code, array($lp_id));
if ($i % 2 == 0) $css_class = "row_odd";
else $css_class = "row_even";
$i++; $i++;
// csv export content
$csv_content[] = array ( $csv_content[] = array (
api_html_entity_decode(stripslashes($learnpath['name']), ENT_QUOTES, $charset), api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset),
api_time_to_hms($total_time), api_time_to_hms($total_time),
$score . '%', $score . '%',
$progress, $progress,
@ -759,7 +613,7 @@ if ($timezone !== null) {
?> ?>
<tr class="<?php echo $css_class;?>"> <tr class="<?php echo $css_class;?>">
<td> <td>
<?php echo stripslashes($learnpath['name']); ?> <?php echo stripslashes($lp_name); ?>
</td> </td>
<td align="center"> <td align="center">
<?php echo api_time_to_hms($total_time) ?> <?php echo api_time_to_hms($total_time) ?>
@ -800,7 +654,7 @@ if ($timezone !== null) {
$from ='&from=myspace'; $from ='&from=myspace';
} }
?> ?>
<a href="lp_tracking.php?course=<?php echo Security::remove_XSS($_GET['course']).$from; ?>&origin=<?php echo Security::remove_XSS($_GET['origin']) ?>&lp_id=<?php echo $learnpath['id']?>&student_id=<?php echo $info_user['user_id'] ?>"> <a href="lp_tracking.php?course=<?php echo Security::remove_XSS($_GET['course']).$from; ?>&origin=<?php echo Security::remove_XSS($_GET['origin']) ?>&lp_id=<?php echo $learnpath['id']?>&student_id=<?php echo $info_user['user_id'] ?>&session_id=<?php echo $session_id ?>">
<img src="../img/2rightarrow.gif" border="0" /> <img src="../img/2rightarrow.gif" border="0" />
</a> </a>
<?php <?php
@ -809,17 +663,12 @@ if ($timezone !== null) {
</td> </td>
</tr> </tr>
<?php <?php
$data_learnpath[$i][] = $learnpath['name']; $data_learnpath[$i][] = $lp_name;
$data_learnpath[$i][] = $progress . '%'; $data_learnpath[$i][] = $progress . '%';
$i++; $i++;
} }
} else { } else {
echo " <tr> echo '<tr><td colspan="6">'.get_lang('NoLearnpath').'</td></tr>';
<td colspan='6'>
" . get_lang('NoLearnpath') . "
</td>
</tr>
";
} }
?> ?>
</table> </table>
@ -827,18 +676,10 @@ if ($timezone !== null) {
<!-- line about exercises --> <!-- line about exercises -->
<table class="data_table"> <table class="data_table">
<tr> <tr>
<th> <th><?php echo get_lang('Exercices'); ?></th>
<?php echo get_lang('Exercices'); ?> <th><?php echo get_lang('Score').Display :: return_icon('info3.gif', get_lang('LastScoreTest'), array('align' => 'absmiddle', 'hspace' => '3px')) ?></th>
</th> <th><?php echo get_lang('Attempts'); ?></th>
<th> <th><?php echo get_lang('CorrectTest'); ?></th>
<?php echo get_lang('Score').Display :: return_icon('info3.gif', get_lang('LastScoreTest'), array('align' => 'absmiddle', 'hspace' => '3px')) ?>
</th>
<th>
<?php echo get_lang('Attempts'); ?>
</th>
<th>
<?php echo get_lang('CorrectTest'); ?>
</th>
</tr> </tr>
<?php <?php
@ -849,10 +690,8 @@ if ($timezone !== null) {
get_lang('Attempts') get_lang('Attempts')
); );
$info_course = CourseManager :: get_course_information(Security :: remove_XSS($_GET['course']));
$t_tool = Database :: get_course_table(TABLE_TOOL_LIST, $info_course['db_name']); $t_tool = Database :: get_course_table(TABLE_TOOL_LIST, $info_course['db_name']);
$sql = 'SELECT visibility FROM ' . $t_tool . ' WHERE name="quiz"'; $sql = 'SELECT visibility FROM ' . $t_tool . ' WHERE name="quiz"';
$result_visibility_quizz = Database::query($sql); $result_visibility_quizz = Database::query($sql);
$t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST, $info_course['db_name']); $t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST, $info_course['db_name']);
@ -860,120 +699,60 @@ if ($timezone !== null) {
$sql_exercices = "SELECT quiz.title,id $sql_exercices = "SELECT quiz.title,id
FROM " . $t_quiz . " AS quiz FROM " . $t_quiz . " AS quiz
WHERE active='1' ORDER BY quiz.title ASC WHERE active='1' AND quiz.session_id = $session_id ORDER BY quiz.title ASC
"; ";
$result_exercices = Database::query($sql_exercices); $result_exercices = Database::query($sql_exercices);
$i = 0; $i = 0;
$is_student = Security :: remove_XSS($_GET['student']);
if (Database :: num_rows($result_exercices) > 0) { if (Database :: num_rows($result_exercices) > 0) {
while ($exercices = Database :: fetch_array($result_exercices)) { while ($exercices = Database :: fetch_array($result_exercices)) {
$sql_essais = "SELECT COUNT(ex.exe_id) as essais $exercise_id = intval($exercices['id']);
FROM $tbl_stats_exercices AS ex $count_attempts = Tracking::count_student_exercise_attempts($student_id, $course_code, $exercise_id);
WHERE ex.exe_cours_id = '" . $info_course['code'] . "' $score_percentage = Tracking::get_avg_student_exercise_score($student_id, $course_code, $exercise_id);
AND ex.exe_exo_id = " . $exercices['id'] . "
AND orig_lp_id = 0
AND orig_lp_item_id = 0
AND exe_user_id='" . Database :: escape_string($is_student) . "'";
$result_essais = Database::query($sql_essais);
$essais = Database :: fetch_array($result_essais);
$sql_score = "SELECT exe_id, exe_result,exe_weighting
FROM $tbl_stats_exercices
WHERE exe_user_id = " . Database :: escape_string($is_student) . "
AND exe_cours_id = '" . $info_course['code'] . "'
AND exe_exo_id = " . $exercices['id'] . "
AND orig_lp_id = 0
AND orig_lp_item_id = 0
ORDER BY exe_date DESC LIMIT 1";
$result_score = Database::query($sql_score);
$score = 0;
while ($scores = Database :: fetch_array($result_score)) {
$score = $score + $scores['exe_result'];
$weighting = $weighting + $scores['exe_weighting'];
$exe_id = $scores['exe_id'];
}
$score_percentage = 0;
if ($weighting != 0) {
//i.e 10.50
$score_percentage = round(($score * 100) / $weighting, 2);
} else {
$score_percentage = null;
}
$weighting = 0;
$csv_content[] = array ( $csv_content[] = array (
$exercices['title'], $exercices['title'],
$score_percentage . '%', $score_percentage . '%',
$essais['essais'] $count_attempts
); );
if ($i % 2 == 0) { if ($i % 2 == 0) $css_class = 'row_odd';
$css_class = "row_odd"; else $css_class = 'row_even';
} else {
$css_class = "row_even";
}
$i++; echo '<tr class="'.$css_class.'"><td>'.$exercices['title'].'</td>';
echo '<tr class="' . $css_class . '"> echo '<td align="center">';
<td>
'; if ($count_attempts > 0) {
echo $exercices['title'];
echo " </td>
";
echo " <td align='center'>
";
if ($essais['essais'] > 0) {
echo $score_percentage . '%'; echo $score_percentage . '%';
} else { } else {
echo '/'; echo '/';
$score_percentage = 0; $score_percentage = 0;
} }
echo " </td> echo '</td>';
<td align='center'> echo '<td align="center">'.$count_attempts.'</td>';
"; echo '<td align="center">';
echo $essais['essais'];
echo " </td>
<td align='center'>
";
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $exercices['id'] . '" AND exe_user_id="' . Security :: remove_XSS($_GET['student']) . '" AND exe_cours_id="' . $info_course['code'] . '" AND orig_lp_id = 0 AND orig_lp_item_id = 0 ORDER BY exe_date DESC LIMIT 1'; $sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="'.$exercise_id.'" AND exe_user_id="'.$student_id.'" AND exe_cours_id="'.$course_code.'" AND orig_lp_id = 0 AND orig_lp_item_id = 0 ORDER BY exe_date DESC LIMIT 1';
$result_last_attempt = Database::query($sql_last_attempt); $result_last_attempt = Database::query($sql_last_attempt);
if (Database :: num_rows($result_last_attempt) > 0) { if (Database :: num_rows($result_last_attempt) > 0) {
$id_last_attempt = Database :: result($result_last_attempt, 0, 0); $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
if ($count_attempts > 0)
if ($essais['essais'] > 0) echo '<a href="../exercice/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&student='.$student_id.'&origin='.(empty($_GET['origin'])?'tracking':Security::remove_XSS($_GET['origin'])).'"> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" border="0" /> </a>';
echo '<a href="../exercice/exercise_show.php?id=' . $id_last_attempt . '&cidReq=' . $info_course['code'] . '&student=' . Security :: remove_XSS($_GET['student']) . '&origin=' . (empty ($_GET['origin']) ? 'tracking' : Security :: remove_XSS($_GET['origin'])) . '"> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" border="0" /> </a>';
} }
echo " </td> echo '</td></tr>';
</tr>
";
$data_exercices[$i][] = $exercices['title']; $data_exercices[$i][] = $exercices['title'];
$data_exercices[$i][] = $score_percentage . '%'; $data_exercices[$i][] = $score_percentage . '%';
$data_exercices[$i][] = $essais['essais']; $data_exercices[$i][] = $count_attempts;
//$data_exercices[$i][] = corrections;
$i++; $i++;
} }
} else { } else {
echo " <tr> echo '<tr><td colspan="6">'.get_lang('NoExercise').'</td></tr>';
<td colspan='6'>
" . get_lang('NoExercise') . "
</td>
</tr>
";
} }
} else { } else {
echo " <tr> echo '<tr><td colspan="6">'.get_lang('NoExercise').'</td></tr>';
<td colspan='6'>
" . get_lang('NoExercise') . "
</td>
</tr>
";
} }
?> ?>
</table> </table>
@ -985,12 +764,11 @@ if ($timezone !== null) {
<?php <?php
$csv_content[] = array (); $csv_content[] = array ();
$nb_assignments = Tracking::count_student_assignments($student_id, $course_code, $session_id);
$nb_assignments = Tracking :: count_student_assignments($info_user['user_id'], $info_course['code']); $messages = Tracking::count_student_messages($student_id, $course_code, $session_id);
$messages = Tracking :: count_student_messages($info_user['user_id'], $info_course['code']); $links = Tracking::count_student_visited_links($student_id, $course_code, $session_id);
$links = Tracking :: count_student_visited_links($info_user['user_id'], $info_course['code']); $chat_last_connection = Tracking::chat_last_connection($student_id, $course_code, $session_id);
$documents = Tracking :: count_student_downloaded_documents($info_user['user_id'], $info_course['code']); $documents = Tracking::count_student_downloaded_documents($student_id, $course_code, $session_id);
$chat_last_connection = Tracking :: chat_last_connection($info_user['user_id'], $info_course['code']);
$csv_content[] = array ( $csv_content[] = array (
get_lang('Student_publication'), get_lang('Student_publication'),
@ -1062,117 +840,193 @@ if ($timezone !== null) {
</td> </td>
</tr> </tr>
</table> </table>
</table>
<br />
<?php <?php
} else { } else {
?>
<tr>
<th>
<?php echo get_lang('Course'); ?>
</th>
<th>
<?php echo get_lang('Time'); ?>
</th>
<th>
<?php echo get_lang('AttendanceFaults'); ?>
</th>
<th>
<?php echo get_lang('Progress'); ?>
</th>
<th>
<?php echo get_lang('Score'); ?>
</th>
<th>
<?php echo get_lang('Details'); ?>
</th>
</tr>
<?php
$courses_in_session = array ();
if (!api_is_platform_admin(true) && $_user['status'] != DRH) { if (!api_is_platform_admin(true) && $_user['status'] != DRH) {
// courses followed by user where we are coach // courses followed by user where we are coach
if (!isset ($_GET['id_coach'])) { if (!isset ($_GET['id_coach'])) {
$courses = Tracking :: get_courses_followed_by_coach($_user['user_id']); $sessions_coached_by_user = Tracking::get_sessions_coached_by_user($_user['user_id']);
foreach ($sessions_coached_by_user as $session_coached_by_user) {
$sid = intval($session_coached_by_user['id']);
$courses_followed_by_coach = Tracking :: get_courses_followed_by_coach($_user['user_id'], $sid);
$courses_in_session[$sid] = $courses_followed_by_coach;
}
} else { } else {
$courses = Tracking :: get_courses_followed_by_coach(Security :: remove_XSS($_GET['id_coach'])); $sessions_coached_by_user = Tracking::get_sessions_coached_by_user(intval($_GET['id_coach']));
foreach ($sessions_coached_by_user as $session_coached_by_user) {
$sid = intval($session_coached_by_user['id']);
$courses_followed_by_coach = Tracking :: get_courses_followed_by_coach(intval($_GET['id_coach']), $sid);
$courses_in_session[$sid] = $courses_followed_by_coach;
}
}
} else {
$sql = 'SELECT course_code FROM ' . $tbl_course_user . ' WHERE relation_type<>'.COURSE_RELATION_TYPE_RRHH.' AND user_id=' . Database :: escape_string($info_user['user_id']);
$rs = Database::query($sql);
while ($row = Database :: fetch_array($rs)) {
$courses_in_session[0][] = $row['course_code'];
}
// get the list of sessions where the user is subscribed as student
$sql = 'SELECT id_session, course_code FROM ' . Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . ' WHERE id_user=' . intval($info_user['user_id']);
$rs = Database::query($sql);
$tmp_sessions = array();
while ($row = Database :: fetch_array($rs)) {
$tmp_sessions[] = $row['id_session'];
if (in_array($row['id_session'],$tmp_sessions)) {
$courses_in_session[$row['id_session']][] = $row['course_code'];
} }
} }
if (count($courses) > 0) { }
$csv_content[] = array (); $csv_content[] = array ();
$csv_content[] = array ( $csv_content[] = array (
get_lang('Session', ''),
get_lang('Course', ''), get_lang('Course', ''),
get_lang('Time', ''), get_lang('Time', ''),
get_lang('AttendanceFaults', ''),
get_lang('Progress', ''), get_lang('Progress', ''),
get_lang('Score', '') get_lang('Score', ''),
get_lang('AttendanceFaults', ''),
get_lang('Evaluations')
); );
$attendance = new Attendance(); $attendance = new Attendance();
foreach ($courses_in_session as $key => $courses) {
$session_id = $key;
$session_info = api_get_session_info($session_id);
$session_name = $session_info['name'];
$date_start = '';
if (!empty ($session_info['date_start'])) {
$date_start = explode('-', $session_info['date_start']);
$date_start = $date_start[2] . '/' . $date_start[1] . '/' . $date_start[0];
}
$date_end = '';
if (!empty ($session_info['date_end'])) {
$date_end = explode('-', $session_info['date_end']);
$date_end = $date_end[2] . '/' . $date_end[1] . '/' . $date_end[0];
}
$date_session = get_lang('From') . ' ' . $date_start . ' ' . get_lang('To') . ' ' . $date_end;
$title = '';
if (empty($session_id)) {
$title = get_lang('TrainingsWithoutSessions');
} else {
$title = ucfirst($session_name).($date_session?' ('.$date_session.')':'');
}
// courses
echo '<h4>'.$title.'</h4>';
echo '<table class="data_table">';
echo '<tr>
<th>'.get_lang('Course').'</th>
<th>'.get_lang('Time').'</th>
<th>'.get_lang('Progress').'</th>
<th>'.get_lang('Score').'</th>
<th>'.get_lang('AttendanceFaults').'</th>
<th>'.get_lang('Evaluations').'</th>
<th>'.get_lang('Details').'</th>
</tr>';
if (!empty($courses)) {
foreach ($courses as $course_code) { foreach ($courses as $course_code) {
if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) { if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
$course_info = CourseManager :: get_course_information($course_code); $course_info = CourseManager :: get_course_information($course_code);
$time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($info_user['user_id'], $course_code));
$time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($info_user['user_id'], $course_code, $session_id));
// get average of faults in attendances by student // get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_by_course($student_id, $course_code); $results_faults_avg = $attendance->get_faults_average_by_course($student_id, $course_code, $session_id);
if (!empty($results_faults_avg)) { if (!empty($results_faults_avg['total'])) {
$attendances_faults_avg = '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$course_code.'&student_id='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
if (api_is_drh()) {
$attendances_faults_avg = '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$course_code.'&id_session='.$session_id.'&student_id='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
} else {
$attendances_faults_avg = $results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)';
}
} else {
$attendances_faults_avg = '0/0 (0%)';
}
// get evaluatios by student
$cats = Category::load(null, null, $course_code, null, null, $session_id);
$scoretotal = array();
if (isset($cats)) {
if (!empty($session_id)) {
$scoretotal= $cats[0]->calc_score($student_id, $course_code, $session_id);
} else { } else {
$attendances_faults_avg = '0%'; $scoretotal= $cats[0]->calc_score($student_id, $course_code);
}
} }
$progress = Tracking :: get_avg_student_progress($info_user['user_id'], $course_code); $scoretotal_display = '0/0 (0%)';
$score = Tracking :: get_avg_student_score($info_user['user_id'], $course_code); if (!empty($scoretotal)) {
/*
if (api_is_drh()) {
$session_param = !empty($session_id)?'&id_session='.$session_id:'';
$scoretotal_display = '<a title="'.get_lang('GoAssessments').'" href="'.api_get_path(WEB_CODE_PATH).'gradebook/index.php?cidReq='.$course_code.'&id_session='.$session_id.'&student_id='.$student_id.'">'.round($scoretotal[0],2).'/'.round($scoretotal[1],2).'('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)</a>';
} else {
$scoretotal_display = round($scoretotal[0],2).'/'.round($scoretotal[1],2).'('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)';
}
*/
$scoretotal_display = round($scoretotal[0],2).'/'.round($scoretotal[1],2).'('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)';
}
$progress = Tracking::get_avg_student_progress($info_user['user_id'], $course_code, null, $session_id);
$score = Tracking :: get_avg_student_score($info_user['user_id'], $course_code, null, $session_id);
$progress = empty($progress) ? '0%' : $progress.'%'; $progress = empty($progress) ? '0%' : $progress.'%';
$score = empty($score) ? '0%' : $score.'%'; $score = empty($score) ? '0%' : $score.'%';
$csv_content[] = array ( $csv_content[] = array (
$session_name,
$course_info['title'], $course_info['title'],
$time_spent_on_course, $time_spent_on_course,
$progress, $progress,
$score $score,
$attendances_faults_avg,
$scoretotal_display
); );
echo ' echo '
<tr> <tr>
<td align="right"> <td align="right">'.$course_info['title'].'</td>
' . $course_info['title'] . ' <td align="right">'.$time_spent_on_course .'</td>
</td> <td align="right">'.$progress.'</td>
<td align="right"> <td align="right">'.$score.'</td>
' . $time_spent_on_course . ' <td align="right">'.$attendances_faults_avg.'</td>
</td> <td align="right">'.$scoretotal_display.'</td>';
<td align="right">
'. $attendances_faults_avg . '
</td>
<td align="right">
' . $progress . '
</td>
<td align="right">
' . $score . '
</td>';
if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) { if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
echo '<td align="center" width="10"> echo '<td align="center" width="10"><a href="'.api_get_self().'?student='.$info_user['user_id'].'&details=true&course='.$course_info['code'].'&id_coach='.Security::remove_XSS($_GET['id_coach']).'&origin='.Security::remove_XSS($_GET['origin']).'&id_session='.$session_id.'#infosStudent"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td>';
<a href="' . api_get_self() . '?student=' . $info_user['user_id'] . '&details=true&course=' . $course_info['code'] . '&id_coach=' . Security :: remove_XSS($_GET['id_coach']) . '&origin=' . Security :: remove_XSS($_GET['origin']) . '&id_session=' . Security :: remove_XSS($_GET['id_session']) . '#infosStudent"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>
</td>';
} else { } else {
echo '<td align="center" width="10"> echo '<td align="center" width="10"><a href="'.api_get_self().'?student='.$info_user['user_id'].'&details=true&course='.$course_info['code'].'&origin='.Security::remove_XSS($_GET['origin']).'&id_session='.$session_id.'#infosStudent"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td>';
<a href="' . api_get_self() . '?student=' . $info_user['user_id'] . '&details=true&course=' . $course_info['code'] . '&origin=' . Security :: remove_XSS($_GET['origin']) . '&id_session=' . Security :: remove_XSS($_GET['id_session']) . '#infosStudent"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>
</td>';
} }
echo '</tr>'; echo '</tr>';
} }
} }
} else { } else {
echo "<tr> echo "<tr><td colspan='5'>".get_lang('NoCourse')."</td></tr>";
<td colspan='5'> }
" . get_lang('NoCourse') . " echo '</table>';
</td>
</tr>
";
} }
} //end of else !empty($details) } //end of else !empty($details)
?> ?>
</table>
<br />
<?php <?php
if (!empty ($_GET['details']) && $_GET['origin'] != 'tracking_course' && $_GET['origin'] != 'user_course') { if (!empty ($_GET['details']) && $_GET['origin'] != 'tracking_course' && $_GET['origin'] != 'user_course') {

@ -49,23 +49,30 @@ class MySpace {
/** /**
* Gets the connections to a course as an array of login and logout time * Gets the connections to a course as an array of login and logout time
* *
* @param int unknown_type $user_id * @param int User ud
* @param string unknown_type $course_code * @param string Course code
* @return unknown * @param int Session id (optional, default = 0)
* @return array Conections
*/ */
function get_connections_to_course($user_id, $course_code) { function get_connections_to_course($user_id, $course_code, $session_id = 0) {
// Database table definitions // Database table definitions
$tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); $tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$tbl_main = Database :: get_main_table(TABLE_MAIN_COURSE); $tbl_main = Database :: get_main_table(TABLE_MAIN_COURSE);
$sql_query = 'SELECT visual_code as course_code FROM '.$tbl_main.' c WHERE code="'.Database::escape_string($course_code).'";'; // protect data
$user_id = intval($user_id);
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
$sql_query = 'SELECT visual_code as course_code FROM '.$tbl_main.' c WHERE code="'.$course_code.'";';
$result = Database::query($sql_query); $result = Database::query($sql_query);
$row_query = Database::fetch_array($result, 'ASSOC'); $row_query = Database::fetch_array($result, 'ASSOC');
$course_true = isset($row_query['course_code']) ? $row_query['course_code']: $course_code; $course_true = isset($row_query['course_code']) ? $row_query['course_code']: $course_code;
$sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . ' $sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . '
WHERE user_id = ' . intval($user_id) . ' WHERE user_id = '.$user_id.'
AND course_code="' . Database::escape_string($course_true) . '" ORDER BY login_course_date ASC'; AND course_code="'.$course_true.'" AND session_id = '.$session_id.' ORDER BY login_course_date ASC';
$rs = Database::query($sql); $rs = Database::query($sql);
$connections = array(); $connections = array();
@ -492,20 +499,25 @@ class MySpace {
*/ */
function get_course_data($from, $number_of_items, $column, $direction) { function get_course_data($from, $number_of_items, $column, $direction) {
global $courses, $csv_content, $charset ; global $courses, $csv_content, $charset, $session_id;
global $tbl_course, $tbl_course_user, $tbl_track_cours_access, $tbl_session_course_user;
// definition database tables
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$a_course_students = array(); $a_course_students = array();
$course_data = array(); $course_data = array();
$arr_course = $courses; $courses_code = array_keys($courses);
foreach ($arr_course as &$cours) {
$cours = "'{$cours[course_code]}'"; foreach ($courses_code as &$code) {
$code = "'$code'";
} }
// get all courses with limit // get all courses with limit
$sql = "SELECT course.code as col1, course.title as col2 $sql = "SELECT course.code as col1, course.title as col2
FROM $tbl_course course FROM $tbl_course course
WHERE course.code IN (".implode(',',$arr_course).")"; WHERE course.code IN (".implode(',',$courses_code).")";
if (!in_array($direction, array('ASC','DESC'))) $direction = 'ASC'; if (!in_array($direction, array('ASC','DESC'))) $direction = 'ASC';
$column = intval($column); $column = intval($column);
@ -520,32 +532,31 @@ class MySpace {
$course_code = $row_course[0]; $course_code = $row_course[0];
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$avg_assignments_in_course = $avg_messages_in_course = $nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0; $avg_assignments_in_course = $avg_messages_in_course = $nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0;
$tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_info['dbName']);
$tbl_forum_post = Database :: get_course_table(TABLE_FORUM_POST, $course_info['dbName']);
$tbl_course_lp_view = Database :: get_course_table(TABLE_LP_VIEW, $course_info['dbName']);
$tbl_course_lp = Database :: get_course_table(TABLE_LP_MAIN, $course_info['dbName']);
// students directly subscribed to the course // students directly subscribed to the course
$sql = "SELECT user_id FROM $tbl_course_user as course_rel_user WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code' if (empty($session_id)) {
UNION DISTINCT SELECT id_user as user_id FROM $tbl_session_course_user srcu WHERE srcu. course_code='$course_code'"; $sql = "SELECT user_id FROM $tbl_course_user as course_rel_user WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code'";
} else {
$sql = "SELECT id_user as user_id FROM $tbl_session_course_user srcu WHERE srcu. course_code='$course_code' AND id_session = '$session_id' AND srcu.status<>2";
}
$rs = Database::query($sql); $rs = Database::query($sql);
$users = array(); $users = array();
while ($row = Database::fetch_array($rs)) { while ($row = Database::fetch_array($rs)) { $users[] = $row['user_id']; }
$users[] = $row['user_id'];
}
if (count($users) > 0) { if (count($users) > 0) {
$nb_students_in_course = count($users); $nb_students_in_course = count($users);
$avg_assignments_in_course = Tracking::count_student_assignments($users, $course_code); $avg_assignments_in_course = Tracking::count_student_assignments($users, $course_code, $session_id);
$avg_messages_in_course = Tracking::count_student_messages($users, $course_code); $avg_messages_in_course = Tracking::count_student_messages($users, $course_code, $session_id);
$avg_time_spent_in_course = Tracking::get_time_spent_on_the_course($users, $course_code); $avg_progress_in_course = Tracking::get_avg_student_progress($users, $course_code, array(), $session_id);
$avg_progress_in_course = Tracking::get_avg_student_progress($users, $course_code); $avg_score_in_course = Tracking :: get_avg_student_score($users, $course_code, array(), $session_id);
$avg_score_in_course = Tracking :: get_avg_student_score($users, $course_code); $avg_score_in_exercise = Tracking::get_avg_student_exercise_score($users, $course_code, 0, $session_id);
$avg_score_in_exercise = Tracking::get_avg_student_exercise_score($users, $course_code); $avg_time_spent_in_course = Tracking::get_time_spent_on_the_course($users, $course_code, $session_id);
$avg_time_spent_in_course = api_time_to_hms($avg_time_spent_in_course / $nb_students_in_course);
$avg_progress_in_course = round($avg_progress_in_course / $nb_students_in_course, 2); $avg_progress_in_course = round($avg_progress_in_course / $nb_students_in_course, 2);
$avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2); $avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2);
$avg_score_in_exercise = round($avg_score_in_exercise / $nb_students_in_course, 2); $avg_score_in_exercise = round($avg_score_in_exercise / $nb_students_in_course, 2);
$avg_time_spent_in_course = api_time_to_hms($avg_time_spent_in_course / $nb_students_in_course);
} else { } else {
$avg_time_spent_in_course = null; $avg_time_spent_in_course = null;
$avg_progress_in_course = null; $avg_progress_in_course = null;
@ -563,8 +574,9 @@ class MySpace {
$table_row[] = is_null($avg_score_in_exercise) ? '' : $avg_score_in_exercise.'%'; $table_row[] = is_null($avg_score_in_exercise) ? '' : $avg_score_in_exercise.'%';
$table_row[] = $avg_messages_in_course; $table_row[] = $avg_messages_in_course;
$table_row[] = $avg_assignments_in_course; $table_row[] = $avg_assignments_in_course;
//set the "from" value to know if I access the Reporting by the Dokeos tab or the course link
$table_row[] = '<center><a href="../tracking/courseLog.php?cidReq='.$course_code.'&studentlist=true&from=myspace"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></center>'; //set the "from" value to know if I access the Reporting by the chamilo tab or the course link
$table_row[] = '<center><a href="../tracking/courseLog.php?cidReq='.$course_code.'&studentlist=true&from=myspace&id_session='.$session_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></center>';
$csv_content[] = array( $csv_content[] = array(
api_html_entity_decode($row_course[1], ENT_QUOTES, $charset), api_html_entity_decode($row_course[1], ENT_QUOTES, $charset),
$nb_students_in_course, $nb_students_in_course,

@ -114,7 +114,7 @@ if ($isCoach || api_is_platform_admin() || api_is_drh()) {
} }
} }
$menu_items[] = get_lang('Students'); $menu_items[] = '<a href="index.php?view=drh_students">'.get_lang('Students').'</a>';
$menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>'; $menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>';
$menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>'; $menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>';
$menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>'; $menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>';
@ -134,6 +134,7 @@ if ($isCoach || api_is_platform_admin() || api_is_drh()) {
echo '<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>'; echo '<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';
} }
echo '</div>'; echo '</div>';
echo '<h4>'.get_lang('YourStudentsList').'</h4>';
} else { } else {
echo '<div align="left" style="float:left"><h4>'.$title.'</h4></div> echo '<div align="left" style="float:left"><h4>'.$title.'</h4></div>
<div align="right"> <div align="right">

@ -24,11 +24,14 @@ class learnpathList {
* (only displays) items if he has enough permissions to view them. * (only displays) items if he has enough permissions to view them.
* @param integer User ID * @param integer User ID
* @param string Optional course code (otherwise we use api_get_course_id()) * @param string Optional course code (otherwise we use api_get_course_id())
* @param int Optional session id (otherwise we use api_get_session_id())
* @return void * @return void
*/ */
function learnpathList($user_id,$course_code='') { function learnpathList($user_id, $course_code='', $session_id = null) {
if (!empty($course_code)){ if (!empty($course_code)){
//proceed with course code given $course_info = api_get_course_info($course_code);
$lp_table = Database::get_course_table(TABLE_LP_MAIN, $course_info['dbName']);
} else{ } else{
$course_code = api_get_course_id(); $course_code = api_get_course_id();
$lp_table = Database::get_course_table(TABLE_LP_MAIN); $lp_table = Database::get_course_table(TABLE_LP_MAIN);
@ -37,7 +40,11 @@ class learnpathList {
$this->user_id = $user_id; $this->user_id = $user_id;
//condition for the session //condition for the session
if (isset($session_id)) {
$session_id = intval($session_id);
} else {
$session_id = api_get_session_id(); $session_id = api_get_session_id();
}
$condition_session = api_get_session_condition($session_id, false); $condition_session = api_get_session_condition($session_id, false);
$sql = "SELECT * FROM $lp_table $condition_session ORDER BY display_order ASC, name ASC"; $sql = "SELECT * FROM $lp_table $condition_session ORDER BY display_order ASC, name ASC";

@ -59,9 +59,11 @@ require api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
// starting the output buffering when we are exporting the information // starting the output buffering when we are exporting the information
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false; $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$session_id = intval($_REQUEST['id_session']);
if ($export_csv) { if ($export_csv) {
if (isset($_REQUEST['id_session']) && $_REQUEST['id_session'] != 0 ) { if (!empty($session_id)) {
$_SESSION['id_session'] = intval($_REQUEST['id_session']); $_SESSION['id_session'] = $session_id;
} }
ob_start(); ob_start();
} }
@ -71,7 +73,7 @@ $csv_content = array();
if (!empty($_GET['scormcontopen'])) { if (!empty($_GET['scormcontopen'])) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN); $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$contopen = (int) $_GET['scormcontopen']; $contopen = (int) $_GET['scormcontopen'];
$sql = "SELECT default_encoding FROM $tbl_lp WHERE id = ".$contopen; $sql = "SELECT default_encoding FROM $tbl_lp WHERE id = $contopen AND session_id = $session_id";
$res = Database::query($sql); $res = Database::query($sql);
$row = Database::fetch_array($res); $row = Database::fetch_array($res);
$lp_charset = $row['default_encoding']; $lp_charset = $row['default_encoding'];
@ -134,13 +136,6 @@ if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_pro
$additional_user_profile_info = TrackingCourseLog::get_addtional_profile_information_of_field_by_user($_GET['additional_profile_field'],$user_array); $additional_user_profile_info = TrackingCourseLog::get_addtional_profile_information_of_field_by_user($_GET['additional_profile_field'],$user_array);
} }
/* /*
============================================================================== ==============================================================================
MAIN CODE MAIN CODE
@ -163,7 +158,7 @@ if($_GET['studentlist'] == 'false') {
if (isset($_GET['additional_profile_field'])) { if (isset($_GET['additional_profile_field'])) {
$addional_param ='additional_profile_field='.intval($_GET['additional_profile_field']); $addional_param ='additional_profile_field='.intval($_GET['additional_profile_field']);
} }
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&id_session='.api_get_session_id().'&export=csv&'.$addional_param.'">'.Display::return_icon('csv.gif',get_lang('ExportAsCSV')).get_lang('ExportAsCSV').'</a>'; echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&'.$addional_param.'">'.Display::return_icon('csv.gif',get_lang('ExportAsCSV')).get_lang('ExportAsCSV').'</a>';
} }
if($_GET['studentlist'] == 'true' || empty($_GET['studentlist'])) { if($_GET['studentlist'] == 'true' || empty($_GET['studentlist'])) {
echo TrackingCourseLog::display_additional_profile_fields(); echo TrackingCourseLog::display_additional_profile_fields();
@ -172,6 +167,8 @@ echo '</div>';
if ($_GET['studentlist'] == 'false') { if ($_GET['studentlist'] == 'false') {
$course_code = api_get_course_id();
echo'<br /><br />'; echo'<br /><br />';
// learning path tracking // learning path tracking
@ -179,7 +176,7 @@ if ($_GET['studentlist'] == 'false') {
<h4>'.Display::return_icon('scormbuilder.gif',get_lang('AverageProgressInLearnpath')).get_lang('AverageProgressInLearnpath').'</h4> <h4>'.Display::return_icon('scormbuilder.gif',get_lang('AverageProgressInLearnpath')).get_lang('AverageProgressInLearnpath').'</h4>
<table class="data_table">'; <table class="data_table">';
$list = new LearnpathList($student); $list = new LearnpathList($student, $course_code, $session_id);
$flat_list = $list->get_flat_list(); $flat_list = $list->get_flat_list();
if ($export_csv) { if ($export_csv) {
@ -193,7 +190,7 @@ if ($_GET['studentlist'] == 'false') {
$lp_avg_progress = 0; $lp_avg_progress = 0;
foreach ($a_students as $student_id => $student) { foreach ($a_students as $student_id => $student) {
// get the progress in learning pathes // get the progress in learning pathes
$lp_avg_progress += learnpath::get_db_progress($lp_id, $student_id); $lp_avg_progress += Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
} }
if ($nbStudents > 0) { if ($nbStudents > 0) {
$lp_avg_progress = $lp_avg_progress / $nbStudents; $lp_avg_progress = $lp_avg_progress / $nbStudents;
@ -228,7 +225,7 @@ if ($_GET['studentlist'] == 'false') {
<table class="data_table">'; <table class="data_table">';
$sql = "SELECT id, title $sql = "SELECT id, title
FROM $TABLEQUIZ WHERE active <> -1"; FROM $TABLEQUIZ WHERE active <> -1 AND session_id = $session_id";
$rs = Database::query($sql); $rs = Database::query($sql);
if ($export_csv) { if ($export_csv) {
@ -238,43 +235,13 @@ if ($_GET['studentlist'] == 'false') {
} }
if (Database::num_rows($rs) > 0) { if (Database::num_rows($rs) > 0) {
// gets course actual administrators $student_ids = array_keys($a_students);
$sql = "SELECT user.user_id FROM $table_user user, $TABLECOURSUSER course_user
WHERE course_user.user_id=user.user_id AND course_user.course_code='".api_get_course_id()."' AND course_user.status <> '1' AND course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." ";
$res = Database::query($sql);
$student_ids = array();
while($row = Database::fetch_row($res)) {
$student_ids[] = $row[0];
}
$count_students = count($student_ids); $count_students = count($student_ids);
while ($quiz = Database::fetch_array($rs)) { while ($quiz = Database::fetch_array($rs)) {
$quiz_avg_score = 0; $quiz_avg_score = 0;
if ($count_students > 0) { if ($count_students > 0) {
foreach ($student_ids as $student_id) { foreach ($student_ids as $student_id) {
// get the scorn in exercises $avg_student_score = Tracking::get_avg_student_exercise_score($student_id, $course_code, $quiz['id'], $session_id);
$sql = 'SELECT exe_result , exe_weighting
FROM '.$TABLETRACK_EXERCISES.'
WHERE exe_exo_id = '.$quiz['id'].'
AND exe_user_id = '.(int)$student_id.'
AND exe_cours_id = "'.api_get_course_id().'"
AND orig_lp_id = 0
AND orig_lp_item_id = 0
ORDER BY exe_date DESC';
$rsAttempt = Database::query($sql);
$nb_attempts = 0;
$avg_student_score = 0;
while ($attempt = Database::fetch_array($rsAttempt)) {
$nb_attempts++;
$exe_weight = $attempt['exe_weighting'];
if ($exe_weight > 0) {
$avg_student_score += round(($attempt['exe_result'] / $exe_weight * 100), 2);
}
}
if ($nb_attempts > 0) {
$avg_student_score = $avg_student_score / $nb_attempts;
}
$quiz_avg_score += $avg_student_score; $quiz_avg_score += $avg_student_score;
} }
} }
@ -297,13 +264,12 @@ if ($_GET['studentlist'] == 'false') {
echo '<div class="clear"></div>'; echo '<div class="clear"></div>';
// forums tracking // forums tracking
echo '<div class="report_section"> echo '<div class="report_section">
<h4>'.Display::return_icon('forum.gif', get_lang('Forum')).get_lang('Forum').'&nbsp;-&nbsp;<a href="../forum/index.php?cidReq='.$_course['id'].'">'.get_lang('SeeDetail').'</a></h4> <h4>'.Display::return_icon('forum.gif', get_lang('Forum')).get_lang('Forum').'&nbsp;-&nbsp;<a href="../forum/index.php?cidReq='.$_course['id'].'">'.get_lang('SeeDetail').'</a></h4>
<table class="data_table">'; <table class="data_table">';
$count_number_of_posts_by_course = Tracking :: count_number_of_posts_by_course($_course['id']); $count_number_of_posts_by_course = Tracking :: count_number_of_posts_by_course($course_code, $session_id);
$count_number_of_forums_by_course = Tracking :: count_number_of_forums_by_course($_course['id']); $count_number_of_forums_by_course = Tracking :: count_number_of_forums_by_course($course_code, $session_id);
$count_number_of_threads_by_course = Tracking :: count_number_of_threads_by_course($_course['id']); $count_number_of_threads_by_course = Tracking :: count_number_of_threads_by_course($course_code, $session_id);
if ($export_csv) { if ($export_csv) {
$csv_content[] = array(get_lang('Forum'), ''); $csv_content[] = array(get_lang('Forum'), '');
$csv_content[] = array(get_lang('ForumForumsNumber', ''), $count_number_of_forums_by_course); $csv_content[] = array(get_lang('ForumForumsNumber', ''), $count_number_of_forums_by_course);
@ -321,7 +287,7 @@ if ($_GET['studentlist'] == 'false') {
echo '<div class="report_section"> echo '<div class="report_section">
<h4>'.Display::return_icon('chat.gif',get_lang('Chat')).get_lang('Chat').'</h4> <h4>'.Display::return_icon('chat.gif',get_lang('Chat')).get_lang('Chat').'</h4>
<table class="data_table">'; <table class="data_table">';
$chat_connections_during_last_x_days_by_course = Tracking :: chat_connections_during_last_x_days_by_course($_course['id'], 7); $chat_connections_during_last_x_days_by_course = Tracking::chat_connections_during_last_x_days_by_course($course_code, 7, $session_id);
if ($export_csv) { if ($export_csv) {
$csv_content[] = array(get_lang('Chat', ''), ''); $csv_content[] = array(get_lang('Chat', ''), '');
$csv_content[] = array(sprintf(get_lang('ChatConnectionsDuringLastXDays', ''), '7'), $chat_connections_during_last_x_days_by_course); $csv_content[] = array(sprintf(get_lang('ChatConnectionsDuringLastXDays', ''), '7'), $chat_connections_during_last_x_days_by_course);
@ -336,21 +302,15 @@ if ($_GET['studentlist'] == 'false') {
<h4>'.Display::return_icon('acces_tool.gif', get_lang('ToolsMostUsed')).get_lang('ToolsMostUsed').'</h4> <h4>'.Display::return_icon('acces_tool.gif', get_lang('ToolsMostUsed')).get_lang('ToolsMostUsed').'</h4>
<table class="data_table">'; <table class="data_table">';
$sql = "SELECT access_tool, COUNT(DISTINCT access_user_id),count( access_tool ) as count_access_tool $tools_most_used = Tracking::get_tools_most_used_by_course($course_code, $session_id);
FROM $TABLETRACK_ACCESS
WHERE access_tool IS NOT NULL
AND access_cours_code = '$_cid'
GROUP BY access_tool
ORDER BY count_access_tool DESC
LIMIT 0, 3";
$rs = Database::query($sql);
if ($export_csv) { if ($export_csv) {
$temp = array(get_lang('ToolsMostUsed'), ''); $temp = array(get_lang('ToolsMostUsed'), '');
$csv_content[] = $temp; $csv_content[] = $temp;
} }
while ($row = Database::fetch_array($rs)) { if (!empty($tools_most_used)) {
foreach ($tools_most_used as $row) {
echo ' <tr> echo ' <tr>
<td>'.get_lang(ucfirst($row['access_tool'])).'</td> <td>'.get_lang(ucfirst($row['access_tool'])).'</td>
<td align="right">'.$row['count_access_tool'].' '.get_lang('Clicks').'</td> <td align="right">'.$row['count_access_tool'].' '.get_lang('Clicks').'</td>
@ -360,6 +320,7 @@ if ($_GET['studentlist'] == 'false') {
$csv_content[] = $temp; $csv_content[] = $temp;
} }
} }
}
echo '</table></div>'; echo '</table></div>';
echo '<div class="clear"></div>'; echo '<div class="clear"></div>';
@ -377,13 +338,7 @@ if ($_GET['studentlist'] == 'false') {
<h4>'.Display::return_icon('documents.gif',get_lang('DocumentsMostDownloaded')).'&nbsp;'.get_lang('DocumentsMostDownloaded').$link.'</h4> <h4>'.Display::return_icon('documents.gif',get_lang('DocumentsMostDownloaded')).'&nbsp;'.get_lang('DocumentsMostDownloaded').$link.'</h4>
<table class="data_table">'; <table class="data_table">';
$sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down $documents_most_downloaded = Tracking::get_documents_most_downloaded_by_course($course_code, $session_id, $num);
FROM $TABLETRACK_DOWNLOADS
WHERE down_cours_id = '$_cid'
GROUP BY down_doc_path
ORDER BY count_down DESC
LIMIT 0, $num";
$rs = Database::query($sql);
if ($export_csv) { if ($export_csv) {
$temp = array(get_lang('DocumentsMostDownloaded', ''), ''); $temp = array(get_lang('DocumentsMostDownloaded', ''), '');
@ -391,8 +346,8 @@ if ($_GET['studentlist'] == 'false') {
$csv_content[] = $temp; $csv_content[] = $temp;
} }
if (Database::num_rows($rs) > 0) { if (!empty($documents_most_downloaded)) {
while($row = Database::fetch_array($rs)) { foreach ($documents_most_downloaded as $row) {
echo ' <tr> echo ' <tr>
<td>'.$row['down_doc_path'].'</td> <td>'.$row['down_doc_path'].'</td>
<td align="right">'.$row['count_down'].' '.get_lang('Clicks').'</td> <td align="right">'.$row['count_down'].' '.get_lang('Clicks').'</td>
@ -418,14 +373,7 @@ if ($_GET['studentlist'] == 'false') {
<h4>'.Display::return_icon('link.gif',get_lang('LinksMostClicked')).'&nbsp;'.get_lang('LinksMostClicked').'</h4> <h4>'.Display::return_icon('link.gif',get_lang('LinksMostClicked')).'&nbsp;'.get_lang('LinksMostClicked').'</h4>
<table class="data_table">'; <table class="data_table">';
$sql = "SELECT cl.title, cl.url,count(DISTINCT sl.links_user_id), count(cl.title) as count_visits $links_most_visited = Tracking::get_links_most_visited_by_course($course_code, $session_id);
FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
WHERE sl.links_link_id = cl.id
AND sl.links_cours_id = '$_cid'
GROUP BY cl.title, cl.url
ORDER BY count_visits DESC
LIMIT 0, 3";
$rs = Database::query($sql);
if ($export_csv) { if ($export_csv) {
$temp = array(get_lang('LinksMostClicked'),''); $temp = array(get_lang('LinksMostClicked'),'');
@ -433,8 +381,8 @@ if ($_GET['studentlist'] == 'false') {
$csv_content[] = $temp; $csv_content[] = $temp;
} }
if (Database::num_rows($rs) > 0) { if (!empty($links_most_visited)) {
while ($row = Database::fetch_array($rs)) { foreach ($links_most_visited as $row) {
echo ' <tr> echo ' <tr>
<td>'.$row['title'].'</td> <td>'.$row['title'].'</td>
<td align="right">'.$row['count_visits'].' '.get_lang('Clicks').'</td> <td align="right">'.$row['count_visits'].' '.get_lang('Clicks').'</td>
@ -514,6 +462,7 @@ if ($_GET['studentlist'] == 'false') {
$table = new SortableTable('users_tracking', array('TrackingCourseLog','get_number_of_users'), array('TrackingCourseLog','get_user_data'), (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2); $table = new SortableTable('users_tracking', array('TrackingCourseLog','get_number_of_users'), array('TrackingCourseLog','get_user_data'), (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
$parameters['cidReq'] = Security::remove_XSS($_GET['cidReq']); $parameters['cidReq'] = Security::remove_XSS($_GET['cidReq']);
$parameters['id_session'] = $session_id;
$parameters['studentlist'] = Security::remove_XSS($_GET['studentlist']); $parameters['studentlist'] = Security::remove_XSS($_GET['studentlist']);
$parameters['from'] = Security::remove_XSS($_GET['myspace']); $parameters['from'] = Security::remove_XSS($_GET['myspace']);

@ -187,12 +187,12 @@ if($is_allowedToTrack && $_configuration['tracking_enabled'])
//--------------------------------BEGIN first/last access //--------------------------------BEGIN first/last access
// first access // first access
$sql = "SELECT access_date FROM $TABLETRACK_ACCESS_2 WHERE `access_user_id` = '".$results[$j][0]."' AND `access_cours_code` = '".$_course['official_code']."' AND `access_tool` = 'learnpath' ORDER BY access_id ASC LIMIT 1"; $sql = "SELECT access_date FROM $TABLETRACK_ACCESS_2 WHERE access_user_id = '".$results[$j][0]."' AND access_cours_code = '".$_course['official_code']."' AND access_tool = 'learnpath' AND access_session_id = '".api_get_session_id()."' ORDER BY access_id ASC LIMIT 1";
$first_access = getOneResult($sql); $first_access = getOneResult($sql);
$first_access = empty($first_access) ? "-" : date('d.m.y',strtotime($first_access)); $first_access = empty($first_access) ? "-" : date('d.m.y',strtotime($first_access));
// last access // last access
$sql = "SELECT access_date FROM $TABLETRACK_ACCESS WHERE `access_user_id` = '".$results[$j][0]."' AND `access_cours_code` = '".$_course['official_code']."' AND `access_tool` = 'learnpath'"; $sql = "SELECT access_date FROM $TABLETRACK_ACCESS WHERE access_user_id = '".$results[$j][0]."' AND access_cours_code = '".$_course['official_code']."' AND access_tool = 'learnpath'";
$last_access = getOneResult($sql); $last_access = getOneResult($sql);
$last_access = empty($last_access) ? "-" : date('d.m.y',strtotime($last_access)); $last_access = empty($last_access) ? "-" : date('d.m.y',strtotime($last_access));
//--------------------------------END first/last access //--------------------------------END first/last access

Loading…
Cancel
Save