courseLog.php 25 KB

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