personnalLog.php 11 KB

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