Completed
Push — master ( 9b8b24...6e1754 )
by Julito
58:58
created

processStudentList()   F

Complexity

Conditions 27
Paths > 20000

Size

Total Lines 244
Code Lines 165

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 27
eloc 165
nc 55729
nop 6
dl 0
loc 244
rs 2
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* For licensing terms, see /license.txt */
3
4
/**
5
 * Exams script
6
 * @package chamilo.tracking
7
 */
8
9
require_once __DIR__.'/../inc/global.inc.php';
10
11
$toolTable = Database::get_course_table(TABLE_TOOL_LIST);
12
$quizTable = Database::get_course_table(TABLE_QUIZ_TEST);
13
14
$this_section = SECTION_TRACKING;
15
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_session_general_coach || $is_sessionAdmin;
16
17
if (!$is_allowedToTrack) {
18
    api_not_allowed();
19
}
20
21
$exportToXLS = false;
22
if (isset($_GET['export'])) {
23
    $exportToXLS = true;
24
}
25
26
if (api_is_platform_admin() && empty($_GET['cidReq'])) {
27
    $global = true;
28
} else {
29
    $global = false;
30
}
31
32
$courseList = array();
33
if ($global) {
34
    $temp = CourseManager::get_courses_list();
35
    foreach ($temp as $tempCourse) {
36
        $courseInfo = api_get_course_info($tempCourse['code']);
37
        $courseList[] = $courseInfo;
38
    }
39
} else {
40
    $courseList = array(api_get_course_info());
41
}
42
43
$sessionId = api_get_session_id();
44
45
if (empty($sessionId)) {
46
    $sessionCondition = ' AND session_id = 0';
47
} else {
48
    $sessionCondition = api_get_session_condition($sessionId, true, true);
49
}
50
51
$form = new FormValidator('search_simple', 'POST', '', '', null, false);
52
$form->addElement('text', 'score', get_lang('Percentage'));
53
if ($global) {
54
    $form->addElement('hidden', 'view', 'admin');
55
} else {
56
    // Get exam lists
57
    $courseId = api_get_course_int_id();
58
59
    $sql = "SELECT quiz.title, id FROM $quizTable AS quiz
60
            WHERE
61
                c_id = $courseId AND
62
                active = 1
63
                $sessionCondition
64
            ORDER BY quiz.title ASC";
65
    $result = Database::query($sql);
66
67
    $exerciseList = array(get_lang('All'));
68
    while ($row = Database::fetch_array($result)) {
69
        $exerciseList[$row['id']] = $row['title'];
70
    }
71
    $form->addElement('select', 'exercise_id', get_lang('Exercise'), $exerciseList);
72
}
73
74
$form->addButtonFilter(get_lang('Filter'));
75
76
$filter_score = isset($_REQUEST['score']) ? intval($_REQUEST['score']) : 70;
77
$exerciseId = isset($_REQUEST['exercise_id']) ? intval($_REQUEST['exercise_id']) : 0;
78
79
$form->setDefaults(array('score' => $filter_score));
80
81
if (!$exportToXLS) {
82
    Display :: display_header(get_lang('Reporting'));
83
    $actionsLeft = $actionsRight = '';
84
    if ($global) {
85
        $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'auth/my_progress.php">'.
86
        Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM);
87
        $actionsLeft .= '</a>';
88
        $courseInfo = api_get_course_info();
89
90
        $actionsRight .= '<a href="'.api_get_self().'?export=1&score='.$filter_score.'&exercise_id='.$exerciseId.'">'.
91
            Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
92
        $actionsRight .= '<a href="javascript: void(0);" onclick="javascript: window.print()">'.
93
            Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).'</a>';
94
95
        $menuItems[] = Display::url(
96
            Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32),
97
            api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher'
98
        );
99
        if (api_is_platform_admin()) {
100
            $menuItems[] = Display::url(
101
                Display::return_icon('star.png', get_lang('AdminInterface'), array(), 32),
102
                api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php'
103
            );
104
        } else {
105
            $menuItems[] = Display::url(
106
                Display::return_icon('star.png', get_lang('CoachInterface'), array(), 32),
107
                api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=coach'
108
            );
109
        }
