Remove unused code.

pull/2487/head
jmontoyaa 8 years ago
parent 2913577df8
commit c79c22b336
  1. 96
      main/inc/lib/formvalidator/Element/receivers.php
  2. 380
      main/inc/lib/tracking.lib.php
  3. 225
      main/tracking/logins_details.php
  4. 368
      main/tracking/userLog.php

@ -1,96 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Form element to select receivers
* This element contains 1 radio-buttons. One with label 'everybody' and one
* with label 'select users/groups'. Only if the second radio-button is
* selected, 2 select-list show up. The user can move items between the 2
* checkboxes.
*/
class HTML_QuickForm_receivers extends HTML_QuickForm_group
{
/**
* Array of all receivers
*/
var $receivers;
/**
* Array of selected receivers
*/
var $receivers_selected;
/**
* Constructor
* @param string $elementName
* @param string $elementLabel
* @param array $attributes This should contain the keys 'receivers' and
* 'receivers_selected'
*/
public function __construct($elementName = null, $elementLabel = null, $attributes = null)
{
$this->receivers = $attributes['receivers'];
$this->receivers_selected = $attributes['receivers_selected'];
unset($attributes['receivers']);
unset($attributes['receivers_selected']);
parent::__construct($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_appendName = true;
$this->_type = 'receivers';
}
/**
* Create the form elements to build this element group
*/
function _createElements()
{
$this->_elements[] = new HTML_QuickForm_Radio('receivers', '', get_lang('Everybody'), '0', array('onclick' => 'javascript:receivers_hide(\'receivers_to\')'));
$this->_elements[0]->setChecked(true);
$this->_elements[] = new HTML_QuickForm_Radio('receivers', '', get_lang('SelectGroupsUsers'), '1', array('onclick' => 'javascript:receivers_show(\'receivers_to\')'));
$this->_elements[] = new HTML_QuickForm_advmultiselect('to', '', $this->receivers);
$this->_elements[2]->setSelected($this->receivers_selected);
}
/**
* HTML representation
*/
public function toHtml()
{
include_once ('HTML/QuickForm/Renderer/Default.php');
$this->_separator = '<br/>';
$renderer = & new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate('{element}');
$select_boxes = $this->_elements[2];
$select_boxes->setElementTemplate('<div style="margin-left:20px;display:block;" id="receivers_'.$select_boxes->getName().'">'.$select_boxes->_elementTemplate.'</div>');
parent::accept($renderer);
$js = $this->getElementJS();
return $renderer->toHtml().$js;
}
/**
* Get the necessary javascript
*/
public function getElementJS()
{
$js = "<script type=\"text/javascript\">
/* <![CDATA[ */
receivers_hide('receivers_to');
function receivers_show(item) {
el = document.getElementById(item);
el.style.display='';
}
function receivers_hide(item) {
el = document.getElementById(item);
el.style.display='none';
}
/* ]]> */
</script>\n";
return $js;
}
/**
* accept renderer
*/
function accept(& $renderer, $required = false, $error = null)
{
$renderer->renderElement($this, $required, $error);
}
}

@ -7302,386 +7302,6 @@ class TrackingCourseLog
*/
class TrackingUserLog
{
/**
* Displays the number of logins every month for a specific user in a specific course.
* @param $view
* @param int $user_id
* @param int $course_id
* @param int $session_id
*/
public static function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
{
$MonthsLong = $GLOBALS['MonthsLong'];
// protected data
$user_id = intval($user_id);
$session_id = intval($session_id);
$course_id = Database::escape_string($course_id);
$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$tempView = $view;
if (substr($view, 0, 1) == '1') {
$new_view = substr_replace($view, '0', 0, 1);
echo "
<tr>
<td valign='top'>
<font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
"<b>".get_lang('LoginsAndAccessTools')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".$user_id."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=10000'>".get_lang('ExportAsCSV')."</a>]
</td>
</tr>
";
echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
FROM $track_access_table
WHERE access_user_id = $user_id
AND c_id = $course_id
AND access_session_id = $session_id
GROUP BY YEAR(access_date),MONTH(access_date)
ORDER BY YEAR(access_date),MONTH(access_date) ASC";
echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
$results = getManyResults3Col($sql);
echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
echo "<tr>
<td class='secLine'>
".get_lang('LoginsTitleMonthColumn')."
</td>
<td class='secLine'>
".get_lang('LoginsTitleCountColumn')."
</td>
</tr>";
$total = 0;
if (is_array($results)) {
for ($j = 0; $j < count($results); $j++) {
echo "<tr>";
echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0]) - 1].' '.date('Y', $results[$j][0])."</a></td>";
echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
echo"</tr>";
$total = $total + $results[$j][1];
}
echo "<tr>";
echo "<td>".get_lang('Total')."</td>";
echo "<td align='right' class='content'>".$total."</td>";
echo"</tr>";
} else {
echo "<tr>";
echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
echo"</tr>";
}
echo "</table>";
echo "</td></tr>";
} else {
$new_view = substr_replace($view, '1', 0, 1);
echo "
<tr>
<td valign='top'>
+<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".$user_id."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LoginsAndAccessTools')."</a>
</td>
</tr>
";
}
}
/**
* Displays the exercise results for a specific user in a specific course.
* @param string $view
* @param int $user_id User ID
* @param string $courseCode Course code
* @return array
* @todo remove globals
*/
public static function display_exercise_tracking_info($view, $user_id, $courseCode)
{
global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
$courseId = api_get_course_int_id($courseCode);
if (substr($view, 1, 1) == '1') {
$new_view = substr_replace($view, '0', 1, 1);
echo "<tr>
<td valign='top'>
<font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>]
</td>
</tr>";
echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
WHERE te.c_id = $courseId
AND te.exe_user_id = ".intval($user_id)."
AND te.exe_exo_id = ce.id
ORDER BY ce.title ASC, te.exe_date ASC";
$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
FROM $TBL_TRACK_HOTPOTATOES AS te
WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId
ORDER BY te.c_id ASC, te.exe_date ASC";
$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
$NoTestRes = 0;
$NoHPTestRes = 0;
echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
$results = StatsUtils::getManyResultsXCol($sql, 4);
echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
echo "
<tr bgcolor='#E6E6E6'>
<td>
".get_lang('ExercicesTitleExerciceColumn')."
</td>
<td>
".get_lang('Date')."
</td>
<td>
".get_lang('ExercicesTitleScoreColumn')."
</td>
</tr>";
if (is_array($results)) {
for ($i = 0; $i < sizeof($results); $i++) {
$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
echo "<tr>\n";
echo "<td class='content'>".$results[$i][0]."</td>\n";
echo "<td class='content'>".$display_date."</td>\n";
echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
echo "</tr>\n";
}
} else {
// istvan begin
$NoTestRes = 1;
}
// The Result of Tests
if (is_array($hpresults)) {
for ($i = 0; $i < sizeof($hpresults); $i++) {
$title = GetQuizName($hpresults[$i][0], '');
if ($title == '')
$title = basename($hpresults[$i][0]);
$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
?>
<tr>
<td class="content"><?php echo $title; ?></td>
<td class="content" align="center"><?php echo $display_date; ?></td>
<td class="content" align="center"><?php echo $hpresults[$i][1]; ?> / <?php echo $hpresults[$i][2]; ?>
</td>
</tr>
<?php
}
} else {
$NoHPTestRes = 1;
}
if ($NoTestRes == 1 && $NoHPTestRes == 1) {
echo "<tr>\n";
echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
echo "</tr>\n";
}
echo "</table>";
echo "</td>\n</tr>\n";
} else {
$new_view = substr_replace($view, '1', 1, 1);
echo "
<tr>
<td valign='top'>
+<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
</td>
</tr>";
}
}
/**
* Displays the student publications for a specific user in a specific course.
* @todo remove globals
*/
public static function display_student_publications_tracking_info($view, $user_id, $course_id)
{
global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
$_course = api_get_course_info_by_id($course_id);
if (substr($view, 2, 1) == '1') {
$new_view = substr_replace($view, '0', 2, 1);
echo "<tr>
<td valign='top'>
<font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('WorkUploads')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>]
</td>
</tr>";
echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
$sql = "SELECT u.upload_date, w.title, w.author,w.url
FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
WHERE u.upload_work_id = w.id
AND u.upload_user_id = '".intval($user_id)."'
AND u.c_id = '".intval($course_id)."'
ORDER BY u.upload_date DESC";
echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
$results = StatsUtils::getManyResultsXCol($sql, 4);
echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
echo "<tr>
<td class='secLine' width='40%'>
".get_lang('WorkTitle')."
</td>
<td class='secLine' width='30%'>
".get_lang('WorkAuthors')."
</td>
<td class='secLine' width='30%'>
".get_lang('Date')."
</td>
</tr>";
if (is_array($results)) {
for ($j = 0; $j < count($results); $j++) {
$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
echo "<tr>";
echo "<td class='content'>"
."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
."</td>";
echo "<td class='content'>".$results[$j][2]."</td>";
echo "<td class='content'>".$beautifulDate."</td>";
echo"</tr>";
}
} else {
echo "<tr>";
echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
echo"</tr>";
}
echo "</table>";
echo "</td></tr>";
} else {
$new_view = substr_replace($view, '1', 2, 1);
echo "
<tr>
<td valign='top'>
+<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('WorkUploads')."</a>
</td>
</tr>
";
}
}
/**
* Displays the links followed for a specific user in a specific course.
* @todo remove globals
*/
public static function display_links_tracking_info($view, $user_id, $courseCode)
{
global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
$courseId = api_get_course_int_id($courseCode);
if (substr($view, 3, 1) == '1') {
$new_view = substr_replace($view, '0', 3, 1);
echo "
<tr>
<td valign='top'>
<font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('LinksAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00010'>".get_lang('ExportAsCSV')."</a>]
</td>
</tr>
";
echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
$sql = "SELECT cl.title, cl.url
FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
WHERE sl.links_link_id = cl.id
AND sl.c_id = $courseId
AND sl.links_user_id = ".intval($user_id)."
GROUP BY cl.title, cl.url";
echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
$results = StatsUtils::getManyResults2Col($sql);
echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
echo "<tr>
<td class='secLine'>
".get_lang('LinksTitleLinkColumn')."
</td>
</tr>";
if (is_array($results)) {
for ($j = 0; $j < count($results); $j++) {
echo "<tr>";
echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
echo"</tr>";
}
} else {
echo "<tr>";
echo "<td ><center>".get_lang('NoResult')."</center></td>";
echo"</tr>";
}
echo "</table>";
echo "</td></tr>";
} else {
$new_view = substr_replace($view, '1', 3, 1);
echo "
<tr>
<td valign='top'>
+<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LinksAccess')."</a>
</td>
</tr>
";
}
}
/**
* Displays the documents downloaded for a specific user in a specific course.
* @param string kind of view inside tracking info
* @param int User id
* @param string Course code
* @param int Session id (optional, default = 0)
* @return void
*/
public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0)
{
// protect data
$user_id = intval($user_id);
$courseId = api_get_course_int_id($course_code);
$session_id = intval($session_id);
$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
if (substr($view, 4, 1) == '1') {
$new_view = substr_replace($view, '0', 4, 1);
echo "
<tr>
<td valign='top'>
<font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('DocumentsAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00001'>".get_lang('ExportAsCSV')."</a>]
</td>
</tr>
";
echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
$sql = "SELECT down_doc_path
FROM $downloads_table
WHERE c_id = $courseId
AND down_user_id = $user_id
AND down_session_id = $session_id
GROUP BY down_doc_path";
echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
$results = StatsUtils::getManyResults1Col($sql);
echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
echo "<tr>
<td class='secLine'>
".get_lang('DocumentsTitleDocumentColumn')."
</td>
</tr>";
if (is_array($results)) {
for ($j = 0; $j < count($results); $j++) {
echo "<tr>";
echo "<td class='content'>".$results[$j]."</td>";
echo"</tr>";
}
} else {
echo "<tr>";
echo "<td><center>".get_lang('NoResult')."</center></td>";
echo"</tr>";
}
echo "</table>";
echo "</td></tr>";
} else {
$new_view = substr_replace($view, '1', 4, 1);
echo "
<tr>
<td valign='top'>
+<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('DocumentsAccess')."</a>
</td>
</tr>
";
}
}
/**
* Gets the IP of a given user, using the last login before the given date
* @param int User ID

@ -1,225 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @author Thomas Depraetere
* @author Hugues Peeters
* @author Christophe Gesche
* @author Sebastien Piraux
*
* @package chamilo.tracking
*/
// TODO: Is this file deprecated?
$uInfo = $_REQUEST['uInfo'];
if (!isset($_REQUEST['reqdate'])) {
$reqdate = time();
} else {
$reqdate = $_REQUEST['reqdate'];
}
$period = $_REQUEST['period'];
if (!isset($_REQUEST['view'])) {
$view = "0000000";
} else {
$view = $_REQUEST['view'];
}
require_once __DIR__.'/../inc/global.inc.php';
$interbreadcrumb[] = array(
"url" => "../user/user.php",
"name" => get_lang('Users')
);
$nameTools = get_lang('ToolName');
$htmlHeadXtra[] = "<style>
.secLine {background-color : #E6E6E6;}
.content {padding-left : 15px;padding-right : 15px; }
.specialLink{color : #0000FF;}
</style>
<style media='print' type='text/css'>
td {border-bottom: thin dashed gray;}
</style>";
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER);
$TABLEUSER = Database::get_main_table(TABLE_MAIN_USER);
$TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
Display::display_header($nameTools, "Tracking");
$courseId = api_get_course_int_id();
// the variables for the days and the months
// Defining the shorts for the days
$DaysShort = api_get_week_days_short();
// Defining the days of the week to allow translation of the days
$DaysLong = api_get_week_days_long();
// Defining the months of the year to allow translation of the months
$MonthsLong = api_get_months_long();
// Defining the months of the year to allow translation of the months
$MonthsShort = api_get_months_short();
$is_allowedToTrack = $is_groupTutor; // allowed to track only user of one group
$is_allowedToTrackEverybodyInCourse = $is_courseAdmin; // allowed to track all student in course
?>
<h3>
<?php echo $nameTools ?>
</h3>
<table width="100%" cellpadding="2" cellspacing="3" border="0">
<?php
// check if uid is tutor of this group
$courseId = api_get_course_int_id();
if (($is_allowedToTrack || $is_allowedToTrackEverybodyInCourse)) {
if ($is_allowedToTrackEverybodyInCourse) {
$sql = "SELECT u.firstname,u.lastname, u.email
FROM $TABLECOURSUSER cu , $TABLEUSER u
WHERE
cu.user_id = u.user_id AND
cu.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND
cu.c_id = '$courseId' AND
u.user_id = '$uInfo'";
} else {
$sql = "SELECT u.firstname,u.lastname, u.email
FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
WHERE gu.user_id = u.user_id
AND gu.group_id = '$_gid'
AND u.user_id = '$uInfo'";
}
$query = Database::query($sql);
$res = @Database::fetch_array($query);
if (is_array($res)) {
$res[2] == "" ? $res2 = get_lang('NoEmail') : $res2 = Display::encrypted_mailto_link($res[2]);
echo "<tr><td>";
echo $informationsAbout." : <br>";
echo "<ul>\n"
. "<li>".get_lang('FirstName')." : ".$res[0]."</li>\n"
. "<li>".get_lang('LastName')." : ".$res[1]."</li>\n"
. "<li>".get_lang('Email')." : ".$res2."</li>\n"
. "</ul>";
echo "</td></tr>";
/* * ***** MENU ******* */
echo "<tr>
<td>
[<a href='userLog.php?uInfo=$uInfo&view=$view'>".get_lang('Back')."</a>]
";
echo " &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;
[<a href='" . api_get_self()."?uInfo=$uInfo&view=$view&period=week&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodWeek')."</a>]
[<a href='" . api_get_self()."?uInfo=$uInfo&view=$view&period=month&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodMonth')."</a>]
&nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;
";
switch ($period) {
case "week" :
// previous and next date must be evaluated
$previousReqDate = $reqdate - 7 * 86400;
$nextReqDate = $reqdate + 7 * 86400;
echo "
[<a href='" . api_get_self()."?uInfo=$uInfo&view=$view&period=week&reqdate=$previousReqDate' class='specialLink'>".get_lang('PreviousWeek')."</a>]
[<a href='" . api_get_self()."?uInfo=$uInfo&view=$view&period=week&reqdate=$nextReqDate' class='specialLink'>".get_lang('NextWeek')."</a>]
";
break;
default:
$period = "month";
case "month":
// previous and next date must be evaluated
// 30 days should be a good approximation
$previousReqDate = mktime(1, 1, 1, date("m", $reqdate) - 1, 1, date("Y", $reqdate));
$nextReqDate = mktime(1, 1, 1, date("m", $reqdate) + 1, 1, date("Y", $reqdate));
echo "
[<a href='" . api_get_self()."?uInfo=$uInfo&view=$view&period=month&reqdate=$previousReqDate' class='specialLink'>".get_lang('PreviousMonth')."</a>]
[<a href='" . api_get_self()."?uInfo=$uInfo&view=$view&period=month&reqdate=$nextReqDate' class='specialLink'>".get_lang('NextMonth')."</a>]
";
break;
}
echo "
</td>
</tr>
";
/* * ***** END OF MENU ******* */
switch ($period) {
case "month":
$sql = "SELECT access_date
FROM $TABLETRACK_ACCESS
WHERE access_user_id = $uInfo
AND c_id = $courseId
AND MONTH(access_date) = MONTH( FROM_UNIXTIME('$reqdate') )
AND YEAR(access_date) = YEAR(FROM_UNIXTIME('$reqdate'))
GROUP BY DAYOFMONTH(access_date)
ORDER BY access_date ASC";
$displayedDate = $MonthsLong[date("n", $reqdate) - 1].date(" Y", $reqdate);
break;
case "week":
$sql = "SELECT access_date
FROM $TABLETRACK_ACCESS
WHERE access_user_id = $uInfo
AND c_id = $courseId
AND WEEK(access_date) = WEEK( FROM_UNIXTIME('$reqdate') )
AND YEAR(access_date) = YEAR(FROM_UNIXTIME('$reqdate'))
GROUP BY DAYOFMONTH(access_date)
ORDER BY access_date ASC";
$weeklowreqdate = ($reqdate - (86400 * date("w", $reqdate)));
$weekhighreqdate = ($reqdate + (86400 * (6 - date("w", $reqdate))));
$displayedDate = get_lang('From')." ".date("d ", $weeklowreqdate).$MonthsLong[date("n", $weeklowreqdate) - 1].date(" Y", $weeklowreqdate)
. " ".get_lang('To')." ".date("d ", $weekhighreqdate).$MonthsLong[date("n", $weekhighreqdate) - 1].date(" Y", $weekhighreqdate);
break;
}
echo "<tr><td>";
$results = StatsUtils::getManyResults1Col($sql);
/* * * display of the displayed period ** */
echo "<table width='100%' cellpadding='2' cellspacing='1' border='0' align=center>";
echo "<td bgcolor='#E6E6E6'>".$displayedDate."</td>";
if (is_array($results)) {
for ($j = 0; $j < sizeof($results); $j++) {
$beautifulDateTime = api_convert_and_format_date($results[$j], null, date_default_timezone_get());
echo "<tr>";
echo "<td style='padding-left : 40px;' valign='top'>".$beautifulDateTime."</td>";
echo"</tr>";
// $limit is used to select only results between $results[$j] (current login) and next one
if ($j == (sizeof($results) - 1))
$limit = date("Y-m-d H:i:s", $nextReqDate);
else
$limit = $results[$j + 1];
// select all access to tool between displayed date and next displayed date or now() if
// displayed date is the last login date
$sql = "SELECT access_tool, count(access_tool)
FROM $TABLETRACK_ACCESS
WHERE access_user_id = $uInfo
AND access_tool IS NOT NULL
AND access_date > '".$results[$j]."'
AND access_date < '" . $limit."'
AND c_id = $courseId
GROUP BY access_tool
ORDER BY access_tool ASC";
$results2 = StatsUtils::getManyResults2Col($sql);
if (is_array($results2)) {
echo "<tr><td colspan='2'>\n";
echo "<table width='50%' cellpadding='0' cellspacing='0' border='0'>\n";
for ($k = 0; $k < count($results2); $k++) {
echo "<tr>\n";
echo "<td width='70%' style='padding-left : 60px;'>".get_lang($results2[$k][0])."</td>\n";
echo "<td width='30%' align='right' style='padding-right : 40px'>".$results2[$k][1]." ".get_lang('Visits')."</td>\n";
echo "</tr>";
}
echo "</table>\n";
echo "</td></tr>\n";
}
$previousDate = $value;
}
} else {
echo "<tr>";
echo "<td colspan='2' bgcolor='#eeeeee'>".get_lang('NoResult')."</td>";
echo "</tr>";
}
echo "</table>";
echo "</td></tr>";
} else {
echo get_lang('ErrorUserNotInGroup');
}
} else {
// not allowed
api_not_allowed();
}
?>
</table>
<?php
Display::display_footer();

@ -1,368 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
// TODO: Is this file deprecated?
/**
* @package chamilo.tracking
* @todo clean code - structure is unclear and difficult to modify
*/
require_once __DIR__.'/../inc/global.inc.php';
$uInfo = isset($_REQUEST['uInfo']) ? intval($_REQUEST['uInfo']) : 0;
$view = isset($_REQUEST['view']) ? Security::remove_XSS($_REQUEST['view']) : '';
// the section (for the tabs)
$this_section = "session_my_space";
// variables
$user_id = api_get_user_id();
$course_id = api_get_course_id();
$courseId = api_get_course_int_id();
//YW Hack security to quick fix RolesRights bug
$is_allowed = true;
require_once api_get_path(SYS_CODE_PATH).'exercise/hotpotatoes.lib.php';
if (isset($uInfo)) {
$interbreadcrumb[] = array(
'url'=>'../user/userInfo.php?uInfo='.Security::remove_XSS($uInfo),
"name"=> api_ucfirst(get_lang('Users'))
);
}
$nameTools = get_lang('ToolName');
$htmlHeadXtra[] = "<style type='text/css'>
/*<![CDATA[*/
.secLine {background-color : #E6E6E6;}
.content {padding-left : 15px;padding-right : 15px; }
.specialLink{color : #0000FF;}
/*]]>*/
</style>
<style media='print' type='text/css'>
/*<![CDATA[*/
td {border-bottom: thin dashed gray;}
/*]]>*/
</style>";
Display::display_header($nameTools, "Tracking");
/* Constants and variables */
$is_allowedToTrack = $is_courseAdmin;
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course($user_id, $courseId);
// Database Table Definitions
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLEUSER = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER);
$now = api_get_utc_datetime();
$sql = "SELECT 1
FROM $tbl_session_course_user AS session_course_user
INNER JOIN $tbl_session AS session
ON session_course_user.session_id = session.id
AND ((access_start_date <= '$now'
AND access_end_date >= '$now')
OR (access_start_date IS NULL AND access_end_date IS NULL))
WHERE session_id='".api_get_session_id()."' AND c_id = $courseId";
//echo $sql;
$result = Database::query($sql);
if (!Database::num_rows($result)) {
$disabled = true;
}
$tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN);
$tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
$tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
$tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
// The variables for the days and the months
$DaysShort = api_get_week_days_short();
$DaysLong = api_get_week_days_long();
$MonthsLong = api_get_months_long();
$MonthsShort = api_get_months_short();
//$is_allowedToTrack = $is_groupTutor; // allowed to track only user of one group
//$is_allowedToTrackEverybodyInCourse = $is_allowed[EDIT_RIGHT]; // allowed to track all students in course
//YW hack security to fix RolesRights bug
$is_allowedToTrack = true; // allowed to track only user of one group
$is_allowedToTrackEverybodyInCourse = $is_allowedToTrack; // allowed to track all students in course
/* MAIN SECTION */
?>
<h3>
<?php echo $nameTools ?>
</h3>
<h4>
<?php echo get_lang('StatsOfUser'); ?>
</h4>
<table width="100%" cellpadding="2" cellspacing="3" border="0">
<?php
// check if uid is tutor of this group
if (($is_allowedToTrack || $is_allowedToTrackEverybodyInCourse)) {
if (!$uInfo && !isset($uInfo)) {
/*
* Display list of user of this group
*/
echo "<h4>".get_lang('ListStudents')."</h4>";
if ($is_allowedToTrackEverybodyInCourse) {
// if user can track everybody : list user of course
$sql = "SELECT count(user_id)
FROM $TABLECOURSUSER
WHERE c_id = '".$courseId."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH."";
} else {
// if user can only track one group : list users of this group
$sql = "SELECT count(user)
FROM $TABLECOURSE_GROUPSUSER
WHERE group_id = '".intval($_gid)."'";
}
$userGroupNb = StatsUtils::getOneResult($sql);
$step = 25; // number of student per page
if ($userGroupNb > $step) {
if (!isset($offset)) {
$offset = 0;
}
$next = $offset + $step;
$previous = $offset - $step;
$navLink = "<table width='100%' border='0'>\n"
."<tr>\n"
."<td align='left'>";
if ($previous >= 0) {
$navLink .= "<a href='".api_get_self()."?offset=$previous'>&lt;&lt; ".get_lang('PreviousPage')."</a>";
}
$navLink .= "</td>\n"
."<td align='right'>";
if ($next < $userGroupNb) {
$navLink .= "<a href='".api_get_self()."?offset=$next'>".get_lang('NextPage')." &gt;&gt;</a>";
}
$navLink .= "</td>\n"
."</tr>\n"
."</table>\n";
} else {
$offset = 0;
}
echo $navLink;
//sanity check of integer vars
if (!settype($offset, 'integer') || !settype($step, 'integer')) {
die('Offset or step variables are not integers.');
}
if ($is_allowedToTrackEverybodyInCourse) {
// list of users in this course
$sql = "SELECT u.user_id, u.firstname,u.lastname
FROM $TABLECOURSUSER cu , $TABLEUSER u
WHERE
cu.user_id = u.user_id AND
cu.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND
cu.c_id = '".$courseId."'
LIMIT $offset,$step";
} else {
// list of users of this group
$sql = "SELECT u.user_id, u.firstname,u.lastname
FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
WHERE
gu.user_id = u.user_id AND
gu.group_id = '".intval($_gid)."'
LIMIT $offset,$step";
}
$list_users = getManyResults3Col($sql);
echo "<table width='100%' cellpadding='2' cellspacing='1' border='0'>\n"
."<tr align='center' valign='top' bgcolor='#E6E6E6'>\n"
."<td align='left'>", get_lang('UserName'), "</td>\n"
."</tr>\n";
for ($i = 0; $i < sizeof($list_users); $i++) {
echo "<tr valign='top' align='center'>\n"
."<td align='left'>"
."<a href='".api_get_self()."?uInfo=", $list_users[$i][0], "'>"
.$list_users[$i][1], " ", $list_users[$i][2]
."</a>".
"</td>\n";
}
echo "</table>";
echo $navLink;
} else {
// if uInfo is set
/*
* Information 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) {
// check if user is in this course
$tracking_is_accepted = $is_course_member;
$tracked_user_info = api_get_user_info($uInfo);
} else {
// check if user is in the group of this tutor
$sql = "SELECT u.firstname,u.lastname, u.email
FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
WHERE gu.user_id = u.user_id
AND gu.group_id = '".intval($_gid)."'
AND u.user_id = '".intval($uInfo)."'";
$query = Database::query($sql);
$tracked_user_info = @Database::fetch_assoc($query);
if (is_array($tracked_user_info)) {
$tracking_is_accepted = true;
}
}
if ($tracking_is_accepted) {
$tracked_user_info['email'] == '' ? $mail_link = get_lang('NoEmail') : $mail_link = Display::encrypted_mailto_link($tracked_user_info['email']);
echo "<tr><td>";
echo get_lang('informationsAbout').' :';
echo "<ul>\n"
."<li>".get_lang('FirstName')." : ".$tracked_user_info['firstname']."</li>\n"
."<li>".get_lang('LastName')." : ".$tracked_user_info['lastname']."</li>\n"
."<li>".get_lang('Email')." : ".$mail_link."</li>\n"
."</ul>";
echo "</td></tr>\n";
// show all : number of 1 is equal to or bigger than number of categories
// show none : number of 0 is equal to or bigger than number of categories
echo "<tr>
<td>
[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($uInfo)."&view=1111111'>".get_lang('ShowAll')."</a>]
[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($uInfo)."&view=0000000'>".get_lang('ShowNone')."</a>]".
//"||[<a href='".api_get_self()."'>".get_lang('BackToList')."</a>]".
"</td>
</tr>
";
if (!isset($view)) {
$view = '0000000';
}
//Logins
TrackingUserLog::display_login_tracking_info($view, $uInfo, $courseId);
//Exercise results
TrackingUserLog::display_exercise_tracking_info($view, $uInfo, $_cid);
//Student publications uploaded
TrackingUserLog::display_student_publications_tracking_info($view, $uInfo, $courseId);
//Links usage
TrackingUserLog::display_links_tracking_info($view, $uInfo, $_cid);
//Documents downloaded
TrackingUserLog::display_document_tracking_info($view, $uInfo, $_cid);
} else {
echo get_lang('ErrorUserNotInGroup');
}
/*
* Scorm contents and Learning Path
*/
if (substr($view, 5, 1) == '1') {
$new_view = substr_replace($view, '0', 5, 1);
echo "<tr>
<td valign='top'>
<font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ScormAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?view=".Security::remove_XSS($new_view)."&uInfo=".Security::remove_XSS($uInfo)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=000001'>".get_lang('ExportAsCSV')."</a>]
</td>
</tr>";
$sql = "SELECT id, name FROM $tbl_learnpath_main";
$result = Database::query($sql);
$ar = Database::fetch_array($result);
echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
echo "<table cellpadding='2' cellspacing='1' border='0' align='center'><tr>
<td class='secLine'>
&nbsp;".get_lang('ScormContentColumn')."&nbsp;
</td>
</tr>";
if (is_array($ar)) {
while ($ar['id'] != '') {
$lp_title = stripslashes($ar['name']);
echo "<tr><td>";
echo "<a href='".api_get_self()."?view=".$view."&scormcontopen=".$ar['id']."&uInfo=".Security::remove_XSS($uInfo)."' class='specialLink'>$lp_title</a>";
echo "</td></tr>";
if ($ar['id'] == $scormcontopen) {
//have to list the students here
$contentId = intval($ar['id']);
$sql3 = "SELECT iv.status, iv.score, i.title, iv.total_time ".
"FROM $tbl_learnpath_item i ".
"INNER JOIN $tbl_learnpath_item_view iv ON i.id=iv.lp_item_id ".
"INNER JOIN $tbl_learnpath_view v ON iv.lp_view_id=v.id ".
"WHERE (v.user_id=".intval($uInfo)." and v.lp_id=$contentId)
ORDER BY v.id, i.id";
$result3 = Database::query($sql3);
$ar3 = Database::fetch_array($result3);
if (is_array($ar3)) {
echo "<tr><td>&nbsp;&nbsp;&nbsp;</td>
<td class='secLine'>
&nbsp;".get_lang('ScormTitleColumn')."&nbsp;
</td>
<td class='secLine'>
&nbsp;".get_lang('ScormStatusColumn')."&nbsp;
</td>
<td class='secLine'>
&nbsp;".get_lang('ScormScoreColumn')."&nbsp;
</td>
<td class='secLine'>
&nbsp;".get_lang('ScormTimeColumn')."&nbsp;
</td>
</tr>";
while ($ar3['status'] != '') {
require_once '../lp/learnpathItem.class.php';
$time = learnpathItem::getScormTimeFromParameter('php', $ar3['total_time']);
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 "</tr>";
$ar3 = Database::fetch_array($result3);
}
} else {
echo "<tr>";
echo "<td colspan='3'><center>".get_lang('ScormNeverOpened')."</center></td>";
echo"</tr>";
}
}
$ar = Database::fetch_array($result);
}
} else {
$noscorm = true;
}
if ($noscorm) {
echo "<tr>";
echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
echo "</tr>";
}
echo "</table>";
echo "</td></tr>";
} else {
$new_view = substr_replace($view, '1', 5, 1);
echo "
<tr>
<td valign='top'>
+<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?view=".Security::remove_XSS($new_view)."&uInfo=".Security::remove_XSS($uInfo)."' class='specialLink'>".get_lang('ScormAccess')."</a>
</td>
</tr>
";
}
}
} else {
// not allowed
api_not_allowed();
}
?>
</table>
<?php
Display::display_footer();
Loading…
Cancel
Save