personnalLog.php 8.9 KB

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