110
        $menuItems[] = '<a href="#">'.Display::return_icon('quiz_na.png', get_lang('ExamTracking'), array(), 32).'</a>';
111
112
        $nb_menu_items = count($menuItems);
113
        if ($nb_menu_items > 1) {
114
            foreach ($menuItems as $key => $item) {
115
                $actionsLeft .= $item;
116
            }
117
        }
118
    } else {
119
        $actionsLeft = TrackingCourseLog::actionsLeft('exams', api_get_session_id());
120
121
        $actionsLeft .= Display::url(
122
            Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), array(), 32),
123
            api_get_self().'?'.api_get_cidreq().'&export=1&score='.$filter_score.'&exercise_id='.$exerciseId
124
        );
125
    }
126
127
    $toolbar = Display::toolbarAction('toolbar-exams', [$actionsLeft, $actionsRight]);
128
    echo $toolbar;
129
130
    $form->display();
131
    echo '<h3>'.sprintf(get_lang('FilteringWithScoreX'), $filter_score).'%</h3>';
132
}
133
134
$html = '<table  class="data_table">';
135
if ($global) {
136
    $html .= '<tr>';
137
    $html .= '<th>'.get_lang('Courses').'</th>';
138
    $html .= '<th>'.get_lang('Quiz').'</th>';
139
    $html .= '<th>'.get_lang('ExamTaken').'</th>';
140
    $html .= '<th>'.get_lang('ExamNotTaken').'</th>';
141
    $html .= '<th>'.sprintf(get_lang('ExamPassX'), $filter_score).'%</th>';
142
    $html .= '<th>'.get_lang('ExamFail').'</th>';
143
    $html .= '<th>'.get_lang('TotalStudents').'</th>';
144
    $html .= '</tr>';
145
} else {
146
    $html .= '<tr>';
147
    $html .= '<th>'.get_lang('Quiz').'</th>';
148
    $html .= '<th>'.get_lang('User').'</th>';
149
    $html .= '<th>'.get_lang('Username').'</th>';
150
    //$html .= '<th>'.sprintf(get_lang('ExamPassX'), $filter_score).'</th>';
151
    $html .= '<th>'.get_lang('Percentage').' %</th>';
152
    $html .= '<th>'.get_lang('Status').'</th>';
153
    $html .= '<th>'.get_lang('Attempts').'</th>';
154
    $html .= '</tr>';
155
}
156
157
$export_array_global = $export_array = array();
158
$s_css_class = null;
159
160
if (!empty($courseList) && is_array($courseList)) {
161
    foreach ($courseList as $courseInfo) {
162
        $sessionList = SessionManager::get_session_by_course($courseInfo['real_id']);
163
164
        $newSessionList = array();
165
        if (!empty($sessionList)) {
166
            foreach ($sessionList as $session) {
167
                $newSessionList[$session['id']] = $session['name'];
168
            }
169
        }
170
171
        $courseId = $courseInfo['real_id'];
172
173
        if ($global) {
174
            $sql = "SELECT count(id) as count
175
                    FROM $quizTable AS quiz
176
                    WHERE c_id = $courseId AND  active = 1 AND (session_id = 0 OR session_id IS NULL)";
177
            $result = Database::query($sql);
178
            $countExercises = Database::store_result($result);
179
            $exerciseCount = $countExercises[0]['count'];
180
181
            $sql = "SELECT count(id) as count
182
                    FROM $quizTable AS quiz
183
                    WHERE c_id = $courseId AND active = 1 AND session_id <> 0";
184
            $result = Database::query($sql);
185
            $countExercises = Database::store_result($result);
186
            $exerciseSessionCount = $countExercises[0]['count'];
187
188
            $exerciseCount = $exerciseCount + $exerciseCount * count($newSessionList) + $exerciseSessionCount;
189
190
            // Add course and session list.
191
            if ($exerciseCount == 0) {
192
                $exerciseCount = 2;
193
            }
194
            $html .= "<tr>
195
                        <td rowspan=$exerciseCount>";
196
            $html .= $courseInfo['title'];
197
            $html .= "</td>";
198
        }
199
200
        $sql = "SELECT visibility FROM $toolTable
201
                WHERE c_id = $courseId AND name = 'quiz'";
202
        $result = Database::query($sql);
203
204
        // If main tool is visible.
205
        if (Database::result($result, 0, 'visibility') == 1) {
206
            // Getting the exam list.
207
            if ($global) {
208
                $sql = "SELECT quiz.title, id, session_id
209
                    FROM $quizTable AS quiz
210
                    WHERE c_id = $courseId AND active = 1
211
                    ORDER BY session_id, quiz.title ASC";
212
            } else {
213
                //$sessionCondition = api_get_session_condition($sessionId, true, false);
214
                if (!empty($exerciseId)) {
215
                    $sql = "SELECT quiz.title, id, session_id
216
                            FROM $quizTable AS quiz
217
                            WHERE
218
                                c_id = $courseId AND
219
                                active = 1 AND
220
                                id = $exerciseId
221
                                $sessionCondition
222
223
                            ORDER BY session_id, quiz.title ASC";
224
                } else {
225
                    $sql = "SELECT quiz.title, id, session_id
226
                            FROM $quizTable AS quiz
227
                            WHERE
228
                                c_id = $courseId AND
229
                                active = 1
230
                                $sessionCondition
231
                            ORDER BY session_id, quiz.title ASC";
232
                }
233
            }
234
235
            $resultExercises = Database::query($sql);
236
237
            if (Database::num_rows($resultExercises) > 0) {
238
                while ($exercise = Database::fetch_array($resultExercises, 'ASSOC')) {
239
                    $exerciseSessionId = $exercise['session_id'];
240
241
                    if (empty($exerciseSessionId)) {
242
                        if ($global) {
243
                            // If the exercise was created in the base course.
244
                            // Load all sessions.
245
                            foreach ($newSessionList as $currentSessionId => $sessionName) {
246
                                $result = processStudentList(
247
                                    $filter_score,
248
                                    $global,
249
                                    $exercise,
250
                                    $courseInfo,
251
                                    $currentSessionId,
252
                                    $newSessionList
253
                                );
254
255
                                $html .= $result['html'];
256
                                $export_array_global = array_merge($export_array_global, $result['export_array_global']);
257
                            }
258
259
                            // Load base course.
260
                            $result = processStudentList(
261
                                $filter_score,
262
                                $global,
263
                                $exercise,
264
                                $courseInfo,
265
                                0,
266
                                $newSessionList
267
                            );
268
                            $html .= $result['html'];
269
                            $export_array_global = array_merge($export_array_global, $result['export_array_global']);
270
                        } else {
271
                            if (empty($sessionId)) {
272
                                // Load base course.
273
                                $result = processStudentList(
274
                                    $filter_score,
275
                                    $global,
276
                                    $exercise,
277
                                    $courseInfo,
278
                                    0,
279
                                    $newSessionList
280
                                );
281
282
                                $html .= $result['html'];
283
                                if (is_array($result['export_array_global'])) {
284
                                    $export_array_global = array_merge(
285
                                        $export_array_global,
286
                                        $result['export_array_global']
287
                                    );
288
                                }
289
                            } else {
290
                                $result = processStudentList(
291
                                    $filter_score,
292
                                    $global,
293
                                    $exercise,
294
                                    $courseInfo,
295
                                    $sessionId,
296
                                    $newSessionList
297
                                );
298
299
                                $html .= $result['html'];
300
                                $export_array_global = array_merge(
301
                                    $export_array_global,
302
                                    $result['export_array_global']
303
                                );
304
                            }
305
                        }
306
                    } else {
307
                        // If the exercise only exists in this session.
308
                        $result = processStudentList(
309
                            $filter_score,
310
                            $global,
311
                            $exercise,
312
                            $courseInfo,
313
                            $exerciseSessionId,
314
                            $newSessionList
315
                        );
316
317
                        $html .= $result['html'];
318
                        $export_array_global = array_merge(
319
                            $export_array_global,
320
                            $result['export_array_global']
321
                        );
322
                    }
323
                }
324
            } else {
325
                $html .= "<tr>
326
                            <td colspan='6'>
327
                                ".get_lang('NoExercise')."
328
                            </td>
329
                        </tr>
330
                     ";
331
            }
332
        } else {
333
            $html .= "<tr>
334
                        <td colspan='6'>
335
                            ".get_lang('NoExercise')."
336
                        </td>
337
                    </tr>
338
                 ";
339
        }
340
    }
341
}
342
343
$html .= '</table>';
344
345
if (!$exportToXLS) {
346
    echo $html;
347
}
348
349
$filename = 'exam-reporting-'.api_get_local_time().'.xlsx';
350
351
if ($exportToXLS) {
352
    export_complete_report_xls($filename, $export_array_global);
353
    exit;
354
}
355
/**
356
 * @param $a
357
 * @param $b
358
 * @return int
359
 */
