@ -34,6 +34,7 @@ if (isset($_GET['from']) && $_GET['from'] == 'myspace') {
$this_section = SECTION_COURSES;
$this_section = SECTION_COURSES;
}
}
// access restrictions
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
if (!$is_allowedToTrack) {
if (!$is_allowedToTrack) {
@ -53,7 +54,10 @@ require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require api_get_path(LIBRARY_PATH).'statsUtils.lib.inc.php';
require api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
// starting the output buffering when we are exporting the information
$export_csv = isset($_GET['export']) & & $_GET['export'] == 'csv' ? true : false;
$export_csv = isset($_GET['export']) & & $_GET['export'] == 'csv' ? true : false;
if ($export_csv) {
if ($export_csv) {
ob_start();
ob_start();
@ -81,12 +85,7 @@ $htmlHeadXtra[] = "<style type='text/css'>
< / style > ";
< / style > ";
/*
// Database table definitions
-----------------------------------------------------------
Constants and variables
-----------------------------------------------------------
*/
// regroup table names for maintenance purpose
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$TABLETRACK_LINKS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
$TABLETRACK_LINKS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
$TABLETRACK_DOWNLOADS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$TABLETRACK_DOWNLOADS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
@ -98,17 +97,12 @@ $TABLECOURSE_LINKS = Database::get_course_table(TABLE_LINK);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$TABLEQUIZ = Database :: get_course_table(TABLE_QUIZ_TEST);
$TABLEQUIZ = Database :: get_course_table(TABLE_QUIZ_TEST);
//$table_scormdata = Database::get_scorm_table(TABLE_SCORM_SCO_DATA);
//$table_scormmain = Database::get_scorm_table(TABLE_SCORM_MAIN);
//$tbl_learnpath_main = Database::get_course_table(TABLE_LEARNPATH_MAIN);
//$tbl_learnpath_item = Database::get_course_table(TABLE_LEARNPATH_ITEM);
//$tbl_learnpath_chapter = Database::get_course_table(TABLE_LEARNPATH_CHAPTER);
$tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN);
$tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN);
$tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
$tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
$tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
$tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
$tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
// breadcrumbs
if (isset($_GET['origin']) & & $_GET['origin'] == 'resume_session') {
if (isset($_GET['origin']) & & $_GET['origin'] == 'resume_session') {
$interbreadcrumb[] = array('url' => '../admin/index.php','name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => '../admin/index.php','name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => '../admin/session_list.php','name' => get_lang('SessionList'));
$interbreadcrumb[] = array('url' => '../admin/session_list.php','name' => get_lang('SessionList'));
@ -119,11 +113,13 @@ $view = (isset($_REQUEST['view']) ? $_REQUEST['view'] : '');
$nameTools = get_lang('Tracking');
$nameTools = get_lang('Tracking');
// display the header
Display::display_header($nameTools, 'Tracking');
Display::display_header($nameTools, 'Tracking');
require api_get_path(LIBRARY_PATH).'statsUtils.lib.inc.php';
require api_get_path(LIBRARY_PATH).'statsUtils.lib.inc.php';
require api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
require api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
// getting all the students of the course
$a_students = CourseManager :: get_student_list_from_course_code($_course['id'], true, (empty($_SESSION['id_session']) ? null : $_SESSION['id_session']));
$a_students = CourseManager :: get_student_list_from_course_code($_course['id'], true, (empty($_SESSION['id_session']) ? null : $_SESSION['id_session']));
$nbStudents = count($a_students);
$nbStudents = count($a_students);
@ -298,31 +294,28 @@ function get_tool_name_table($tool) {
echo '< div class = "actions" > ';
echo '< div class = "actions" > ';
if ($_GET['studentlist'] == 'false') {
if ($_GET['studentlist'] == 'false') {
echo '< a href = "courseLog.php?'.api_get_cidreq().'&studentlist=true" > '.get_lang('StudentsTracking').'< / a > | '.get_lang('CourseTracking').' | < a href = "courseLog.php?'.api_get_cidreq().'&studentlist=resources" > '.get_lang('ResourcesTracking');
echo '< a href = "courseLog.php?'.api_get_cidreq().'&studentlist=true" > '.get_lang('StudentsTracking').'< / a > | '.get_lang('CourseTracking').' | < a href = "courseLog.php?'.api_get_cidreq().'&studentlist=resources" > '.get_lang('ResourcesTracking');
} elseif($_GET['studentlist'] == 'resources') {
} elseif($_GET['studentlist'] == 'resources') {
echo '< a href = "courseLog.php?'.api_get_cidreq().'&studentlist=true" > '.get_lang('StudentsTracking').'< / a > | < a href = "courseLog.php?'.api_get_cidreq().'&studentlist=false" > '.get_lang('CourseTracking').'< / a > | '.get_lang('ResourcesTracking');
echo '< a href = "courseLog.php?'.api_get_cidreq().'&studentlist=true" > '.get_lang('StudentsTracking').'< / a > | < a href = "courseLog.php?'.api_get_cidreq().'&studentlist=false" > '.get_lang('CourseTracking').'< / a > | '.get_lang('ResourcesTracking');
} elseif($_GET['studentlist'] == '' || $_GET['studentlist'] == 'true') {
} elseif($_GET['studentlist'] == '' || $_GET['studentlist'] == 'true') {
echo get_lang('StudentsTracking').' | < a href = "courseLog.php?'.api_get_cidreq().'&studentlist=false" > '.get_lang('CourseTracking').'< / a > | < a href = "courseLog.php?'.api_get_cidreq().'&studentlist=resources" > '.get_lang('ResourcesTracking').'< / a > ';
echo get_lang('StudentsTracking').' | < a href = "courseLog.php?'.api_get_cidreq().'&studentlist=false" > '.get_lang('CourseTracking').'< / a > | < a href = "courseLog.php?'.api_get_cidreq().'&studentlist=resources" > '.get_lang('ResourcesTracking').'< / a > ';
}
}
echo ' < a href = "javascript: void(0);" onclick = "javascript: window.print();" > < img align = "absbottom" src = "../img/printmgr.gif" > ' .get_lang('Print').'< / a > ';
echo ' < a href = "javascript: void(0);" onclick = "javascript: window.print();" > '.Display::return_icon('printmgr.gif',get_lang('Print')) .get_lang('Print').'< / a > ';
if($_GET['studentlist'] == 'false') {
if($_GET['studentlist'] == 'false') {
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&export=csv&studentlist=false" > < img align = "absbottom" src = "../img/excel.gif" > '.get_lang('ExportAsCSV').'< / a > ';
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&export=csv&studentlist=false" > < img align = "absbottom" src = "../img/excel.gif" > '.get_lang('ExportAsCSV').'< / a > ';
} elseif ($_GET['studentlist'] == '' || $_GET['studentlist'] == 'true') {
} elseif ($_GET['studentlist'] == '' || $_GET['studentlist'] == 'true') {
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&export=csv" > < img align = "absbottom" src = "../img/excel.gif" > ' .get_lang('ExportAsCSV').'< / a > ';
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&export=csv" > '.Display::return_icon('csv.gif',get_lang('ExportAsCSV')) .get_lang('ExportAsCSV').'< / a > ';
}
}
echo display_additional_profile_fields();
echo '< / div > ';
echo '< / div > ';
if ($_GET['studentlist'] == 'false') {
if ($_GET['studentlist'] == 'false') {
echo'< br / > < br / > ';
echo'< br / > < br / > ';
/***************************
// learning path tracking
* LEARNING PATHS
***************************/
echo '< div class = "report_section" >
echo '< div class = "report_section" >
< h4 >
< h4 > '.Display::return_icon('scormbuilder.gif',get_lang('AverageProgressInLearnpath')).get_lang('AverageProgressInLearnpath').'< / h4 >
< img src = "../img/scormbuilder.gif" align = "absbottom" > '.get_lang('AverageProgressInLearnpath').'
< / h4 >
< table class = "data_table" > ';
< table class = "data_table" > ';
$list = new LearnpathList($student);
$list = new LearnpathList($student);
@ -368,13 +361,9 @@ if ($_GET['studentlist'] == 'false') {
echo '< / table > < / div > ';
echo '< / table > < / div > ';
echo '< div class = "clear" > < / div > ';
echo '< div class = "clear" > < / div > ';
/***************************
// Exercices tracking
* EXERCICES
***************************/
echo '< div class = "report_section" >
echo '< div class = "report_section" >
< h4 >
< h4 > '.Display::return_icon('quiz.gif',get_lang('AverageResultsToTheExercices')).get_lang('AverageResultsToTheExercices').' - < a href = "../exercice/exercice.php?'.api_get_cidreq().'&show=result" > '.get_lang('SeeDetail').'< / a > < / h4 >
< img src = "../img/quiz.gif" align = "absbottom" > '.get_lang('AverageResultsToTheExercices').' - < a href = "../exercice/exercice.php?'.api_get_cidreq().'&show=result" > '.get_lang('SeeDetail').'< / a >
< / h4 >
< table class = "data_table" > ';
< table class = "data_table" > ';
$sql = "SELECT id, title
$sql = "SELECT id, title
@ -446,14 +435,10 @@ if ($_GET['studentlist'] == 'false') {
echo '< / table > < / div > ';
echo '< / table > < / div > ';
echo '< div class = "clear" > < / div > ';
echo '< div class = "clear" > < / div > ';
/**********************
// forums tracking
* FORUMS
**********************/
echo '< div class = "report_section" >
echo '< div class = "report_section" >
< h4 >
< h4 > '.Display::return_icon('forum.gif', get_lang('Forum')).get_lang('Forum').' - < a href = "../forum/index.php?cidReq='.$_course['id'].'" > '.get_lang('SeeDetail').'< / a > < / h4 >
< img src = "../img/forum.gif" align = "absbottom" > '.get_lang('Forum').' - < 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['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['id']);
@ -470,14 +455,10 @@ if ($_GET['studentlist'] == 'false') {
echo '< / table > < / div > ';
echo '< / table > < / div > ';
echo '< div class = "clear" > < / div > ';
echo '< div class = "clear" > < / div > ';
/**********************
// chat tracking
* CHAT
**********************/
echo '< div class = "report_section" >
echo '< div class = "report_section" >
< h4 >
< h4 > '.Display::return_icon('chat.gif',get_lang('Chat')).get_lang('Chat').'< / h4 >
< img src = "../img/chat.gif" align = "absbottom" > '.get_lang('Chat').'< / a >
< / 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['id'], 7);
if ($export_csv) {
if ($export_csv) {
@ -489,13 +470,9 @@ if ($_GET['studentlist'] == 'false') {
echo '< / table > < / div > ';
echo '< / table > < / div > ';
echo '< div class = "clear" > < / div > ';
echo '< div class = "clear" > < / div > ';
/**********************
// tools tracking
* TOOLS
**********************/
echo '< div class = "report_section" >
echo '< div class = "report_section" >
< h4 >
< h4 > '.Display::return_icon('acces_tool.gif', get_lang('ToolsMostUsed')).get_lang('ToolsMostUsed').'< / h4 >
< img src = "../img/acces_tool.gif" align = "absbottom" > '.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
$sql = "SELECT access_tool, COUNT(DISTINCT access_user_id),count( access_tool ) as count_access_tool
@ -526,21 +503,17 @@ if ($_GET['studentlist'] == 'false') {
echo '< / table > < / div > ';
echo '< / table > < / div > ';
echo '< div class = "clear" > < / div > ';
echo '< div class = "clear" > < / div > ';
/***************************
// Documents tracking
* DOCUMENTS
***************************/
if ($_GET['num'] == 0 or empty($_GET['num'])) {
if ($_GET['num'] == 0 or empty($_GET['num'])) {
$num = 3;
$num = 3;
$link = ' - < a href = "'.api_get_self().'?'.api_get_cidreq().'&studentlist=false&num=1#ancle " > '.get_lang('SeeDetail').'< / a > ';
$link=' - < a href = "'.api_get_self().'?'.api_get_cidreq().'&studentlist=false&num=1#documents_tracking " > '.get_lang('SeeDetail').'< / a > ';
} else {
} else {
$num = 1000;
$num = 1000;
$link = ' - < a href = "'.api_get_self().'?'.api_get_cidreq().'&studentlist=false&num=0#ancle " > '.get_lang('ViewMinus').'< / a > ';
$link=' - < a href = "'.api_get_self().'?'.api_get_cidreq().'&studentlist=false&num=0#documents_tracking " > '.get_lang('ViewMinus').'< / a > ';
}
}
echo '< a name = "ancle" id = "a" > < / a > < div class = "report_section" >
echo '< a name = "documents_tracking" id = "a" > < / a > < div class = "report_section" >
< h4 >
< h4 > '.Display::return_icon('documents.gif',get_lang('DocumentsMostDownloaded')).' '.get_lang('DocumentsMostDownloaded').$link.'< / h4 >
< img src = "../img/documents.gif" align = "absbottom" > '.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
$sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
@ -579,13 +552,9 @@ if ($_GET['studentlist'] == 'false') {
echo '< div class = "clear" > < / div > ';
echo '< div class = "clear" > < / div > ';
/***************************
// links tracking
* LINKS
***************************/
echo '< div class = "report_section" >
echo '< div class = "report_section" >
< h4 >
< h4 > '.Display::return_icon('link.gif',get_lang('LinksMostClicked')).' '.get_lang('LinksMostClicked').'< / h4 >
< img src = "../img/link.gif" align = "absbottom" > '.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
$sql = "SELECT cl.title, cl.url,count(DISTINCT sl.links_user_id), count(cl.title) as count_visits
@ -629,7 +598,7 @@ if ($_GET['studentlist'] == 'false') {
ob_end_clean();
ob_end_clean();
Export :: export_table_csv($csv_content, 'reporting_course_tracking');
Export :: export_table_csv($csv_content, 'reporting_course_tracking');
}
}
} elseif($_GET['studentlist'] == 'true' or $_GET['studentlist'] == '') {
} elseif ($_GET['studentlist'] == 'true' or $_GET['studentlist'] == '') {
// else display student list with all the informations
// else display student list with all the informations
// BEGIN : form to remind inactives susers
// BEGIN : form to remind inactives susers
@ -665,27 +634,32 @@ if ($_GET['studentlist'] == 'false') {
}
}
$sort_by_first_name = api_sort_by_first_name();
$sort_by_first_name = api_sort_by_first_name();
$tracking_column = isset($_GET['tracking_column']) ? $_GET['tracking_column'] : ($is_western_name_order xor $sort_by_first_name) ? 2 : 1 ;
$tracking_column = isset($_GET['tracking_column']) ? $_GET['tracking_column'] : 0 ;
$tracking_direction = isset($_GET['tracking_direction']) ? $_GET['tracking_direction'] : 'DESC';
$tracking_direction = isset($_GET['tracking_direction']) ? $_GET['tracking_direction'] : 'DESC';
if (count($a_students) > 0) {
if (count($a_students) > 0) {
$table = new SortableTable('tracking', 'count_student_in_course', null, ($is_western_name_order xor $sort_by_first_name) ? 2 : 1);
$table = new SortableTable('tracking', 'count_student_in_course', null, ($is_western_name_order xor $sort_by_first_name) ? 2 : 1);
$table -> set_header(0, get_lang('OfficialCode'), tru e, 'align="center"');
$table -> set_header(0, get_lang('OfficialCode'), fals e, 'align="center"');
if ($is_western_name_order) {
if ($is_western_name_order) {
$table -> set_header(1, get_lang('FirstName'), tru e, 'align="center"');
$table -> set_header(1, get_lang('FirstName'), fals e, 'align="center"');
$table -> set_header(2, get_lang('LastName'), true, 'align="center"');
$table -> set_header(2, get_lang('LastName'), true, 'align="center"');
} else {
} else {
$table -> set_header(1, get_lang('LastName'), true, 'align="center"');
$table -> set_header(1, get_lang('LastName'), true, 'align="center"');
$table -> set_header(2, get_lang('FirstName'), true, 'align="center"');
$table -> set_header(2, get_lang('FirstName'), false, 'align="center"');
}
$table -> set_header(3, get_lang('TrainingTime'),false);
$table -> set_header(4, get_lang('CourseProgress'),false);
$table -> set_header(5, get_lang('Score'),false);
$table -> set_header(6, get_lang('Student_publication'),false);
$table -> set_header(7, get_lang('Messages'),false);
$table -> set_header(8, get_lang('FirstLogin'), false, 'align="center"');
$table -> set_header(9, get_lang('LatestLogin'), false, 'align="center"'); $table -> set_header(10, get_lang('Details'),false);
if (isset($_GET['additional_profile_field']) AND is_numeric($_GET['additional_profile_field'])) {
$table -> set_header(11, get_lang('AdditionalProfileField'),false);
}
if ($export_csv) {
$csv_content[] = array ();
}
}
$table -> set_header(3, get_lang('TrainingTime'), true);
$table -> set_header(4, get_lang('CourseProgress'), true);
$table -> set_header(5, get_lang('Score'), true);
$table -> set_header(6, get_lang('Student_publication'), true);
$table -> set_header(7, get_lang('Messages'), true);
$table -> set_header(8, get_lang('FirstLogin'), true, 'align="center"');
$table -> set_header(9, get_lang('LatestLogin'), true, 'align="center"');
$table -> set_header(10, get_lang('Details'), false);
$all_datas = array();
$all_datas = array();
$course_code = $_course['id'];
$course_code = $_course['id'];
@ -826,3 +800,68 @@ if ($_GET['studentlist'] == 'false') {
< / table >
< / table >
<?php
<?php
Display::display_footer();
Display::display_footer();
// creating the form
$return = '< form action = "courseLog.php" method = "get" name = "additional_profile_field_form" id = "additional_profile_field_form" > ';
// the select field with the additional user profile fields (= this is where we select the field of which we want to see
// the information the users have entered or selected.
$return .= '< select name = "additional_profile_field" > ';
$return .= '< option value = "-" > '.get_lang('SelectFieldToAdd').'< / option > ';
foreach ($extra_fields as $key=>$field)
{
if ($field[0] == $_GET['additional_profile_field']) {
$selected = 'selected="selected"';
}
else {
$selected = '';
}
$return .= '< option value = "'.$field[0].'" ' . $ selected . ' > '.$field[3].'< / option > ';
}
$return .= '< / select > ';
// the form elements for the $_GET parameters (because the form is passed through GET
foreach ($_GET as $key=>$value){
$return .= '< input type = "hidden" name = "'.$key.'" value = "'.Security::Remove_XSS($value).'" / > ';
}
// the submit button
$return .= '< button class = "save" type = "submit" > '.get_lang('AddAdditionalProfileField').'< / button > ';
$return .= '< / form > ';
return $return;
}
/**
* This function gets all the information of a certrain ($field_id) additional profile field.
* It gets the information of all the users so that it can be displayed in the sortable table or in the csv or xls export
*
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @since October 2009
* @version 1.8.7
*/
function get_addtional_profile_information_of_field($field_id){
// Database table definition
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_user_field_values = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
$sql = "SELECT user.user_id, field.field_value FROM $table_user user, $table_user_field_values field
WHERE user.user_id = field.user_id
AND field.field_id='".Database::escape_string($field_id)."'";
$result = api_sql_query($sql,__FILE__,__LINE__);
while($row = Database::fetch_array($result))
{
$return[$row['user_id']][] = $row['field_value'];
}
return $return;
}
/**
* count the number of students in this course (used for SortableTable)
*/
function count_student_in_course() {
global $nbStudents;
return $nbStudents;
}
function sort_users($a, $b) {
return api_strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
}