[svn r15494] Added access details page submitted by Furio Petrossi

skala
Yannick Warnier 17 years ago
parent f5356fea30
commit 280ebbdc69
  1. 125
      main/mySpace/access_details.php
  2. 16
      main/mySpace/myStudents.php

@ -0,0 +1,125 @@
<?php
// $Id:
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2008 Furio Petrossi
Copyright (c) 2008 Dokeos SPRL
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* This is the tracking library for Dokeos.
* Include/require it in your code to use its functionality.
*
* @package dokeos.library
==============================================================================
* Calculates the time spent on the course
* @param integer $user_id the user id
* @param string $course_code the course code
* Funzione scritta da Mario per testare cose
*/
$language_file = array ('registration', 'index', 'tracking');
require_once('../inc/global.inc.php');
/**
* Gets the connections to a course as an array of login and logout time
*/
function get_connections_to_course($user_id, $course_code) {
$course_code = Database::escape_string($course_code);
$tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . '
WHERE user_id = ' . intval($user_id) . '
AND course_code="' . $course_code . '"ORDER BY login_course_date';
$rs = api_sql_query($sql);
$connections = array();
while ($a_connections = Database::fetch_array($rs)) {
$s_login_date = $a_connections['login_course_date'];
$s_logout_date = $a_connections['logout_course_date'];
$i_timestamp_login_date = strtotime($s_login_date);
$i_timestamp_logout_date = strtotime($s_logout_date);
$connections[] = array('login'=>$i_timestamp_login_date, 'logout'=>$i_timestamp_logout_date);
}
return $connections;
}
/**
* Transforms seconds into a time format
*/
function calculHours($seconds)
{
//How many hours ?
$hours = floor($seconds / 3600);
//How many minutes ?
$min = floor(($seconds - ($hours * 3600)) / 60);
if ($min < 10)
$min = '0'.$min;
//How many seconds
$sec = $seconds - ($hours * 3600) - ($min * 60);
if ($sec < 10)
$sec = '0'.$sec;
return $hours.get_lang('HourShort').' '.$min.':'.$sec;
}
/* MAIN */
//Print headers
$nameTools= get_lang('AccessDetails');
Display :: display_header($nameTools);
$user_id = (int)$_REQUEST['student'];
$course_code=Database::escape_string($_REQUEST['course']);
$TBL_USERINFO_DEF = Database :: get_course_table(TABLE_USER_INFO);
$mainUserInfo = api_get_user_info($user_id, $course_code);
echo '<strong>',get_lang('User'),': ',$mainUserInfo['firstName'],' ',$mainUserInfo['lastName'],'</strong> <br />';
$connections = get_connections_to_course($user_id, $course_code);
echo '<strong>'.get_lang('Course').': ',$course_code,' - ',$_course['name'],'</strong><br />';
echo '<strong>',get_lang('DateAndTimeOfAccess'),' - ',get_lang('Duration'),'</strong><br />';
/* Login time against logout time
foreach ($connections as $key=>$data)
{
echo ("<tr><td>".date("d-m-Y (H:i:s)",$data['login'])."</td><td>".date("d-m-Y (H:i:s)",$data['logout'])."</td></tr>");
}
*/
/*
foreach ($connections as $key=>$data)
{
echo ("<tr><td>".date("d-m-Y (H:i:s)",$data['login'])."</td><td>".calculHours($data['logout']-$data['login'])."</td></tr>");
}
echo ("</table>");
*/
foreach ($connections as $key=>$data)
{
echo '&nbsp;&nbsp;'.date('d-m-Y (H:i:s)',$data['login']).' - '.calculHours($data['logout']-$data['login']).'<br />'."\n";
}
Display:: display_footer();
?>

@ -1,4 +1,4 @@
<?php //$Id: myStudents.php 15252 2008-05-08 21:51:28Z yannoo $
<?php //$Id: myStudents.php 15494 2008-05-29 22:26:36Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
@ -174,11 +174,11 @@ $course_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATI
if(isset($_GET["user_id"]) && $_GET["user_id"]!="")
{
$i_user_id=$_GET["user_id"];
$i_user_id=(int)$_GET["user_id"];
}
else
{
$i_user_id = $_user['user_id'];
$i_user_id =$_user['user_id'];
}
if(!empty($_GET['student']))
@ -432,6 +432,16 @@ if(!empty($_GET['student']))
?>
</tr>
<?php
if(!empty($_GET['student']) && !empty($_GET['course']))
{ //only show link to connection details if course and student were defined in the URL
echo '<tr>';
echo '<td class="noLink none">';
echo '<img align="absbottom" src="../img/statistics.gif">&nbsp; <strong> <a href="access_details.php?student='.$_GET['student'].'&course='.$_GET['course'].'">'.get_lang('AccessDetails').'</a> </strong>';
echo '</td>';
echo '</tr>';
}
?>
</table>
</td>
</tr>

Loading…
Cancel
Save