Dokeos PHP Cross Reference Learning Management Systems

Source: /main/tracking/toolaccess_details.php - 312 lines - 12226 bytes - Summary - Text - Print

   1  <?php // $Id: toolaccess_details.php 20472 2009-05-11 10:02:06Z ivantcholakov $
   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  // TODO: Is this file deprecated?
  26  
  27  /**
  28  ==============================================================================
  29  *    @author Thomas Depraetere
  30  *    @author Hugues Peeters
  31  *    @author Christophe Gesche
  32  *    @author Sebastien Piraux
  33  *
  34  *    @package dokeos.tracking
  35  ==============================================================================
  36  */
  37  
  38  /*
  39  ==============================================================================
  40          INIT SECTION
  41  ==============================================================================
  42  */
  43  
  44  $tool = $_REQUEST['tool'];
  45  $period = $_REQUEST['period'];
  46  $reqDate = $_REQUEST['reqDate'];
  47  // name of the language file that needs to be included
  48  $language_file = "tracking";
  49  
  50  include ('../inc/global.inc.php');
  51  
  52  $nameTools = get_lang('ToolName');
  53  
  54  $interbreadcrumb[]= array ("url"=>"courseLog.php", "name"=> "Statistics");
  55  
  56  $htmlHeadXtra[] = "<style type='text/css'>
  57  /*<![CDATA[*/
  58  .mainLine {font-weight : bold;color : #FFFFFF;background-color : $colorDark;padding-left : 15px;padding-right : 15px;}
  59  .secLine {color : #000000;background-color : $666666;padding-left : 15px;padding-right : 15px;}
  60  .content {padding-left : 25px;}
  61  .specialLink{color : #0000FF;}
  62  .minilink{}
  63  .minitext{}
  64  /*]]>*/
  65  </style>
  66  <style media='print' type='text/css'>
  67  /*<![CDATA[*/
  68  td {border-bottom: thin dashed gray;}
  69  /*]]>*/
  70  </style>";
  71  Display::display_tool_header($nameTools,"Tracking");
  72  ?>
  73  
  74  <h3>
  75      <?php echo $nameTools; ?>
  76  </h3>
  77  
  78  <?php
  79  include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php");
  80  
  81  // the variables for the days and the months
  82  // Defining the shorts for the days
  83  $DaysShort = api_get_week_days_short();
  84  // Defining the days of the week to allow translation of the days
  85  $DaysLong = api_get_week_days_long();
  86  // Defining the months of the year to allow translation of the months
  87  $MonthsLong = api_get_months_long();
  88  // Defining the months of the year to allow translation of the months
  89  $MonthsShort = api_get_months_short();
  90  
  91  $tool=$_REQUEST['tool'];
  92  $period=$_REQUEST['period'];
  93  $reqdate=$_REQUEST['reqdate'];
  94  ?>
  95  <table width="100%" cellpadding="2" cellspacing="0" border="0">
  96  <?php
  97  
  98  
  99      $TABLETRACK_ACCESS = $_configuration['statistics_database']."`.`track_e_access";
 100  
 101      if(isset($_cid)) //stats for the current course
 102      {
 103          // to see stats of one course user must be courseAdmin of this course
 104          $is_allowedToTrack = $is_courseAdmin;
 105          $courseCodeEqualcidIfNeeded = "AND `access_cours_code` = '$_cid'";
 106      }
 107      else // stats for all courses
 108      {
 109          // to see stats of all courses user must be platformAdmin
 110          $is_allowedToTrack = $is_platformAdmin;
 111          $courseCodeEqualcidIfNeeded = "";
 112      }
 113      if( $is_allowedToTrack && $_configuration['tracking_enabled'])
 114      {
 115          // list of all tools
 116          if (!isset($tool))
 117          {
 118              $sql = "SELECT `access_tool`, count( access_tool )
 119                          FROM `$TABLETRACK_ACCESS`
 120                          WHERE `access_tool` IS NOT NULL
 121                              ".$courseCodeEqualcidIfNeeded."
 122                          GROUP BY `access_tool`";
 123              echo "<tr><td>";
 124              echo "<tr>
 125                      <td>
 126                      ";
 127              if(isset($_cid)) echo "<b>$_cid : </b>";
 128              echo "        <b>".get_lang('ToolList')."</b>
 129                      </td>
 130                  </tr>
 131              ";
 132  
 133              $results = getManyResults2Col($sql);
 134              echo "<table cellpadding='0' cellspacing='0' border='0' align=center>";
 135              echo "<tr bgcolor='#E6E6E6'>
 136                      <td width='70%'>
 137                      $langToolTitleToolnameColumn
 138                      </td>
 139                      <td width='30%'>
 140                      $langToolTitleCountColumn
 141                      </td>
 142                  </tr>";
 143              if (is_array($results))
 144              {
 145                  for($j = 0 ; $j < count($results) ; $j++)
 146                  {
 147                          echo "<tr>";
 148                          echo "<td><a href='toolaccess_details.php?tool=".urlencode($results[$j][0])."'>".get_lang($results[$j][0])."</a></td>";
 149                          echo "<td align='right'>".$results[$j][1]."</td>";
 150                          echo"</tr>";
 151                  }
 152  
 153              }
 154              else
 155              {
 156                  echo "<tr>";
 157                  echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
 158                  echo"</tr>";
 159              }
 160              echo "</table></td></tr>";
 161          }
 162          else
 163          {
 164              // this can prevent bug if there is special chars in $tool
 165              $encodedTool = urlencode($tool);
 166              $tool = urldecode($tool);
 167  
 168              if( !isset($reqdate) )
 169                  $reqdate = time();
 170              echo "<tr>
 171                      <td>
 172                      ";
 173              if(isset($_cid)) echo "<b>$_cid : </b>";
 174              echo "        <b>".get_lang($tool)."</b>
 175                      </td>
 176                  </tr>
 177              ";
 178  
 179              /* ------ display ------ */
 180              // displayed period
 181              echo "<tr><td>";
 182              switch($period)
 183              {
 184                  case "month" :
 185                      echo $MonthsLong[date("n", $reqdate)-1].date(" Y", $reqdate);
 186                      break;
 187                  case "week" :
 188                      $weeklowreqdate = ($reqdate-(86400*date("w" , $reqdate)));
 189                      $weekhighreqdate = ($reqdate+(86400*(6-date("w" , $reqdate)) ));
 190                      echo "<b>".$langFrom."</b> ".date("d " , $weeklowreqdate).$MonthsLong[date("n", $weeklowreqdate)-1].date(" Y" , $weeklowreqdate);
 191                      echo " <b>".$langTo."</b> ".date("d " , $weekhighreqdate ).$MonthsLong[date("n", $weekhighreqdate)-1].date(" Y" , $weekhighreqdate);
 192                      break;
 193                  // default == day
 194                  default :
 195                      $period = "day";
 196                  case "day" :
 197                      echo $DaysLong[date("w" , $reqdate)].date(" d " , $reqdate).$MonthsLong[date("n", $reqdate)-1].date(" Y" , $reqdate);
 198                      break;
 199              }
 200              echo "</tr></td>";
 201              // periode choice
 202              echo "<tr>
 203                      <td>
 204                      <small>
 205                      [<a href='".api_get_self()."?tool=$encodedTool&period=day&reqdate=$reqdate' class='specialLink'>$langPeriodDay</a>]
 206                      [<a href='".api_get_self()."?tool=$encodedTool&period=week&reqdate=$reqdate' class='specialLink'>$langPeriodWeek</a>]
 207                      [<a href='".api_get_self()."?tool=$encodedTool&period=month&reqdate=$reqdate' class='specialLink'>$langPeriodMonth</a>]
 208                      &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;
 209  
 210                      ";
 211              switch($period)
 212              {
 213                  case "month" :
 214                      // previous and next date must be evaluated
 215                      // 30 days should be a good approximation
 216                      $previousReqDate = mktime(1,1,1,date("m",$reqdate)-1,1,date("Y",$reqdate));
 217                      $nextReqDate = mktime(1,1,1,date("m",$reqdate)+1,1,date("Y",$reqdate));
 218                      echo   "
 219                          [<a href='".api_get_self()."?tool=$encodedTool&period=month&reqdate=$previousReqDate' class='specialLink'>$langPreviousMonth</a>]
 220                          [<a href='".api_get_self()."?tool=$encodedTool&period=month&reqdate=$nextReqDate' class='specialLink'>$langNextMonth</a>]
 221                      ";
 222                      break;
 223                  case "week" :
 224                      // previous and next date must be evaluated
 225                      $previousReqDate = $reqdate - 7*86400;
 226                      $nextReqDate = $reqdate + 7*86400;
 227                      echo   "
 228                          [<a href='".api_get_self()."?tool=$encodedTool&period=week&reqdate=$previousReqDate' class='specialLink'>$langPreviousWeek</a>]
 229                          [<a href='".api_get_self()."?tool=$encodedTool&period=week&reqdate=$nextReqDate' class='specialLink'>$langNextWeek</a>]
 230                      ";
 231                      break;
 232                  case "day" :
 233                      // previous and next date must be evaluated
 234                      $previousReqDate = $reqdate - 86400;
 235                      $nextReqDate = $reqdate + 86400;
 236                      echo   "
 237                          [<a href='".api_get_self()."?tool=$encodedTool&period=day&reqdate=$previousReqDate' class='specialLink'>$langPreviousDay</a>]
 238                          [<a href='".api_get_self()."?tool=$encodedTool&period=day&reqdate=$nextReqDate' class='specialLink'>$langNextDay</a>]
 239                      ";
 240                      break;
 241              }
 242  
 243              echo"   &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;
 244                      [<a href='".api_get_self()."' class='specialLink'>$langViewToolList</a>]
 245                      </small>
 246                      </td>
 247                  </tr>
 248              ";
 249              // display information about this period
 250              switch($period)
 251              {
 252                  // all days
 253                  case "month" :
 254                      $sql = "SELECT UNIX_TIMESTAMP(`access_date`)
 255                              FROM `$TABLETRACK_ACCESS`
 256                              WHERE `access_tool` = '$tool'
 257                                  ".$courseCodeEqualcidIfNeeded."
 258                                  AND MONTH(`access_date`) = MONTH(FROM_UNIXTIME('$reqdate'))
 259                                  AND YEAR(`access_date`) = YEAR(FROM_UNIXTIME('$reqdate'))
 260                                  ORDER BY `access_date` ASC";
 261  
 262                      $days_array = daysTab($sql);
 263                      makeHitsTable($days_array,$langDay);
 264                      break;
 265                  // all days
 266                  case "week" :
 267                      $sql = "SELECT UNIX_TIMESTAMP(`access_date`)
 268                              FROM `$TABLETRACK_ACCESS`
 269                              WHERE `access_tool` = '$tool'
 270                                  ".$courseCodeEqualcidIfNeeded."
 271                                  AND WEEK(`access_date`) = WEEK(FROM_UNIXTIME('$reqdate'))
 272                                  AND YEAR(`access_date`) = YEAR(FROM_UNIXTIME('$reqdate'))
 273                                  ORDER BY `access_date` ASC";
 274  
 275                      $days_array = daysTab($sql);
 276                      makeHitsTable($days_array,$langDay);
 277                      break;
 278                  // all hours
 279                  case "day"  :
 280                      $sql = "SELECT UNIX_TIMESTAMP(`access_date`)
 281                                  FROM `$TABLETRACK_ACCESS`
 282                                  WHERE `access_tool` = '$tool'
 283                                      ".$courseCodeEqualcidIfNeeded."
 284                                      AND DAYOFYEAR(`access_date`) = DAYOFYEAR(FROM_UNIXTIME('$reqdate'))
 285                                      AND YEAR(`access_date`) = YEAR(FROM_UNIXTIME('$reqdate'))
 286                                  ORDER BY `access_date` ASC";
 287  
 288                      $hours_array = hoursTab($sql,$reqdate);
 289                      makeHitsTable($hours_array,$langHour);
 290                      break;
 291              }
 292          }
 293      }
 294      else // not allowed to track
 295      {
 296          if(!$_configuration['tracking_enabled'])
 297          {
 298              echo $langTrackingDisabled;
 299          }
 300          else
 301          {
 302              echo get_lang('NotAllowed');
 303          }
 304      }
 305  
 306  
 307  ?>
 308  </table>
 309  <?php
 310  // footer
 311  Display::display_footer();
 312  ?>

title

Description

title

Description

title

Description

title

title

Body