Completed
Push — 1.10.x ( ba0bf0...97c0d2 )
by Angel Fernando Quiroz
44:06
created

exams.php ➔ processStudentList()   F

Complexity

Conditions 26
Paths > 20000

Size

Total Lines 244
Code Lines 164

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 26
eloc 164
nc 27865
nop 6
dl 0
loc 244
rs 2

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 '../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_courseCoach || $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
72
    $form->addElement('select', 'exercise_id', get_lang('Exercise'), $exerciseList);
73
}
74
75
$form->addButtonFilter(get_lang('Filter'));
76
77
$filter_score = isset($_REQUEST['score']) ? intval($_REQUEST['score']) : 70;
78
$exerciseId = isset($_REQUEST['exercise_id']) ? intval($_REQUEST['exercise_id']) : 0;
79
80
$form->setDefaults(array('score' => $filter_score));
81
82
if (!$exportToXLS) {
83
    Display :: display_header(get_lang('Reporting'));
84
    $actionsLeft = $actionsRight ='';
85
    if ($global) {
86
87
        $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'auth/my_progress.php">'.
88
        Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM);
89
        $actionsLeft .= '</a>';
90
91
        
92
93
        $courseLink = '';
94
        $courseInfo = api_get_course_info();
95
96
        if (!empty($courseInfo)) {
97
            $courseLink = api_get_cidreq();
98
        }
99
100
        $actionsRight .= '<a href="'.api_get_self().'?export=1&score='.$filter_score.'&exercise_id='.$exerciseId.'&'.$courseLink.'">'.
101
            Display::return_icon('export_excel.png',get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a>';
102
        $actionsRight .= '<a href="javascript: void(0);" onclick="javascript: window.print()">'.
103
            Display::return_icon('printer.png',get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
104
        
105
106
        $menuItems[] = Display::url(
107
            Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32),
108
            api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher'
109
        );
110
        if (api_is_platform_admin()) {
111
            $menuItems[] = Display::url(
112
                Display::return_icon('star.png', get_lang('AdminInterface'), array(), 32),
113
                api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php'
114
            );
115 View Code Duplication
        } else {
116
            $menuItems[] = Display::url(
117
                Display::return_icon('star.png', get_lang('CoachInterface'), array(), 32),
118
                api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=coach'
119
            );
120
        }
121
        $menuItems[] = '<a href="#">'.Display::return_icon('quiz_na.png', get_lang('ExamTracking'), array(), 32).'</a>';
122
123
        $nb_menu_items = count($menuItems);
124
        if ($nb_menu_items > 1) {
125
            foreach ($menuItems as $key=> $item) {
126
                $actionsLeft .= $item;
127
            }
128
        }
129
    } else {
130
        $actionsLeft .= Display::url(
131
            Display::return_icon('user.png', get_lang('StudentsTracking'), array(), 32),
132
            'courseLog.php?'.api_get_cidreq().'&studentlist=true'
133
        );
134
        $actionsLeft .= Display::url(
135
            Display::return_icon('course.png', get_lang('CourseTracking'), array(), 32),
136
            'courseLog.php?'.api_get_cidreq().'&studentlist=false'
137
        );
138
        $actionsLeft .= Display::url(
139
            Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), 32),
140
            'courseLog.php?'.api_get_cidreq().'&studentlist=resouces'
141
        );
142
        $actionsLeft .= Display::url(
143
            Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), array(), 32),
144
            api_get_self().'?'.api_get_cidreq().'&export=1&score='.$filter_score.'&exercise_id='.$exerciseId
145
        );
146
147
    }
148
    
149
    
150
    $toolbar = Display::toolbarAction('toolbar-exams', $content = array( 0 => $actionsLeft, 1 => $actionsRight ));
151
    echo $toolbar;
152
153
    $form->display();
154
    echo '<h3>'.sprintf(get_lang('FilteringWithScoreX'), $filter_score).'%</h3>';
