courseLog.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * @package chamilo.tracking
  6. */
  7. $pathopen = isset($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null;
  8. // Including the global initialization file
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. $current_course_tool = TOOL_TRACKING;
  11. $courseInfo = api_get_course_info(api_get_course_id());
  12. $courseCode = $courseInfo['code'];
  13. $from_myspace = false;
  14. $from = isset($_GET['from']) ? $_GET['from'] : null;
  15. // Starting the output buffering when we are exporting the information.
  16. $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
  17. $session_id = isset($_REQUEST['id_session']) ? intval($_REQUEST['id_session']) : 0;
  18. if ($from == 'myspace') {
  19. $from_myspace = true;
  20. $this_section = "session_my_space";
  21. } else {
  22. $this_section = SECTION_COURSES;
  23. }
  24. // Access restrictions.
  25. $is_allowedToTrack =
  26. api_is_platform_admin() ||
  27. SessionManager::user_is_general_coach(api_get_user_id(), $session_id) ||
  28. api_is_allowed_to_create_course() ||
  29. api_is_session_admin() ||
  30. api_is_drh() ||
  31. api_is_course_tutor() ||
  32. api_is_course_admin();
  33. if (!$is_allowedToTrack) {
  34. api_not_allowed(true);
  35. exit;
  36. }
  37. // If the user is a HR director (drh)
  38. if (api_is_drh()) {
  39. // Blocking course for drh
  40. if (api_drh_can_access_all_session_content()) {
  41. // If the drh has been configured to be allowed to see all session content, give him access to the session courses
  42. $coursesFromSession = SessionManager::getAllCoursesFollowedByUser(
  43. api_get_user_id(),
  44. null
  45. );
  46. $coursesFromSessionCodeList = array();
  47. if (!empty($coursesFromSession)) {
  48. foreach ($coursesFromSession as $course) {
  49. $coursesFromSessionCodeList[$course['code']] = $course['code'];
  50. }
  51. }
  52. $coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
  53. if (!empty($coursesFollowedList)) {
  54. $coursesFollowedList = array_keys($coursesFollowedList);
  55. }
  56. if (!in_array($courseCode, $coursesFollowedList)) {
  57. if (!in_array($courseCode, $coursesFromSessionCodeList)) {
  58. api_not_allowed();
  59. }
  60. }
  61. } else {
  62. // If the drh has *not* been configured to be allowed to see all session content,
  63. // then check if he has also been given access to the corresponding courses
  64. $coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
  65. $coursesFollowedList = array_keys($coursesFollowedList);
  66. if (!in_array(api_get_course_id(), $coursesFollowedList)) {
  67. api_not_allowed(true);
  68. exit;
  69. }
  70. }
  71. }
  72. if ($export_csv) {
  73. if (!empty($session_id)) {
  74. Session::write('id_session', $session_id);
  75. }
  76. ob_start();
  77. }
  78. $columnsToHideFromSetting = api_get_configuration_value('course_log_hide_columns');
  79. $columnsToHide = empty($columnsToHideFromSetting) ? array(0, 8, 9, 10, 11) : $columnsToHideFromSetting;
  80. $columnsToHide = json_encode($columnsToHide);
  81. $csv_content = array();
  82. // Scripts for reporting array hide/show columns
  83. $js = "<script>
  84. // hide column and display the button to unhide it
  85. function foldup(in_id) {
  86. $('#reporting_table .data_table tr td:nth-child(' + (in_id + 1) + ')').toggleClass('hide');
  87. $('#reporting_table .data_table tr th:nth-child(' + (in_id + 1) + ')').toggleClass('hide');
  88. $('div#unhideButtons a:nth-child(' + (in_id + 1) + ')').toggleClass('hide');
  89. }
  90. // add the red cross on top of each column
  91. function init_hide() {
  92. $('#reporting_table .data_table tr th').each(
  93. function(index) {
  94. $(this).prepend(
  95. '<div style=\"cursor:pointer\" onclick=\"foldup(' + index + ')\">" . Display::return_icon(
  96. 'visible.png',
  97. get_lang('HideColumn'),
  98. array('align' => 'absmiddle', 'hspace' => '3px'),
  99. ICON_SIZE_SMALL
  100. )."</div>'
  101. );
  102. }
  103. );
  104. }
  105. // hide some column at startup
  106. // be sure that these columns always exists
  107. // see headers = array();
  108. // tab of header texts
  109. $(document).ready( function() {
  110. init_hide();
  111. var columnsToHide = ".$columnsToHide.";
  112. columnsToHide.forEach(function(id) {
  113. foldup(id);
  114. });
  115. })
  116. </script>";
  117. $htmlHeadXtra[] = "<style type='text/css'>
  118. .secLine {background-color : #E6E6E6;}
  119. .content {padding-left : 15px;padding-right : 15px; }
  120. .specialLink{color : #0000FF;}
  121. div#reporting_table table th {
  122. vertical-align:top;
  123. }
  124. </style>";
  125. $htmlHeadXtra[] .= $js;
  126. // Database table definitions.
  127. //@todo remove this calls
  128. $TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
  129. $TABLETRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
  130. $TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  131. $TABLECOURSE = Database::get_main_table(TABLE_MAIN_COURSE);
  132. $table_user = Database::get_main_table(TABLE_MAIN_USER);
  133. $TABLEQUIZ = Database::get_course_table(TABLE_QUIZ_TEST);
  134. $sessionId = api_get_session_id();
  135. // Breadcrumbs.
  136. if (isset($_GET['origin']) && $_GET['origin'] == 'resume_session') {
  137. $interbreadcrumb[] = array(
  138. 'url' => '../admin/index.php',
  139. 'name' => get_lang('PlatformAdmin')
  140. );
  141. $interbreadcrumb[] = array(
  142. 'url' => '../session/session_list.php',
  143. 'name' => get_lang('SessionList')
  144. );
  145. $interbreadcrumb[] = array(
  146. 'url' => '../session/resume_session.php?id_session='.$sessionId,
  147. 'name' => get_lang('SessionOverview')
  148. );
  149. }
  150. $view = isset($_REQUEST['view']) ? $_REQUEST['view'] : '';
  151. $nameTools = get_lang('Tracking');
  152. // getting all the students of the course
  153. if (empty($session_id)) {
  154. // Registered students in a course outside session.
  155. $a_students = CourseManager::get_student_list_from_course_code(
  156. api_get_course_id()
  157. );
  158. } else {
  159. // Registered students in session.
  160. $a_students = CourseManager::get_student_list_from_course_code(
  161. api_get_course_id(),
  162. true,
  163. $sessionId
  164. );
  165. }
  166. $nbStudents = count($a_students);
  167. $extra_info = array();
  168. $userProfileInfo = [];
  169. // Getting all the additional information of an additional profile field.
  170. if (isset($_GET['additional_profile_field'])) {
  171. $user_array = array();
  172. foreach ($a_students as $key => $item) {
  173. $user_array[] = $key;
  174. }
  175. foreach ($_GET['additional_profile_field'] as $fieldId) {
  176. // Fetching only the user that are loaded NOT ALL user in the portal.
  177. $userProfileInfo[$fieldId] = TrackingCourseLog::getAdditionalProfileInformationOfFieldByUser(
  178. $fieldId,
  179. $user_array
  180. );
  181. $extra_info[$fieldId] = UserManager::get_extra_field_information(
  182. $fieldId
  183. );
  184. }
  185. }
  186. Session::write('additional_user_profile_info', $userProfileInfo);
  187. Session::write('extra_field_info', $extra_info);
  188. // Display the header.
  189. Display::display_header($nameTools, 'Tracking');
  190. /* MAIN CODE */
  191. $actionsLeft = Display::return_icon(
  192. 'user_na.png',
  193. get_lang('StudentsTracking'),
  194. array(),
  195. ICON_SIZE_MEDIUM
  196. );
  197. $actionsLeft .= Display::url(
  198. Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM),
  199. 'course_log_groups.php?'.api_get_cidreq()
  200. );
  201. $actionsLeft .= Display::url(
  202. Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
  203. 'course_log_tools.php?'.api_get_cidreq()
  204. );
  205. $actionsLeft .= Display::url(
  206. Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM),
  207. 'course_log_resources.php?'.api_get_cidreq()
  208. );
  209. $actionsLeft .= Display::url(
  210. Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), ICON_SIZE_MEDIUM),
  211. api_get_path(WEB_CODE_PATH).'tracking/exams.php?'.api_get_cidreq()
  212. );
  213. if (!empty($sessionId)) {
  214. $actionsLeft .= Display::url(
  215. Display::return_icon('attendance_list.png', get_lang('Logins'), '', ICON_SIZE_MEDIUM),
  216. api_get_path(WEB_CODE_PATH).'attendance/index.php?'.api_get_cidreq().'&action=calendar_logins'
  217. );
  218. }
  219. $actionsRight = '<div class="pull-right">';
  220. $actionsRight .= '<a href="javascript: void(0);" onclick="javascript: window.print();">'.
  221. Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).'</a>';
  222. $addional_param = '';
  223. if (isset($_GET['additional_profile_field'])) {
  224. foreach ($_GET['additional_profile_field'] as $fieldId) {
  225. $addional_param .= '&additional_profile_field[]='. (int) $fieldId;
  226. }
  227. }
  228. $users_tracking_per_page = '';
  229. if (isset($_GET['users_tracking_per_page'])) {
  230. $users_tracking_per_page = '&users_tracking_per_page='.intval($_GET['users_tracking_per_page']);
  231. }
  232. $actionsRight .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&'.$addional_param.$users_tracking_per_page.'">
  233. '.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a>';
  234. $actionsRight .= '</div>';
  235. // Create a search-box.
  236. $form_search = new FormValidator(
  237. 'search_simple',
  238. 'GET',
  239. api_get_path(WEB_CODE_PATH).'tracking/courseLog.php?'.api_get_cidreq(),
  240. '',
  241. array(),
  242. FormValidator::LAYOUT_INLINE
  243. );
  244. $form_search->addElement('hidden', 'from', Security::remove_XSS($from));
  245. $form_search->addElement('hidden', 'session_id', $sessionId);
  246. $form_search->addElement('hidden', 'id_session', $sessionId);
  247. $form_search->addElement('text', 'user_keyword');
  248. $form_search->addButtonSearch(get_lang('SearchUsers'));
  249. echo Display::toolbarAction(
  250. 'toolbar-courselog',
  251. [$actionsLeft, $form_search->returnForm(), $actionsRight]
  252. );
  253. $course_name = get_lang('Course').' '.$courseInfo['name'];
  254. if ($session_id) {
  255. $titleSession = Display::return_icon(
  256. 'session.png',
  257. get_lang('Session'),
  258. array(),
  259. ICON_SIZE_SMALL
  260. ).' '.api_get_session_name($session_id);
  261. $titleCourse = Display::return_icon(
  262. 'course.png',
  263. get_lang('Course'),
  264. array(),
  265. ICON_SIZE_SMALL
  266. ).' '.$course_name;
  267. } else {
  268. $titleSession = Display::return_icon(
  269. 'course.png',
  270. get_lang('Course'),
  271. array(),
  272. ICON_SIZE_SMALL
  273. ).' '.$courseInfo['name'];
  274. }
  275. $teacherList = CourseManager::get_teacher_list_from_course_code_to_string(
  276. $courseInfo['code'],
  277. ',',
  278. false,
  279. true
  280. );
  281. $coaches = null;
  282. if (!empty($session_id)) {
  283. $coaches = CourseManager::get_coachs_from_course_to_string(
  284. $session_id,
  285. $courseInfo['real_id'],
  286. ',',
  287. false,
  288. true
  289. );
  290. }
  291. $html = '';
  292. if (!empty($teacherList)) {
  293. $html .= Display::page_subheader2(get_lang('Teachers'));
  294. $html .= $teacherList;
  295. }
  296. if (!empty($coaches)) {
  297. $html .= Display::page_subheader2(get_lang('Coaches'));
  298. $html .= $coaches;
  299. }
  300. if (api_is_platform_admin(true) ||
  301. api_is_session_general_coach()
  302. ) {
  303. $sessionList = SessionManager::get_session_by_course($courseInfo['real_id']);
  304. if (!empty($sessionList)) {
  305. $html .= Display::page_subheader2(get_lang('SessionList'));
  306. $icon = Display::return_icon(
  307. 'session.png',
  308. null,
  309. null,
  310. ICON_SIZE_TINY
  311. );
  312. $html .= '<ul class="session-list">';
  313. foreach ($sessionList as $session) {
  314. $url = api_get_path(WEB_CODE_PATH).'mySpace/course.php?session_id='
  315. .$session['id'].'&cidReq='.$courseInfo['code'];
  316. $html .= Display::tag('li', $icon.' '.Display::url($session['name'], $url));
  317. }
  318. $html .= '</ul>';
  319. }
  320. }
  321. $html .= Display::page_subheader2(get_lang('StudentList'));
  322. // PERSON_NAME_DATA_EXPORT is buggy
  323. $is_western_name_order = api_is_western_name_order();
  324. if (count($a_students) > 0) {
  325. $getLangXDays = get_lang('XDays');
  326. $form = new FormValidator(
  327. 'reminder_form',
  328. 'get',
  329. api_get_path(WEB_CODE_PATH).'announcements/announcements.php?'.api_get_cidreq(),
  330. null,
  331. ['style' => 'margin-bottom: 10px'],
  332. FormValidator::LAYOUT_INLINE
  333. );
  334. $options = array(
  335. 2 => sprintf($getLangXDays, 2),
  336. 3 => sprintf($getLangXDays, 3),
  337. 4 => sprintf($getLangXDays, 4),
  338. 5 => sprintf($getLangXDays, 5),
  339. 6 => sprintf($getLangXDays, 6),
  340. 7 => sprintf($getLangXDays, 7),
  341. 15 => sprintf($getLangXDays, 15),
  342. 30 => sprintf($getLangXDays, 30),
  343. 'never' => get_lang('Never')
  344. );
  345. $el = $form->addSelect(
  346. 'since',
  347. Display::returnFontAwesomeIcon('warning').get_lang('RemindInactivesLearnersSince'),
  348. $options,
  349. ['class' => 'col-sm-3']
  350. );
  351. $el->setSelected(7);
  352. $form->addElement('hidden', 'action', 'add');
  353. $form->addElement('hidden', 'remindallinactives', 'true');
  354. $form->addElement('hidden', 'cidReq', $courseInfo['code']);
  355. $form->addElement('hidden', 'id_session', api_get_session_id());
  356. $form->addButtonSend(get_lang('SendNotification'));
  357. $extra_field_select = TrackingCourseLog::display_additional_profile_fields();
  358. if (!empty($extra_field_select)) {
  359. $html .= $extra_field_select;
  360. }
  361. $html .= $form->return_form();
  362. if ($export_csv) {
  363. $csv_content = array();
  364. //override the SortableTable "per page" limit if CSV
  365. $_GET['users_tracking_per_page'] = 1000000;
  366. }
  367. $all_datas = array();
  368. $course_code = $_course['id'];
  369. $user_ids = array_keys($a_students);
  370. $table = new SortableTable(
  371. 'users_tracking',
  372. array('TrackingCourseLog', 'get_number_of_users'),
  373. array('TrackingCourseLog', 'get_user_data'),
  374. (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2
  375. );
  376. $parameters['cidReq'] = Security::remove_XSS($_GET['cidReq']);
  377. $parameters['id_session'] = $session_id;
  378. $parameters['from'] = isset($_GET['myspace']) ? Security::remove_XSS($_GET['myspace']) : null;
  379. $table->set_additional_parameters($parameters);
  380. $headers = array();
  381. // tab of header texts
  382. $table->set_header(0, get_lang('OfficialCode'), true);
  383. $headers['official_code'] = get_lang('OfficialCode');
  384. if ($is_western_name_order) {
  385. $table->set_header(1, get_lang('FirstName'), true);
  386. $headers['firstname'] = get_lang('FirstName');
  387. $table->set_header(2, get_lang('LastName'), true);
  388. $headers['lastname'] = get_lang('LastName');
  389. } else {
  390. $table->set_header(1, get_lang('LastName'), true);
  391. $headers['lastname'] = get_lang('LastName');
  392. $table->set_header(2, get_lang('FirstName'), true);
  393. $headers['firstname'] = get_lang('FirstName');
  394. }
  395. $table->set_header(3, get_lang('Login'), false);
  396. $headers['login'] = get_lang('Login');
  397. $table->set_header(4, get_lang('TrainingTime').'&nbsp;'.
  398. Display::return_icon('info3.gif', get_lang('CourseTimeInfo'), array('align' => 'absmiddle', 'hspace' => '3px')), false, array('style' => 'width:110px;'));
  399. $headers['training_time'] = get_lang('TrainingTime');
  400. $table->set_header(5, get_lang('CourseProgress').'&nbsp;'.
  401. Display::return_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), false, array('style' => 'width:110px;'));
  402. $headers['course_progress'] = get_lang('CourseProgress');
  403. $table->set_header(6, get_lang('ExerciseProgress').'&nbsp;'.
  404. Display::return_icon('info3.gif', get_lang('ExerciseProgressInfo'), array('align' => 'absmiddle', 'hspace' => '3px')), false, array('style' => 'width:110px;'));
  405. $headers['exercise_progress'] = get_lang('ExerciseProgress');
  406. $table->set_header(7, get_lang('ExerciseAverage').'&nbsp;'.
  407. Display::return_icon('info3.gif', get_lang('ExerciseAverageInfo'), array('align' => 'absmiddle', 'hspace' => '3px')), false, array('style' => 'width:110px;'));
  408. $headers['exercise_average'] = get_lang('ExerciseAverage');
  409. $table->set_header(8, get_lang('Score').'&nbsp;'.
  410. Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), false, array('style' => 'width:110px;'));
  411. $headers['score'] = get_lang('Score');
  412. $table->set_header(9, get_lang('Student_publication'), false);
  413. $headers['student_publication'] = get_lang('Student_publication');
  414. $table->set_header(10, get_lang('Messages'), false);
  415. $headers['messages'] = get_lang('Messages');
  416. $table->set_header(11, get_lang('Classes'));
  417. $headers['clasess'] = get_lang('Classes');
  418. if (empty($session_id)) {
  419. $table->set_header(12, get_lang('Survey'), false);
  420. $headers['survey'] = get_lang('Survey');
  421. $table->set_header(13, get_lang('FirstLoginInCourse'), false);
  422. $headers['first_login'] = get_lang('FirstLoginInCourse');
  423. $table->set_header(14, get_lang('LatestLoginInCourse'), false);
  424. $headers['latest_login'] = get_lang('LatestLoginInCourse');
  425. if (isset($_GET['additional_profile_field'])) {
  426. $counter = 15;
  427. foreach ($_GET['additional_profile_field'] as $fieldId) {
  428. $table->set_header($counter, $extra_info[$fieldId]['display_text'], false);
  429. $headers[$extra_info[$fieldId]['variable']] = $extra_info[$fieldId]['display_text'];
  430. $counter++;
  431. }
  432. $table->set_header($counter, get_lang('Details'), false);
  433. $headers['details'] = get_lang('Details');
  434. } else {
  435. $table->set_header(15, get_lang('Details'), false);
  436. $headers['details'] = get_lang('Details');
  437. }
  438. } else {
  439. $table->set_header(12, get_lang('FirstLoginInCourse'), false);
  440. $headers['first_login'] = get_lang('FirstLoginInCourse');
  441. $table->set_header(13, get_lang('LatestLoginInCourse'), false);
  442. $headers['latest_login'] = get_lang('LatestLoginInCourse');
  443. if (isset($_GET['additional_profile_field'])) {
  444. $counter = 15;
  445. foreach ($_GET['additional_profile_field'] as $fieldId) {
  446. $table->set_header($counter, $extra_info[$fieldId]['display_text'], false);
  447. $headers[$extra_info[$fieldId]['variable']] = $extra_info[$fieldId]['display_text'];
  448. $counter++;
  449. }
  450. } else {
  451. $table->set_header(14, get_lang('Details'), false);
  452. $headers['Details'] = get_lang('Details');
  453. }
  454. }
  455. // display buttons to un hide hidden columns
  456. $html .= '<div id="unhideButtons" class="btn-toolbar">';
  457. $index = 0;
  458. $getLangDisplayColumn = get_lang('DisplayColumn');
  459. foreach ($headers as $header) {
  460. $html .= Display::toolbarButton(
  461. $header,
  462. '#',
  463. 'arrow-right',
  464. 'default',
  465. [
  466. 'title' => htmlentities("$getLangDisplayColumn \"$header\"", ENT_QUOTES),
  467. 'class' => 'hide',
  468. 'onclick' => "foldup($index); return false;"
  469. ]
  470. );
  471. $index++;
  472. }
  473. $html .= "</div>";
  474. // Display the table
  475. $html .= "<div id='reporting_table'>";
  476. $html .= $table->return_table();
  477. $html .= "</div>";
  478. } else {
  479. $html .= Display::return_message(get_lang('NoUsersInCourse'), 'warning', true);
  480. }
  481. echo Display::panel($html, $titleSession);
  482. // Send the csv file if asked.
  483. if ($export_csv) {
  484. $csv_headers = [];
  485. $csv_headers[] = get_lang('OfficialCode');
  486. if ($is_western_name_order) {
  487. $csv_headers[] = get_lang('FirstName');
  488. $csv_headers[] = get_lang('LastName');
  489. } else {
  490. $csv_headers[] = get_lang('LastName');
  491. $csv_headers[] = get_lang('FirstName');
  492. }
  493. $csv_headers[] = get_lang('Login');
  494. $csv_headers[] = get_lang('TrainingTime');
  495. $csv_headers[] = get_lang('CourseProgress');
  496. $csv_headers[] = get_lang('ExerciseProgress');
  497. $csv_headers[] = get_lang('ExerciseAverage');
  498. $csv_headers[] = get_lang('Score');
  499. $csv_headers[] = get_lang('Student_publication');
  500. $csv_headers[] = get_lang('Messages');
  501. if (empty($session_id)) {
  502. $csv_headers[] = get_lang('Survey');
  503. }
  504. $csv_headers[] = get_lang('FirstLoginInCourse');
  505. $csv_headers[] = get_lang('LatestLoginInCourse');
  506. if (isset($_GET['additional_profile_field'])) {
  507. foreach ($_GET['additional_profile_field'] as $fieldId) {
  508. $csv_headers[] = $extra_info[$fieldId]['display_text'];
  509. }
  510. }
  511. ob_end_clean();
  512. // Adding headers before the content.
  513. array_unshift($csv_content, $csv_headers);
  514. if ($session_id) {
  515. $sessionData = [];
  516. $sessionInfo = api_get_session_info($session_id);
  517. $sessionDates = SessionManager::parseSessionDates($sessionInfo);
  518. array_unshift($csv_content, [get_lang('Date'), $sessionDates['access']]);
  519. array_unshift($csv_content, [get_lang('SessionName'), $sessionInfo['name']]);
  520. }
  521. Export::arrayToCsv($csv_content, 'reporting_student_list');
  522. exit;
  523. }
  524. Display::display_footer();