personnalLog.php 11 KB

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