personnalLog.php 8.3 KB

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