155
}
156
157
$html = null;
158
if ($global) {
159
    $html .= '<table  class="data_table">';
160
    $html .= '<tr><th>'.get_lang('Courses').'</th>';
161
    $html .= '<th>'.get_lang('Quiz').'</th>';
162
    $html .= '<th>'.get_lang('ExamTaken').'</th>';
163
    $html .= '<th>'.get_lang('ExamNotTaken').'</th>';
164
    $html .= '<th>'.sprintf(get_lang('ExamPassX'), $filter_score).'%</th>';
165
    $html .= '<th>'.get_lang('ExamFail').'</th>';
166
    $html .= '<th>'.get_lang('TotalStudents').'</th>';
167
    $html .= '</tr>';
168
} else {
169
    $html .= '<table class="data_table">';
170
    $html .= '<tr><th>'.get_lang('Quiz').'</th>';
171
    $html .= '<th>'.get_lang('User').'</th>';
172
    //$html .= '<th>'.sprintf(get_lang('ExamPassX'), $filter_score).'</th>';
173
    $html .= '<th>'.get_lang('Percentage').' %</th>';
174
    $html .= '<th>'.get_lang('Status').'</th>';
175
    $html .= '<th>'.get_lang('Attempts').'</th>';
176
    $html .= '</tr>';
177
}
178
179
$export_array_global = $export_array = array();
180
$s_css_class = null;
181
182
if (!empty($courseList) && is_array($courseList)) {
183
    foreach ($courseList as $courseInfo) {
184
        $sessionList = SessionManager::get_session_by_course($courseInfo['real_id']);
185
186
        $newSessionList = array();
187
        if (!empty($sessionList)) {
188
            foreach ($sessionList as $session) {
189
                $newSessionList[$session['id']] = $session['name'];
190
            }
191
        }
192
193
        $courseId = $courseInfo['real_id'];
194
195
        if ($global) {
196
            $sql = "SELECT count(id) as count
197
                    FROM $quizTable AS quiz
198
                    WHERE c_id = $courseId AND  active = 1 AND (session_id = 0 OR session_id IS NULL)";
199
            $result = Database::query($sql);
200
            $countExercises = Database::store_result($result);
201
            $exerciseCount = $countExercises[0]['count'];
202
203
            $sql = "SELECT count(id) as count
204
                    FROM $quizTable AS quiz
205
                    WHERE c_id = $courseId AND active = 1 AND session_id <> 0";
206
            $result = Database::query($sql);
207
            $countExercises = Database::store_result($result);
208
            $exerciseSessionCount = $countExercises[0]['count'];
209
210
            $exerciseCount =  $exerciseCount + $exerciseCount * count($newSessionList) + $exerciseSessionCount;
211
212
            // Add course and session list.
213
            if ($exerciseCount == 0) {
214
                $exerciseCount = 2;
215
            }
216
            $html .= "<tr>
217
                        <td rowspan=$exerciseCount>";
218
            $html .= $courseInfo['title'];
219
            $html .= "</td>";
220
        }
221
222
        $sql = "SELECT visibility FROM $toolTable
223
                WHERE c_id = $courseId AND name = 'quiz'";
224
        $result = Database::query($sql);
225
226
        // If main tool is visible.
227
        if (Database::result($result, 0, 'visibility') == 1) {
228
            // Getting the exam list.
229
            if ($global) {
230
                $sql = "SELECT quiz.title, id, session_id
231
                    FROM $quizTable AS quiz
232
                    WHERE c_id = $courseId AND active = 1
233
                    ORDER BY session_id, quiz.title ASC";
234
            } else {
235
                //$sessionCondition = api_get_session_condition($sessionId, true, false);
236
                if (!empty($exerciseId)) {
237
                    $sql = "SELECT quiz.title, id, session_id
238
                            FROM $quizTable AS quiz
239
                            WHERE
240
                                c_id = $courseId AND
241
                                active = 1 AND
242
                                id = $exerciseId
243
                                $sessionCondition
244
245
                            ORDER BY session_id, quiz.title ASC";
246
                } else {
247
                    $sql = "SELECT quiz.title, id, session_id
248
                            FROM $quizTable AS quiz
249
                            WHERE
250
                                c_id = $courseId AND
251
                                active = 1
252
                                $sessionCondition
253
                            ORDER BY session_id, quiz.title ASC";
254
                }
255
            }
256
257
            $resultExercises = Database::query($sql);
258
259
            if (Database::num_rows($resultExercises) > 0) {
260
                $export_array_global = array();
261
262
                while ($exercise = Database::fetch_array($resultExercises, 'ASSOC')) {
263
264
                    $exerciseSessionId = $exercise['session_id'];
265
266
                    if (empty($exerciseSessionId)) {
267
268
                        if ($global) {
269
                            // If the exercise was created in the base course.
270
                            // Load all sessions.
271
                            foreach ($newSessionList as $currentSessionId => $sessionName) {
272
                                $result = processStudentList(
273
                                    $filter_score,
274
                                    $global,
275
                                    $exercise,
276
                                    $courseInfo,
277
                                    $currentSessionId,
278
                                    $newSessionList
279
                                );
280
281
                                $html .= $result['html'];
282
                                $export_array_global = array_merge($export_array_global, $result['export_array_global']);
283
                            }
284
285
                            // Load base course.
286
                            $result = processStudentList(
287
                                $filter_score,
288
                                $global,
289
                                $exercise,
290
                                $courseInfo,
291
                                0,
292
                                $newSessionList
293
                            );
294
                            $html .= $result['html'];
295
                            $export_array_global = array_merge($export_array_global, $result['export_array_global']);
296
                        } else {
297
298
                            if (empty($sessionId)) {
299
                                // Load base course.
300
                                $result = processStudentList(
301
                                    $filter_score,
302
                                    $global,
303
                                    $exercise,
304
                                    $courseInfo,
305
                                    0,
306
                                    $newSessionList
307
                                );
308
309
                                $html .= $result['html'];
310
                                $export_array_global = array_merge(
311
                                    $export_array_global,
312
                                    $result['export_array_global']
313
                                );
314 View Code Duplication
                            } else {
315
316
                                $result = processStudentList(
317
                                    $filter_score,
318
                                    $global,
319
                                    $exercise,
320
                                    $courseInfo,
321
                                    $sessionId,
322
                                    $newSessionList
323
                                );
324
325
                                $html .= $result['html'];
326
                                $export_array_global = array_merge(
327
                                    $export_array_global,
328
                                    $result['export_array_global']
329
                                );
330
                            }
331
                        }
332 View Code Duplication
                    } else {
333
                        // If the exercise only exists in this session.
334
335
                        $result = processStudentList(
336
                            $filter_score,
337
                            $global,
338
                            $exercise,
339
                            $courseInfo,
340
                            $exerciseSessionId,
341
                            $newSessionList
342
                        );
343
344
                        $html .= $result['html'];
345
                        $export_array_global = array_merge(
346
                            $export_array_global,
347
                            $result['export_array_global']
348
                        );
349
                    }
350
                }
351
            } else {
352
                $html .= "<tr>
353
                            <td colspan='6'>
354
                                ".get_lang('NoExercise')."
355
                            </td>
356
                        </tr>
357
                     ";
358
            }
359
        } else {
360
            $html .= "<tr>
361
                        <td colspan='6'>
362
                            ".get_lang('NoExercise')."
363
                        </td>
364
                    </tr>
365
                 ";
366
        }
367
    }
368
}
369
370
$html .= '</table>';
371
372
if (!$exportToXLS) {
373
    echo $html;
374
}
375
376
$filename = 'exam-reporting-'.api_get_local_time().'.xlsx';
377
378
if ($exportToXLS) {
379
    if ($global) {
380
        export_complete_report_xls($filename, $export_array_global);
381
    } else {
382
        export_complete_report_xls($filename, $export_array);
383
    }
384
    exit;
385
}
386
/**
387
 * @param $a
388
 * @param $b
389
 * @return int
390
 */
