personnalLog.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <?php
  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. /**
  20. ==============================================================================
  21. * @author Thomas Depraetere
  22. * @author Hugues Peeters
  23. * @author Christophe Gesche
  24. * @author Sebastien Piraux
  25. *
  26. * @package dokeos.tracking
  27. ==============================================================================
  28. */
  29. /*
  30. ==============================================================================
  31. INIT SECTION
  32. ==============================================================================
  33. */
  34. $langFile = "tracking";
  35. include('../inc/global.inc.php');
  36. $interbreadcrumb[]= array ("url"=>"../auth/profile.php", "name"=> get_lang('ModifyProfile'));
  37. $nameTools = get_lang('ToolName');
  38. $htmlHeadXtra[] = "<style type=\"text/css\">
  39. /*<![CDATA[*/
  40. .secLine {background-color : #E6E6E6;}
  41. .content {padding-left : 15px; padding-right : 15px;}
  42. .specialLink{color : #0000FF;}
  43. /*]]>*/
  44. </style>
  45. <style media='print' type='text/css'>
  46. /*<![CDATA[*/
  47. td {border-bottom: thin dashed gray;}
  48. /*]]>*/
  49. </style>";
  50. /*
  51. -----------------------------------------------------------
  52. Constants and variables
  53. -----------------------------------------------------------
  54. */
  55. $view = $_REQUEST['view'];
  56. // regroup table names for maintenance purpose
  57. $TABLECOURSUSER = Database::get_main_table(MAIN_COURSE_USER_TABLE);
  58. $TABLETRACK_ACCESS = $statsDbName."`.`track_e_access";
  59. $TABLETRACK_LINKS = $statsDbName."`.`track_e_links";
  60. $TABLETRACK_DOWNLOADS = $statsDbName."`.`track_e_downloads";
  61. $TABLETRACK_LOGIN = $statsDbName."`.`track_e_login";
  62. $TABLETRACK_EXERCICES = $statsDbName."`.`track_e_exercices";
  63. $limitOfDisplayedLogins = 25; // number of logins to display
  64. include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php");
  65. ////////////// OUTPUT //////////////////////
  66. Display::display_header($nameTools,"Tracking");
  67. api_display_tool_title($nameTools);
  68. /*
  69. ==============================================================================
  70. MAIN SECTION
  71. ==============================================================================
  72. */
  73. if ( $is_trackingEnabled )
  74. {
  75. // show all : view must be equal to the sum of all view values (1024+512+...+64)
  76. // show none : 0
  77. echo "
  78. <table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">
  79. <tr>
  80. <td class='minilink'>
  81. [<a href='".$_SERVER['PHP_SELF']."?view=1111111'>".get_lang('ShowAll')."</a>]
  82. [<a href='".$_SERVER['PHP_SELF']."?view=0000000'>".get_lang('ShowNone')."</a>]
  83. </td>
  84. </tr>
  85. ";
  86. if(!isset($view)) $view ="0000000";
  87. /***************************************************************************
  88. *
  89. * Logins
  90. *
  91. ***************************************************************************/
  92. $tempView = $view;
  93. if($tempView[0] == '1')
  94. {
  95. $tempView[0] = '0';
  96. echo "
  97. <tr>
  98. <td valign='top'>
  99. <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>
  100. <b>".get_lang('Logins')."</b>
  101. &nbsp;&nbsp;&nbsp;
  102. [<a href='".$_SERVER['PHP_SELF']."?view=".$tempView."'>".get_lang('Close')."</a>]
  103. </td>
  104. </tr>";
  105. $sql = "SELECT `login_date`
  106. FROM `".$TABLETRACK_LOGIN."`
  107. WHERE `login_user_id` = '".$_uid."'
  108. ORDER BY `login_date` DESC
  109. LIMIT ".$limitOfDisplayedLogins."";
  110. echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsExplaination')."<br/>";
  111. $results = getManyResults1Col($sql);
  112. echo "
  113. <table width='100%' cellpadding='2' cellspacing='1' border='0' align='center'>";
  114. if (is_array($results))
  115. {
  116. while ( list($key,$value) = each($results))
  117. {
  118. $timestamp = strtotime($value);
  119. //$beautifulDate = $langDay_of_weekNames['long'][date("w" , $timestamp)].date(" d " , $timestamp).$langMonthNames['long'][date("n", $timestamp)-1].date(" Y" , $timestamp);
  120. //$beautifulHour = date("H : i" , $timestamp);
  121. $beautifulDate = format_locale_date($dateTimeFormatLong,$timestamp);
  122. echo "
  123. <tr>
  124. <td class='secLine'>
  125. ".$beautifulDate."
  126. </td>
  127. </tr>";
  128. if(!isset($previousDate))
  129. {
  130. $sql = "SELECT NOW()";
  131. $previousDate = getOneResult($sql);
  132. }
  133. $sql = "SELECT `access_tool`, count(access_tool), `access_cours_code`
  134. FROM `".$TABLETRACK_ACCESS."`
  135. WHERE `access_user_id` = '".$_uid."'".
  136. //AND access_tool IS NOT NULL
  137. "AND access_date > '".$value."'
  138. AND access_date < '".$previousDate."'
  139. GROUP BY access_tool, access_cours_code
  140. ORDER BY access_cours_code ASC";
  141. $results2 = getManyResults3Col($sql);
  142. if (is_array($results2))
  143. {
  144. echo "
  145. <tr>
  146. <td colspan='2'>
  147. <table width='50%' cellpadding='0' cellspacing='0' border='0' >";
  148. $previousCourse = "???";
  149. for($j = 0 ; $j < count($results2) ; $j++)
  150. {
  151. // if course is different, write the name of the course
  152. if($results2[$j][2] != $previousCourse)
  153. {
  154. echo "
  155. <tr>
  156. <td colspan='2' width='100%' style='padding-left : 40px;'>
  157. ".$results2[$j][2]."
  158. </td>
  159. </tr>";
  160. }
  161. // if count != de 0 then display toolname et number of visits, else its a course visit
  162. if( $results2[$j][1] != 0 )
  163. {
  164. echo "<tr>";
  165. echo "<td width='70%' style='padding-left : 60px;'>".get_lang($results2[$j][0])."</td>";
  166. echo "<td width='30%' align='right'>".$results2[$j][1]." ".get_lang('Visits')."</td>";
  167. echo "</tr>";
  168. }
  169. $previousCourse = $results2[$j][2];
  170. }
  171. echo "</table>";
  172. echo "</td></tr>";
  173. }
  174. $previousDate = $value;
  175. }
  176. }
  177. else
  178. {
  179. echo "<tr>";
  180. echo "<td colspan='2' bgcolor='#eeeeee' align='center' >".get_lang('NoResult')."</td>";
  181. echo"</tr>";
  182. }
  183. echo "</table>";
  184. echo "</td></tr>";
  185. }
  186. else
  187. {
  188. $tempView[0] = '1';
  189. echo "
  190. <tr>
  191. <td valign='top'>
  192. +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".$_SERVER['PHP_SELF']."?view=".$tempView."' class='specialLink'>".get_lang('Logins')."</a>
  193. </td>
  194. </tr>
  195. ";
  196. }
  197. /***************************************************************************
  198. *
  199. * Exercices
  200. *
  201. ***************************************************************************/
  202. /*
  203. $tempView = $view;
  204. if($view[1] == '1')
  205. {
  206. $tempView[1] = '0';
  207. echo "
  208. <tr>
  209. <td valign='top'>
  210. <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".$_SERVER['PHP_SELF']."?view=".$tempView."'>".get_lang('Close')."</a>]
  211. </td>
  212. </tr>
  213. ";
  214. echo " Ceci est amen etre dplac vers la page de garde des exercices ";
  215. $sql = "SELECT `ce`.`title`, `te`.`exe_result` , `te`.`exe_weighting`, `te`.`exe_date`
  216. FROM `$TABLECOURSE_EXERCICES` AS ce , `$TABLETRACK_EXERCICES` AS te
  217. WHERE `te`.`exe_user_id` = '$_uid'
  218. AND `te`.`exe_exo_id` = `ce`.`id`
  219. ORDER BY `te`.`exe_cours_id` ASC, `ce`.`title` ASC, `te`.`exe_date`ASC";
  220. echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
  221. $results = getManyResultsXCol($sql,4);
  222. echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
  223. echo "<tr>
  224. <td class='secLine' width='60%'>
  225. ".get_lang('ExercicesTitleExerciceColumn')."
  226. </td>
  227. <td class='secLine' width='20%'>
  228. ".get_lang('Date')."
  229. </td>
  230. <td class='secLine' width='20%'>
  231. ".get_lang('ExercicesTitleScoreColumn')."
  232. </td>
  233. </tr>";
  234. if (is_array($results))
  235. {
  236. for($i = 0; $i < sizeof($results); $i++)
  237. {
  238. if( $results[$i][1] < ($results[$i][2]/2) )
  239. $scoreColor = "red";
  240. elseif( $results[$i][1] > ($results[$i][2]/100*60) )
  241. $scoreColor = "green";
  242. else
  243. $scoreColor = "#FF8C00";
  244. echo "<tr>";
  245. echo "<td class='content'>".$results[$i][0]."</td>";
  246. echo "<td class='content'>".$results[$i][3]."</td>";
  247. echo "<td valign='top' align='right' class='content'><font color=$scoreColor>".$results[$i][1]." / ".$results[$i][2]."</font></td>";
  248. echo"</tr>";
  249. }
  250. }
  251. else
  252. {
  253. echo "<tr>";
  254. echo "<td colspan='2' align='center'>".get_lang('NoResult')."</td>";
  255. echo"</tr>";
  256. }
  257. echo "</table>";
  258. echo "</td></tr>";
  259. }
  260. else
  261. {
  262. $tempView[1] = '1';
  263. echo "
  264. <tr>
  265. <td valign='top'>
  266. <font color='#0000FF'>+&nbsp;&nbsp;</font><a href='".$_SERVER['PHP_SELF']."?view=".$tempView."' class='specialLink'>".get_lang('ExercicesResults')."</a>
  267. </td>
  268. </tr>
  269. ";
  270. }
  271. */
  272. echo "\n</table>";
  273. }
  274. else
  275. {
  276. echo get_lang('TrackingDisabled');
  277. }
  278. Display::display_footer();
  279. ?>