Task #1765 - Cleaning the files for the Tracking tool.

skala
Ivan Tcholakov 15 years ago
parent 39f071a55c
commit 7bae09894a
  1. 33
      main/tracking/courseLog.php
  2. 117
      main/tracking/courseLogCSV.php
  3. 82
      main/tracking/userLog.php
  4. 95
      main/tracking/userlogCSV.php

@ -1,14 +1,15 @@
<?php //$id: $
<?php
/* For licensing terms, see /license.txt */
/**
* @author Thomas Depraetere
* @author Hugues Peeters
* @author Christophe Gesche
* @author Sebastien Piraux
* @author Toon Keppens (Vi-Host.net)
*
* @package chamilo.tracking
*/
* @author Thomas Depraetere
* @author Hugues Peeters
* @author Christophe Gesche
* @author Sebastien Piraux
* @author Toon Keppens (Vi-Host.net)
*
* @package chamilo.tracking
*/
/*
* INIT SECTION
@ -70,16 +71,6 @@ if ($export_csv) {
}
$csv_content = array();
// charset determination
if (!empty($_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 AND session_id = $session_id";
$res = Database::query($sql);
$row = Database::fetch_array($res);
$lp_charset = $row['default_encoding'];
}
$htmlHeadXtra[] = "<style type='text/css'>
/*<![CDATA[*/
.secLine {background-color : #E6E6E6;}
@ -464,9 +455,9 @@ if ($_GET['studentlist'] == 'false') {
$all_datas = array();
$course_code = $_course['id'];
$user_ids = array_keys($a_students);
$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']);

@ -12,39 +12,21 @@
// TODO: Is this file deprecated?
/*
==============================================================================
INIT SECTION
==============================================================================
*/
/* INIT SECTION */
$pathopen = isset($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null;
// name of the language file that needs to be included
$language_file = "tracking";
include('../inc/global.inc.php');
require_once '../inc/global.inc.php';
//includes for SCORM and LP
require_once('../newscorm/learnpath.class.php');
require_once('../newscorm/learnpathItem.class.php');
require_once('../newscorm/scorm.class.php');
require_once('../newscorm/scormItem.class.php');
require_once '../newscorm/learnpath.class.php';
require_once '../newscorm/learnpathItem.class.php';
require_once '../newscorm/scorm.class.php';
require_once '../newscorm/scormItem.class.php';
// 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']);
}
/* Constants and variables */
/*
-----------------------------------------------------------
Constants and variables
-----------------------------------------------------------
*/
// regroup table names for maintenance purpose
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$TABLETRACK_LINKS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
@ -83,11 +65,7 @@ include("../resourcelinker/resourcelinker.inc.php");
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || api_is_drh();
/*
==============================================================================
MAIN CODE
==============================================================================
*/
/* MAIN CODE */
$title[0]=get_lang('StatsOfCourse')." : ".$_course['official_code'];
@ -106,18 +84,14 @@ if($is_allowedToTrack && $_configuration['tracking_enabled'])
if(!isset($view)) $view ="0000000";
/***************************************************************************
*
* Reporting
*
***************************************************************************/
/* Reporting */
$tempView = $view;
if($view[6] == '1'){
$tempView[6] = '0';
//--------------------------------BEGIN users in this course
// BEGIN users in this course
$sql = "SELECT $TABLECOURSUSER.user_i, $table_user.lastname, $table_user.firstname
FROM $TABLECOURSUSER, $table_user
WHERE $TABLECOURSUSER.course_code = '".$_cid."' AND $TABLECOURSUSER.user_id = $table_user.user_id AND $TABLECOURSUSER.relation_type<>".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();
}
}
?>

@ -1,4 +1,4 @@
<?php // $Id: userLog.php 21626 2009-06-26 12:19:41Z pcool $
<?php
/* For licensing terms, see /license.txt */
// TODO: Is this file deprecated?
@ -17,8 +17,8 @@ $view = $_REQUEST['view'];
// name of the language file that needs to be included
$language_file = 'tracking';
// including the global Dokeos file
//include('../inc/global.inc.php');
// Including the global initialization file
require_once '../inc/global.inc.php';
// the section (for the tabs)
$this_section = "session_my_space";
@ -29,34 +29,15 @@ $course_id = api_get_course_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 (isset($_GET['scormcontopen'])) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$contopen = Database::escape_string($_GET['scormcontopen']);
if (is_numeric($contopen)) {
$contopen = intval($contopen);
$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'));
@ -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 */
?>
<h3>
<?php echo $nameTools ?>
@ -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 "<h4>".get_lang('ListStudents')."</h4>";
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 "<tr>
@ -380,11 +348,10 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configura
</td>
</tr>";
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 "<tr><td>&nbsp;&nbsp;&nbsp;</td><td>";
echo "$title</td><td align=right>{$ar3['status']}</td><td align=right>{$ar3['score']}</td><td align=right>$time</td>";
echo "$title</td><td align=right>{$ar3['status']}</td><td align=right>{$ar3['score']}</td><td align=right>$time</td>";
echo "</tr>";
$ar3=Database::fetch_array($result3);
}
@ -432,4 +399,3 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configura
</table>
<?php
Display::display_footer();
?>

@ -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);

Loading…
Cancel
Save