personnalLog.php 9.4 KB

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