courseLog.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <?php //$id: $
  2. /* For licensing terms, see /dokeos_license.txt */
  3. /**
  4. ==============================================================================
  5. * @author Thomas Depraetere
  6. * @author Hugues Peeters
  7. * @author Christophe Gesche
  8. * @author Sebastien Piraux
  9. * @author Toon Keppens (Vi-Host.net)
  10. *
  11. * @package dokeos.tracking
  12. ==============================================================================
  13. */
  14. /**
  15. * INIT SECTION
  16. */
  17. $pathopen = isset($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null;
  18. // name of the language file that needs to be included
  19. $language_file[] = 'admin';
  20. $language_file[] = 'tracking';
  21. $language_file[] = 'scorm';
  22. //$cidReset = true; //TODO: delete this line bug 457
  23. // including the global Dokeos file
  24. require_once '../inc/global.inc.php';
  25. // the section (for the tabs)
  26. //$this_section = "session_my_space";
  27. $from_myspace = false;
  28. if (isset($_GET['from']) && $_GET['from'] == 'myspace') {
  29. $from_myspace = true;
  30. $this_section = "session_my_space";
  31. } else {
  32. $this_section = SECTION_COURSES;
  33. }
  34. // access restrictions
  35. $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
  36. if (!$is_allowedToTrack) {
  37. Display :: display_header(null);
  38. api_not_allowed();
  39. Display :: display_footer();
  40. exit;
  41. }
  42. // including additional libraries
  43. require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
  44. require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathItem.class.php';
  45. require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
  46. require_once api_get_path(SYS_CODE_PATH).'newscorm/scorm.class.php';
  47. require_once api_get_path(SYS_CODE_PATH).'newscorm/scormItem.class.php';
  48. require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
  49. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  50. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  51. require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  52. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  53. require api_get_path(LIBRARY_PATH).'statsUtils.lib.inc.php';
  54. require api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
  55. // starting the output buffering when we are exporting the information
  56. $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
  57. if ($export_csv) {
  58. if (isset($_REQUEST['id_session']) && $_REQUEST['id_session'] != 0 ) {
  59. $_SESSION['id_session'] = intval($_REQUEST['id_session']);
  60. }
  61. ob_start();
  62. }
  63. $csv_content = array();
  64. // charset determination
  65. if (!empty($_GET['scormcontopen'])) {
  66. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  67. $contopen = (int) $_GET['scormcontopen'];
  68. $sql = "SELECT default_encoding FROM $tbl_lp WHERE id = ".$contopen;
  69. $res = Database::query($sql,__FILE__,__LINE__);
  70. $row = Database::fetch_array($res);
  71. $lp_charset = $row['default_encoding'];
  72. }
  73. $htmlHeadXtra[] = "<style type='text/css'>
  74. /*<![CDATA[*/
  75. .secLine {background-color : #E6E6E6;}
  76. .content {padding-left : 15px;padding-right : 15px; }
  77. .specialLink{color : #0000FF;}
  78. /*]]>*/
  79. </style>
  80. <style media='print' type='text/css'>
  81. </style>";
  82. // Database table definitions
  83. $TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
  84. $TABLETRACK_LINKS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
  85. $TABLETRACK_DOWNLOADS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
  86. $TABLETRACK_ACCESS_2 = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
  87. $TABLETRACK_EXERCISES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  88. $TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  89. $TABLECOURSE = Database::get_main_table(TABLE_MAIN_COURSE);
  90. $TABLECOURSE_LINKS = Database::get_course_table(TABLE_LINK);
  91. $table_user = Database::get_main_table(TABLE_MAIN_USER);
  92. $TABLEQUIZ = Database :: get_course_table(TABLE_QUIZ_TEST);
  93. $tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN);
  94. $tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
  95. $tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
  96. $tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
  97. // breadcrumbs
  98. if (isset($_GET['origin']) && $_GET['origin'] == 'resume_session') {
  99. $interbreadcrumb[] = array('url' => '../admin/index.php','name' => get_lang('PlatformAdmin'));
  100. $interbreadcrumb[] = array('url' => '../admin/session_list.php','name' => get_lang('SessionList'));
  101. $interbreadcrumb[] = array('url' => '../admin/resume_session.php?id_session='.$_SESSION['id_session'], 'name' => get_lang('SessionOverview'));
  102. }
  103. $view = (isset($_REQUEST['view']) ? $_REQUEST['view'] : '');
  104. $nameTools = get_lang('Tracking');
  105. // display the header
  106. Display::display_header($nameTools, 'Tracking');
  107. // getting all the students of the course
  108. $a_students = CourseManager :: get_student_list_from_course_code($_course['id'], true, (empty($_SESSION['id_session']) ? null : $_SESSION['id_session']));
  109. $nbStudents = count($a_students);
  110. // gettting all the additional information of an additional profile field
  111. if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
  112. //$additional_user_profile_info = get_addtional_profile_information_of_field($_GET['additional_profile_field']);
  113. $user_array = array();
  114. foreach ($a_students as $key=>$item) {
  115. $user_array[] = $key;
  116. }
  117. //fetching only the user that are loaded NOT ALL user in the portal
  118. $additional_user_profile_info = TrackingCourseLog::get_addtional_profile_information_of_field_by_user($_GET['additional_profile_field'],$user_array);
  119. }
  120. /*
  121. ==============================================================================
  122. MAIN CODE
  123. ==============================================================================
  124. */
  125. echo '<div class="actions">';
  126. if ($_GET['studentlist'] == 'false') {
  127. echo '<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a> | '.get_lang('CourseTracking').'&nbsp;|&nbsp;<a href="courseLog.php?'.api_get_cidreq().'&studentlist=resources">'.get_lang('ResourcesTracking');
  128. } elseif($_GET['studentlist'] == 'resources') {
  129. echo '<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a> | <a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a> | '.get_lang('ResourcesTracking');
  130. } elseif($_GET['studentlist'] == '' || $_GET['studentlist'] == 'true') {
  131. echo get_lang('StudentsTracking').' | <a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a> | <a href="courseLog.php?'.api_get_cidreq().'&studentlist=resources">'.get_lang('ResourcesTracking').'</a>';
  132. }
  133. echo '&nbsp;<a href="javascript: void(0);" onclick="javascript: window.print();">'.Display::return_icon('printmgr.gif',get_lang('Print')).get_lang('Print').'</a>';
  134. if($_GET['studentlist'] == 'false') {
  135. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&id_session='.api_get_session_id().'&export=csv&studentlist=false"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';
  136. } elseif ($_GET['studentlist'] == '' || $_GET['studentlist'] == 'true') {
  137. $addional_param = '';
  138. if (isset($_GET['additional_profile_field'])) {
  139. $addional_param ='additional_profile_field='.intval($_GET['additional_profile_field']);
  140. }
  141. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&id_session='.api_get_session_id().'&export=csv&'.$addional_param.'">'.Display::return_icon('csv.gif',get_lang('ExportAsCSV')).get_lang('ExportAsCSV').'</a>';
  142. }
  143. if($_GET['studentlist'] == 'true' || empty($_GET['studentlist'])) {
  144. echo TrackingCourseLog::display_additional_profile_fields();
  145. }
  146. echo '</div>';
  147. if ($_GET['studentlist'] == 'false') {
  148. echo'<br /><br />';
  149. // learning path tracking
  150. echo '<div class="report_section">
  151. <h4>'.Display::return_icon('scormbuilder.gif',get_lang('AverageProgressInLearnpath')).get_lang('AverageProgressInLearnpath').'</h4>
  152. <table class="data_table">';
  153. $list = new LearnpathList($student);
  154. $flat_list = $list->get_flat_list();
  155. if ($export_csv) {
  156. $temp = array(get_lang('AverageProgressInLearnpath', ''), '');
  157. $csv_content[] = array('', '');
  158. $csv_content[] = $temp;
  159. }
  160. if (count($flat_list) > 0) {
  161. foreach ($flat_list as $lp_id => $lp) {
  162. $lp_avg_progress = 0;
  163. foreach ($a_students as $student_id => $student) {
  164. // get the progress in learning pathes
  165. $lp_avg_progress += learnpath::get_db_progress($lp_id, $student_id);
  166. }
  167. if ($nbStudents > 0) {
  168. $lp_avg_progress = $lp_avg_progress / $nbStudents;
  169. } else {
  170. $lp_avg_progress = null;
  171. }
  172. // Separated presentation logic.
  173. if (is_null($lp_avg_progress)) {
  174. $lp_avg_progress = '0%';
  175. } else {
  176. $lp_avg_progress = round($lp_avg_progress, 1).'%';
  177. }
  178. echo '<tr><td>'.$lp['lp_name'].'</td><td align="right">'.$lp_avg_progress.'</td></tr>';
  179. if ($export_csv) {
  180. $temp = array($lp['lp_name'], $lp_avg_progress);
  181. $csv_content[] = $temp;
  182. }
  183. }
  184. } else {
  185. echo '<tr><td>'.get_lang('NoLearningPath').'</td></tr>';
  186. if ($export_csv) {
  187. $temp = array(get_lang('NoLearningPath', ''), '');
  188. $csv_content[] = $temp;
  189. }
  190. }
  191. echo '</table></div>';
  192. echo '<div class="clear"></div>';
  193. // Exercices tracking
  194. echo '<div class="report_section">
  195. <h4>'.Display::return_icon('quiz.gif',get_lang('AverageResultsToTheExercices')).get_lang('AverageResultsToTheExercices').'&nbsp;-&nbsp;<a href="../exercice/exercice.php?'.api_get_cidreq().'&show=result">'.get_lang('SeeDetail').'</a></h4>
  196. <table class="data_table">';
  197. $sql = "SELECT id, title
  198. FROM $TABLEQUIZ WHERE active <> -1";
  199. $rs = Database::query($sql, __FILE__, __LINE__);
  200. if ($export_csv) {
  201. $temp = array(get_lang('AverageProgressInLearnpath'), '');
  202. $csv_content[] = array('', '');
  203. $csv_content[] = $temp;
  204. }
  205. if (Database::num_rows($rs) > 0) {
  206. // gets course actual administrators
  207. $sql = "SELECT user.user_id FROM $table_user user, $TABLECOURSUSER course_user
  208. WHERE course_user.user_id=user.user_id AND course_user.course_code='".api_get_course_id()."' AND course_user.status <> '1' ";
  209. $res = Database::query($sql, __FILE__, __LINE__);
  210. $student_ids = array();
  211. while($row = Database::fetch_row($res)) {
  212. $student_ids[] = $row[0];
  213. }
  214. $count_students = count($student_ids);
  215. while ($quiz = Database::fetch_array($rs)) {
  216. $quiz_avg_score = 0;
  217. if ($count_students > 0) {
  218. foreach ($student_ids as $student_id) {
  219. // get the scorn in exercises
  220. $sql = 'SELECT exe_result , exe_weighting
  221. FROM '.$TABLETRACK_EXERCISES.'
  222. WHERE exe_exo_id = '.$quiz['id'].'
  223. AND exe_user_id = '.(int)$student_id.'
  224. AND exe_cours_id = "'.api_get_course_id().'"
  225. AND orig_lp_id = 0
  226. AND orig_lp_item_id = 0
  227. ORDER BY exe_date DESC';
  228. $rsAttempt = Database::query($sql, __FILE__, __LINE__);
  229. $nb_attempts = 0;
  230. $avg_student_score = 0;
  231. while ($attempt = Database::fetch_array($rsAttempt)) {
  232. $nb_attempts++;
  233. $exe_weight = $attempt['exe_weighting'];
  234. if ($exe_weight > 0) {
  235. $avg_student_score += round(($attempt['exe_result'] / $exe_weight * 100), 2);
  236. }
  237. }
  238. if ($nb_attempts > 0) {
  239. $avg_student_score = $avg_student_score / $nb_attempts;
  240. }
  241. $quiz_avg_score += $avg_student_score;
  242. }
  243. }
  244. $count_students = ($count_students == 0 || is_null($count_students) || $count_students == '') ? 1 : $count_students;
  245. echo '<tr><td>'.$quiz['title'].'</td><td align="right">'.round(($quiz_avg_score / $count_students), 2).'%'.'</td></tr>';
  246. if ($export_csv) {
  247. $temp = array($quiz['title'], $quiz_avg_score);
  248. $csv_content[] = $temp;
  249. }
  250. }
  251. } else {
  252. echo '<tr><td>'.get_lang('NoExercises').'</td></tr>';
  253. if ($export_csv) {
  254. $temp = array(get_lang('NoExercises', ''), '');
  255. $csv_content[] = $temp;
  256. }
  257. }
  258. echo '</table></div>';
  259. echo '<div class="clear"></div>';
  260. // forums tracking
  261. echo '<div class="report_section">
  262. <h4>'.Display::return_icon('forum.gif', get_lang('Forum')).get_lang('Forum').'&nbsp;-&nbsp;<a href="../forum/index.php?cidReq='.$_course['id'].'">'.get_lang('SeeDetail').'</a></h4>
  263. <table class="data_table">';
  264. $count_number_of_posts_by_course = Tracking :: count_number_of_posts_by_course($_course['id']);
  265. $count_number_of_forums_by_course = Tracking :: count_number_of_forums_by_course($_course['id']);
  266. $count_number_of_threads_by_course = Tracking :: count_number_of_threads_by_course($_course['id']);
  267. if ($export_csv) {
  268. $csv_content[] = array(get_lang('Forum'), '');
  269. $csv_content[] = array(get_lang('ForumForumsNumber', ''), $count_number_of_forums_by_course);
  270. $csv_content[] = array(get_lang('ForumThreadsNumber', ''), $count_number_of_threads_by_course);
  271. $csv_content[] = array(get_lang('ForumPostsNumber', ''), $count_number_of_posts_by_course);
  272. }
  273. echo '<tr><td>'.get_lang('ForumForumsNumber').'</td><td align="right">'.$count_number_of_forums_by_course.'</td></tr>';
  274. echo '<tr><td>'.get_lang('ForumThreadsNumber').'</td><td align="right">'.$count_number_of_threads_by_course.'</td></tr>';
  275. echo '<tr><td>'.get_lang('ForumPostsNumber').'</td><td align="right">'.$count_number_of_posts_by_course.'</td></tr>';
  276. echo '</table></div>';
  277. echo '<div class="clear"></div>';
  278. // chat tracking
  279. echo '<div class="report_section">
  280. <h4>'.Display::return_icon('chat.gif',get_lang('Chat')).get_lang('Chat').'</h4>
  281. <table class="data_table">';
  282. $chat_connections_during_last_x_days_by_course = Tracking :: chat_connections_during_last_x_days_by_course($_course['id'], 7);
  283. if ($export_csv) {
  284. $csv_content[] = array(get_lang('Chat', ''), '');
  285. $csv_content[] = array(sprintf(get_lang('ChatConnectionsDuringLastXDays', ''), '7'), $chat_connections_during_last_x_days_by_course);
  286. }
  287. echo '<tr><td>'.sprintf(get_lang('ChatConnectionsDuringLastXDays'), '7').'</td><td align="right">'.$chat_connections_during_last_x_days_by_course.'</td></tr>';
  288. echo '</table></div>';
  289. echo '<div class="clear"></div>';
  290. // tools tracking
  291. echo '<div class="report_section">
  292. <h4>'.Display::return_icon('acces_tool.gif', get_lang('ToolsMostUsed')).get_lang('ToolsMostUsed').'</h4>
  293. <table class="data_table">';
  294. $sql = "SELECT access_tool, COUNT(DISTINCT access_user_id),count( access_tool ) as count_access_tool
  295. FROM $TABLETRACK_ACCESS
  296. WHERE access_tool IS NOT NULL
  297. AND access_cours_code = '$_cid'
  298. GROUP BY access_tool
  299. ORDER BY count_access_tool DESC
  300. LIMIT 0, 3";
  301. $rs = Database::query($sql, __FILE__, __LINE__);
  302. if ($export_csv) {
  303. $temp = array(get_lang('ToolsMostUsed'), '');
  304. $csv_content[] = $temp;
  305. }
  306. while ($row = Database::fetch_array($rs)) {
  307. echo ' <tr>
  308. <td>'.get_lang(ucfirst($row['access_tool'])).'</td>
  309. <td align="right">'.$row['count_access_tool'].' '.get_lang('Clicks').'</td>
  310. </tr>';
  311. if ($export_csv) {
  312. $temp = array(get_lang(ucfirst($row['access_tool']), ''), $row['count_access_tool'].' '.get_lang('Clicks', ''));
  313. $csv_content[] = $temp;
  314. }
  315. }
  316. echo '</table></div>';
  317. echo '<div class="clear"></div>';
  318. // Documents tracking
  319. if ($_GET['num'] == 0 or empty($_GET['num'])) {
  320. $num = 3;
  321. $link='&nbsp;-&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&studentlist=false&num=1#documents_tracking">'.get_lang('SeeDetail').'</a>';
  322. } else {
  323. $num = 1000;
  324. $link='&nbsp;-&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&studentlist=false&num=0#documents_tracking">'.get_lang('ViewMinus').'</a>';
  325. }
  326. echo '<a name="documents_tracking" id="a"></a><div class="report_section">
  327. <h4>'.Display::return_icon('documents.gif',get_lang('DocumentsMostDownloaded')).'&nbsp;'.get_lang('DocumentsMostDownloaded').$link.'</h4>
  328. <table class="data_table">';
  329. $sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
  330. FROM $TABLETRACK_DOWNLOADS
  331. WHERE down_cours_id = '$_cid'
  332. GROUP BY down_doc_path
  333. ORDER BY count_down DESC
  334. LIMIT 0, $num";
  335. $rs = Database::query($sql, __FILE__, __LINE__);
  336. if ($export_csv) {
  337. $temp = array(get_lang('DocumentsMostDownloaded', ''), '');
  338. $csv_content[] = array('', '');
  339. $csv_content[] = $temp;
  340. }
  341. if (Database::num_rows($rs) > 0) {
  342. while($row = Database::fetch_array($rs)) {
  343. echo ' <tr>
  344. <td>'.$row['down_doc_path'].'</td>
  345. <td align="right">'.$row['count_down'].' '.get_lang('Clicks').'</td>
  346. </tr>';
  347. if ($export_csv) {
  348. $temp = array($row['down_doc_path'], $row['count_down'].' '.get_lang('Clicks', ''));
  349. $csv_content[] = $temp;
  350. }
  351. }
  352. } else {
  353. echo '<tr><td>'.get_lang('NoDocumentDownloaded').'</td></tr>';
  354. if ($export_csv) {
  355. $temp = array(get_lang('NoDocumentDownloaded', ''),'');
  356. $csv_content[] = $temp;
  357. }
  358. }
  359. echo '</table></div>';
  360. echo '<div class="clear"></div>';
  361. // links tracking
  362. echo '<div class="report_section">
  363. <h4>'.Display::return_icon('link.gif',get_lang('LinksMostClicked')).'&nbsp;'.get_lang('LinksMostClicked').'</h4>
  364. <table class="data_table">';
  365. $sql = "SELECT cl.title, cl.url,count(DISTINCT sl.links_user_id), count(cl.title) as count_visits
  366. FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
  367. WHERE sl.links_link_id = cl.id
  368. AND sl.links_cours_id = '$_cid'
  369. GROUP BY cl.title, cl.url
  370. ORDER BY count_visits DESC
  371. LIMIT 0, 3";
  372. $rs = Database::query($sql, __FILE__, __LINE__);
  373. if ($export_csv) {
  374. $temp = array(get_lang('LinksMostClicked'),'');
  375. $csv_content[] = array('','');
  376. $csv_content[] = $temp;
  377. }
  378. if (Database::num_rows($rs) > 0) {
  379. while ($row = Database::fetch_array($rs)) {
  380. echo ' <tr>
  381. <td>'.$row['title'].'</td>
  382. <td align="right">'.$row['count_visits'].' '.get_lang('Clicks').'</td>
  383. </tr>';
  384. if ($export_csv){
  385. $temp = array($row['title'],$row['count_visits'].' '.get_lang('Clicks', ''));
  386. $csv_content[] = $temp;
  387. }
  388. }
  389. } else {
  390. echo '<tr><td>'.get_lang('NoLinkVisited').'</td></tr>';
  391. if ($export_csv) {
  392. $temp = array(get_lang('NoLinkVisited'), '');
  393. $csv_content[] = $temp;
  394. }
  395. }
  396. echo '</table></div>';
  397. echo '<div class="clear"></div>';
  398. // send the csv file if asked
  399. if ($export_csv) {
  400. ob_end_clean();
  401. Export :: export_table_csv($csv_content, 'reporting_course_tracking');
  402. exit;
  403. }
  404. } elseif ($_GET['studentlist'] == 'true' or $_GET['studentlist'] == '') {
  405. // else display student list with all the informations
  406. // BEGIN : form to remind inactives susers
  407. $form = new FormValidator('reminder_form', 'get', api_get_path(REL_CODE_PATH).'announcements/announcements.php');
  408. $renderer = $form->defaultRenderer();
  409. $renderer->setElementTemplate('<span>{label} {element}</span>&nbsp;<button class="save" type="submit">'.get_lang('SendNotification').'</button>','since');
  410. $options = array (
  411. 2 => '2 '.get_lang('Days'),
  412. 3 => '3 '.get_lang('Days'),
  413. 4 => '4 '.get_lang('Days'),
  414. 5 => '5 '.get_lang('Days'),
  415. 6 => '6 '.get_lang('Days'),
  416. 7 => '7 '.get_lang('Days'),
  417. 15 => '15 '.get_lang('Days'),
  418. 30 => '30 '.get_lang('Days'),
  419. 'never' => get_lang('Never')
  420. );
  421. $el = $form -> addElement('select', 'since', '<img width="22" align="middle" src="'.api_get_path(WEB_IMG_PATH).'messagebox_warning.gif" border="0" />'.get_lang('RemindInactivesLearnersSince'), $options);
  422. $el -> setSelected(7);
  423. $form -> addElement('hidden', 'action', 'add');
  424. $form -> addElement('hidden', 'remindallinactives', 'true');
  425. $form -> display();
  426. // END : form to remind inactives susers
  427. if ($export_csv) {
  428. $is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
  429. } else {
  430. $is_western_name_order = api_is_western_name_order();
  431. }
  432. $sort_by_first_name = api_sort_by_first_name();
  433. $tracking_column = isset($_GET['tracking_column']) ? $_GET['tracking_column'] : 0;
  434. $tracking_direction = isset($_GET['tracking_direction']) ? $_GET['tracking_direction'] : 'DESC';
  435. if (count($a_students) > 0) {
  436. if ($export_csv) {
  437. $csv_content[] = array ();
  438. }
  439. $all_datas = array();
  440. $course_code = $_course['id'];
  441. $user_ids = array_keys($a_students);
  442. $table = new SortableTable('users_tracking', array('TrackingCourseLog','get_number_of_users'), array('TrackingCourseLog','get_user_data'), (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
  443. $parameters['cidReq'] = Security::remove_XSS($_GET['cidReq']);
  444. $parameters['studentlist'] = Security::remove_XSS($_GET['studentlist']);
  445. $parameters['from'] = Security::remove_XSS($_GET['myspace']);
  446. $table->set_additional_parameters($parameters);
  447. $table -> set_header(0, get_lang('OfficialCode'), false, 'align="center"');
  448. if ($is_western_name_order) {
  449. $table -> set_header(1, get_lang('FirstName'), false, 'align="center"');
  450. $table -> set_header(2, get_lang('LastName'), true, 'align="center"');
  451. } else {
  452. $table -> set_header(1, get_lang('LastName'), true, 'align="center"');
  453. $table -> set_header(2, get_lang('FirstName'), false, 'align="center"');
  454. }
  455. $table -> set_header(3, get_lang('TrainingTime'),false);
  456. $table -> set_header(4, get_lang('CourseProgress'),false);
  457. $table -> set_header(5, get_lang('Score'),false);
  458. $table -> set_header(6, get_lang('Student_publication'),false);
  459. $table -> set_header(7, get_lang('Messages'),false);
  460. $table -> set_header(8, get_lang('FirstLogin'), false, 'align="center"');
  461. $table -> set_header(9, get_lang('LatestLogin'), false, 'align="center"');
  462. //if (isset($_GET['additional_profile_field']) AND is_numeric($_GET['additional_profile_field'])) {
  463. $table -> set_header(10, get_lang('AdditionalProfileField'),false);
  464. /*} else {
  465. $table -> set_header(10, ,false);
  466. }*/
  467. $table -> set_header(11, get_lang('Details'),false);
  468. $table->display();
  469. } else {
  470. echo get_lang('NoUsersInCourseTracking');
  471. }
  472. // send the csv file if asked
  473. if ($export_csv) {
  474. if ($is_western_name_order) {
  475. $csv_headers = array (
  476. get_lang('OfficialCode', ''),
  477. get_lang('FirstName', ''),
  478. get_lang('LastName', ''),
  479. get_lang('TrainingTime', ''),
  480. get_lang('CourseProgress', ''),
  481. get_lang('Score', ''),
  482. get_lang('Student_publication', ''),
  483. get_lang('Messages', ''),
  484. get_lang('FirstLogin', ''),
  485. get_lang('LatestLogin', '')
  486. );
  487. } else {
  488. $csv_headers = array (
  489. get_lang('OfficialCode', ''),
  490. get_lang('LastName', ''),
  491. get_lang('FirstName', ''),
  492. get_lang('TrainingTime', ''),
  493. get_lang('CourseProgress', ''),
  494. get_lang('Score', ''),
  495. get_lang('Student_publication', ''),
  496. get_lang('Messages', ''),
  497. get_lang('FirstLogin', ''),
  498. get_lang('LatestLogin', '')
  499. );
  500. }
  501. if (isset($_GET['additional_profile_field']) AND is_numeric($_GET['additional_profile_field'])) {
  502. $csv_headers[]=get_lang('AdditionalProfileField');
  503. }
  504. ob_end_clean();
  505. array_unshift($csv_content, $csv_headers); // adding headers before the content
  506. Export :: export_table_csv($csv_content, 'reporting_student_list');
  507. exit;
  508. }
  509. } elseif($_GET['studentlist'] == 'resources') {
  510. // Create a search-box
  511. $form = new FormValidator('search_simple','get',api_get_path(WEB_CODE_PATH).'tracking/courseLog.php?'.api_get_cidreq().'&studentlist=resources','','width=200px',false);
  512. $renderer =& $form->defaultRenderer();
  513. $renderer->setElementTemplate('<span>{element}</span>');
  514. $form->addElement('hidden','studentlist','resources');
  515. $form->addElement('text','keyword',get_lang('keyword'));
  516. $form->addElement('style_submit_button', 'submit', get_lang('Search'),'class="search"');
  517. echo '<div class="actions">';
  518. $form->display();
  519. echo '</div>';
  520. $table = new SortableTable('resources', array('TrackingCourseLog','count_item_resources'), array('TrackingCourseLog','get_item_resources_data'), 5, 20, 'DESC');
  521. $parameters = array();
  522. if (isset($_GET['keyword'])) {
  523. $parameters['keyword'] = Security::remove_XSS($_GET['keyword']);
  524. }
  525. $parameters['studentlist'] = 'resources';
  526. $table->set_additional_parameters($parameters);
  527. $table->set_header(0, get_lang('Tool'));
  528. $table->set_header(1, get_lang('EventType'));
  529. $table->set_header(2, get_lang('Session'), false);
  530. $table->set_header(3, get_lang('UserName'));
  531. $table->set_header(4, get_lang('Document'), false);
  532. $table->set_header(5, get_lang('Date'));
  533. $table->display();
  534. }
  535. ?>
  536. </table>
  537. <?php
  538. Display::display_footer();