exams.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  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>'.get_lang('Username').'</th>';
  137. //$html .= '<th>'.sprintf(get_lang('ExamPassX'), $filter_score).'</th>';
  138. $html .= '<th>'.get_lang('Percentage').' %</th>';
  139. $html .= '<th>'.get_lang('Status').'</th>';
  140. $html .= '<th>'.get_lang('Attempts').'</th>';
  141. $html .= '</tr>';
  142. }
  143. $export_array_global = $export_array = array();
  144. $s_css_class = null;
  145. if (!empty($courseList) && is_array($courseList)) {
  146. foreach ($courseList as $courseInfo) {
  147. $sessionList = SessionManager::get_session_by_course($courseInfo['real_id']);
  148. $newSessionList = array();
  149. if (!empty($sessionList)) {
  150. foreach ($sessionList as $session) {
  151. $newSessionList[$session['id']] = $session['name'];
  152. }
  153. }
  154. $courseId = $courseInfo['real_id'];
  155. if ($global) {
  156. $sql = "SELECT count(id) as count
  157. FROM $quizTable AS quiz
  158. WHERE c_id = $courseId AND active = 1 AND (session_id = 0 OR session_id IS NULL)";
  159. $result = Database::query($sql);
  160. $countExercises = Database::store_result($result);
  161. $exerciseCount = $countExercises[0]['count'];
  162. $sql = "SELECT count(id) as count
  163. FROM $quizTable AS quiz
  164. WHERE c_id = $courseId AND active = 1 AND session_id <> 0";
  165. $result = Database::query($sql);
  166. $countExercises = Database::store_result($result);
  167. $exerciseSessionCount = $countExercises[0]['count'];
  168. $exerciseCount = $exerciseCount + $exerciseCount * count($newSessionList) + $exerciseSessionCount;
  169. // Add course and session list.
  170. if ($exerciseCount == 0) {
  171. $exerciseCount = 2;
  172. }
  173. $html .= "<tr>
  174. <td rowspan=$exerciseCount>";
  175. $html .= $courseInfo['title'];
  176. $html .= "</td>";
  177. }
  178. $sql = "SELECT visibility FROM $toolTable
  179. WHERE c_id = $courseId AND name = 'quiz'";
  180. $result = Database::query($sql);
  181. // If main tool is visible.
  182. if (Database::result($result, 0, 'visibility') == 1) {
  183. // Getting the exam list.
  184. if ($global) {
  185. $sql = "SELECT quiz.title, id, session_id
  186. FROM $quizTable AS quiz
  187. WHERE c_id = $courseId AND active = 1
  188. ORDER BY session_id, quiz.title ASC";
  189. } else {
  190. //$sessionCondition = api_get_session_condition($sessionId, true, false);
  191. if (!empty($exerciseId)) {
  192. $sql = "SELECT quiz.title, id, session_id
  193. FROM $quizTable AS quiz
  194. WHERE
  195. c_id = $courseId AND
  196. active = 1 AND
  197. id = $exerciseId
  198. $sessionCondition
  199. ORDER BY session_id, quiz.title ASC";
  200. } else {
  201. $sql = "SELECT quiz.title, id, session_id
  202. FROM $quizTable AS quiz
  203. WHERE
  204. c_id = $courseId AND
  205. active = 1
  206. $sessionCondition
  207. ORDER BY session_id, quiz.title ASC";
  208. }
  209. }
  210. $resultExercises = Database::query($sql);
  211. if (Database::num_rows($resultExercises) > 0) {
  212. while ($exercise = Database::fetch_array($resultExercises, 'ASSOC')) {
  213. $exerciseSessionId = $exercise['session_id'];
  214. if (empty($exerciseSessionId)) {
  215. if ($global) {
  216. // If the exercise was created in the base course.
  217. // Load all sessions.
  218. foreach ($newSessionList as $currentSessionId => $sessionName) {
  219. $result = processStudentList(
  220. $filter_score,
  221. $global,
  222. $exercise,
  223. $courseInfo,
  224. $currentSessionId,
  225. $newSessionList
  226. );
  227. $html .= $result['html'];
  228. $export_array_global = array_merge($export_array_global, $result['export_array_global']);
  229. }
  230. // Load base course.
  231. $result = processStudentList(
  232. $filter_score,
  233. $global,
  234. $exercise,
  235. $courseInfo,
  236. 0,
  237. $newSessionList
  238. );
  239. $html .= $result['html'];
  240. $export_array_global = array_merge($export_array_global, $result['export_array_global']);
  241. } else {
  242. if (empty($sessionId)) {
  243. // Load base course.
  244. $result = processStudentList(
  245. $filter_score,
  246. $global,
  247. $exercise,
  248. $courseInfo,
  249. 0,
  250. $newSessionList
  251. );
  252. $html .= $result['html'];
  253. $export_array_global = array_merge(
  254. $export_array_global,
  255. $result['export_array_global']
  256. );
  257. } else {
  258. $result = processStudentList(
  259. $filter_score,
  260. $global,
  261. $exercise,
  262. $courseInfo,
  263. $sessionId,
  264. $newSessionList
  265. );
  266. $html .= $result['html'];
  267. $export_array_global = array_merge(
  268. $export_array_global,
  269. $result['export_array_global']
  270. );
  271. }
  272. }
  273. } else {
  274. // If the exercise only exists in this session.
  275. $result = processStudentList(
  276. $filter_score,
  277. $global,
  278. $exercise,
  279. $courseInfo,
  280. $exerciseSessionId,
  281. $newSessionList
  282. );
  283. $html .= $result['html'];
  284. $export_array_global = array_merge(
  285. $export_array_global,
  286. $result['export_array_global']
  287. );
  288. }
  289. }
  290. } else {
  291. $html .= "<tr>
  292. <td colspan='6'>
  293. ".get_lang('NoExercise')."
  294. </td>
  295. </tr>
  296. ";
  297. }
  298. } else {
  299. $html .= "<tr>
  300. <td colspan='6'>
  301. ".get_lang('NoExercise')."
  302. </td>
  303. </tr>
  304. ";
  305. }
  306. }
  307. }
  308. $html .= '</table>';
  309. if (!$exportToXLS) {
  310. echo $html;
  311. }
  312. $filename = 'exam-reporting-'.api_get_local_time().'.xlsx';
  313. if ($exportToXLS) {
  314. export_complete_report_xls($filename, $export_array_global);
  315. exit;
  316. }
  317. /**
  318. * @param $a
  319. * @param $b
  320. * @return int
  321. */
  322. function sort_user($a, $b) {
  323. if (is_numeric($a['score']) && is_numeric($b['score'])) {
  324. if ($a['score'] < $b['score']) {
  325. return 1;
  326. }
  327. return 0;
  328. }
  329. return 1;
  330. }
  331. /**
  332. * @param string $filename
  333. * @param array $array
  334. */
  335. function export_complete_report_xls($filename, $array)
  336. {
  337. global $global, $filter_score;
  338. $spreadsheet = new PHPExcel();
  339. $spreadsheet->setActiveSheetIndex(0);
  340. $worksheet = $spreadsheet->getActiveSheet();
  341. $line = 1;
  342. $column = 0; //skip the first column (row titles)
  343. if ($global) {
  344. $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Courses'));
  345. $column++;
  346. $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Exercises'));
  347. $column++;
  348. $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ExamTaken'));
  349. $column++;
  350. $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ExamNotTaken'));
  351. $column++;
  352. $worksheet->setCellValueByColumnAndRow($column, $line, sprintf(get_lang('ExamPassX'), $filter_score).'%');
  353. $column++;
  354. $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ExamFail'));
  355. $column++;
  356. $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('TotalStudents'));
  357. $column++;
  358. $line++;
  359. foreach ($array as $row) {
  360. $column = 0;
  361. foreach ($row as $item) {
  362. $worksheet->setCellValueByColumnAndRow($column, $line, html_entity_decode(strip_tags($item)));
  363. $column++;
  364. }
  365. $line++;
  366. }
  367. $line++;
  368. } else {
  369. $worksheet->setCellValueByColumnAndRow(0, $line, get_lang('Exercises'));
  370. $worksheet->setCellValueByColumnAndRow(1, $line, get_lang('User'));
  371. $worksheet->setCellValueByColumnAndRow(2, $line, get_lang('Username'));
  372. $worksheet->setCellValueByColumnAndRow(3, $line, get_lang('Percentage'));
  373. $worksheet->setCellValueByColumnAndRow(4, $line, get_lang('Status'));
  374. $worksheet->setCellValueByColumnAndRow(5, $line, get_lang('Attempts'));
  375. $line++;
  376. foreach ($array as $row) {
  377. $worksheet->setCellValueByColumnAndRow(
  378. 0,
  379. $line,
  380. html_entity_decode(strip_tags($row['exercise']))
  381. );
  382. foreach ($row['users'] as $key => $user) {
  383. $worksheet->setCellValueByColumnAndRow(
  384. 1,
  385. $line,
  386. html_entity_decode(strip_tags($user))
  387. );
  388. $worksheet->setCellValueByColumnAndRow(
  389. 2,
  390. $line,
  391. $row['usernames'][$key]
  392. );
  393. $column = 3;
  394. foreach ($row['results'][$key] as $result_item) {
  395. $worksheet->setCellValueByColumnAndRow(
  396. $column,
  397. $line,
  398. html_entity_decode(strip_tags($result_item))
  399. );
  400. $column++;
  401. }
  402. $line++;
  403. }
  404. }
  405. }
  406. $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
  407. $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
  408. $writer->save($file);
  409. DocumentManager::file_send_for_download($file, true, $filename);
  410. exit;
  411. }
  412. /**
  413. * @param $filter_score
  414. * @param $global
  415. * @param $exercise
  416. * @param $courseInfo
  417. * @param $sessionId
  418. * @param $newSessionList
  419. * @return array
  420. */
  421. function processStudentList($filter_score, $global, $exercise, $courseInfo, $sessionId, $newSessionList)
  422. {
  423. if (
  424. (isset($exercise['id']) && empty($exercise['id'])) ||
  425. !isset($exercise['id'])
  426. ) {
  427. return array(
  428. 'html' => '',
  429. 'export_array_global' => [],
  430. 'total_students' => 0
  431. );
  432. }
  433. $exerciseStatsTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
  434. $courseId = api_get_course_int_id($courseInfo['code']);
  435. if (empty($sessionId)) {
  436. $students = CourseManager::get_student_list_from_course_code(
  437. $courseInfo['code'],
  438. false,
  439. 0,
  440. null,
  441. null,
  442. false
  443. );
  444. } else {
  445. $students = CourseManager::get_student_list_from_course_code(
  446. $courseInfo['code'],
  447. true,
  448. $sessionId,
  449. null,
  450. null,
  451. false
  452. );
  453. }
  454. $html = null;
  455. $totalStudents = count($students);
  456. if (!$global) {
  457. $html .= "<tr>";
  458. }
  459. if (!$global) {
  460. $html .= '<td rowspan="'.$totalStudents.'">';
  461. } else {
  462. $html .= '<td>';
  463. }
  464. $html .= $exercise['title'];
  465. if ($global && !empty($sessionId)) {
  466. $sessionName = isset($newSessionList[$sessionId]) ? $newSessionList[$sessionId] : null;
  467. $html .= Display::return_icon('star.png', get_lang('Session')).' ('.$sessionName.')';
  468. }
  469. $html .= '</td>';
  470. $globalRow = array(
  471. $courseInfo['title'],
  472. $exercise['title']
  473. );
  474. $total_with_parameter_score = 0;
  475. $taken = 0;
  476. $export_array_global = array();
  477. $studentResult = array();
  478. foreach ($students as $student) {
  479. $studentId = isset($student['user_id']) ? $student['user_id'] : $student['id_user'];
  480. $sql = "SELECT COUNT(ex.exe_id) as count
  481. FROM $exerciseStatsTable AS ex
  482. WHERE
  483. ex.c_id = $courseId AND
  484. ex.exe_exo_id = ".$exercise['id']." AND
  485. exe_user_id= $studentId AND
  486. session_id = $sessionId
  487. ";
  488. $result = Database::query($sql);
  489. $attempts = Database::fetch_array($result);
  490. $sql = "SELECT exe_id, exe_result, exe_weighting
  491. FROM $exerciseStatsTable
  492. WHERE
  493. exe_user_id = $studentId AND
  494. c_id = $courseId AND
  495. exe_exo_id = ".$exercise['id']." AND
  496. session_id = $sessionId
  497. ORDER BY exe_result DESC
  498. LIMIT 1";
  499. $result = Database::query($sql);
  500. $score = 0;
  501. $weighting = 0;
  502. while ($scoreInfo = Database::fetch_array($result)) {
  503. $score = $score + $scoreInfo['exe_result'];
  504. $weighting = $weighting + $scoreInfo['exe_weighting'];
  505. }
  506. $percentageScore = 0;
  507. if ($weighting != 0) {
  508. $percentageScore = round(($score * 100) / $weighting);
  509. }
  510. if ($attempts['count'] > 0) {
  511. $taken++;
  512. }
  513. if ($percentageScore >= $filter_score) {
  514. $total_with_parameter_score++;
  515. }
  516. $tempArray = array();
  517. if (!$global) {
  518. $userInfo = api_get_user_info($studentId);
  519. // User
  520. $userRow = '<td>';
  521. $userRow .= $userInfo['complete_name'];
  522. $userRow .= '</td>';
  523. $userRow .= '<td>'.$userInfo['username'].'</td>';
  524. // Best result
  525. if (!empty($attempts['count'])) {
  526. $userRow .= '<td>';
  527. $userRow .= $percentageScore;
  528. $tempArray[] = $percentageScore;
  529. $userRow .= '</td>';
  530. if ($percentageScore >= $filter_score) {
  531. $userRow .= '<td style="background-color:#DFFFA8">';
  532. $userRow .= get_lang('PassExam').'</td>';
  533. $tempArray[] = get_lang('PassExam');
  534. } else {
  535. $userRow .= '<td style="background-color:#FC9A9E" >';
  536. $userRow .= get_lang('ExamFail').'</td>';
  537. $tempArray[] = get_lang('ExamFail');
  538. }
  539. $userRow .= '<td>';
  540. $userRow .= $attempts['count'];
  541. $tempArray[] = $attempts['count'];
  542. $userRow .= '</td>';
  543. } else {
  544. $score = '-';
  545. $userRow .= '<td>';
  546. $userRow .= '-';
  547. $tempArray[] = '-';
  548. $userRow .= '</td>';
  549. $userRow .= '<td style="background-color:#FCE89A">';
  550. $userRow .= get_lang('NoAttempt');
  551. $tempArray[] = get_lang('NoAttempt');
  552. $userRow .= '</td>';
  553. $userRow .= '<td>';
  554. $userRow .= 0;
  555. $tempArray[] = 0;
  556. $userRow .= '</td>';
  557. }
  558. $userRow .= '</tr>';
  559. $studentResult[$studentId] = array(
  560. 'html' => $userRow,
  561. 'score' => $score,
  562. 'array' => $tempArray,
  563. 'user' => $userInfo['complete_name'],
  564. 'username' => $userInfo['username']
  565. );
  566. }
  567. }
  568. $row_not_global['exercise'] = $exercise['title'];
  569. if (!$global) {
  570. if (!empty($studentResult)) {
  571. $studentResultEmpty = $studentResultContent = array();
  572. foreach ($studentResult as $row) {
  573. if ($row['score'] == '-') {
  574. $studentResultEmpty[] = $row;
  575. } else {
  576. $studentResultContent[] = $row;
  577. }
  578. }
  579. // Sort only users with content
  580. usort($studentResultContent, 'sort_user');
  581. $studentResult = array_merge($studentResultContent, $studentResultEmpty);
  582. foreach ($studentResult as $row) {
  583. $html .= $row['html'];
  584. $row_not_global['results'][] = $row['array'];
  585. $row_not_global['users'][] = $row['user'];
  586. $row_not_global['usernames'][] = $row['username'];
  587. }
  588. $export_array[] = $row_not_global;
  589. }
  590. }
  591. if ($global) {
  592. // Exam taken
  593. $html .= '<td>';
  594. $html .= $taken;
  595. $globalRow[] = $taken;
  596. $html .= '</td>';
  597. // Exam NOT taken
  598. $html .= '<td>';
  599. $html .= $not_taken = $totalStudents - $taken;
  600. $globalRow[] = $not_taken;
  601. $html .= '</td>';
  602. // Exam pass
  603. if (!empty($total_with_parameter_score)) {
  604. $html .= '<td style="background-color:#DFFFA8" >';
  605. } else {
  606. $html .= '<td style="background-color:#FCE89A" >';
  607. }
  608. $html .= $total_with_parameter_score;
  609. $globalRow[] = $total_with_parameter_score;
  610. $html .= '</td>';
  611. // Exam fail
  612. $html .= '<td>';
  613. $html .= $fail = $taken - $total_with_parameter_score;
  614. $globalRow[] = $fail;
  615. $html .= '</td>';
  616. $html .= '<td>';
  617. $html .= $totalStudents;
  618. $globalRow[] = $totalStudents;
  619. $html .= '</td>';
  620. $html .= '</tr>';
  621. $export_array_global[] = $globalRow;
  622. }
  623. return array(
  624. 'html' => $html,
  625. 'export_array_global' => $global ? $export_array_global : $export_array,
  626. 'total_students' => $totalStudents
  627. );
  628. }
  629. Display :: display_footer();