courseLog.php 27 KB

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