toolaccess_details.php 12 KB

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