360
function sort_user($a, $b)
361
{
362
    if (is_numeric($a['score']) && is_numeric($b['score'])) {
363
        if ($a['score'] < $b['score']) {
364
            return 1;
365
        }
366
367
        return 0;
368
    }
369
370
    return 1;
371
}
372
373
/**
374
 * @param string $filename
375
 * @param array $array
376
 */
377
function export_complete_report_xls($filename, $array)
378
{
379
    global $global, $filter_score;
380
381
    $spreadsheet = new PHPExcel();
382
    $spreadsheet->setActiveSheetIndex(0);
383
    $worksheet = $spreadsheet->getActiveSheet();
384
385
    $line = 1;
386
    $column = 0; //skip the first column (row titles)
387
388
    if ($global) {
389
        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Courses'));
390
        $column++;
391
        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Exercises'));
392
        $column++;
393
        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ExamTaken'));
394
        $column++;
395
        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ExamNotTaken'));
396
        $column++;
397
        $worksheet->setCellValueByColumnAndRow($column, $line, sprintf(get_lang('ExamPassX'), $filter_score).'%');
398
        $column++;
399
        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ExamFail'));
400
        $column++;
401
        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('TotalStudents'));
402
        $column++;
403
404
        $line++;
405
        foreach ($array as $row) {
406
            $column = 0;
407
            foreach ($row as $item) {
408
                $worksheet->setCellValueByColumnAndRow($column, $line, html_entity_decode(strip_tags($item)));
409
                $column++;
410
            }
411
            $line++;
412
        }
413
        $line++;
414
    } else {
415
        $worksheet->setCellValueByColumnAndRow(0, $line, get_lang('Exercises'));
416
        $worksheet->setCellValueByColumnAndRow(1, $line, get_lang('User'));
417
        $worksheet->setCellValueByColumnAndRow(2, $line, get_lang('Username'));
418
        $worksheet->setCellValueByColumnAndRow(3, $line, get_lang('Percentage'));
419
        $worksheet->setCellValueByColumnAndRow(4, $line, get_lang('Status'));
420
        $worksheet->setCellValueByColumnAndRow(5, $line, get_lang('Attempts'));
421
        $line++;
422
423
        foreach ($array as $row) {
424
            $worksheet->setCellValueByColumnAndRow(
425
                0,
426
                $line,
427
                html_entity_decode(strip_tags($row['exercise']))
428
            );
429
430
            foreach ($row['users'] as $key => $user) {
431
                $worksheet->setCellValueByColumnAndRow(
432
                    1,
433
                    $line,
434
                    html_entity_decode(strip_tags($user))
435
                );
436
                $worksheet->setCellValueByColumnAndRow(
437
                    2,
438
                    $line,
439
                    $row['usernames'][$key]
440
                );
441
                $column = 3;
442
443
                foreach ($row['results'][$key] as $result_item) {
444
                    $worksheet->setCellValueByColumnAndRow(
445
                        $column,
446
                        $line,
447
                        html_entity_decode(strip_tags($result_item))
448
                    );
449
                    $column++;
450
                }
451
452
                $line++;
453
            }
454
        }
455
    }
