personnalLog.php 9.9 KB

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