dokeos-library
[ class tree: dokeos-library ] [ index: dokeos-library ] [ all elements ]

Source for file access_details.php

Documentation is available at access_details.php

  1. <?php
  2. // $Id:
  3. /*
  4. ==============================================================================
  5.     Dokeos - elearning and course management software
  6.  
  7.     Copyright (c) 2008 Furio Petrossi
  8.     Copyright (c) 2008 Dokeos SPRL
  9.  
  10.     For a full list of contributors, see "credits.txt".
  11.     The full license can be read in "license.txt".
  12.  
  13.     This program is free software; you can redistribute it and/or
  14.     modify it under the terms of the GNU General Public License
  15.     as published by the Free Software Foundation; either version 2
  16.     of the License, or (at your option) any later version.
  17.  
  18.     See the GNU General Public License for more details.
  19.  
  20.     Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
  21. ==============================================================================
  22. */
  23. /**
  24. ==============================================================================
  25. *    This is the tracking library for Dokeos.
  26. *    Include/require it in your code to use its functionality.
  27. *
  28. *    @package dokeos.library
  29. ==============================================================================
  30.  
  31.          *  Calculates the time spent on the course
  32.      * @param integer $user_id the user id
  33.      * @param string $course_code the course code
  34. *     Funzione scritta da Mario per testare cose
  35. */
  36. $language_file array ('registration''index''tracking');
  37. require_once('../inc/global.inc.php');
  38.  
  39. /**
  40.  * Gets the connections to a course as an array of login and logout time
  41.  */     
  42. function get_connections_to_course($user_id$course_code{
  43.     $course_code Database::escape_string($course_code);
  44.     
  45.     
  46.     $sql 'SELECT login_course_date, logout_course_date FROM ' $tbl_track_course 
  47.                     WHERE user_id = ' intval($user_id'
  48.                     AND course_code="' $course_code '"ORDER BY login_course_date';
  49.     
  50.     $rs api_sql_query($sql);
  51.     $connections  array();
  52.     
  53.     while ($a_connections Database::fetch_array($rs)) {
  54.     
  55.         $s_login_date $a_connections['login_course_date'];
  56.         $s_logout_date $a_connections['logout_course_date'];
  57.         
  58.         $i_timestamp_login_date strtotime($s_login_date);
  59.         $i_timestamp_logout_date strtotime($s_logout_date);
  60.         
  61.         $connections[array('login'=>$i_timestamp_login_date'logout'=>$i_timestamp_logout_date);
  62.         
  63.     }
  64.     
  65.     return $connections;
  66. }
  67.     
  68. /**
  69.  * Transforms seconds into a time format
  70.  */
  71. function calculHours($seconds)
  72. {
  73.     
  74.   //How many hours ?
  75.   $hours floor($seconds 3600);
  76.  
  77.   //How many minutes ?
  78.   $min floor(($seconds ($hours 3600)) 60);
  79.   if ($min 10)
  80.     $min '0'.$min;
  81.  
  82.   //How many seconds
  83.   $sec $seconds ($hours 3600($min 60);
  84.   if ($sec 10)
  85.     $sec '0'.$sec;
  86.  
  87.   return $hours.get_lang('HourShort').' '.$min.':'.$sec;
  88.  
  89. }
  90.  
  91. /* MAIN */
  92. //Print headers
  93. $nameToolsget_lang('AccessDetails');
  94. Display :: display_header($nameTools);
  95.  
  96. $user_id = (int)$_REQUEST['student'];
  97. $course_code=Database::escape_string($_REQUEST['course']);
  98.  
  99. $TBL_USERINFO_DEF         Database :: get_course_table(TABLE_USER_INFO);
  100. $mainUserInfo api_get_user_info($user_id$course_code);
  101. echo '<strong>',get_lang('User'),': ',$mainUserInfo['firstName'],' ',$mainUserInfo['lastName'],'</strong> <br />';
  102.  
  103. $connections get_connections_to_course($user_id$course_code);
  104. echo '<strong>'.get_lang('Course').': ',$course_code,' - ',$_course['name'],'</strong><br />';
  105. echo '<strong>',get_lang('DateAndTimeOfAccess'),' - ',get_lang('Duration'),'</strong><br />';
  106. /* Login time against logout time
  107. foreach ($connections as $key=>$data)
  108. {
  109.     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>"); 
  110. }
  111. */
  112. /*
  113. foreach ($connections as $key=>$data)
  114. {
  115.     echo ("<tr><td>".date("d-m-Y (H:i:s)",$data['login'])."</td><td>".calculHours($data['logout']-$data['login'])."</td></tr>"); 
  116. }
  117. echo ("</table>");
  118. */
  119. foreach ($connections as $key=>$data)
  120.     echo '&nbsp;&nbsp;'.date('d-m-Y (H:i:s)',$data['login']).' - '.calculHours($data['logout']-$data['login']).'<br />'."\n"
  121. }
  122. ?>

Documentation generated on Thu, 12 Jun 2008 12:53:20 -0500 by phpDocumentor 1.4.1