personnalLog.php 8.4 KB

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