391
function sort_user($a, $b) {
392
    if (is_numeric($a['score']) && is_numeric($b['score'])) {
393
        if ($a['score'] < $b['score']) {
394
            return 1;
395
        }
396
397
        return 0;
398
    }
399
400
    return 1;
401
}
402
403
/**
404
 * @param string $filename
405
 * @param array $array
406
 */
407
function export_complete_report_xls($filename, $array)
408
{
409
    global $global, $filter_score;
410
411
    $spreadsheet = new PHPExcel();
412
    $spreadsheet->setActiveSheetIndex(0);
413
    $worksheet = $spreadsheet->getActiveSheet();
414
415
    $line = 0;
416
    $column = 0; //skip the first column (row titles)
417
418
    if ($global) {
419
        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Courses'));
420
        $column++;
421
        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Exercises'));
422
        $column++;
423
        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('ExamTaken'));
424
        $column++;
425
        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('ExamNotTaken'));
426
        $column++;
427
        $worksheet->SetCellValueByColumnAndRow($line, $column, sprintf(get_lang('ExamPassX'), $filter_score) . '%');
428
        $column++;
429
        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('ExamFail'));
430
        $column++;
431
        $worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('TotalStudents'));
432
        $column++;
433
434
        $line++;
435 View Code Duplication
        foreach ($array as $row) {
436
            $column = 0;
437
            foreach ($row as $item) {
438
                $worksheet->SetCellValueByColumnAndRow($line, $column, html_entity_decode(strip_tags($item)));
439
                $column++;
440
            }
441
            $line++;
442
        }
443
        $line++;
444
    } else {
445
        $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Exercises'));
446
        $column++;
447
        $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('User'));
448
        $column++;
449
        $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Percentage'));
450
        $column++;
451
        $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Status'));
452
        $column++;
453
        $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Attempts'));
454
        $column++;
