diff --git a/main/tracking/courseLog.php b/main/tracking/courseLog.php index 7bc96bb879..fd3e6f2227 100755 --- a/main/tracking/courseLog.php +++ b/main/tracking/courseLog.php @@ -1,14 +1,15 @@ - /*".COURSE_RELATION_TYPE_RRHH." @@ -138,7 +112,7 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) { - //--------------------------------BEGIN % visited + // BEGIN % visited // sum of all items (= multiple learningpaths + SCORM imported paths) $sql = "SELECT COUNT(DISTINCT(iv.lp_item_id)) " . "FROM $tbl_learnpath_item_view iv " . @@ -157,11 +131,11 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) // calculation & bgcolor setting $lpath_pct_completed = empty($total_lpath_items) ? "-" : round(($total_lpath_items_completed / $total_lpath_items) * 100); - //--------------------------------END % visited + // END % visited - //--------------------------------BEGIN first/last access + // BEGIN first/last 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' AND access_session_id = '".api_get_session_id()."' ORDER BY access_id ASC LIMIT 1"; $first_access = getOneResult($sql); @@ -171,14 +145,14 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) $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 = empty($last_access) ? "-" : date('d.m.y',strtotime($last_access)); - //--------------------------------END first/last access + // END first/last access - //--------------------------------BEGIN presentation of data + // BEGIN presentation of data $line .= $results[$j][1]." ".$results[$j][2].";".$first_access.";".$last_access.";".$lpath_pct_completed."\n"; - //--------------------------------END presentation of data + // END presentation of data @@ -194,11 +168,7 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) -/*************************************************************************** - * - * Main - * - ***************************************************************************/ +/* Main */ $tempView = $view; if($view[0] == '1') @@ -217,11 +187,7 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) } -/*************************************************************************** -* -* Access to this course -* -***************************************************************************/ +/* Access to this course */ $tempView = $view; if($view[1] == '1'){ @@ -274,11 +240,7 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) -/*************************************************************************** - * - * Tools - * - ***************************************************************************/ +/* Tools */ $tempView = $view; if($view[2] == '1'){ @@ -313,11 +275,7 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) } -/*************************************************************************** -* -* Links -* -***************************************************************************/ +/* Links */ $tempView = $view; if($view[3] == '1'){ @@ -352,11 +310,7 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) } -/*************************************************************************** -* -* Documents -* -***************************************************************************/ +/* Documents */ $tempView = $view; if($view[4] == '1'){ @@ -390,11 +344,7 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) } -/*************************************************************************** -* -* Scorm contents and Learning Path -* -***************************************************************************/ +/* Scorm contents and Learning Path */ $tempView = $view; if($view[5] == '1'){ @@ -455,9 +405,8 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) $ar3=Database::fetch_array($result3); $title_line .= get_lang('ScormTitleColumn').";".get_lang('ScormStatusColumn').";".get_lang('ScormScoreColumn').";".get_lang('ScormTimeColumn'); while ($ar3['status'] != '') { - require_once('../newscorm/learnpathItem.class.php'); + require_once '../newscorm/learnpathItem.class.php'; $time = learnpathItem::get_scorm_time('php',$ar3['total_time']); - $title = api_htmlentities($ar3['title'],ENT_QUOTES,$lp_charset); $line .= $title.";".$ar3['status'].";".$ar3['score'].";".$time; $ar3=Database::fetch_array($result3); } @@ -482,17 +431,17 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) } - /*************************************************************************** - * - * Export to a CSV file - * force the browser to save the file instead of opening it - ***************************************************************************/ + /* + * Export to a CSV file + * Force the browser to save the file instead of opening it. + */ $len = strlen($title_line.$line); header('Content-type: application/octet-stream'); //header('Content-Type: application/force-download'); header('Content-length: '.$len); - $filename = html_entity_decode(str_replace(":","",str_replace(" ","_", $title[0].'_'.$title[1].'.csv'))); + $filename = api_html_entity_decode(str_replace(":","",str_replace(" ","_", $title[0].'_'.$title[1].'.csv'))); + $filename = replace_dangerous_char($filename); if(preg_match("/MSIE 5.5/",$_SERVER['HTTP_USER_AGENT'])) { header('Content-Disposition: filename= '.$filename); @@ -510,12 +459,11 @@ if($is_allowedToTrack && $_configuration['tracking_enabled']) header('Content-Description: '.$filename); header('Content-transfer-encoding: binary'); - echo api_html_entity_decode($title_line, ENT_COMPAT, $charset); - echo api_html_entity_decode($line, ENT_COMPAT, $charset); + echo api_html_entity_decode($title_line, ENT_COMPAT); + echo api_html_entity_decode($line, ENT_COMPAT); exit; - } // not allowed else @@ -529,4 +477,3 @@ else api_not_allowed(); } } -?> diff --git a/main/tracking/userLog.php b/main/tracking/userLog.php index 7d1bdc45fb..01c9f83ea6 100755 --- a/main/tracking/userLog.php +++ b/main/tracking/userLog.php @@ -1,4 +1,4 @@ -"../group/group.php", "name"=> get_lang('BredCrumpGroups')); @@ -84,11 +65,8 @@ td {border-bottom: thin dashed gray;} Display::display_header($nameTools,"Tracking"); -/* ------------------------------------------------------------ - Constants and variables ------------------------------------------------------------ -*/ +/* Constants and variables */ + $is_allowedToTrack = $is_courseAdmin; $is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course($user_id, $course_id); @@ -146,11 +124,7 @@ $MonthsShort = api_get_months_short(); $is_allowedToTrack = true; // allowed to track only user of one group $is_allowedToTrackEverybodyInCourse = $is_allowedToTrack; // allowed to track all students in course -/* -============================================================================== - MAIN SECTION -============================================================================== -*/ +/* MAIN SECTION */ ?>

