personnalLog.php 9.4 KB

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