455
        $line++;
456
        foreach ($array as $row) {
457
            $column = 0;
458
            $worksheet->SetCellValueByColumnAndRow(
459
                $line,
460
                $column,
461
                html_entity_decode(strip_tags($row['exercise']))
462
            );
463
            $column++;
464
            foreach ($row['users'] as $key=>$user) {
465
                $column = 1;
466
                $worksheet->SetCellValueByColumnAndRow(
467
                    $line,
468
                    $column,
469
                    html_entity_decode(strip_tags($user))
470
                );
471
                $column++;
472
                foreach ($row['results'][$key] as $result_item) {
473
                    $worksheet->SetCellValueByColumnAndRow(
474
                        $line,
475
                        $column,
476
                        html_entity_decode(strip_tags($result_item))
477
                    );
478
                    $column++;
479
                }
480
                $line++;
481
            }
482
        }
483
        $line++;
484
    }
485
486
    $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
487
    $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
488
    $writer->save($file);
489
    DocumentManager::file_send_for_download($file, true, $filename);
490
    exit;
491
}
492
493
/**
494
 * @param $filter_score
495
 * @param $global
496
 * @param $exercise
497
 * @param $courseInfo
498
 * @param $sessionId
499
 * @param $newSessionList
500
 * @return array
501
 */