@@ -163,11 +137,9 @@ $is_allowedToTrackEverybodyInCourse = $is_allowedToTrack; // allowed to track al // check if uid is tutor of this group if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configuration['tracking_enabled'] ) { if(!$uInfo && !isset($uInfo) ) { - /*************************************************************************** - * - * Display list of user of this group - * - ***************************************************************************/ + /* + * Display list of user of this group + */ echo "

".get_lang('ListStudents')."

"; if( $is_allowedToTrackEverybodyInCourse ) { @@ -257,11 +229,9 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configura } else { // if uInfo is set - /*************************************************************************** - * - * Informations about student uInfo - * - ***************************************************************************/ + /* + * Informations about student uInfo + */ // these checks exists for security reasons, neither a prof nor a tutor can see statistics of a user from // another course, or group if( $is_allowedToTrackEverybodyInCourse ) { @@ -326,11 +296,9 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configura } - /*************************************************************************** - * + /* * Scorm contents and Learning Path - * - ***************************************************************************/ + */ if(substr($view,5,1) == '1') { $new_view = substr_replace($view,'0',5,1); echo " @@ -380,11 +348,10 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configura "; while ($ar3['status'] != '') { - require_once('../newscorm/learnpathItem.class.php'); + require_once '../newscorm/learnpathItem.class.php'; $time = learnpathItem::get_scorm_time('php',$ar3['total_time']); - $title = api_htmlentities($ar3['title'],ENT_QUOTES,$lp_charset); echo "   "; - echo "$title{$ar3['status']}{$ar3['score']}$time"; + echo "$title{$ar3['status']}{$ar3['score']}$time"; echo ""; $ar3=Database::fetch_array($result3); } @@ -432,4 +399,3 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configura diff --git a/main/tracking/userlogCSV.php b/main/tracking/userlogCSV.php index e8bae2385b..9dbd604de8 100755 --- a/main/tracking/userlogCSV.php +++ b/main/tracking/userlogCSV.php @@ -3,23 +3,18 @@ // TODO: Is this file deprecated? /** -============================================================================== -* @package dokeos.tracking -* @todo clean code - structure is unclear and difficult to modify -============================================================================== -*/ + * @package chamilo.tracking + * @todo clean code - structure is unclear and difficult to modify + */ + +/* INIT SECTION */ -/* -============================================================================== - INIT SECTION -============================================================================== -*/ $uInfo = $_REQUEST['uInfo']; $view = $_REQUEST['view']; // name of the language file that needs to be included $language_file = 'tracking'; -include('../inc/global.inc.php'); +require_once '../inc/global.inc.php'; // Roles and rights system $user_id = api_get_user_id(); @@ -35,33 +30,15 @@ RolesRights::protect_location($role_id, $location_id); */ //YW Hack security to quick fix RolesRights bug $is_allowed = true; -/* ------------------------------------------------------------ - Libraries ------------------------------------------------------------ -*/ -include(api_get_path(LIBRARY_PATH).'statsUtils.lib.inc.php'); -include(api_get_path(LIBRARY_PATH).'course.lib.php'); -include(api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php'); -require_once(api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php'); -/* ------------------------------------------------------------ - Header ------------------------------------------------------------ -*/ -// charset determination -if ($_GET['scormcontopen']) -{ - $tbl_lp = Database::get_course_table(TABLE_LP_MAIN); - $contopen = (int) $_GET['scormcontopen']; - $sql = "SELECT default_encoding FROM $tbl_lp WHERE id = ".$contopen; - $res = Database::query($sql); - $row = Database::fetch_array($res); - $lp_charset = $row['default_encoding']; - //header('Content-Type: text/html; charset='. $row['default_encoding']); -} +/* Libraries */ +require_once api_get_path(LIBRARY_PATH).'statsUtils.lib.inc.php'; +require_once api_get_path(LIBRARY_PATH).'course.lib.php'; +require_once api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php'; +require_once api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php'; + +/* Header */ /* $interbreadcrumb[]= array ("url"=>"../group/group.php", "name"=> get_lang('BredCrumpGroups')); @@ -75,12 +52,8 @@ if($uInfo) $nameTools = get_lang('ToolName'); +/* Constants and variables */ -/* ------------------------------------------------------------ - Constants and variables ------------------------------------------------------------ -*/ $is_allowedToTrack = $is_courseAdmin; $is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course($user_id, $course_id); @@ -140,11 +113,8 @@ $MonthsShort = api_get_months_short(); $is_allowedToTrack = true; // allowed to track only user of one group $is_allowedToTrackEverybodyInCourse = $is_allowedToTrack; // allowed to track all students in course -/* -============================================================================== - MAIN SECTION -============================================================================== -*/ +/* MAIN SECTION */ + $title[0]=''; $title[1]=''; $line=''; @@ -155,11 +125,9 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configura { if(!$uInfo && !isset($uInfo) ) { - /*************************************************************************** - * - * Display list of user of this group - * - ***************************************************************************/ + /* + * Display list of user of this group + */ if( $is_allowedToTrackEverybodyInCourse ) { @@ -240,11 +208,9 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configura } else // if uInfo is set { - /*************************************************************************** - * - * Informations about student uInfo - * - ***************************************************************************/ + /* + * Informations about student uInfo + */ // these checks exists for security reasons, neither a prof nor a tutor can see statistics of a user from // another course, or group if( $is_allowedToTrackEverybodyInCourse ) @@ -301,11 +267,9 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configura } - /*************************************************************************** - * + /* * Scorm contents and Learning Path - * - ***************************************************************************/ + */ //TODO: scorm tools is in work and the logs will change in few days... /*if(substr($view,5,1) == '1') { @@ -338,7 +302,6 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configura while ($ar3['status'] != '') { require_once('../newscorm/learnpathItem.class.php'); $time = learnpathItem::get_scorm_time('php',$ar3['total_time']); - $title = api_htmlentities($ar3['title'],ENT_QUOTES,$lp_charset); $line .= $title.';'.$ar3['status'].';'.$ar3['score'].';'.$time."\n"; $ar3=Database::fetch_array($result3); } @@ -365,17 +328,17 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configura }*/ } - /*************************************************************************** - * - * Export to a CSV file - * force the browser to save the file instead of opening it - ***************************************************************************/ + /* + * Export to a CSV file + * force the browser to save the file instead of opening it + */ $len = strlen($title_line.$line); header('Content-type: application/octet-stream'); //header('Content-Type: application/force-download'); header('Content-length: '.$len); $filename = html_entity_decode(str_replace(":","",str_replace(" ","_", $title[0].'_'.$title[1].'.csv'))); + $filename = replace_dangerous_char($filename); if(preg_match("/MSIE 5.5/",$_SERVER['HTTP_USER_AGENT'])) { header('Content-Disposition: filename= '.$filename);