exams.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Exams script
  5. * @package chamilo.tracking
  6. */
  7. require_once __DIR__.'/../inc/global.inc.php';
  8. $toolTable = Database::get_course_table(TABLE_TOOL_LIST);
  9. $quizTable = Database::get_course_table(TABLE_QUIZ_TEST);
  10. $this_section = SECTION_TRACKING;
  11. $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
  12. if (!$is_allowedToTrack) {
  13. api_not_allowed();
  14. }
  15. $exportToXLS = false;
  16. if (isset($_GET['export'])) {
  17. $exportToXLS = true;
  18. }
  19. if (api_is_platform_admin() && empty($_GET['cidReq'])) {
  20. $global = true;
  21. } else {
  22. $global = false;
  23. }
  24. $courseList = array();
  25. if ($global) {
  26. $temp = CourseManager::get_courses_list();
  27. foreach ($temp as $tempCourse) {
  28. $courseInfo = api_get_course_info($tempCourse['code']);
  29. $courseList[] = $courseInfo;
  30. }
  31. } else {
  32. $courseList = array(api_get_course_info());
  33. }
  34. $sessionId = api_get_session_id();
  35. if (empty($sessionId)) {
  36. $sessionCondition = ' AND session_id = 0';
  37. } else {
  38. $sessionCondition = api_get_session_condition($sessionId, true, true);
  39. }
  40. $form = new FormValidator('search_simple', 'POST', '', '', null, false);
  41. $form->addElement('text', 'score', get_lang('Percentage'));
  42. if ($global) {
  43. $form->addElement('hidden', 'view', 'admin');
  44. } else {
  45. // Get exam lists
  46. $courseId = api_get_course_int_id();
  47. $sql = "SELECT quiz.title, id FROM $quizTable AS quiz
  48. WHERE
  49. c_id = $courseId AND
  50. active = 1
  51. $sessionCondition
  52. ORDER BY quiz.title ASC";
  53. $result = Database::query($sql);
  54. $exerciseList = array(get_lang('All'));
  55. while ($row = Database::fetch_array($result)) {
  56. $exerciseList[$row['id']] = $row['title'];
  57. }
  58. $form->addElement('select', 'exercise_id', get_lang('Exercise'), $exerciseList);
  59. }
  60. $form->addButtonFilter(get_lang('Filter'));
  61. $filter_score = isset($_REQUEST['score']) ? intval($_REQUEST['score']) : 70;
  62. $exerciseId = isset($_REQUEST['exercise_id']) ? intval($_REQUEST['exercise_id']) : 0;
  63. $form->setDefaults(array('score' => $filter_score));
  64. if (!$exportToXLS) {
  65. Display :: display_header(get_lang('Reporting'));
  66. $actionsLeft = $actionsRight = '';
  67. if ($global) {
  68. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'auth/my_progress.php">'.
  69. Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM);
  70. $actionsLeft .= '</a>';
  71. $courseInfo = api_get_course_info();
  72. $actionsRight .= '<a href="'.api_get_self().'?export=1&score='.$filter_score.'&exercise_id='.$exerciseId.'">'.
  73. Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
  74. $actionsRight .= '<a href="javascript: void(0);" onclick="javascript: window.print()">'.
  75. Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).'</a>';
  76. $menuItems[] = Display::url(
  77. Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32),
  78. api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher'
  79. );
  80. if (api_is_platform_admin()) {
  81. $menuItems[] = Display::url(
  82. Display::return_icon('star.png', get_lang('AdminInterface'), array(), 32),
  83. api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php'
  84. );
  85. } else {
  86. $menuItems[] = Display::url(
  87. Display::return_icon('star.png', get_lang('CoachInterface'), array(), 32),
  88. api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=coach'
  89. );
  90. }
  91. $menuItems[] = '<a href="#">'.Display::return_icon('quiz_na.png', get_lang('ExamTracking'), array(), 32).'</a>';
  92. $nb_menu_items = count($menuItems);
  93. if ($nb_menu_items > 1) {
  94. foreach ($menuItems as $key => $item) {
  95. $actionsLeft .= $item;
  96. }
  97. }
  98. } else {
  99. $actionsLeft .= Display::url(
  100. Display::return_icon('user.png', get_lang('StudentsTracking'), array(), 32),
  101. 'courseLog.php?'.api_get_cidreq().'&studentlist=true'
  102. );
  103. $actionsLeft .= Display::url(
  104. Display::return_icon('course.png', get_lang('CourseTracking'), array(), 32),
  105. 'courseLog.php?'.api_get_cidreq().'&studentlist=false'
  106. );
  107. $actionsLeft .= Display::url(
  108. Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), 32),
  109. 'courseLog.php?'.api_get_cidreq().'&studentlist=resouces'
  110. );
  111. $actionsLeft .= Display::url(
  112. Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), array(), 32),
  113. api_get_self().'?'.api_get_cidreq().'&export=1&score='.$filter_score.'&exercise_id='.$exerciseId
  114. );
  115. }
  116. $toolbar = Display::toolbarAction('toolbar-exams', [$actionsLeft, $actionsRight]);
  117. echo $toolbar;
  118. $form->display();
  119. echo '<h3>'.sprintf(get_lang('FilteringWithScoreX'), $filter_score).'%</h3>';
  120. }
  121. $html = '<table class="data_table">';
  122. if ($global) {
  123. $html .= '<tr>';
  124. $html .= '<th>'.get_lang('Courses').'</th>';
  125. $html .= '<th>'.get_lang('Quiz').'</th>';
  126. $html .= '<th>'.get_lang('ExamTaken').'</th>';
  127. $html .= '<th>'.get_lang('ExamNotTaken').'</th>';
  128. $html .= '<th>'.sprintf(get_lang('ExamPassX'), $filter_score).'%</th>';
  129. $html .= '<th>'.get_lang('ExamFail').'</th>';
  130. $html .= '<th>'.get_lang('TotalStudents').'</th>';
  131. $html .= '</tr>';
  132. } else {
  133. $html .= '<tr>';
  134. $html .= '<th>'.get_lang('Quiz').'</th>';
  135. $html .= '<th>'.get_lang('User').'</th>';
  136. //$html .= '<th>'.sprintf(get_lang('ExamPassX'), $filter_score).'</th>';
  137. $html .= '<th>'.get_lang('Percentage').' %</th>';
  138. $html .= '<th>'.get_lang('Status').'</th>';
  139. $html .= '<th>'.get_lang('Attempts').'</th>';
  140. $html .= '</tr>';
  141. }
  142. $export_array_global = $export_array = array();
  143. $s_css_class = null;
  144. if (!empty($courseList) && is_array($courseList)) {
  145. foreach ($courseList as $courseInfo) {
  146. $sessionList = SessionManager::get_session_by_course($courseInfo['real_id']);
  147. $newSessionList = array();
  148. if (!empty($sessionList)) {
  149. foreach ($sessionList as $session) {
  150. $newSessionList[$session['id']] = $session['name'];
  151. }
  152. }
  153. $courseId = $courseInfo['real_id'];
  154. if ($global) {
  155. $sql = "SELECT count(id) as count
  156. FROM $quizTable AS quiz
  157. WHERE c_id = $courseId AND active = 1 AND (session_id = 0 OR session_id IS NULL)";
  158. $result = Database::query($sql);
  159. $countExercises = Database::store_result($result);
  160. $exerciseCount = $countExercises[0]['count'];
  161. $sql = "SELECT count(id) as count
  162. FROM $quizTable AS quiz
  163. WHERE c_id = $courseId AND active = 1 AND session_id <> 0";
  164. $result = Database::query($sql);
  165. $countExercises = Database::store_result($result);
  166. $exerciseSessionCount = $countExercises[0]['count'];
  167. $exerciseCount = $exerciseCount + $exerciseCount * count($newSessionList) + $exerciseSessionCount;
  168. // Add course and session list.
  169. if ($exerciseCount == 0) {
  170. $exerciseCount = 2;
  171. }
  172. $html .= "<tr>
  173. <td rowspan=$exerciseCount>";
  174. $html .= $courseInfo['title'];
  175. $html .= "</td>";
  176. }
  177. $sql = "SELECT visibility FROM $toolTable
  178. WHERE c_id = $courseId AND name = 'quiz'";
  179. $result = Database::query($sql);
  180. // If main tool is visible.
  181. if (Database::result($result, 0, 'visibility') == 1) {
  182. // Getting the exam list.
  183. if ($global) {
  184. $sql = "SELECT quiz.title, id, session_id
  185. FROM $quizTable AS quiz
  186. WHERE c_id = $courseId AND active = 1
  187. ORDER BY session_id, quiz.title ASC";
  188. } else {
  189. //$sessionCondition = api_get_session_condition($sessionId, true, false);
  190. if (!empty($exerciseId)) {
  191. $sql = "SELECT quiz.title, id, session_id
  192. FROM $quizTable AS quiz
  193. WHERE
  194. c_id = $courseId AND
  195. active = 1 AND
  196. id = $exerciseId
  197. $sessionCondition
  198. ORDER BY session_id, quiz.title ASC";
  199. } else {
  200. $sql = "SELECT quiz.title, id, session_id
  201. FROM $quizTable AS quiz
  202. WHERE
  203. c_id = $courseId AND
  204. active = 1
  205. $sessionCondition
  206. ORDER BY session_id, quiz.title ASC";
  207. }
  208. }
  209. $resultExercises = Database::query($sql);
  210. if (Database::num_rows($resultExercises) > 0) {
  211. while ($exercise = Database::fetch_array($resultExercises, 'ASSOC')) {
  212. $exerciseSessionId = $exercise['session_id'];
  213. if (empty($exerciseSessionId)) {
  214. if ($global) {
  215. // If the exercise was created in the base course.
  216. // Load all sessions.
  217. foreach ($newSessionList as $currentSessionId => $sessionName) {
  218. $result = processStudentList(
  219. $filter_score,
  220. $global,
  221. $exercise,
  222. $courseInfo,
  223. $currentSessionId,
  224. $newSessionList
  225. );
  226. $html .= $result['html'];
  227. $export_array_global = array_merge($export_array_global, $result['export_array_global']);
  228. }
  229. // Load base course.
  230. $result = processStudentList(
  231. $filter_score,
  232. $global,
  233. $exercise,
  234. $courseInfo,
  235. 0,
  236. $newSessionList
  237. );
  238. $html .= $result['html'];
  239. $export_array_global = array_merge($export_array_global, $result['export_array_global']);
  240. } else {
  241. if (empty($sessionId)) {
  242. // Load base course.
  243. $result = processStudentList(
  244. $filter_score,
  245. $global,
  246. $exercise,
  247. $courseInfo,
  248. 0,
  249. $newSessionList
  250. );
  251. $html .= $result['html'];
  252. $export_array_global = array_merge(
  253. $export_array_global,
  254. $result['export_array_global']
  255. );
  256. } else {
  257. $result = processStudentList(
  258. $filter_score,
  259. $global,
  260. $exercise,
  261. $courseInfo,
  262. $sessionId,
  263. $newSessionList
  264. );
  265. $html .= $result['html'];
  266. $export_array_global = array_merge(
  267. $export_array_global,
  268. $result['export_array_global']
  269. );
  270. }
  271. }
  272. } else {
  273. // If the exercise only exists in this session.
  274. $result = processStudentList(
  275. $filter_score,
  276. $global,
  277. $exercise,
  278. $courseInfo,
  279. $exerciseSessionId,
  280. $newSessionList
  281. );
  282. $html .= $result['html'];
  283. $export_array_global = array_merge(
  284. $export_array_global,
  285. $result['export_array_global']
  286. );
  287. }
  288. }
  289. } else {
  290. $html .= "<tr>
  291. <td colspan='6'>
  292. ".get_lang('NoExercise')."
  293. </td>
  294. </tr>
  295. ";
  296. }
  297. } else {
  298. $html .= "<tr>
  299. <td colspan='6'>
  300. ".get_lang('NoExercise')."
  301. </td>
  302. </tr>
  303. ";
  304. }
  305. }
  306. }
  307. $html .= '</table>';
  308. if (!$exportToXLS) {
  309. echo $html;
  310. }
  311. $filename = 'exam-reporting-'.api_get_local_time().'.xlsx';
  312. if ($exportToXLS) {
  313. export_complete_report_xls($filename, $export_array_global);
  314. exit;
  315. }
  316. /**
  317. * @param $a
  318. * @param $b
  319. * @return int
  320. */
  321. function sort_user($a, $b) {
  322. if (is_numeric($a['score']) && is_numeric($b['score'])) {
  323. if ($a['score'] < $b['score']) {
  324. return 1;
  325. }
  326. return 0;
  327. }
  328. return 1;
  329. }
  330. /**
  331. * @param string $filename
  332. * @param array $array
  333. */
  334. function export_complete_report_xls($filename, $array)
  335. {
  336. global $global, $filter_score;
  337. $spreadsheet = new PHPExcel();
  338. $spreadsheet->setActiveSheetIndex(0);
  339. $worksheet = $spreadsheet->getActiveSheet();
  340. $line = 1;
  341. $column = 0; //skip the first column (row titles)
  342. if ($global) {
  343. $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Courses'));
  344. $column++;
  345. $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Exercises'));
  346. $column++;
  347. $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ExamTaken'));
  348. $column++;
  349. $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ExamNotTaken'));
  350. $column++;
  351. $worksheet->setCellValueByColumnAndRow($column, $line, sprintf(get_lang('ExamPassX'), $filter_score).'%');
  352. $column++;
  353. $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ExamFail'));
  354. $column++;
  355. $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('TotalStudents'));
  356. $column++;
  357. $line++;
  358. foreach ($array as $row) {
  359. $column = 0;
  360. foreach ($row as $item) {
  361. $worksheet->setCellValueByColumnAndRow($column, $line, html_entity_decode(strip_tags($item)));
  362. $column++;
  363. }
  364. $line++;
  365. }
  366. $line++;
  367. } else {
  368. $worksheet->setCellValueByColumnAndRow(0, $line, get_lang('Exercises'));
  369. $worksheet->setCellValueByColumnAndRow(1, $line, get_lang('User'));
  370. $worksheet->setCellValueByColumnAndRow(2, $line, get_lang('Percentage'));
  371. $worksheet->setCellValueByColumnAndRow(3, $line, get_lang('Status'));
  372. $worksheet->setCellValueByColumnAndRow(4, $line, get_lang('Attempts'));
  373. $line++;
  374. foreach ($array as $row) {
  375. $worksheet->setCellValueByColumnAndRow(
  376. 0,
  377. $line,
  378. html_entity_decode(strip_tags($row['exercise']))
  379. );
  380. foreach ($row['users'] as $key => $user) {
  381. $worksheet->setCellValueByColumnAndRow(
  382. 1,
  383. $line,
  384. html_entity_decode(strip_tags($user))
  385. );
  386. $column = 2;
  387. foreach ($row['results'][$key] as $result_item) {
  388. $worksheet->setCellValueByColumnAndRow(
  389. $column,
  390. $line,
  391. html_entity_decode(strip_tags($result_item))
  392. );
  393. $column++;
  394. }
  395. $line++;
  396. }
  397. }
  398. }
  399. $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
  400. $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
  401. $writer->save($file);
  402. DocumentManager::file_send_for_download($file, true, $filename);
  403. exit;
  404. }
  405. /**
  406. * @param $filter_score
  407. * @param $global
  408. * @param $exercise
  409. * @param $courseInfo
  410. * @param $sessionId
  411. * @param $newSessionList
  412. * @return array
  413. */
  414. function processStudentList($filter_score, $global, $exercise, $courseInfo, $sessionId, $newSessionList)
  415. {
  416. if (
  417. (isset($exercise['id']) && empty($exercise['id'])) ||
  418. !isset($exercise['id'])
  419. ) {
  420. return array(
  421. 'html' => '',
  422. 'export_array_global' => [],
  423. 'total_students' => 0
  424. );
  425. }
  426. $exerciseStatsTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
  427. $courseId = api_get_course_int_id($courseInfo['code']);
  428. if (empty($sessionId)) {
  429. $students = CourseManager::get_student_list_from_course_code(
  430. $courseInfo['code'],
  431. false,
  432. 0,
  433. null,
  434. null,
  435. false
  436. );
  437. } else {
  438. $students = CourseManager::get_student_list_from_course_code(
  439. $courseInfo['code'],
  440. true,
  441. $sessionId,
  442. null,
  443. null,
  444. false
  445. );
  446. }
  447. $html = null;
  448. $totalStudents = count($students);
  449. if (!$global) {
  450. $html .= "<tr>";
  451. }
  452. if (!$global) {
  453. $html .= '<td rowspan="'.$totalStudents.'">';
  454. } else {
  455. $html .= '<td>';
  456. }
  457. $html .= $exercise['title'];
  458. if ($global && !empty($sessionId)) {
  459. $sessionName = isset($newSessionList[$sessionId]) ? $newSessionList[$sessionId] : null;
  460. $html .= Display::return_icon('star.png', get_lang('Session')).' ('.$sessionName.')';
  461. }
  462. $html .= '</td>';
  463. $globalRow = array(
  464. $courseInfo['title'],
  465. $exercise['title']
  466. );
  467. $total_with_parameter_score = 0;
  468. $taken = 0;
  469. $export_array_global = array();
  470. $studentResult = array();
  471. foreach ($students as $student) {
  472. $studentId = isset($student['user_id']) ? $student['user_id'] : $student['id_user'];
  473. $sql = "SELECT COUNT(ex.exe_id) as count
  474. FROM $exerciseStatsTable AS ex
  475. WHERE
  476. ex.c_id = $courseId AND
  477. ex.exe_exo_id = ".$exercise['id']." AND
  478. exe_user_id= $studentId AND
  479. session_id = $sessionId
  480. ";
  481. $result = Database::query($sql);
  482. $attempts = Database::fetch_array($result);
  483. $sql = "SELECT exe_id, exe_result, exe_weighting
  484. FROM $exerciseStatsTable
  485. WHERE
  486. exe_user_id = $studentId AND
  487. c_id = $courseId AND
  488. exe_exo_id = ".$exercise['id']." AND
  489. session_id = $sessionId
  490. ORDER BY exe_result DESC
  491. LIMIT 1";
  492. $result = Database::query($sql);
  493. $score = 0;
  494. $weighting = 0;
  495. while ($scoreInfo = Database::fetch_array($result)) {
  496. $score = $score + $scoreInfo['exe_result'];
  497. $weighting = $weighting + $scoreInfo['exe_weighting'];
  498. }
  499. $percentageScore = 0;
  500. if ($weighting != 0) {
  501. $percentageScore = round(($score * 100) / $weighting);
  502. }
  503. if ($attempts['count'] > 0) {
  504. $taken++;
  505. }
  506. if ($percentageScore >= $filter_score) {
  507. $total_with_parameter_score++;
  508. }
  509. $tempArray = array();
  510. if (!$global) {
  511. $userInfo = api_get_user_info($studentId);
  512. // User
  513. $userRow = '<td>';
  514. $userRow .= $userInfo['complete_name'];
  515. $userRow .= '</td>';
  516. // Best result
  517. if (!empty($attempts['count'])) {
  518. $userRow .= '<td>';
  519. $userRow .= $percentageScore;
  520. $tempArray[] = $percentageScore;
  521. $userRow .= '</td>';
  522. if ($percentageScore >= $filter_score) {
  523. $userRow .= '<td style="background-color:#DFFFA8">';
  524. $userRow .= get_lang('PassExam').'</td>';
  525. $tempArray[] = get_lang('PassExam');
  526. } else {
  527. $userRow .= '<td style="background-color:#FC9A9E" >';
  528. $userRow .= get_lang('ExamFail').'</td>';
  529. $tempArray[] = get_lang('ExamFail');
  530. }
  531. $userRow .= '<td>';
  532. $userRow .= $attempts['count'];
  533. $tempArray[] = $attempts['count'];
  534. $userRow .= '</td>';
  535. } else {
  536. $score = '-';
  537. $userRow .= '<td>';
  538. $userRow .= '-';
  539. $tempArray[] = '-';
  540. $userRow .= '</td>';
  541. $userRow .= '<td style="background-color:#FCE89A">';
  542. $userRow .= get_lang('NoAttempt');
  543. $tempArray[] = get_lang('NoAttempt');
  544. $userRow .= '</td>';
  545. $userRow .= '<td>';
  546. $userRow .= 0;
  547. $tempArray[] = 0;
  548. $userRow .= '</td>';
  549. }
  550. $userRow .= '</tr>';
  551. $studentResult[$studentId] = array(
  552. 'html' => $userRow,
  553. 'score' => $score,
  554. 'array' => $tempArray,
  555. 'user' => $userInfo['complete_name']
  556. );
  557. }
  558. }
  559. $row_not_global['exercise'] = $exercise['title'];
  560. if (!$global) {
  561. if (!empty($studentResult)) {
  562. $studentResultEmpty = $studentResultContent = array();
  563. foreach ($studentResult as $row) {
  564. if ($row['score'] == '-') {
  565. $studentResultEmpty[] = $row;
  566. } else {
  567. $studentResultContent[] = $row;
  568. }
  569. }
  570. // Sort only users with content
  571. usort($studentResultContent, 'sort_user');
  572. $studentResult = array_merge($studentResultContent, $studentResultEmpty);
  573. foreach ($studentResult as $row) {
  574. $html .= $row['html'];
  575. $row_not_global['results'][] = $row['array'];
  576. $row_not_global['users'][] = $row['user'];
  577. }
  578. $export_array[] = $row_not_global;
  579. }
  580. }
  581. if ($global) {
  582. // Exam taken
  583. $html .= '<td>';
  584. $html .= $taken;
  585. $globalRow[] = $taken;
  586. $html .= '</td>';
  587. // Exam NOT taken
  588. $html .= '<td>';
  589. $html .= $not_taken = $totalStudents - $taken;
  590. $globalRow[] = $not_taken;
  591. $html .= '</td>';
  592. // Exam pass
  593. if (!empty($total_with_parameter_score)) {
  594. $html .= '<td style="background-color:#DFFFA8" >';
  595. } else {
  596. $html .= '<td style="background-color:#FCE89A" >';
  597. }
  598. $html .= $total_with_parameter_score;
  599. $globalRow[] = $total_with_parameter_score;
  600. $html .= '</td>';
  601. // Exam fail
  602. $html .= '<td>';
  603. $html .= $fail = $taken - $total_with_parameter_score;
  604. $globalRow[] = $fail;
  605. $html .= '</td>';
  606. $html .= '<td>';
  607. $html .= $totalStudents;
  608. $globalRow[] = $totalStudents;
  609. $html .= '</td>';
  610. $html .= '</tr>';
  611. $export_array_global[] = $globalRow;
  612. }
  613. return array(
  614. 'html' => $html,
  615. 'export_array_global' => $global ? $export_array_global : $export_array,
  616. 'total_students' => $totalStudents
  617. );
  618. }
  619. Display :: display_footer();