502
function processStudentList($filter_score, $global, $exercise, $courseInfo, $sessionId, $newSessionList)
503
{
504
    if (
505
        (isset($exercise['id']) && empty($exercise['id'])) ||
506
        !isset($exercise['id'])
507
    ) {
508
        return array(
509
            'html' => '',
510
            'export_array_global' =>  [],
511
            'total_students' => 0
512
        );
513
    }
514
515
    $exerciseStatsTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
516
    $courseId = api_get_course_int_id($courseInfo['code']);
517
518
    if (empty($sessionId)) {
519
        $students = CourseManager::get_student_list_from_course_code(
520
            $courseInfo['code'],
521
            false,
522
            0,
523
            null,
524
            null,
525
            false
526
        );
527
    } else {
528
        $students = CourseManager::get_student_list_from_course_code(
529
            $courseInfo['code'],
530
            true,
531
            $sessionId,
532
            null,
533
            null,
534
            false
535
        );
536
    }
537
538
    $html = null;
539
540
    $totalStudents = count($students);
541
542
    if (!$global) {
543
        $html .= "<tr>";
544
    }
545
546
    if (!$global) {
547
        $html .= '<td rowspan="'.$totalStudents.'">';
548
    } else {
549
        $html .= '<td>';
550
    }
551
552
    $html .= $exercise['title'];
553
554
    if ($global && !empty($sessionId)) {
555
        $sessionName = isset($newSessionList[$sessionId]) ? $newSessionList[$sessionId] : null;
556
        $html .= Display::return_icon('star.png', get_lang('Session')).' ('.$sessionName.')';
557
    }
558
559
    $html .= '</td>';
560
561
    $globalRow = array(
562
        $courseInfo['title'],
563
        $exercise['title']
564
    );
565
566
    $total_with_parameter_score = 0;
567
    $taken = 0;
568
    $export_array_global = array();
569
    $studentResult = array();
570
571
    foreach ($students as $student) {
572
        $studentId = isset($student['user_id']) ? $student['user_id'] : $student['id_user'];
573
        $sql = "SELECT COUNT(ex.exe_id) as count
574
                FROM $exerciseStatsTable AS ex
575
                WHERE
576
                    ex.c_id = $courseId AND
577
                    ex.exe_exo_id = ".$exercise['id']." AND
578
                    exe_user_id= $studentId AND
579
                    session_id = $sessionId
580
                ";
581
        $result = Database::query($sql);
582
        $attempts = Database::fetch_array($result);
583
584
        $sql = "SELECT exe_id, exe_result, exe_weighting
585
                FROM $exerciseStatsTable
586
                WHERE
587
                    exe_user_id = $studentId AND
588
                    c_id = $courseId AND
589
                    exe_exo_id = ".$exercise['id']." AND
590
                    session_id = $sessionId
591
                ORDER BY exe_result DESC
592
                LIMIT 1";
593
        $result = Database::query($sql);
594
        $score = 0;
595
        $weighting = 0;
596
        while ($scoreInfo = Database::fetch_array($result)) {
597
            $score = $score + $scoreInfo['exe_result'];
598
            $weighting = $weighting + $scoreInfo['exe_weighting'];
599
        }
600
601
        $percentageScore = 0;
602
603
        if ($weighting != 0) {
604
            $percentageScore = round(($score*100)/$weighting);
605
        }
606
607
        if ($attempts['count'] > 0 ) {
608
            $taken++;
609
        }
610
611
        if ($percentageScore >= $filter_score) {
612
            $total_with_parameter_score++;
613
        }
614
615
        $tempArray = array();
616
617
        if (!$global) {
618
            $userInfo = api_get_user_info($studentId);
619
620
            // User
621
            $userRow = '<td>';
622
            $userRow .= $userInfo['complete_name'];
623
            $userRow .= '</td>';
624
625
            // Best result
626
627
            if (!empty($attempts['count'])) {
628
                $userRow .= '<td>';
629
                $userRow .= $percentageScore;
630
                $tempArray[] = $percentageScore;
631
                $userRow .= '</td>';
632
633
                if ($percentageScore >= $filter_score) {
634
                    $userRow .= '<td style="background-color:#DFFFA8">';
635
                    $userRow .= get_lang('PassExam').'</td>';
636
                    $tempArray[] = get_lang('PassExam');
637
                } else {
638
                    $userRow .= '<td style="background-color:#FC9A9E"  >';
639
                    $userRow .= get_lang('ExamFail').'</td>';
640
                    $tempArray[] = get_lang('ExamFail');
641
                }
642
643
                $userRow .= '<td>';
644
                $userRow .= $attempts['count'];
645
                $tempArray[] = $attempts['count'];
646
                $userRow .= '</td>';
647
            } else {
648
                $score = '-';
649
                $userRow .= '<td>';
650
                $userRow .=  '-';
651
                $tempArray[] = '-';
652
                $userRow .= '</td>';
653
654
                $userRow .= '<td style="background-color:#FCE89A">';
655
                $userRow .= get_lang('NoAttempt');
656
                $tempArray[] = get_lang('NoAttempt');
657
                $userRow .= '</td>';
658
                $userRow .= '<td>';
659
                $userRow .= 0;
660
                $tempArray[] = 0;
661
                $userRow .= '</td>';
662
            }
663
            $userRow .= '</tr>';
664
665
            $studentResult[$studentId] = array(
666
                'html' => $userRow,
667
                'score' => $score,
668
                'array' => $tempArray,
669
                'user' => $userInfo['complete_name']
670
            );
671
        }
672
    }
673
674
    $row_not_global['exercise'] = $exercise['title'];
675
676
    if (!$global) {
677
        if (!empty($studentResult)) {
678
            $studentResultEmpty = $studentResultContent = array();
679
            foreach ($studentResult as $row) {
680
                if ($row['score'] == '-') {
681
                    $studentResultEmpty[] = $row;
682
                } else {
683
                    $studentResultContent[] = $row;
684
                }
685
            }
686
687
            // Sort only users with content
688
            usort($studentResultContent, 'sort_user');
689
            $studentResult = array_merge($studentResultContent, $studentResultEmpty);
690
691
            foreach ($studentResult as $row) {
692
                $html .= $row['html'];
693
                $row_not_global['results'][] = $row['array'];
694
                $row_not_global['users'][] = $row['user'];
695
            }
696
            $export_array[] = $row_not_global;
697
        }
698
    }
699
700
    if ($global) {
701
        // Exam taken
702
        $html .= '<td>';
703
        $html .= $taken;
704
        $globalRow[]= $taken;
705
        $html .= '</td>';
706
707
        // Exam NOT taken
708
        $html .= '<td>';
709
        $html .= $not_taken = $totalStudents - $taken;
710
        $globalRow[]= $not_taken;
711
        $html .= '</td>';
712
713
        // Exam pass
714
        if (!empty($total_with_parameter_score)) {
715
            $html .= '<td style="background-color:#DFFFA8" >';
716
        } else {
717
            $html .= '<td style="background-color:#FCE89A"  >';
718
        }
719
720
        $html .= $total_with_parameter_score;
721
        $globalRow[]= $total_with_parameter_score;
722
        $html .= '</td>';
723
724
        // Exam fail
725
        $html .= '<td>';
726
727
        $html .= $fail = $taken - $total_with_parameter_score;
728
        $globalRow[]= $fail;
729
        $html .= '</td>';
730
731
        $html .= '<td>';
732
        $html .= $totalStudents;
733
        $globalRow[]= $totalStudents;
734
735
        $html .= '</td>';
736
737
        $html .= '</tr>';
738
        $export_array_global[] = $globalRow;
739
    }
740
    return array(
741
        'html' => $html,
742
        'export_array_global' => $export_array_global,
743
        'total_students' => $totalStudents
744
    );
745
}
746
Display :: display_footer();
747