456
457
    $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
458
    $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
459
    $writer->save($file);
460
    DocumentManager::file_send_for_download($file, true, $filename);
461
    exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
462
}
463
464
/**
465
 * @param $filter_score
466
 * @param $global
467
 * @param $exercise
468
 * @param $courseInfo
469
 * @param $sessionId
470
 * @param $newSessionList
471
 * @return array
472
 */
473
function processStudentList($filter_score, $global, $exercise, $courseInfo, $sessionId, $newSessionList)
474
{
475
    if ((isset($exercise['id']) && empty($exercise['id'])) ||
476
        !isset($exercise['id'])
477
    ) {
478
        return array(
479
            'html' => '',
480
            'export_array_global' =>  [],
481
            'total_students' => 0
482
        );
483
    }
484
485
    $exerciseStatsTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
486
    $courseId = api_get_course_int_id($courseInfo['code']);
487
488
    if (empty($sessionId)) {
489
        $students = CourseManager::get_student_list_from_course_code(
490
            $courseInfo['code'],
491
            false,
492
            0,
493
            null,
494
            null,
495
            false
496
        );
497
    } else {
498
        $students = CourseManager::get_student_list_from_course_code(
499
            $courseInfo['code'],
500
            true,
501
            $sessionId,
502
            null,
503
            null,
504
            false
505
        );
506
    }
507
508
    $html = null;
509
    $totalStudents = count($students);
510
511
    if (!$global) {
512
        $html .= "<tr>";
513
    }
514
515
    if (!$global) {
516
        $html .= '<td rowspan="'.$totalStudents.'">';
517
    } else {
518
        $html .= '<td>';
519
    }
520
521
    $html .= $exercise['title'];
522
523
    if ($global && !empty($sessionId)) {
524
        $sessionName = isset($newSessionList[$sessionId]) ? $newSessionList[$sessionId] : null;
525
        $html .= Display::return_icon('star.png', get_lang('Session')).' ('.$sessionName.')';
526
    }
527
528
    $html .= '</td>';
529
530
    $globalRow = array(
531
        $courseInfo['title'],
532
        $exercise['title']
533
    );
534
535
    $total_with_parameter_score = 0;
536
    $taken = 0;
537
    $export_array_global = [];
538
    $studentResult = [];
539
    $export_array = [];
540
541
    foreach ($students as $student) {
542
        $studentId = isset($student['user_id']) ? $student['user_id'] : $student['id_user'];
543
        $sql = "SELECT COUNT(ex.exe_id) as count
544
                FROM $exerciseStatsTable AS ex
545
                WHERE
546
                    ex.c_id = $courseId AND
547
                    ex.exe_exo_id = ".$exercise['id']." AND
548
                    exe_user_id= $studentId AND
549
                    session_id = $sessionId
550
                ";
551
        $result = Database::query($sql);
552
        $attempts = Database::fetch_array($result);
553
554
        $sql = "SELECT exe_id, exe_result, exe_weighting
555
                FROM $exerciseStatsTable
556
                WHERE
557
                    exe_user_id = $studentId AND
558
                    c_id = $courseId AND
559
                    exe_exo_id = ".$exercise['id']." AND
560
                    session_id = $sessionId
561
                ORDER BY exe_result DESC
562
                LIMIT 1";
563
        $result = Database::query($sql);
564
        $score = 0;
565
        $weighting = 0;
566
        while ($scoreInfo = Database::fetch_array($result)) {
567
            $score = $score + $scoreInfo['exe_result'];
568
            $weighting = $weighting + $scoreInfo['exe_weighting'];
569
        }
570
571
        $percentageScore = 0;
572
573
        if ($weighting != 0) {
574
            $percentageScore = round(($score * 100) / $weighting);
575
        }
576
577
        if ($attempts['count'] > 0) {
578
            $taken++;
579
        }
580
581
        if ($percentageScore >= $filter_score) {
582
            $total_with_parameter_score++;
583
        }
584
585
        $tempArray = array();
586
587
        if (!$global) {
588
            $userInfo = api_get_user_info($studentId);
589
590
            // User
591
            $userRow = '<td>';
592
            $userRow .= $userInfo['complete_name'];
593
            $userRow .= '</td>';
594
            $userRow .= '<td>'.$userInfo['username'].'</td>';
595
596
            // Best result
597
598
            if (!empty($attempts['count'])) {
599
                $userRow .= '<td>';
600
                $userRow .= $percentageScore;
601
                $tempArray[] = $percentageScore;
602
                $userRow .= '</td>';
603
604
                if ($percentageScore >= $filter_score) {
605
                    $userRow .= '<td style="background-color:#DFFFA8">';
606
                    $userRow .= get_lang('PassExam').'</td>';
607
                    $tempArray[] = get_lang('PassExam');
608
                } else {
609
                    $userRow .= '<td style="background-color:#FC9A9E"  >';
610
                    $userRow .= get_lang('ExamFail').'</td>';
611
                    $tempArray[] = get_lang('ExamFail');
612
                }
613
614
                $userRow .= '<td>';
615
                $userRow .= $attempts['count'];
616
                $tempArray[] = $attempts['count'];
617
                $userRow .= '</td>';
618
            } else {
619
                $score = '-';
620
                $userRow .= '<td>';
621
                $userRow .= '-';
622
                $tempArray[] = '-';
623
                $userRow .= '</td>';
624
625
                $userRow .= '<td style="background-color:#FCE89A">';
626
                $userRow .= get_lang('NoAttempt');
627
                $tempArray[] = get_lang('NoAttempt');
628
                $userRow .= '</td>';
629
                $userRow .= '<td>';
630
                $userRow .= 0;
631
                $tempArray[] = 0;
632
                $userRow .= '</td>';
633
            }
634
            $userRow .= '</tr>';
635
636
            $studentResult[$studentId] = array(
637
                'html' => $userRow,
638
                'score' => $score,
639
                'array' => $tempArray,
640
                'user' => $userInfo['complete_name'],
641
                'username' => $userInfo['username']
642
            );
643
        }
644
    }
645
646
    $row_not_global['exercise'] = $exercise['title'];
0 ignored issues
show
Comprehensibility Best Practice introduced by
$row_not_global was never initialized. Although not strictly required by PHP, it is generally a good practice to add $row_not_global = array(); before regardless.
Loading history...
647
648
    if (!$global) {
649
        if (!empty($studentResult)) {
650
            $studentResultEmpty = $studentResultContent = array();
651
            foreach ($studentResult as $row) {
652
                if ($row['score'] == '-') {
653
                    $studentResultEmpty[] = $row;
654
                } else {
655
                    $studentResultContent[] = $row;
656
                }
657
            }
658
659
            // Sort only users with content
660
            usort($studentResultContent, 'sort_user');
661
            $studentResult = array_merge($studentResultContent, $studentResultEmpty);
662
663
            foreach ($studentResult as $row) {
664
                $html .= $row['html'];
665
                $row_not_global['results'][] = $row['array'];
666
                $row_not_global['users'][] = $row['user'];
667
                $row_not_global['usernames'][] = $row['username'];
668
            }
669
            $export_array[] = $row_not_global;
670
        }
671
    }
672
673
    if ($global) {
674
        // Exam taken
675
        $html .= '<td>';
676
        $html .= $taken;
677
        $globalRow[] = $taken;
678
        $html .= '</td>';
679
680
        // Exam NOT taken
681
        $html .= '<td>';
682
        $html .= $not_taken = $totalStudents - $taken;
683
        $globalRow[] = $not_taken;
684
        $html .= '</td>';
685
686
        // Exam pass
687
        if (!empty($total_with_parameter_score)) {
688
            $html .= '<td style="background-color:#DFFFA8" >';
689
        } else {
690
            $html .= '<td style="background-color:#FCE89A"  >';
691
        }
692
693
        $html .= $total_with_parameter_score;
694
        $globalRow[] = $total_with_parameter_score;
695
        $html .= '</td>';
696
697
        // Exam fail
698
        $html .= '<td>';
699
700
        $html .= $fail = $taken - $total_with_parameter_score;
701
        $globalRow[] = $fail;
702
        $html .= '</td>';
703
704
        $html .= '<td>';
705
        $html .= $totalStudents;
706
        $globalRow[] = $totalStudents;
707
708
        $html .= '</td>';
709
710
        $html .= '</tr>';
711
        $export_array_global[] = $globalRow;
712
    }
713
    return array(
714
        'html' => $html,
715
        'export_array_global' => $global ? $export_array_global : $export_array,
716
        'total_students' => $totalStudents
717
    );
718
}
719
Display :: display_footer();
720