courseLog.php 31 KB

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