courseLog.php 26 KB

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