userLog.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. <?php // $Id: userLog.php 21626 2009-06-26 12:19:41Z pcool $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2009 Dokeos SPRL
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Roan Embrechts (Vrije Universiteit Brussel)
  9. Copyright (c) Sebastien Piraux <piraux_seb@hotmail.com>
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  18. ==============================================================================
  19. */
  20. // TODO: Is this file deprecated?
  21. /**
  22. ==============================================================================
  23. * @package dokeos.tracking
  24. * @todo clean code - structure is unclear and difficult to modify
  25. ==============================================================================
  26. */
  27. /*
  28. ==============================================================================
  29. INIT SECTION
  30. ==============================================================================
  31. */
  32. $uInfo = $_REQUEST['uInfo'];
  33. $view = $_REQUEST['view'];
  34. // name of the language file that needs to be included
  35. $language_file = 'tracking';
  36. // including the global Dokeos file
  37. include('../inc/global.inc.php');
  38. // the section (for the tabs)
  39. $this_section = "session_my_space";
  40. // variables
  41. $user_id = api_get_user_id();
  42. $course_id = api_get_course_id();
  43. //YW Hack security to quick fix RolesRights bug
  44. $is_allowed = true;
  45. /*
  46. -----------------------------------------------------------
  47. Libraries
  48. -----------------------------------------------------------
  49. */
  50. include(api_get_path(LIBRARY_PATH).'statsUtils.lib.inc.php');
  51. include(api_get_path(LIBRARY_PATH).'course.lib.php');
  52. include(api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php');
  53. require_once(api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php');
  54. /*
  55. -----------------------------------------------------------
  56. Header
  57. -----------------------------------------------------------
  58. */
  59. // charset determination
  60. if (isset($_GET['scormcontopen'])) {
  61. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  62. $contopen = Database::escape_string($_GET['scormcontopen']);
  63. if (is_numeric($contopen)) {
  64. $contopen = intval($contopen);
  65. $sql = "SELECT default_encoding FROM $tbl_lp WHERE id = ".$contopen;
  66. $res = Database::query($sql,__FILE__,__LINE__);
  67. $row = Database::fetch_array($res);
  68. $lp_charset = $row['default_encoding'];
  69. }
  70. //header('Content-Type: text/html; charset='. $row['default_encoding']);
  71. }
  72. /*
  73. $interbreadcrumb[]= array ("url"=>"../group/group.php", "name"=> get_lang('BredCrumpGroups'));
  74. $interbreadcrumb[]= array ("url"=>"../group/group_space.php?gidReq=$_gid", "name"=> get_lang('BredCrumpGroupSpace'));
  75. */
  76. if(isset($uInfo)) {
  77. $interbreadcrumb[]= array ('url'=>'../user/userInfo.php?uInfo='.Security::remove_XSS($uInfo), "name"=> api_ucfirst(get_lang('Users')));
  78. }
  79. $nameTools = get_lang('ToolName');
  80. $htmlHeadXtra[] = "<style type='text/css'>
  81. /*<![CDATA[*/
  82. .secLine {background-color : #E6E6E6;}
  83. .content {padding-left : 15px;padding-right : 15px; }
  84. .specialLink{color : #0000FF;}
  85. /*]]>*/
  86. </style>
  87. <style media='print' type='text/css'>
  88. /*<![CDATA[*/
  89. td {border-bottom: thin dashed gray;}
  90. /*]]>*/
  91. </style>";
  92. Display::display_header($nameTools,"Tracking");
  93. /*
  94. -----------------------------------------------------------
  95. Constants and variables
  96. -----------------------------------------------------------
  97. */
  98. $is_allowedToTrack = $is_courseAdmin;
  99. $is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course($user_id, $course_id);
  100. // Database Table Definitions
  101. $TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  102. $TABLEUSER = Database::get_main_table(TABLE_MAIN_USER);
  103. $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  104. $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
  105. $TABLETRACK_ACCESS = $_configuration['statistics_database']."`.`track_e_access";
  106. $TABLETRACK_LINKS = $_configuration['statistics_database']."`.`track_e_links";
  107. $TABLETRACK_LOGIN = $_configuration['statistics_database']."`.`track_e_login";
  108. $TABLETRACK_DOWNLOADS = $_configuration['statistics_database']."`.`track_e_downloads";
  109. $TABLETRACK_UPLOADS = $_configuration['statistics_database']."`.`track_e_uploads";
  110. $TABLETRACK_EXERCICES = $_configuration['statistics_database']."`.`track_e_exercices";
  111. $TABLECOURSE_LINKS = Database::get_course_table(TABLE_LINK);
  112. $TABLECOURSE_WORK = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
  113. $TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER);
  114. $TABLECOURSE_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
  115. $TBL_TRACK_HOTPOTATOES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
  116. if(api_get_setting('use_session_mode') == "true") {
  117. $sql = "SELECT 1
  118. FROM $tbl_session_course_user AS session_course_user
  119. INNER JOIN $tbl_session AS session
  120. ON session_course_user.id_session = session.id
  121. AND ((date_start<=NOW()
  122. AND date_end>=NOW())
  123. OR (date_start='0000-00-00' AND date_end='0000-00-00'))
  124. WHERE id_session='".$_SESSION['id_session']."' AND course_code='$_cid'";
  125. //echo $sql;
  126. $result=Database::query($sql,__FILE__,__LINE__);
  127. if(!Database::num_rows($result)){
  128. $disabled = true;
  129. }
  130. }
  131. $tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN);
  132. $tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
  133. $tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
  134. $tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
  135. $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  136. // The variables for the days and the months
  137. $DaysShort = api_get_week_days_short();
  138. $DaysLong = api_get_week_days_long();
  139. $MonthsLong = api_get_months_long();
  140. $MonthsShort = api_get_months_short();
  141. //$is_allowedToTrack = $is_groupTutor; // allowed to track only user of one group
  142. //$is_allowedToTrackEverybodyInCourse = $is_allowed[EDIT_RIGHT]; // allowed to track all students in course
  143. //YW hack security to fix RolesRights bug
  144. $is_allowedToTrack = true; // allowed to track only user of one group
  145. $is_allowedToTrackEverybodyInCourse = $is_allowedToTrack; // allowed to track all students in course
  146. /*
  147. ==============================================================================
  148. FUNCTIONS
  149. ==============================================================================
  150. */
  151. /**
  152. * Displays the number of logins every month for a specific user in a specific course.
  153. */
  154. function display_login_tracking_info($view, $user_id, $course_id)
  155. {
  156. $MonthsLong = $GLOBALS['MonthsLong'];
  157. $track_access_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
  158. $tempView = $view;
  159. if(substr($view,0,1) == '1') {
  160. $new_view = substr_replace($view,'0',0,1);
  161. echo "
  162. <tr>
  163. <td valign='top'>
  164. <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
  165. "<b>".get_lang('LoginsAndAccessTools')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=10000'>".get_lang('ExportAsCSV')."</a>]
  166. </td>
  167. </tr>
  168. ";
  169. echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
  170. $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
  171. FROM $track_access_table
  172. WHERE access_user_id = '".Database::escape_string($user_id)."'
  173. AND access_cours_code = '".Database::escape_string($course_id)."'
  174. GROUP BY YEAR(access_date),MONTH(access_date)
  175. ORDER BY YEAR(access_date),MONTH(access_date) ASC";
  176. echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
  177. //$results = getManyResults2Col($sql);
  178. $results = getManyResults3Col($sql);
  179. echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
  180. echo "<tr>
  181. <td class='secLine'>
  182. ".get_lang('LoginsTitleMonthColumn')."
  183. </td>
  184. <td class='secLine'>
  185. ".get_lang('LoginsTitleCountColumn')."
  186. </td>
  187. </tr>";
  188. $total = 0;
  189. if (is_array($results)) {
  190. for($j = 0 ; $j < count($results) ; $j++) {
  191. echo "<tr>";
  192. //echo "<td class='content'><a href='logins_details.php?uInfo=$user_id&reqdate=".$results[$j][0]."'>".$langMonthNames['long'][date("n", $results[$j][0])-1]." ".date("Y", $results[$j][0])."</a></td>";
  193. echo "<td class='content'><a href='logins_details.php?uInfo=".Security::remove_XSS($user_id)."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
  194. echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
  195. echo"</tr>";
  196. $total = $total + $results[$j][1];
  197. }
  198. echo "<tr>";
  199. echo "<td>".get_lang('Total')."</td>";
  200. echo "<td align='right' class='content'>".$total."</td>";
  201. echo"</tr>";
  202. } else {
  203. echo "<tr>";
  204. echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
  205. echo"</tr>";
  206. }
  207. echo "</table>";
  208. echo "</td></tr>";
  209. } else {
  210. $new_view = substr_replace($view,'1',0,1);
  211. echo "
  212. <tr>
  213. <td valign='top'>
  214. +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LoginsAndAccessTools')."</a>
  215. </td>
  216. </tr>
  217. ";
  218. }
  219. }
  220. /**
  221. * Displays the exercise results for a specific user in a specific course.
  222. * @todo remove globals
  223. */
  224. function display_exercise_tracking_info($view, $user_id, $course_id)
  225. {
  226. global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES;
  227. if(substr($view,1,1) == '1')
  228. {
  229. $new_view = substr_replace($view,'0',1,1);
  230. echo "<tr>
  231. <td valign='top'>
  232. <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>]
  233. </td>
  234. </tr>";
  235. echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
  236. $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
  237. FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
  238. WHERE te.exe_cours_id = '".Database::escape_string($course_id)."'
  239. AND te.exe_user_id = '".Database::escape_string($user_id)."'
  240. AND te.exe_exo_id = ce.id
  241. ORDER BY ce.title ASC, te.exe_date ASC";
  242. $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
  243. FROM $TBL_TRACK_HOTPOTATOES AS te
  244. WHERE te.exe_user_id = '".Database::escape_string($user_id)."' AND te.exe_cours_id = '".Database::escape_string($course_id)."'
  245. ORDER BY te.exe_cours_id ASC, te.exe_date ASC";
  246. $hpresults = getManyResultsXCol($hpsql, 4);
  247. $NoTestRes = 0;
  248. $NoHPTestRes = 0;
  249. echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
  250. $results = getManyResultsXCol($sql, 4);
  251. echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
  252. echo "
  253. <tr bgcolor='#E6E6E6'>
  254. <td>
  255. ".get_lang('ExercicesTitleExerciceColumn')."
  256. </td>
  257. <td>
  258. ".get_lang('Date')."
  259. </td>
  260. <td>
  261. ".get_lang('ExercicesTitleScoreColumn')."
  262. </td>
  263. </tr>";
  264. if (is_array($results)) {
  265. for($i = 0; $i < sizeof($results); $i++) {
  266. $display_date = format_locale_date(get_lang('dateTimeFormatLong'), $results[$i][3]);
  267. echo "<tr>\n";
  268. echo "<td class='content'>".$results[$i][0]."</td>\n";
  269. echo "<td class='content'>".$display_date."</td>\n";
  270. echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
  271. echo "</tr>\n";
  272. }
  273. } else {
  274. // istvan begin
  275. $NoTestRes = 1;
  276. }
  277. // The Result of Tests
  278. if(is_array($hpresults)) {
  279. for($i = 0; $i < sizeof($hpresults); $i++) {
  280. $title = GetQuizName($hpresults[$i][0],'');
  281. if ($title == '')
  282. $title = basename($hpresults[$i][0]);
  283. $display_date = format_locale_date(get_lang('dateTimeFormatLong'), $hpresults[$i][3]);
  284. ?>
  285. <tr>
  286. <td class="content"><?php echo $title; ?></td>
  287. <td class="content" align="center"><?php echo $display_date; ?></td>
  288. <td class="content" align="center"><?php echo $hpresults[$i][1]; ?> / <?php echo $hpresults[$i][2]; ?></td>
  289. </tr>
  290. <?php }
  291. } else {
  292. $NoHPTestRes = 1;
  293. }
  294. if ($NoTestRes == 1 && $NoHPTestRes == 1) {
  295. echo "<tr>\n";
  296. echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
  297. echo "</tr>\n";
  298. }
  299. echo "</table>";
  300. echo "</td>\n</tr>\n";
  301. } else {
  302. $new_view = substr_replace($view,'1',1,1);
  303. echo "
  304. <tr>
  305. <td valign='top'>
  306. +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
  307. </td>
  308. </tr>";
  309. }
  310. }
  311. /**
  312. * Displays the student publications for a specific user in a specific course.
  313. * @todo remove globals
  314. */
  315. function display_student_publications_tracking_info($view, $user_id, $course_id)
  316. {
  317. global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK, $dateTimeFormatLong, $_course;
  318. if(substr($view,2,1) == '1') {
  319. $new_view = substr_replace($view,'0',2,1);
  320. echo "<tr>
  321. <td valign='top'>
  322. <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('WorkUploads')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>]
  323. </td>
  324. </tr>";
  325. echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
  326. $sql = "SELECT u.upload_date, w.title, w.author,w.url
  327. FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
  328. WHERE u.upload_work_id = w.id
  329. AND u.upload_user_id = '".Database::escape_string($user_id)."'
  330. AND u.upload_cours_id = '".Database::escape_string($course_id)."'
  331. ORDER BY u.upload_date DESC";
  332. echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
  333. $results = getManyResultsXCol($sql,4);
  334. echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
  335. echo "<tr>
  336. <td class='secLine' width='40%'>
  337. ".get_lang('WorkTitle')."
  338. </td>
  339. <td class='secLine' width='30%'>
  340. ".get_lang('WorkAuthors')."
  341. </td>
  342. <td class='secLine' width='30%'>
  343. ".get_lang('Date')."
  344. </td>
  345. </tr>";
  346. if (is_array($results)) {
  347. for($j = 0 ; $j < count($results) ; $j++) {
  348. $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
  349. $timestamp = strtotime($results[$j][0]);
  350. $beautifulDate = format_locale_date($dateTimeFormatLong,$timestamp);
  351. echo "<tr>";
  352. echo "<td class='content'>"
  353. ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
  354. ."</td>";
  355. echo "<td class='content'>".$results[$j][2]."</td>";
  356. echo "<td class='content'>".$beautifulDate."</td>";
  357. echo"</tr>";
  358. }
  359. } else {
  360. echo "<tr>";
  361. echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
  362. echo"</tr>";
  363. }
  364. echo "</table>";
  365. echo "</td></tr>";
  366. } else {
  367. $new_view = substr_replace($view,'1',2,1);
  368. echo "
  369. <tr>
  370. <td valign='top'>
  371. +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('WorkUploads')."</a>
  372. </td>
  373. </tr>
  374. ";
  375. }
  376. }
  377. /**
  378. * Displays the links followed for a specific user in a specific course.
  379. * @todo remove globals
  380. */
  381. function display_links_tracking_info($view, $user_id, $course_id)
  382. {
  383. global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
  384. if(substr($view,3,1) == '1') {
  385. $new_view = substr_replace($view,'0',3,1);
  386. echo "
  387. <tr>
  388. <td valign='top'>
  389. <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('LinksAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00010'>".get_lang('ExportAsCSV')."</a>]
  390. </td>
  391. </tr>
  392. ";
  393. echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
  394. $sql = "SELECT cl.title, cl.url
  395. FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
  396. WHERE sl.links_link_id = cl.id
  397. AND sl.links_cours_id = '".Database::escape_string($course_id)."'
  398. AND sl.links_user_id = '".Database::escape_string($user_id)."'
  399. GROUP BY cl.title, cl.url";
  400. echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
  401. $results = getManyResults2Col($sql);
  402. echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
  403. echo "<tr>
  404. <td class='secLine'>
  405. ".get_lang('LinksTitleLinkColumn')."
  406. </td>
  407. </tr>";
  408. if (is_array($results)) {
  409. for($j = 0 ; $j < count($results) ; $j++) {
  410. echo "<tr>";
  411. echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
  412. echo"</tr>";
  413. }
  414. } else {
  415. echo "<tr>";
  416. echo "<td ><center>".get_lang('NoResult')."</center></td>";
  417. echo"</tr>";
  418. }
  419. echo "</table>";
  420. echo "</td></tr>";
  421. } else {
  422. $new_view = substr_replace($view,'1',3,1);
  423. echo "
  424. <tr>
  425. <td valign='top'>
  426. +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LinksAccess')."</a>
  427. </td>
  428. </tr>
  429. ";
  430. }
  431. }
  432. /**
  433. * Displays the documents downloaded for a specific user in a specific course.
  434. */
  435. function display_document_tracking_info($view, $user_id, $course_id)
  436. {
  437. $downloads_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
  438. if(substr($view,4,1) == '1')
  439. {
  440. $new_view = substr_replace($view,'0',4,1);
  441. echo "
  442. <tr>
  443. <td valign='top'>
  444. <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('DocumentsAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00001'>".get_lang('ExportAsCSV')."</a>]
  445. </td>
  446. </tr>
  447. ";
  448. echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
  449. $sql = "SELECT down_doc_path
  450. FROM $downloads_table
  451. WHERE down_cours_id = '".Database::escape_string($course_id)."'
  452. AND down_user_id = '".Database::escape_string($user_id)."'
  453. GROUP BY down_doc_path";
  454. echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
  455. $results = getManyResults1Col($sql);
  456. echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
  457. echo "<tr>
  458. <td class='secLine'>
  459. ".get_lang('DocumentsTitleDocumentColumn')."
  460. </td>
  461. </tr>";
  462. if (is_array($results)) {
  463. for($j = 0 ; $j < count($results) ; $j++) {
  464. echo "<tr>";
  465. echo "<td class='content'>".$results[$j]."</td>";
  466. echo"</tr>";
  467. }
  468. } else {
  469. echo "<tr>";
  470. echo "<td><center>".get_lang('NoResult')."</center></td>";
  471. echo"</tr>";
  472. }
  473. echo "</table>";
  474. echo "</td></tr>";
  475. } else {
  476. $new_view = substr_replace($view,'1',4,1);
  477. echo "
  478. <tr>
  479. <td valign='top'>
  480. +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('DocumentsAccess')."</a>
  481. </td>
  482. </tr>
  483. ";
  484. }
  485. }
  486. /*
  487. ==============================================================================
  488. MAIN SECTION
  489. ==============================================================================
  490. */
  491. ?>
  492. <h3>
  493. <?php echo $nameTools ?>
  494. </h3>
  495. <h4>
  496. <?php echo get_lang('StatsOfUser'); ?>
  497. </h4>
  498. <table width="100%" cellpadding="2" cellspacing="3" border="0">
  499. <?php
  500. // check if uid is tutor of this group
  501. if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse ) && $_configuration['tracking_enabled'] ) {
  502. if(!$uInfo && !isset($uInfo) ) {
  503. /***************************************************************************
  504. *
  505. * Display list of user of this group
  506. *
  507. ***************************************************************************/
  508. echo "<h4>".get_lang('ListStudents')."</h4>";
  509. if( $is_allowedToTrackEverybodyInCourse ) {
  510. // if user can track everybody : list user of course
  511. if(api_get_setting('use_session_mode')) {
  512. $sql = "SELECT count(user_id)
  513. FROM $TABLECOURSUSER
  514. WHERE course_code = '".Database::escape_string($_cid)."'";
  515. } else {
  516. $sql = "SELECT count(id_user)
  517. FROM $tbl_session_course_user
  518. WHERE course_code = '".Database::escape_string($_cid)."'";
  519. }
  520. } else {
  521. // if user can only track one group : list users of this group
  522. $sql = "SELECT count(user)
  523. FROM $TABLECOURSE_GROUPSUSER
  524. WHERE group_id = '".Database::escape_string($_gid)."'";
  525. }
  526. $userGroupNb = getOneResult($sql);
  527. $step = 25; // number of student per page
  528. if ($userGroupNb > $step) {
  529. if(!isset($offset)) {
  530. $offset=0;
  531. }
  532. $next = $offset + $step;
  533. $previous = $offset - $step;
  534. $navLink = "<table width='100%' border='0'>\n"
  535. ."<tr>\n"
  536. ."<td align='left'>";
  537. if ($previous >= 0) {
  538. $navLink .= "<a href='".api_get_self()."?offset=$previous'>&lt;&lt; ".get_lang('PreviousPage')."</a>";
  539. }
  540. $navLink .= "</td>\n"
  541. ."<td align='right'>";
  542. if ($next < $userGroupNb) {
  543. $navLink .= "<a href='".api_get_self()."?offset=$next'>".get_lang('NextPage')." &gt;&gt;</a>";
  544. }
  545. $navLink .= "</td>\n"
  546. ."</tr>\n"
  547. ."</table>\n";
  548. } else {
  549. $offset = 0;
  550. }
  551. echo $navLink;
  552. if (!settype($offset, 'integer') || !settype($step, 'integer')) die('Offset or step variables are not integers.'); //sanity check of integer vars
  553. if( $is_allowedToTrackEverybodyInCourse ) {
  554. // list of users in this course
  555. $sql = "SELECT u.user_id, u.firstname,u.lastname
  556. FROM $TABLECOURSUSER cu , $TABLEUSER u
  557. WHERE cu.user_id = u.user_id
  558. AND cu.course_code = '".Database::escape_string($_cid)."'
  559. LIMIT $offset,$step";
  560. }
  561. else
  562. {
  563. // list of users of this group
  564. $sql = "SELECT u.user_id, u.firstname,u.lastname
  565. FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
  566. WHERE gu.user_id = u.user_id
  567. AND gu.group_id = '".Database::escape_string($_gid)."'
  568. LIMIT $offset,$step";
  569. }
  570. $list_users = getManyResults3Col($sql);
  571. echo "<table width='100%' cellpadding='2' cellspacing='1' border='0'>\n"
  572. ."<tr align='center' valign='top' bgcolor='#E6E6E6'>\n"
  573. ."<td align='left'>",get_lang('UserName'),"</td>\n"
  574. ."</tr>\n";
  575. for($i = 0 ; $i < sizeof($list_users) ; $i++) {
  576. echo "<tr valign='top' align='center'>\n"
  577. ."<td align='left'>"
  578. ."<a href='".api_get_self()."?uInfo=",$list_users[$i][0],"'>"
  579. .$list_users[$i][1]," ",$list_users[$i][2]
  580. ."</a>".
  581. "</td>\n";
  582. }
  583. echo "</table>\n";
  584. echo $navLink;
  585. } else {
  586. // if uInfo is set
  587. /***************************************************************************
  588. *
  589. * Informations about student uInfo
  590. *
  591. ***************************************************************************/
  592. // these checks exists for security reasons, neither a prof nor a tutor can see statistics of a user from
  593. // another course, or group
  594. if( $is_allowedToTrackEverybodyInCourse ) {
  595. // check if user is in this course
  596. $tracking_is_accepted = $is_course_member;
  597. $tracked_user_info = Database::get_user_info_from_id($uInfo);
  598. } else {
  599. // check if user is in the group of this tutor
  600. $sql = "SELECT u.firstname,u.lastname, u.email
  601. FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
  602. WHERE gu.user_id = u.user_id`
  603. AND gu.group_id = '".Database::escape_string($_gid)."'
  604. AND u.user_id = '".Database::escape_string($uInfo)."'";
  605. $query = Database::query($sql,__FILE__,__LINE__);
  606. $tracked_user_info = @mysql_fetch_assoc($query);
  607. if(is_array($tracked_user_info)) $tracking_is_accepted = true;
  608. }
  609. if ($tracking_is_accepted) {
  610. $tracked_user_info['email'] == '' ? $mail_link = get_lang('NoEmail') : $mail_link = Display::encrypted_mailto_link($tracked_user_info['email']);
  611. echo "<tr><td>";
  612. echo get_lang('informationsAbout').' :';
  613. echo "<ul>\n"
  614. ."<li>".get_lang('FirstName')." : ".$tracked_user_info['firstname']."</li>\n"
  615. ."<li>".get_lang('LastName')." : ".$tracked_user_info['lastname']."</li>\n"
  616. ."<li>".get_lang('Email')." : ".$mail_link."</li>\n"
  617. ."</ul>";
  618. echo "</td></tr>\n";
  619. // show all : number of 1 is equal to or bigger than number of categories
  620. // show none : number of 0 is equal to or bigger than number of categories
  621. echo "<tr>
  622. <td>
  623. [<a href='".api_get_self()."?uInfo=".Security::remove_XSS($uInfo)."&view=1111111'>".get_lang('ShowAll')."</a>]
  624. [<a href='".api_get_self()."?uInfo=".Security::remove_XSS($uInfo)."&view=0000000'>".get_lang('ShowNone')."</a>]".
  625. //"||[<a href='".api_get_self()."'>".get_lang('BackToList')."</a>]".
  626. "</td>
  627. </tr>
  628. ";
  629. if(!isset($view))
  630. {
  631. $view ='0000000';
  632. }
  633. //Logins
  634. display_login_tracking_info($view, $uInfo, $_cid);
  635. //Exercise results
  636. display_exercise_tracking_info($view, $uInfo, $_cid);
  637. //Student publications uploaded
  638. display_student_publications_tracking_info($view, $uInfo, $_cid);
  639. //Links usage
  640. display_links_tracking_info($view, $uInfo, $_cid);
  641. //Documents downloaded
  642. display_document_tracking_info($view, $uInfo, $_cid);
  643. } else {
  644. echo get_lang('ErrorUserNotInGroup');
  645. }
  646. /***************************************************************************
  647. *
  648. * Scorm contents and Learning Path
  649. *
  650. ***************************************************************************/
  651. if(substr($view,5,1) == '1') {
  652. $new_view = substr_replace($view,'0',5,1);
  653. echo "<tr>
  654. <td valign='top'>
  655. <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ScormAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?view=".Security::remove_XSS($new_view)."&uInfo=".Security::remove_XSS($uInfo)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=000001'>".get_lang('ExportAsCSV')."</a>]
  656. </td>
  657. </tr>";
  658. $sql = "SELECT id, name FROM $tbl_learnpath_main";
  659. $result=Database::query($sql,__FILE__,__LINE__);
  660. $ar=Database::fetch_array($result);
  661. echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
  662. echo "<table cellpadding='2' cellspacing='1' border='0' align='center'><tr>
  663. <td class='secLine'>
  664. &nbsp;".get_lang('ScormContentColumn')."&nbsp;
  665. </td>
  666. </tr>";
  667. if (is_array($ar)) {
  668. while ($ar['id'] != '') {
  669. $lp_title = stripslashes($ar['name']);
  670. echo "<tr><td>";
  671. echo "<a href='".api_get_self()."?view=".$view."&scormcontopen=".$ar['id']."&uInfo=".Security::remove_XSS($uInfo)."' class='specialLink'>$lp_title</a>";
  672. echo "</td></tr>";
  673. if ($ar['id']==$scormcontopen) { //have to list the students here
  674. $contentId=$ar['id'];
  675. $sql3 = "SELECT iv.status, iv.score, i.title, iv.total_time " .
  676. "FROM $tbl_learnpath_item i " .
  677. "INNER JOIN $tbl_learnpath_item_view iv ON i.id=iv.lp_item_id " .
  678. "INNER JOIN $tbl_learnpath_view v ON iv.lp_view_id=v.id " .
  679. "WHERE (v.user_id=".Database::escape_string($uInfo)." and v.lp_id=$contentId) ORDER BY v.id, i.id";
  680. $result3=Database::query($sql3,__FILE__,__LINE__);
  681. $ar3=Database::fetch_array($result3);
  682. if (is_array($ar3)) {
  683. echo "<tr><td>&nbsp;&nbsp;&nbsp;</td>
  684. <td class='secLine'>
  685. &nbsp;".get_lang('ScormTitleColumn')."&nbsp;
  686. </td>
  687. <td class='secLine'>
  688. &nbsp;".get_lang('ScormStatusColumn')."&nbsp;
  689. </td>
  690. <td class='secLine'>
  691. &nbsp;".get_lang('ScormScoreColumn')."&nbsp;
  692. </td>
  693. <td class='secLine'>
  694. &nbsp;".get_lang('ScormTimeColumn')."&nbsp;
  695. </td>
  696. </tr>";
  697. while ($ar3['status'] != '') {
  698. require_once('../newscorm/learnpathItem.class.php');
  699. $time = learnpathItem::get_scorm_time('php',$ar3['total_time']);
  700. $title = api_htmlentities($ar3['title'],ENT_QUOTES,$lp_charset);
  701. echo "<tr><td>&nbsp;&nbsp;&nbsp;</td><td>";
  702. echo "$title</td><td align=right>{$ar3['status']}</td><td align=right>{$ar3['score']}</td><td align=right>$time</td>";
  703. echo "</tr>";
  704. $ar3=Database::fetch_array($result3);
  705. }
  706. } else {
  707. echo "<tr>";
  708. echo "<td colspan='3'><center>".get_lang('ScormNeverOpened')."</center></td>";
  709. echo"</tr>";
  710. }
  711. }
  712. $ar=Database::fetch_array($result);
  713. }
  714. } else {
  715. $noscorm=true;
  716. }
  717. if ($noscorm) {
  718. echo "<tr>";
  719. echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
  720. echo "</tr>";
  721. }
  722. echo "</table>";
  723. echo "</td></tr>";
  724. } else {
  725. $new_view = substr_replace($view,'1',5,1);
  726. echo "
  727. <tr>
  728. <td valign='top'>
  729. +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?view=".Security::remove_XSS($new_view)."&uInfo=".Security::remove_XSS($uInfo)."' class='specialLink'>".get_lang('ScormAccess')."</a>
  730. </td>
  731. </tr>
  732. ";
  733. }
  734. }
  735. } else {
  736. // not allowed
  737. if(!$_configuration['tracking_enabled'])
  738. {
  739. echo get_lang('TrackingDisabled');
  740. } else {
  741. api_not_allowed();
  742. }
  743. }
  744. ?>
  745. </table>
  746. <?php
  747. Display::display_footer();
  748. ?>