courseLog.php 31 KB

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