exams.php 24 KB

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