Dokeos PHP Cross Reference Learning Management Systems

Source: /main/tracking/course_access_details.php - 256 lines - 10618 bytes - Summary - Text - Print

   1  <?php
   2  /*
   3  ==============================================================================
   4      Dokeos - elearning and course management software
   5  
   6      Copyright (c) 2004 Dokeos S.A.
   7      Copyright (c) 2003 Ghent University (UGent)
   8      Copyright (c) 2001 Universite catholique de Louvain (UCL)
   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 address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  21      Mail: info@dokeos.com
  22  ==============================================================================
  23  */
  24  /**
  25  ==============================================================================
  26  *    @author Thomas Depraetere
  27  *    @author Hugues Peeters
  28  *    @author Christophe Gesche
  29  *    @author Sebastien Piraux
  30  *
  31  *    @package dokeos.tracking
  32  ==============================================================================
  33  */
  34  
  35  // TODO: Is this file deprecated?
  36  
  37  /*
  38  ==============================================================================
  39          INIT SECTION
  40  ==============================================================================
  41  */
  42  $reqdate = $_REQUEST['reqdate'];
  43  $period = $_REQUEST['period'];
  44  $displayType = $_REQUEST['displayType'];
  45  // name of the language file that needs to be included
  46  $language_file = "tracking";
  47  include ('../inc/global.inc.php');
  48  
  49  $interbreadcrumb[]= array ("url"=>"courseLog.php", "name"=> get_lang('ToolName'));
  50  
  51  $nameTools = get_lang('TrafficDetails');
  52  
  53  $htmlHeadXtra[] = "<style type='text/css'>
  54  /*<![CDATA[*/
  55  .secLine {background-color : #E6E6E6;}
  56  .content {padding-left : 15px;padding-right : 15px; }
  57  .specialLink{color : #0000FF;}
  58  /*]]>*/
  59  </style>
  60  <style media='print' type='text/css'>
  61  /*<![CDATA[*/
  62  td {border-bottom: thin dashed gray;}
  63  /*]]>*/
  64  </style>";
  65  //@todo use Database library
  66  $TABLETRACK_ACCESS = $_configuration['statistics_database']."`.`track_e_access";
  67  Display::display_tool_header($nameTools,"Tracking");
  68  include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php");
  69  
  70  // the variables for the days and the months
  71  // Defining the shorts for the days
  72  $DaysShort = api_get_week_days_short();
  73  // Defining the days of the week to allow translation of the days
  74  $DaysLong = api_get_week_days_long();
  75  // Defining the months of the year to allow translation of the months
  76  $MonthsLong = api_get_months_long();
  77  
  78  $is_allowedToTrack = $is_courseAdmin;
  79  
  80  ?>
  81  <h3>
  82      <?php echo $nameTools ?>
  83  </h3>
  84  <table width="100%" cellpadding="2" cellspacing="3" border="0">
  85  <?php
  86      if( $is_allowedToTrack && $_configuration['tracking_enabled'])
  87      {
  88          if( !isset($reqdate) || $reqdate < 0 || $reqdate > 2149372861 )
  89                  $reqdate = time();
  90          //** dislayed period
  91          echo "<tr><td><b>";
  92              switch($period)
  93              {
  94                  case "year" :
  95                      echo date(" Y", $reqdate);
  96                      break;
  97                  case "month" :
  98                      echo $MonthsLong[date("n", $reqdate)-1].date(" Y", $reqdate);
  99                      break;
 100                  // default == day
 101                  default :
 102                      $period = "day";
 103                  case "day" :
 104                      echo $DaysLong[date("w" , $reqdate)].date(" d " , $reqdate).$MonthsLong[date("n", $reqdate)-1].date(" Y" , $reqdate);
 105                      break;
 106              }
 107          echo "</b></tr></td>";
 108          //** menu
 109          echo "<tr>
 110                  <td>
 111          ";
 112          echo "  ".get_lang('PeriodToDisplay')." : [<a href='".api_get_self()."?period=year&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodYear')."</a>]
 113                  [<a href='".api_get_self()."?period=month&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodMonth')."</a>]
 114                  [<a href='".api_get_self()."?period=day&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodDay')."</a>]
 115                  &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;
 116                  ".get_lang('DetailView')." :
 117          ";
 118          switch($period)
 119          {
 120              case "year" :
 121                      //-- if period is "year" display can be by month, day or hour
 122                      echo "  [<a href='".api_get_self()."?period=$period&reqdate=$reqdate&displayType=month' class='specialLink'>".get_lang('PeriodMonth')."</a>]";
 123              case "month" :
 124                      //-- if period is "month" display can be by day or hour
 125                      echo "  [<a href='".api_get_self()."?period=$period&reqdate=$reqdate&displayType=day' class='specialLink'>".get_lang('PeriodDay')."</a>]";
 126              case "day" :
 127                      //-- if period is "day" display can only be by hour
 128                      echo "  [<a href='".api_get_self()."?period=$period&reqdate=$reqdate&displayType=hour' class='specialLink'>".get_lang('PeriodHour')."</a>]";
 129                      break;
 130          }
 131  
 132          echo "&nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;";
 133  
 134          switch($period)
 135          {
 136              case "year" :
 137                  // previous and next date must be evaluated
 138                  // 30 days should be a good approximation
 139                  $previousReqDate = mktime(1,1,1,1,1,date("Y",$reqdate)-1);
 140                  $nextReqDate = mktime(1,1,1,1,1,date("Y",$reqdate)+1);
 141                  echo   "
 142                      [<a href='".api_get_self()."?period=$period&reqdate=$previousReqDate&displayType=$displayType' class='specialLink'>".get_lang('PreviousYear')."</a>]
 143                      [<a href='".api_get_self()."?period=$period&reqdate=$nextReqDate&displayType=$displayType' class='specialLink'>".get_lang('NextYear')."</a>]
 144                  ";
 145                  break;
 146              case "month" :
 147                  // previous and next date must be evaluated
 148                  // 30 days should be a good approximation
 149                  $previousReqDate = mktime(1,1,1,date("m",$reqdate)-1,1,date("Y",$reqdate));
 150                  $nextReqDate = mktime(1,1,1,date("m",$reqdate)+1,1,date("Y",$reqdate));
 151                  echo   "
 152                      [<a href='".api_get_self()."?period=$period&reqdate=$previousReqDate&displayType=$displayType' class='specialLink'>".get_lang('PreviousMonth')."</a>]
 153                      [<a href='".api_get_self()."?period=$period&reqdate=$nextReqDate&displayType=$displayType' class='specialLink'>".get_lang('NextMonth')."</a>]
 154                  ";
 155                  break;
 156              case "day" :
 157                  // previous and next date must be evaluated
 158                  $previousReqDate = $reqdate - 86400;
 159                  $nextReqDate = $reqdate + 86400;
 160                  echo   "
 161                      [<a href='".api_get_self()."?period=$period&reqdate=$previousReqDate&displayType=$displayType' class='specialLink'>".get_lang('PreviousDay')."</a>]
 162                      [<a href='".api_get_self()."?period=$period&reqdate=$nextReqDate&displayType=$displayType' class='specialLink'>".get_lang('NextDay')."</a>]
 163                  ";
 164                  break;
 165          }
 166          echo "
 167                  </td>
 168                </tr>
 169          ";
 170          //**
 171          // display information about this period
 172          switch($period)
 173          {
 174              // all days
 175              case "year" :
 176                  $sql = "SELECT UNIX_TIMESTAMP( `access_date` )
 177                              FROM `$TABLETRACK_ACCESS`
 178                              WHERE YEAR( `access_date` ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
 179                              AND `access_cours_code` = '$_cid'
 180                              AND `access_tool` IS NULL ";
 181                  if($displayType == "month")
 182                  {
 183                      $sql .= "ORDER BY UNIX_TIMESTAMP( `access_date`)";
 184                      $month_array = monthTab($sql);
 185                      makeHitsTable($month_array,get_lang('PeriodMonth'));
 186                  }
 187                  elseif($displayType == "day")
 188                  {
 189                      $sql .= "ORDER BY DAYOFYEAR( `access_date`)";
 190                      $days_array = daysTab($sql);
 191                      makeHitsTable($days_array,get_lang('PeriodDay'));
 192                  }
 193                  else // by hours by default
 194                  {
 195                      $sql .= "ORDER BY HOUR( `access_date`)";
 196                      $hours_array = hoursTab($sql);
 197                      makeHitsTable($hours_array,get_lang('PeriodHour'));
 198                  }
 199                  break;
 200              // all days
 201              case "month" :
 202                  $sql = "SELECT UNIX_TIMESTAMP( `access_date` )
 203                              FROM `$TABLETRACK_ACCESS`
 204                              WHERE MONTH(`access_date`) = MONTH (FROM_UNIXTIME( '$reqdate' ) )
 205                              AND YEAR( `access_date` ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
 206                              AND `access_cours_code` = '$_cid'
 207                              AND `access_tool` IS NULL ";
 208                  if($displayType == "day")
 209                  {
 210                      $sql .= "ORDER BY DAYOFYEAR( `access_date`)";
 211                      $days_array = daysTab($sql);
 212                      makeHitsTable($days_array,get_lang('PeriodDay'));
 213                  }
 214                  else // by hours by default
 215                  {
 216                      $sql .= "ORDER BY HOUR( `access_date`)";
 217                      $hours_array = hoursTab($sql);
 218                      makeHitsTable($hours_array,get_lang('PeriodHour'));
 219                  }
 220                  break;
 221              // all hours
 222              case "day"  :
 223                  $sql = "SELECT UNIX_TIMESTAMP( `access_date` )
 224                              FROM `$TABLETRACK_ACCESS`
 225                              WHERE DAYOFMONTH(`access_date`) = DAYOFMONTH(FROM_UNIXTIME( '$reqdate' ) )
 226                              AND MONTH(`access_date`) = MONTH (FROM_UNIXTIME( '$reqdate' ) )
 227                              AND YEAR( `access_date` ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
 228                              AND `access_cours_code` = '$_cid'
 229                              AND `access_tool` IS NULL
 230                              ORDER BY HOUR( `access_date` )";
 231                  $hours_array = hoursTab($sql,$reqdate);
 232                  makeHitsTable($hours_array,get_lang('PeriodHour'));
 233                  break;
 234          }
 235      }
 236      else // not allowed to track
 237      {
 238          if(!$_configuration['tracking_enabled'])
 239          {
 240              echo get_lang('TrackingDisabled');
 241          }
 242          else
 243          {
 244              api_not_allowed();
 245          }
 246      }
 247  
 248  
 249  
 250  ?>
 251  
 252  </table>
 253  
 254  <?php
 255  Display::display_footer();
 256  ?>

title

Description

title

Description

title

Description

title

title

Body