Completed
Push — 1.11.x ( fe82c8...de15b7 )
by Julito
28:24
created
main/inc/lib/tracking.lib.php 1 patch
Spacing   +432 added lines, -432 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         $extendedAttempt = null,
115 115
         $extendedAll = null,
116 116
         $type = 'classic',
117
-        $allowExtend =  true
117
+        $allowExtend = true
118 118
     ) {
119 119
         if (empty($courseInfo) || empty($lp_id)) {
120 120
             return null;
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
         $extend_all = 0;
139 139
 
140 140
         if ($origin == 'tracking') {
141
-            $url_suffix = '&session_id=' . $session_id . '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . $lp_id . '&origin=' . $origin;
141
+            $url_suffix = '&session_id='.$session_id.'&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.$lp_id.'&origin='.$origin;
142 142
         } else {
143
-            $url_suffix = '&lp_id=' . $lp_id;
143
+            $url_suffix = '&lp_id='.$lp_id;
144 144
         }
145 145
 
146 146
         if (!empty($extendedAll)) {
147 147
             $extend_all_link = Display::url(
148 148
                 Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
149
-                api_get_self() . '?action=stats' . $url_suffix
149
+                api_get_self().'?action=stats'.$url_suffix
150 150
             );
151 151
 
152 152
             $extend_all = 1;
153 153
         } else {
154 154
             $extend_all_link = Display::url(
155 155
                 Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttempts')),
156
-                api_get_self() . '?action=stats&extend_all=1' . $url_suffix
156
+                api_get_self().'?action=stats&extend_all=1'.$url_suffix
157 157
             );
158 158
         }
159 159
 
@@ -165,24 +165,24 @@  discard block
 block discarded – undo
165 165
 
166 166
         $actionColumn = null;
167 167
         if ($type == 'classic') {
168
-            $actionColumn = ' <th>' . get_lang('Actions') . '</th>';
168
+            $actionColumn = ' <th>'.get_lang('Actions').'</th>';
169 169
         }
170 170
         $output .= '<div class="table-responsive">';
171 171
         $output .= '<table class="table tracking">
172 172
             <thead>
173 173
             <tr class="table-header">
174
-                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;') . '</th>
174
+                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;').'</th>
175 175
                 <th colspan="4">
176
-                    ' . get_lang('ScormLessonTitle') .'
176
+                    ' . get_lang('ScormLessonTitle').'
177 177
                 </th>
178 178
                 <th colspan="2">
179
-                    ' . get_lang('ScormStatus') . '
179
+                    ' . get_lang('ScormStatus').'
180 180
                 </th>
181 181
                 <th colspan="2">
182
-                    ' . get_lang('ScormScore') . '
182
+                    ' . get_lang('ScormScore').'
183 183
                 </th>
184 184
                 <th colspan="2">
185
-                    ' . get_lang('ScormTime') . '
185
+                    ' . get_lang('ScormTime').'
186 186
                 </th>
187 187
                 '.$actionColumn.'
188 188
                 </tr>
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                 // Prepare statement to go through each attempt.
246 246
                 $viewCondition = null;
247 247
                 if (!empty($view)) {
248
-                    $viewCondition =  " AND v.view_count = $view  ";
248
+                    $viewCondition = " AND v.view_count = $view  ";
249 249
                 }
250 250
 
251 251
                 $sql = "SELECT
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
                                 FROM $TBL_QUIZ
294 294
                                 WHERE
295 295
                                     c_id = $course_id AND
296
-                                    id ='" . $my_path . "'";
296
+                                    id ='".$my_path."'";
297 297
                         $res_result_disabled = Database::query($sql);
298 298
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
299 299
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                     if (!empty($inter_num)) {
316 316
                         $extend_link = Display::url(
317 317
                               Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
318
+                              api_get_self().'?action=stats&fold_id='.$my_item_id.$url_suffix
319 319
                         );
320 320
                     }
321 321
                     $title = $row['mytitle'];
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
                     $action = null;
335 335
                     if ($type == 'classic') {
336
-                        $action =  '<td></td>';
336
+                        $action = '<td></td>';
337 337
                     }
338 338
 
339 339
                     if (in_array($row['item_type'], $chapterTypes)) {
@@ -377,13 +377,13 @@  discard block
 block discarded – undo
377 377
                                 $extend_this_attempt = 1;
378 378
                                 $extend_attempt_link = Display::url(
379 379
                                     Display::return_icon('visible.gif', get_lang('HideAttemptView')),
380
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
380
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
381 381
                                 );
382 382
                             } else { // Same case if fold_attempt_id is set, so not implemented explicitly.
383 383
                                 // The extend button for this attempt has not been clicked.
384 384
                                 $extend_attempt_link = Display::url(
385 385
                                     Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
386
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
386
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
387 387
                                 );
388 388
                             }
389 389
                         }
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
                         }
417 417
 
418 418
                         // Remove "NaN" if any (@todo: locate the source of these NaN)
419
-                        $time = str_replace('NaN', '00' . $h . '00\'00"', $time);
419
+                        $time = str_replace('NaN', '00'.$h.'00\'00"', $time);
420 420
 
421 421
                         if ($row['item_type'] != 'dir') {
422 422
                             if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
                                 $action = '<td></td>';
445 445
                             }
446 446
 
447
-                            $output .= '<tr class="' . $oddclass . '">
447
+                            $output .= '<tr class="'.$oddclass.'">
448 448
                                     <td></td>
449
-                                    <td>' . $extend_attempt_link . '</td>
450
-                                    <td colspan="3">' . get_lang('Attempt') . ' ' . $attemptCount . '</td>
451
-                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type) . '</td>
452
-                                    <td colspan="2">' . $view_score . '</td>
453
-                                    <td colspan="2">' . $time . '</td>
449
+                                    <td>' . $extend_attempt_link.'</td>
450
+                                    <td colspan="3">' . get_lang('Attempt').' '.$attemptCount.'</td>
451
+                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type).'</td>
452
+                                    <td colspan="2">' . $view_score.'</td>
453
+                                    <td colspan="2">' . $time.'</td>
454 454
                                     '.$action.'
455 455
                                 </tr>';
456 456
                             $attemptCount++;
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
                                     if (!$is_allowed_to_edit && $result_disabled_ext_all) {
464 464
                                         $temp[] = '/';
465 465
                                     } else {
466
-                                        $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
466
+                                        $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
467 467
                                     }
468 468
                                 } else {
469
-                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
469
+                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
470 470
                                 }
471 471
                                 $temp[] = $time;
472 472
                                 $csv_content[] = $temp;
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
                                         <td></td>
504 504
                                         <td></td>
505 505
                                         <td></td>
506
-                                        <td>'.$interaction['order_id'] . '</td>
507
-                                        <td>'.$interaction['id'] . '</td>
506
+                                        <td>'.$interaction['order_id'].'</td>
507
+                                        <td>'.$interaction['id'].'</td>
508 508
                                         <td colspan="2">' . $interaction['type'].'</td>
509
-                                        <td>'.$student_response . '</td>
510
-                                        <td>'.$interaction['result'] . '</td>
511
-                                        <td>'.$interaction['latency'] . '</td>
512
-                                        <td>'.$interaction['time'] . '</td>
509
+                                        <td>'.$student_response.'</td>
510
+                                        <td>'.$interaction['result'].'</td>
511
+                                        <td>'.$interaction['latency'].'</td>
512
+                                        <td>'.$interaction['time'].'</td>
513 513
                                         '.$action.'
514 514
                                     </tr>';
515 515
                                 $counter++;
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
                                         <td></td>
527 527
                                         <td></td>
528 528
                                         <td></td>
529
-                                        <td>' . $interaction['order_id'] . '</td>
530
-                                        <td colspan="2">' . $interaction['objective_id'] . '</td>
531
-                                        <td colspan="2">' . $interaction['status'] .'</td>
532
-                                        <td>' . $interaction['score_raw'] . '</td>
533
-                                        <td>' . $interaction['score_max'] . '</td>
534
-                                        <td>' . $interaction['score_min'] . '</td>
529
+                                        <td>' . $interaction['order_id'].'</td>
530
+                                        <td colspan="2">' . $interaction['objective_id'].'</td>
531
+                                        <td colspan="2">' . $interaction['status'].'</td>
532
+                                        <td>' . $interaction['score_raw'].'</td>
533
+                                        <td>' . $interaction['score_max'].'</td>
534
+                                        <td>' . $interaction['score_min'].'</td>
535 535
                                         '.$action.'
536 536
                                      </tr>';
537 537
                                 $counter++;
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
                         $my_path = Database::escape_string($my_path);
555 555
                         $sql = "SELECT results_disabled
556 556
                                 FROM $TBL_QUIZ
557
-                                WHERE c_id = $course_id AND id ='" . $my_path . "'";
557
+                                WHERE c_id = $course_id AND id ='".$my_path."'";
558 558
                         $res_result_disabled = Database::query($sql);
559 559
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
560 560
 
@@ -578,14 +578,14 @@  discard block
 block discarded – undo
578 578
                             $extend_this_attempt = 1;
579 579
                             $extend_attempt_link = Display::url(
580 580
                                 Display::return_icon('visible.gif', get_lang('HideAttemptView')),
581
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
581
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
582 582
                             );
583 583
                         } else {
584 584
                             // Same case if fold_attempt_id is set, so not implemented explicitly.
585 585
                             // The extend button for this attempt has not been clicked.
586 586
                             $extend_attempt_link = Display::url(
587 587
                                 Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
588
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
588
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
589 589
                             );
590 590
                         }
591 591
                     }
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
                     if ($inter_num > 1) {
601 601
                         $extend_link = Display::url(
602 602
                             Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
603
-                            api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
603
+                            api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
604 604
                         );
605 605
                     }
606 606
 
@@ -616,15 +616,15 @@  discard block
 block discarded – undo
616 616
 
617 617
                     // Selecting the exe_id from stats attempts tables in order to look the max score value.
618 618
 
619
-                    $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
619
+                    $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
620 620
                              WHERE
621
-                                exe_exo_id="' . $row['path'] . '" AND
622
-                                exe_user_id="' . $user_id . '" AND
623
-                                orig_lp_id = "' . $lp_id . '" AND
624
-                                orig_lp_item_id = "' . $row['myid'] . '" AND
625
-                                c_id = ' . $course_id . ' AND
621
+                                exe_exo_id="' . $row['path'].'" AND
622
+                                exe_user_id="' . $user_id.'" AND
623
+                                orig_lp_id = "' . $lp_id.'" AND
624
+                                orig_lp_item_id = "' . $row['myid'].'" AND
625
+                                c_id = ' . $course_id.' AND
626 626
                                 status <> "incomplete" AND
627
-                                session_id = ' . $session_id . '
627
+                                session_id = ' . $session_id.'
628 628
                              ORDER BY exe_date DESC
629 629
                              LIMIT 1';
630 630
 
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
                                         FROM $TBL_LP_ITEM_VIEW
656 656
                                         WHERE
657 657
                                             c_id = $course_id AND
658
-                                            lp_item_id = '" . (int) $my_id . "' AND
659
-                                            lp_view_id = '" . (int) $my_lp_view_id . "'
658
+                                            lp_item_id = '".(int) $my_id."' AND
659
+                                            lp_view_id = '" . (int) $my_lp_view_id."'
660 660
                                         ORDER BY view_count DESC limit 1";
661 661
                                 $res_score = Database::query($sql);
662 662
                                 $row_score = Database::fetch_array($res_score);
@@ -665,8 +665,8 @@  discard block
 block discarded – undo
665 665
                                         FROM $TBL_LP_ITEM_VIEW
666 666
                                         WHERE
667 667
                                             c_id = $course_id AND
668
-                                            lp_item_id = '" . (int) $my_id . "' AND
669
-                                            lp_view_id = '" . (int) $my_lp_view_id . "'";
668
+                                            lp_item_id = '".(int) $my_id."' AND
669
+                                            lp_view_id = '" . (int) $my_lp_view_id."'";
670 670
                                 $res_time = Database::query($sql);
671 671
                                 $row_time = Database::fetch_array($res_time);
672 672
 
@@ -725,16 +725,16 @@  discard block
 block discarded – undo
725 725
                     } else {
726 726
                         $correct_test_link = '-';
727 727
                         if ($row['item_type'] == 'quiz') {
728
-                            $my_url_suffix = '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . intval($row['mylpid']) . '&origin=' . $origin;
729
-                            $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
728
+                            $my_url_suffix = '&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.intval($row['mylpid']).'&origin='.$origin;
729
+                            $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
730 730
                                      WHERE
731
-                                        exe_exo_id="' . $row['path'] . '" AND
732
-                                        exe_user_id="' . $user_id . '" AND
733
-                                        orig_lp_id = "' . $lp_id . '" AND
734
-                                        orig_lp_item_id = "' . $row['myid'] . '" AND
735
-                                        c_id = ' . $course_id . ' AND
731
+                                        exe_exo_id="' . $row['path'].'" AND
732
+                                        exe_user_id="' . $user_id.'" AND
733
+                                        orig_lp_id = "' . $lp_id.'" AND
734
+                                        orig_lp_item_id = "' . $row['myid'].'" AND
735
+                                        c_id = ' . $course_id.' AND
736 736
                                         status <> "incomplete" AND
737
-                                        session_id = ' . $session_id . '
737
+                                        session_id = ' . $session_id.'
738 738
                                      ORDER BY exe_date DESC ';
739 739
 
740 740
                             $resultLastAttempt = Database::query($sql);
@@ -746,12 +746,12 @@  discard block
 block discarded – undo
746 746
                                 ) {
747 747
                                     $correct_test_link = Display::url(
748 748
                                         Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
749
-                                        api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id
749
+                                        api_get_self().'?action=stats'.$my_url_suffix.'&session_id='.$session_id.'&lp_item_id='.$my_id
750 750
                                     );
751 751
                                 } else {
752 752
                                     $correct_test_link = Display::url(
753 753
                                         Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttemptsByExercise')),
754
-                                        api_get_self() . '?action=stats&extend_attempt=1' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id
754
+                                        api_get_self().'?action=stats&extend_attempt=1'.$my_url_suffix.'&session_id='.$session_id.'&lp_item_id='.$my_id
755 755
                                     );
756 756
                                 }
757 757
                             }
@@ -761,14 +761,14 @@  discard block
 block discarded – undo
761 761
 
762 762
                         $action = null;
763 763
                         if ($type == 'classic') {
764
-                            $action =  '<td>' . $correct_test_link . '</td>';
764
+                            $action = '<td>'.$correct_test_link.'</td>';
765 765
                         }
766 766
 
767 767
                         if ($lp_id == $my_lp_id && false) {
768 768
 
769
-                            $output .= '<tr class =' . $oddclass . '>
770
-                                    <td>' . $extend_link . '</td>
771
-                                    <td colspan="4">' . $title . '</td>
769
+                            $output .= '<tr class ='.$oddclass.'>
770
+                                    <td>' . $extend_link.'</td>
771
+                                    <td colspan="4">' . $title.'</td>
772 772
                                     <td colspan="2">&nbsp;</td>
773 773
                                     <td colspan="2">&nbsp;</td>
774 774
                                     <td colspan="2">&nbsp;</td>
@@ -793,13 +793,13 @@  discard block
 block discarded – undo
793 793
                                     $scoreItem .= ExerciseLib::show_score($score, $maxscore, false);
794 794
                                 }
795 795
                             } else {
796
-                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore);
796
+                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.$maxscore);
797 797
                             }
798 798
 
799 799
                             $output .= '
800 800
                                 <td>'.$extend_link.'</td>
801
-                                <td colspan="4">' . $title . '</td>
802
-                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status) .'</td>
801
+                                <td colspan="4">' . $title.'</td>
802
+                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status).'</td>
803 803
                                 <td colspan="2">'.$scoreItem.'</td>
804 804
                                 <td colspan="2">'.$time.'</td>
805 805
                                 '.$action.'
@@ -816,10 +816,10 @@  discard block
 block discarded – undo
816 816
                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
817 817
                                     $temp[] = '/';
818 818
                                 } else {
819
-                                    $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
819
+                                    $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
820 820
                                 }
821 821
                             } else {
822
-                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
822
+                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
823 823
                             }
824 824
                             $temp[] = $time;
825 825
                             $csv_content[] = $temp;
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 
831 831
                     $action = null;
832 832
                     if ($type == 'classic') {
833
-                        $action =  '<td></td>';
833
+                        $action = '<td></td>';
834 834
                     }
835 835
 
836 836
                     if ($extend_this_attempt || $extend_all) {
@@ -867,11 +867,11 @@  discard block
 block discarded – undo
867 867
                                     <td></td>
868 868
                                     <td></td>
869 869
                                     <td></td>
870
-                                    <td>' . $interaction['order_id'] . '</td>
871
-                                    <td colspan="2">'.$interaction['objective_id'] . '</td>
872
-                                    <td colspan="2">' . $interaction['status'] . '</td>
870
+                                    <td>' . $interaction['order_id'].'</td>
871
+                                    <td colspan="2">'.$interaction['objective_id'].'</td>
872
+                                    <td colspan="2">' . $interaction['status'].'</td>
873 873
                                     <td>' . $interaction['score_raw'].'</td>
874
-                                    <td>' . $interaction['score_max'] .'</td>
874
+                                    <td>' . $interaction['score_max'].'</td>
875 875
                                     <td>' . $interaction['score_min'].'</td>
876 876
                                     '.$action.'
877 877
                                </tr>';
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
                     }
881 881
 
882 882
                     // Attempts listing by exercise.
883
-                    if ($lp_id == $my_lp_id && $lp_item_id== $my_id && $extendedAttempt) {
883
+                    if ($lp_id == $my_lp_id && $lp_item_id == $my_id && $extendedAttempt) {
884 884
                         // Get attempts of a exercise.
885 885
                         if (!empty($lp_id) &&
886 886
                             !empty($lp_item_id) &&
@@ -895,15 +895,15 @@  discard block
 block discarded – undo
895 895
                             $row_path = Database::fetch_array($res_path);
896 896
 
897 897
                             if (Database::num_rows($res_path) > 0) {
898
-                                $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
898
+                                $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
899 899
                                         WHERE
900
-                                            exe_exo_id="' . (int) $row_path['path'] . '" AND
900
+                                            exe_exo_id="' . (int) $row_path['path'].'" AND
901 901
                                             status <> "incomplete" AND
902
-                                            exe_user_id="' . $user_id . '" AND
903
-                                            orig_lp_id = "' . (int) $lp_id . '" AND
904
-                                            orig_lp_item_id = "' . (int) $lp_item_id . '" AND
905
-                                            c_id = ' . $course_id . '  AND
906
-                                            session_id = ' . $session_id . '
902
+                                            exe_user_id="' . $user_id.'" AND
903
+                                            orig_lp_id = "' . (int) $lp_id.'" AND
904
+                                            orig_lp_item_id = "' . (int) $lp_item_id.'" AND
905
+                                            c_id = ' . $course_id.'  AND
906
+                                            session_id = ' . $session_id.'
907 907
                                         ORDER BY exe_date';
908 908
                                 $res_attempts = Database::query($sql);
909 909
                                 $num_attempts = Database::num_rows($res_attempts);
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
                                         if ($mktime_start_date && $mktime_exe_date) {
922 922
                                             $mytime = ((int) $mktime_exe_date - (int) $mktime_start_date);
923 923
                                             $time_attemp = learnpathItem :: getScormTimeFromParameter('js', $mytime);
924
-                                            $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
924
+                                            $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp);
925 925
                                         } else {
926 926
                                             $time_attemp = ' - ';
927 927
                                         }
@@ -947,33 +947,33 @@  discard block
 block discarded – undo
947 947
                                             $my_lesson_status = learnpathitem::humanize_status('incomplete');
948 948
                                         }
949 949
 
950
-                                        $output .= '<tr class="' . $oddclass . '" >
950
+                                        $output .= '<tr class="'.$oddclass.'" >
951 951
                                         <td></td>
952
-                                        <td>' . $extend_attempt_link . '</td>
953
-                                        <td colspan="3">' . get_lang('Attempt').' '. $n.'</td>
954
-                                        <td colspan="2">' . $my_lesson_status . '</td>
955
-                                        <td colspan="2">'.$view_score . '</td>
956
-                                        <td colspan="2">'.$time_attemp . '</td>';
952
+                                        <td>' . $extend_attempt_link.'</td>
953
+                                        <td colspan="3">' . get_lang('Attempt').' '.$n.'</td>
954
+                                        <td colspan="2">' . $my_lesson_status.'</td>
955
+                                        <td colspan="2">'.$view_score.'</td>
956
+                                        <td colspan="2">'.$time_attemp.'</td>';
957 957
                                         if ($action == 'classic') {
958 958
                                             if ($origin != 'tracking') {
959 959
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
960 960
                                                     $output .= '<td>
961
-                                                            <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
961
+                                                            <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
962 962
                                                             </td>';
963 963
                                                 } else {
964 964
                                                     $output .= '<td>
965
-                                                            <a href="../exercise/exercise_show.php?origin=' . $origin . '&id=' . $my_exe_id . '&cidReq=' . $courseCode . '" target="_parent">
966
-                                                            <img src="' . Display::returnIconPath('quiz.gif').'" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
965
+                                                            <a href="../exercise/exercise_show.php?origin=' . $origin.'&id='.$my_exe_id.'&cidReq='.$courseCode.'" target="_parent">
966
+                                                            <img src="' . Display::returnIconPath('quiz.gif').'" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
967 967
                                                             </a></td>';
968 968
                                                 }
969 969
                                             } else {
970 970
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
971 971
                                                     $output .= '<td>
972
-                                                                <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></td>';
972
+                                                                <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></td>';
973 973
                                                 } else {
974 974
                                                     $output .= '<td>
975
-                                                                    <a href="../exercise/exercise_show.php?cidReq=' . $courseCode . '&origin=correct_exercise_in_lp&id=' . $my_exe_id . '" target="_parent">
976
-                                                                    <img src="' . Display::returnIconPath('quiz.gif').'" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></a></td>';
975
+                                                                    <a href="../exercise/exercise_show.php?cidReq=' . $courseCode.'&origin=correct_exercise_in_lp&id='.$my_exe_id.'" target="_parent">
976
+                                                                    <img src="' . Display::returnIconPath('quiz.gif').'" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></a></td>';
977 977
                                                 }
978 978
                                             }
979 979
                                         }
@@ -1032,13 +1032,13 @@  discard block
 block discarded – undo
1032 1032
         }
1033 1033
 
1034 1034
         $total_time = learnpathItem::getScormTimeFromParameter('js', $total_time);
1035
-        $total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time);
1035
+        $total_time = str_replace('NaN', '00'.$h.'00\'00"', $total_time);
1036 1036
 
1037 1037
         if (!$is_allowed_to_edit && $result_disabled_ext_all) {
1038 1038
             $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
1039 1039
         } else {
1040 1040
             if (is_numeric($total_score)) {
1041
-                $final_score = $total_score . '%';
1041
+                $final_score = $total_score.'%';
1042 1042
             } else {
1043 1043
                 $final_score = $total_score;
1044 1044
             }
@@ -1054,19 +1054,19 @@  discard block
 block discarded – undo
1054 1054
 
1055 1055
         $action = null;
1056 1056
         if ($type == 'classic') {
1057
-            $action =  '<td></td>';
1057
+            $action = '<td></td>';
1058 1058
         }
1059 1059
 
1060 1060
         $output .= '<tr class="'.$oddclass.'">
1061 1061
                 <td></td>
1062 1062
                 <td colspan="4">
1063
-                    <i>' . get_lang('AccomplishedStepsTotal') .'</i>
1063
+                    <i>' . get_lang('AccomplishedStepsTotal').'</i>
1064 1064
                 </td>
1065 1065
                 <td colspan="2">'.$progress.'%</td>
1066 1066
                 <td colspan="2">
1067 1067
                     ' . $final_score.'
1068 1068
                 </td>
1069
-                <td colspan="2">' . $total_time . '</div>
1069
+                <td colspan="2">' . $total_time.'</div>
1070 1070
                 '.$action.'
1071 1071
            </tr>';
1072 1072
 
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
     	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1411 1411
     	if (is_array($user_id)) {
1412 1412
     	    $user_id = array_map('intval', $user_id);
1413
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1413
+    		$condition_user = " AND user_id IN (".implode(',', $user_id).") ";
1414 1414
     	} else {
1415 1415
     		$user_id = intval($user_id);
1416 1416
     		$condition_user = " AND user_id = $user_id ";
@@ -1446,13 +1446,13 @@  discard block
 block discarded – undo
1446 1446
     {
1447 1447
     	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1448 1448
     	$sql = 'SELECT login_date
1449
-    	        FROM ' . $tbl_track_login . '
1450
-                WHERE login_user_id = ' . intval($student_id) . '
1449
+    	        FROM ' . $tbl_track_login.'
1450
+                WHERE login_user_id = ' . intval($student_id).'
1451 1451
                 ORDER BY login_date ASC
1452 1452
                 LIMIT 0,1';
1453 1453
 
1454 1454
     	$rs = Database::query($sql);
1455
-    	if (Database::num_rows($rs)>0) {
1455
+    	if (Database::num_rows($rs) > 0) {
1456 1456
     		if ($first_login_date = Database::result($rs, 0, 0)) {
1457 1457
                 return api_convert_and_format_date(
1458 1458
                     $first_login_date,
@@ -1477,8 +1477,8 @@  discard block
 block discarded – undo
1477 1477
     {
1478 1478
     	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1479 1479
     	$sql = 'SELECT login_date
1480
-    	        FROM ' . $table . '
1481
-                WHERE login_user_id = ' . intval($student_id) . '
1480
+    	        FROM ' . $table.'
1481
+                WHERE login_user_id = ' . intval($student_id).'
1482 1482
                 ORDER BY login_date
1483 1483
                 DESC LIMIT 0,1';
1484 1484
 
@@ -1487,18 +1487,18 @@  discard block
 block discarded – undo
1487 1487
     		if ($last_login_date = Database::result($rs, 0, 0)) {
1488 1488
     			$last_login_date = api_get_local_time($last_login_date);
1489 1489
     			if ($return_timestamp) {
1490
-    				return api_strtotime($last_login_date,'UTC');
1490
+    				return api_strtotime($last_login_date, 'UTC');
1491 1491
     			} else {
1492 1492
     				if (!$warning_message) {
1493 1493
     					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1494 1494
     				} else {
1495
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1495
+    					$timestamp = api_strtotime($last_login_date, 'UTC');
1496 1496
     					$currentTimestamp = time();
1497 1497
 
1498 1498
     					//If the last connection is > than 7 days, the text is red
1499 1499
     					//345600 = 7 days in seconds
1500 1500
     					if ($currentTimestamp - $timestamp > 604800) {
1501
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1501
+    						return '<span style="color: #F00;">'.api_format_date($last_login_date, DATE_FORMAT_SHORT).'</span>';
1502 1502
     					} else {
1503 1503
     						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1504 1504
     					}
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
         $sql = "$select
1534 1534
                 FROM $tbl_track_login
1535 1535
                 WHERE
1536
-                    login_user_id IN (' ". implode("','", $studentList) . "' ) AND
1536
+                    login_user_id IN (' ".implode("','", $studentList)."' ) AND
1537 1537
                     login_date < '$date'
1538 1538
                 ";
1539 1539
         $rs = Database::query($sql);
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
                               '.Display::return_icon('messagebox_warning.gif').'
1633 1633
                              </a>'
1634 1634
                             : null;
1635
-    					return $icon. Display::label($last_login_date, 'warning');
1635
+    					return $icon.Display::label($last_login_date, 'warning');
1636 1636
     				} else {
1637 1637
     					return $last_login_date;
1638 1638
     				}
@@ -1667,8 +1667,8 @@  discard block
 block discarded – undo
1667 1667
 
1668 1668
         // Given we're storing in cache, round the start and end times
1669 1669
         // to the lower minute
1670
-        $roundedStart = substr($start, 0, -2) . '00';
1671
-        $roundedStop = substr($stop, 0, -2) . '00';
1670
+        $roundedStart = substr($start, 0, -2).'00';
1671
+        $roundedStop = substr($stop, 0, -2).'00';
1672 1672
         $roundedStart = Database::escape_string($roundedStart);
1673 1673
         $roundedStop = Database::escape_string($roundedStop);
1674 1674
 
@@ -1678,7 +1678,7 @@  discard block
 block discarded – undo
1678 1678
     	$session_id  = intval($session_id);
1679 1679
     	$count = 0;
1680 1680
         $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1681
-        $sql =  "SELECT count(*) as count_connections
1681
+        $sql = "SELECT count(*) as count_connections
1682 1682
                 FROM $tbl_track_e_course_access
1683 1683
                 WHERE
1684 1684
                     c_id = $courseId AND
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
                 $count = apcu_fetch($apc_var);
1701 1701
             } else {
1702 1702
                 $rs = Database::query($sql);
1703
-                if (Database::num_rows($rs)>0) {
1703
+                if (Database::num_rows($rs) > 0) {
1704 1704
                     $row = Database::fetch_object($rs);
1705 1705
                     $count = $row->count_connections;
1706 1706
                 }
@@ -1709,7 +1709,7 @@  discard block
 block discarded – undo
1709 1709
             }
1710 1710
         } else {
1711 1711
             $rs = Database::query($sql);
1712
-            if (Database::num_rows($rs)>0) {
1712
+            if (Database::num_rows($rs) > 0) {
1713 1713
                 $row = Database::fetch_object($rs);
1714 1714
                 $count = $row->count_connections;
1715 1715
             }
@@ -1731,14 +1731,14 @@  discard block
 block discarded – undo
1731 1731
     	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1732 1732
 
1733 1733
     	$sql = 'SELECT DISTINCT c_id
1734
-                FROM ' . $tbl_course_rel_user . '
1734
+                FROM ' . $tbl_course_rel_user.'
1735 1735
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1736 1736
     	$rs = Database::query($sql);
1737 1737
     	$nb_courses = Database::num_rows($rs);
1738 1738
 
1739 1739
     	if ($include_sessions) {
1740 1740
     		$sql = 'SELECT DISTINCT c_id
1741
-                    FROM ' . $tbl_session_course_rel_user . '
1741
+                    FROM ' . $tbl_session_course_rel_user.'
1742 1742
                     WHERE user_id = ' . $user_id;
1743 1743
     		$rs = Database::query($sql);
1744 1744
     		$nb_courses += Database::num_rows($rs);
@@ -1785,7 +1785,7 @@  discard block
 block discarded – undo
1785 1785
     		$condition_quiz = "";
1786 1786
     		if (!empty($exercise_id)) {
1787 1787
     			$exercise_id = intval($exercise_id);
1788
-    			$condition_quiz =" AND id = $exercise_id ";
1788
+    			$condition_quiz = " AND id = $exercise_id ";
1789 1789
     		}
1790 1790
 
1791 1791
     		// Compose a filter based on optional session id given
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
                         }
1839 1839
                     }
1840 1840
                     if (!empty($exercise_list)) {
1841
-                        $exercise_id = implode("','",$exercise_list);
1841
+                        $exercise_id = implode("','", $exercise_list);
1842 1842
                     }
1843 1843
     			}
1844 1844
 
@@ -1863,10 +1863,10 @@  discard block
 block discarded – undo
1863 1863
     			$quiz_avg_score = null;
1864 1864
 
1865 1865
     			if (!empty($row['avg_score'])) {
1866
-    				$quiz_avg_score = round($row['avg_score'],2);
1866
+    				$quiz_avg_score = round($row['avg_score'], 2);
1867 1867
     			}
1868 1868
 
1869
-    			if(!empty($row['num_attempts'])) {
1869
+    			if (!empty($row['num_attempts'])) {
1870 1870
     				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1871 1871
     			}
1872 1872
     			if (is_array($student_id)) {
@@ -1996,7 +1996,7 @@  discard block
 block discarded – undo
1996 1996
             $row = Database::fetch_row($rs);
1997 1997
             $count = $row[0];
1998 1998
         }
1999
-        $count = ($count != 0 ) ? 100*round(intval($count)/count($exercise_list), 2) .'%' : '0%';
1999
+        $count = ($count != 0) ? 100 * round(intval($count) / count($exercise_list), 2).'%' : '0%';
2000 2000
         return $count;
2001 2001
     }
2002 2002
 
@@ -2021,7 +2021,7 @@  discard block
 block discarded – undo
2021 2021
                 );
2022 2022
 
2023 2023
                 if (!empty($best_attempt) && !empty($best_attempt['exe_weighting'])) {
2024
-                    $result += $best_attempt['exe_result']/$best_attempt['exe_weighting'];
2024
+                    $result += $best_attempt['exe_result'] / $best_attempt['exe_weighting'];
2025 2025
                 }
2026 2026
             }
2027 2027
             $result = $result / count($exercise_list);
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
         $query = sprintf($sql, intval($courseId), $sessionId);
2059 2059
         $rs = Database::query($query);
2060 2060
         $teachers = array();
2061
-        while ($teacher = Database::fetch_array($rs,'ASSOC')) {
2061
+        while ($teacher = Database::fetch_array($rs, 'ASSOC')) {
2062 2062
             $teachers[] = $teacher;
2063 2063
         }
2064 2064
         $data = array();
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
             $data[] = array(
2183 2183
                 'course' => $course['title'],
2184 2184
                 'session' => $teacher['name'],
2185
-                'tutor' => $tutor['username'] . ' - ' . $tutor['lastname'] . ' ' . $tutor['firstname'],
2185
+                'tutor' => $tutor['username'].' - '.$tutor['lastname'].' '.$tutor['firstname'],
2186 2186
                 'documents' => $totalDocuments,
2187 2187
                 'links' => $totalLinks,
2188 2188
                 'forums' => $totalForums,
@@ -2245,7 +2245,7 @@  discard block
 block discarded – undo
2245 2245
             for ($i = 0; $i < count($lpIdList); $i++) {
2246 2246
                 $placeHolders[] = '?';
2247 2247
             }
2248
-            $lpConditions['AND id IN(' . implode(', ', $placeHolders) . ') '] = $lpIdList;
2248
+            $lpConditions['AND id IN('.implode(', ', $placeHolders).') '] = $lpIdList;
2249 2249
         }
2250 2250
 
2251 2251
         if ($onlySeriousGame) {
@@ -2265,14 +2265,14 @@  discard block
 block discarded – undo
2265 2265
 
2266 2266
         $conditions = [
2267 2267
             " c_id = {$courseInfo['real_id']} ",
2268
-            " lp_view.lp_id IN(" . implode(', ', $filteredLP) . ") "
2268
+            " lp_view.lp_id IN(".implode(', ', $filteredLP).") "
2269 2269
         ];
2270 2270
 
2271 2271
         $groupBy = 'GROUP BY lp_id';
2272 2272
 
2273 2273
         if (is_array($studentId)) {
2274 2274
             $studentId = array_map('intval', $studentId);
2275
-            $conditions[] = " lp_view.user_id IN (" . implode(',', $studentId) . ")  ";
2275
+            $conditions[] = " lp_view.user_id IN (".implode(',', $studentId).")  ";
2276 2276
 
2277 2277
 
2278 2278
         } else {
@@ -2407,7 +2407,7 @@  discard block
 block discarded – undo
2407 2407
             // Compose a filter based on optional learning paths list given
2408 2408
             $condition_lp = "";
2409 2409
             if (count($lp_ids) > 0) {
2410
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2410
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2411 2411
             }
2412 2412
 
2413 2413
             // Compose a filter based on optional session id
@@ -2447,9 +2447,9 @@  discard block
 block discarded – undo
2447 2447
             // prepare filter on users
2448 2448
             if (is_array($student_id)) {
2449 2449
                 array_walk($student_id, 'intval');
2450
-                $condition_user1 =" AND user_id IN (".implode(',', $student_id).") ";
2450
+                $condition_user1 = " AND user_id IN (".implode(',', $student_id).") ";
2451 2451
             } else {
2452
-                $condition_user1 =" AND user_id = $student_id ";
2452
+                $condition_user1 = " AND user_id = $student_id ";
2453 2453
             }
2454 2454
 
2455 2455
             if ($count_row_lp > 0 && !empty($student_id)) {
@@ -2492,7 +2492,7 @@  discard block
 block discarded – undo
2492 2492
                                     ORDER BY lp_item_id";
2493 2493
                             $res_lp_item = Database::query($sql);
2494 2494
 
2495
-                            while ($row_lp_item = Database::fetch_array($res_lp_item,'ASSOC')) {
2495
+                            while ($row_lp_item = Database::fetch_array($res_lp_item, 'ASSOC')) {
2496 2496
                                 $my_lp_item_id = $row_lp_item['lp_item_id'];
2497 2497
 
2498 2498
                                 // Getting the most recent attempt
@@ -2515,8 +2515,8 @@  discard block
 block discarded – undo
2515 2515
                                         ORDER BY view_count DESC
2516 2516
                                         LIMIT 1";
2517 2517
                                 $res_lp_item_result = Database::query($sql);
2518
-                                while ($row_max_score = Database::fetch_array($res_lp_item_result,'ASSOC')) {
2519
-                                    $list[]= $row_max_score;
2518
+                                while ($row_max_score = Database::fetch_array($res_lp_item_result, 'ASSOC')) {
2519
+                                    $list[] = $row_max_score;
2520 2520
                                 }
2521 2521
                             }
2522 2522
                         } else {
@@ -2540,8 +2540,8 @@  discard block
 block discarded – undo
2540 2540
                             if ($debug) echo $sql.'<br />';
2541 2541
                             $res_max_score = Database::query($sql);
2542 2542
 
2543
-                            while ($row_max_score = Database::fetch_array($res_max_score,'ASSOC')) {
2544
-                                $list[]= $row_max_score;
2543
+                            while ($row_max_score = Database::fetch_array($res_max_score, 'ASSOC')) {
2544
+                                $list[] = $row_max_score;
2545 2545
                             }
2546 2546
                         }
2547 2547
 
@@ -2556,7 +2556,7 @@  discard block
 block discarded – undo
2556 2556
                             $max_score_item_view = $row_max_score['max_score_item_view'];
2557 2557
                             $score = $row_max_score['score'];
2558 2558
 
2559
-                            if ($debug) echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2559
+                            if ($debug) echo '<h3>Item Type: '.$row_max_score['item_type'].'</h3>';
2560 2560
 
2561 2561
                             if ($row_max_score['item_type'] == 'sco') {
2562 2562
                                 /* Check if it is sco (easier to get max_score)
@@ -2574,7 +2574,7 @@  discard block
 block discarded – undo
2574 2574
                                 }
2575 2575
                                 // Avoid division by zero errors
2576 2576
                                 if (!empty($max_score)) {
2577
-                                    $lp_partial_total += $score/$max_score;
2577
+                                    $lp_partial_total += $score / $max_score;
2578 2578
                                 }
2579 2579
                                 if ($debug) echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2580 2580
                             } else {
@@ -2598,10 +2598,10 @@  discard block
 block discarded – undo
2598 2598
                                         ORDER BY exe_date DESC
2599 2599
                                         LIMIT 1";
2600 2600
 
2601
-                                if ($debug) echo $sql .'<br />';
2601
+                                if ($debug) echo $sql.'<br />';
2602 2602
                                 $result_last_attempt = Database::query($sql);
2603 2603
                                 $num = Database :: num_rows($result_last_attempt);
2604
-                                if ($num > 0 ) {
2604
+                                if ($num > 0) {
2605 2605
                                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
2606 2606
                                     if ($debug) echo $id_last_attempt.'<br />';
2607 2607
 
@@ -2630,13 +2630,13 @@  discard block
 block discarded – undo
2630 2630
                                         $max_score = $row_max_score_bis['maxscore'];
2631 2631
                                     }
2632 2632
                                     if (!empty($max_score) && floatval($max_score) > 0) {
2633
-                                        $lp_partial_total += $score/$max_score;
2633
+                                        $lp_partial_total += $score / $max_score;
2634 2634
                                     }
2635 2635
                                     if ($debug) echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2636 2636
                                 }
2637 2637
                             }
2638 2638
 
2639
-                            if (in_array($row_max_score['item_type'], array('quiz','sco'))) {
2639
+                            if (in_array($row_max_score['item_type'], array('quiz', 'sco'))) {
2640 2640
                                 // Normal way
2641 2641
                                 if ($use_max_score[$lp_id]) {
2642 2642
                                     $count_items++;
@@ -2671,8 +2671,8 @@  discard block
 block discarded – undo
2671 2671
                     if ($debug) echo $sql;
2672 2672
                     $result_have_quiz = Database::query($sql);
2673 2673
 
2674
-                    if (Database::num_rows($result_have_quiz) > 0 ) {
2675
-                        $row = Database::fetch_array($result_have_quiz,'ASSOC');
2674
+                    if (Database::num_rows($result_have_quiz) > 0) {
2675
+                        $row = Database::fetch_array($result_have_quiz, 'ASSOC');
2676 2676
                         if (is_numeric($row['count']) && $row['count'] != 0) {
2677 2677
                             $lp_with_quiz++;
2678 2678
                         }
@@ -2684,7 +2684,7 @@  discard block
 block discarded – undo
2684 2684
 
2685 2685
                 if ($lp_with_quiz != 0) {
2686 2686
                     if (!$return_array) {
2687
-                        $score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
2687
+                        $score_of_scorm_calculate = round(($global_result / $lp_with_quiz), 2);
2688 2688
                         if ($debug) var_dump($score_of_scorm_calculate);
2689 2689
                         if (empty($lp_ids)) {
2690 2690
                             if ($debug) echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
@@ -2758,9 +2758,9 @@  discard block
 block discarded – undo
2758 2758
 
2759 2759
         if (is_array($student_id)) {
2760 2760
             array_walk($student_id, 'intval');
2761
-            $conditions[] =" lp_view.user_id IN (".implode(',', $student_id).") ";
2761
+            $conditions[] = " lp_view.user_id IN (".implode(',', $student_id).") ";
2762 2762
         } else {
2763
-            $conditions[] =" lp_view.user_id = $student_id ";
2763
+            $conditions[] = " lp_view.user_id = $student_id ";
2764 2764
         }
2765 2765
 
2766 2766
         $conditionsToString = implode('AND ', $conditions);
@@ -2784,7 +2784,7 @@  discard block
 block discarded – undo
2784 2784
             return 0;
2785 2785
         }
2786 2786
 
2787
-        return ($row['sum_score'] / $row['sum_max_score'])*100;
2787
+        return ($row['sum_score'] / $row['sum_max_score']) * 100;
2788 2788
 
2789 2789
     }
2790 2790
 
@@ -2814,7 +2814,7 @@  discard block
 block discarded – undo
2814 2814
             // Compose a filter based on optional learning paths list given
2815 2815
             $condition_lp = "";
2816 2816
             if (count($lp_ids) > 0) {
2817
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2817
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2818 2818
             }
2819 2819
 
2820 2820
             // Compose a filter based on optional session id
@@ -2876,7 +2876,7 @@  discard block
 block discarded – undo
2876 2876
 
2877 2877
         if (!empty($course)) {
2878 2878
 
2879
-            $course_id	 = $course['real_id'];
2879
+            $course_id = $course['real_id'];
2880 2880
 
2881 2881
             $lp_table    = Database :: get_course_table(TABLE_LP_MAIN);
2882 2882
             $t_lpv       = Database :: get_course_table(TABLE_LP_VIEW);
@@ -2890,8 +2890,8 @@  discard block
 block discarded – undo
2890 2890
             // calculates last connection time
2891 2891
             if ($count_row_lp > 0) {
2892 2892
                 $sql = 'SELECT MAX(start_time)
2893
-                        FROM ' . $t_lpiv . ' AS item_view
2894
-                        INNER JOIN ' . $t_lpv . ' AS view
2893
+                        FROM ' . $t_lpiv.' AS item_view
2894
+                        INNER JOIN ' . $t_lpv.' AS view
2895 2895
                             ON item_view.lp_view_id = view.id
2896 2896
                         WHERE
2897 2897
                             item_view.c_id 		= '.$course_id.' AND
@@ -2927,15 +2927,15 @@  discard block
 block discarded – undo
2927 2927
 
2928 2928
         // At first, courses where $coach_id is coach of the course //
2929 2929
         $sql = 'SELECT session_id, c_id
2930
-                FROM ' . $tbl_session_course_user . '
2930
+                FROM ' . $tbl_session_course_user.'
2931 2931
                 WHERE user_id=' . $coach_id.' AND status=2';
2932 2932
 
2933 2933
         if (api_is_multiple_url_enabled()) {
2934
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2934
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2935 2935
             $access_url_id = api_get_current_access_url_id();
2936 2936
             if ($access_url_id != -1) {
2937 2937
                 $sql = 'SELECT scu.session_id, scu.c_id
2938
-                    FROM ' . $tbl_session_course_user . ' scu
2938
+                    FROM ' . $tbl_session_course_user.' scu
2939 2939
                     INNER JOIN '.$tbl_session_rel_access_url.'  sru
2940 2940
                     ON (scu.session_id=sru.session_id)
2941 2941
                     WHERE
@@ -2969,28 +2969,28 @@  discard block
 block discarded – undo
2969 2969
 
2970 2970
         // Then, courses where $coach_id is coach of the session    //
2971 2971
         $sql = 'SELECT session_course_user.user_id
2972
-                FROM ' . $tbl_session_course_user . ' as session_course_user
2972
+                FROM ' . $tbl_session_course_user.' as session_course_user
2973 2973
                 INNER JOIN     '.$tbl_session_user.' sru
2974 2974
                 ON session_course_user.user_id = sru.user_id AND session_course_user.session_id = sru.session_id
2975
-                INNER JOIN ' . $tbl_session_course . ' as session_course
2975
+                INNER JOIN ' . $tbl_session_course.' as session_course
2976 2976
                 ON session_course.c_id = session_course_user.c_id
2977 2977
                 AND session_course_user.session_id = session_course.session_id
2978
-                INNER JOIN ' . $tbl_session . ' as session
2978
+                INNER JOIN ' . $tbl_session.' as session
2979 2979
                 ON session.id = session_course.session_id
2980 2980
                 AND session.id_coach = ' . $coach_id;
2981 2981
         if (api_is_multiple_url_enabled()) {
2982
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2982
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2983 2983
             $access_url_id = api_get_current_access_url_id();
2984
-            if ($access_url_id != -1){
2984
+            if ($access_url_id != -1) {
2985 2985
                 $sql = 'SELECT session_course_user.user_id
2986
-                        FROM ' . $tbl_session_course_user . ' as session_course_user
2986
+                        FROM ' . $tbl_session_course_user.' as session_course_user
2987 2987
                         INNER JOIN     '.$tbl_session_user.' sru
2988 2988
                             ON session_course_user.user_id = sru.user_id AND
2989 2989
                                session_course_user.session_id = sru.session_id
2990
-                        INNER JOIN ' . $tbl_session_course . ' as session_course
2990
+                        INNER JOIN ' . $tbl_session_course.' as session_course
2991 2991
                             ON session_course.c_id = session_course_user.c_id AND
2992 2992
                             session_course_user.session_id = session_course.session_id
2993
-                        INNER JOIN ' . $tbl_session . ' as session
2993
+                        INNER JOIN ' . $tbl_session.' as session
2994 2994
                             ON session.id = session_course.session_id AND
2995 2995
                             session.id_coach = ' . $coach_id.'
2996 2996
                         INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
@@ -3020,8 +3020,8 @@  discard block
 block discarded – undo
3020 3020
 
3021 3021
         $students = [];
3022 3022
         // At first, courses where $coach_id is coach of the course //
3023
-        $sql = 'SELECT c_id FROM ' . $tbl_session_course_user . '
3024
-                WHERE session_id="' . $id_session . '" AND user_id=' . $coach_id.' AND status=2';
3023
+        $sql = 'SELECT c_id FROM '.$tbl_session_course_user.'
3024
+                WHERE session_id="' . $id_session.'" AND user_id='.$coach_id.' AND status=2';
3025 3025
         $result = Database::query($sql);
3026 3026
 
3027 3027
         while ($a_courses = Database::fetch_array($result)) {
@@ -3031,7 +3031,7 @@  discard block
 block discarded – undo
3031 3031
                     FROM $tbl_session_course_user AS srcru
3032 3032
                     WHERE
3033 3033
                         c_id = '$courseId' AND
3034
-                        session_id = '" . $id_session . "'";
3034
+                        session_id = '".$id_session."'";
3035 3035
             $rs = Database::query($sql);
3036 3036
             while ($row = Database::fetch_array($rs)) {
3037 3037
                 $students[$row['user_id']] = $row['user_id'];
@@ -3039,15 +3039,15 @@  discard block
 block discarded – undo
3039 3039
         }
3040 3040
 
3041 3041
         // Then, courses where $coach_id is coach of the session
3042
-        $sql = 'SELECT id_coach FROM ' . $tbl_session . '
3043
-                WHERE id="' . $id_session.'" AND id_coach="' . $coach_id . '"';
3042
+        $sql = 'SELECT id_coach FROM '.$tbl_session.'
3043
+                WHERE id="' . $id_session.'" AND id_coach="'.$coach_id.'"';
3044 3044
         $result = Database::query($sql);
3045 3045
 
3046 3046
         //He is the session_coach so we select all the users in the session
3047 3047
         if (Database::num_rows($result) > 0) {
3048 3048
             $sql = 'SELECT DISTINCT srcru.user_id
3049
-                    FROM ' . $tbl_session_course_user . ' AS srcru
3050
-                    WHERE session_id="' . $id_session . '"';
3049
+                    FROM ' . $tbl_session_course_user.' AS srcru
3050
+                    WHERE session_id="' . $id_session.'"';
3051 3051
             $result = Database::query($sql);
3052 3052
             while ($row = Database::fetch_array($result)) {
3053 3053
                 $students[$row['user_id']] = $row['user_id'];
@@ -3074,8 +3074,8 @@  discard block
 block discarded – undo
3074 3074
 
3075 3075
         // At first, courses where $coach_id is coach of the course //
3076 3076
 
3077
-        $sql = 'SELECT 1 FROM ' . $tbl_session_course_user . '
3078
-                WHERE user_id=' . $coach_id .' AND status=2';
3077
+        $sql = 'SELECT 1 FROM '.$tbl_session_course_user.'
3078
+                WHERE user_id=' . $coach_id.' AND status=2';
3079 3079
         $result = Database::query($sql);
3080 3080
         if (Database::num_rows($result) > 0) {
3081 3081
             return true;
@@ -3083,12 +3083,12 @@  discard block
 block discarded – undo
3083 3083
 
3084 3084
         // Then, courses where $coach_id is coach of the session
3085 3085
         $sql = 'SELECT session_course_user.user_id
3086
-                FROM ' . $tbl_session_course_user . ' as session_course_user
3087
-                INNER JOIN ' . $tbl_session_course . ' as session_course
3086
+                FROM ' . $tbl_session_course_user.' as session_course_user
3087
+                INNER JOIN ' . $tbl_session_course.' as session_course
3088 3088
                     ON session_course.c_id = session_course_user.c_id
3089
-                INNER JOIN ' . $tbl_session . ' as session
3089
+                INNER JOIN ' . $tbl_session.' as session
3090 3090
                     ON session.id = session_course.session_id
3091
-                    AND session.id_coach = ' . $coach_id . '
3091
+                    AND session.id_coach = ' . $coach_id.'
3092 3092
                 WHERE user_id = ' . $student_id;
3093 3093
         $result = Database::query($sql);
3094 3094
         if (Database::num_rows($result) > 0) {
@@ -3120,16 +3120,16 @@  discard block
 block discarded – undo
3120 3120
         // At first, courses where $coach_id is coach of the course.
3121 3121
 
3122 3122
         $sql = 'SELECT DISTINCT c.code
3123
-                FROM ' . $tbl_session_course_user . ' sc
3123
+                FROM ' . $tbl_session_course_user.' sc
3124 3124
                 INNER JOIN '.$tbl_course.' c
3125 3125
                 ON (c.id = sc.c_id)
3126 3126
                 WHERE user_id = ' . $coach_id.' AND status = 2';
3127 3127
 
3128 3128
         if (api_is_multiple_url_enabled()) {
3129 3129
             $access_url_id = api_get_current_access_url_id();
3130
-            if ($access_url_id != -1){
3130
+            if ($access_url_id != -1) {
3131 3131
                 $sql = 'SELECT DISTINCT c.code
3132
-                        FROM ' . $tbl_session_course_user . ' scu
3132
+                        FROM ' . $tbl_session_course_user.' scu
3133 3133
                         INNER JOIN '.$tbl_course.' c
3134 3134
                         ON (c.code = scu.c_id)
3135 3135
                         INNER JOIN '.$tbl_course_rel_access_url.' cru
@@ -3142,7 +3142,7 @@  discard block
 block discarded – undo
3142 3142
         }
3143 3143
 
3144 3144
         if (!empty($id_session)) {
3145
-            $sql .= ' AND session_id=' . $id_session;
3145
+            $sql .= ' AND session_id='.$id_session;
3146 3146
         }
3147 3147
 
3148 3148
         $courseList = array();
@@ -3154,25 +3154,25 @@  discard block
 block discarded – undo
3154 3154
         // Then, courses where $coach_id is coach of the session
3155 3155
 
3156 3156
         $sql = 'SELECT DISTINCT course.code
3157
-                FROM ' . $tbl_session_course . ' as session_course
3158
-                INNER JOIN ' . $tbl_session . ' as session
3157
+                FROM ' . $tbl_session_course.' as session_course
3158
+                INNER JOIN ' . $tbl_session.' as session
3159 3159
                     ON session.id = session_course.session_id
3160
-                    AND session.id_coach = ' . $coach_id . '
3161
-                INNER JOIN ' . $tbl_course . ' as course
3160
+                    AND session.id_coach = ' . $coach_id.'
3161
+                INNER JOIN ' . $tbl_course.' as course
3162 3162
                     ON course.id = session_course.c_id';
3163 3163
 
3164 3164
         if (api_is_multiple_url_enabled()) {
3165 3165
             $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
3166 3166
             $access_url_id = api_get_current_access_url_id();
3167
-            if ($access_url_id != -1){
3167
+            if ($access_url_id != -1) {
3168 3168
                 $sql = 'SELECT DISTINCT c.code
3169
-                    FROM ' . $tbl_session_course . ' as session_course
3169
+                    FROM ' . $tbl_session_course.' as session_course
3170 3170
                     INNER JOIN '.$tbl_course.' c
3171 3171
                     ON (c.id = session_course.c_id)
3172
-                    INNER JOIN ' . $tbl_session . ' as session
3172
+                    INNER JOIN ' . $tbl_session.' as session
3173 3173
                     ON session.id = session_course.session_id
3174
-                        AND session.id_coach = ' . $coach_id . '
3175
-                    INNER JOIN ' . $tbl_course . ' as course
3174
+                        AND session.id_coach = ' . $coach_id.'
3175
+                    INNER JOIN ' . $tbl_course.' as course
3176 3176
                         ON course.id = session_course.c_id
3177 3177
                      INNER JOIN '.$tbl_course_rel_access_url.' course_rel_url
3178 3178
                     ON (course_rel_url.c_id = c.id)';
@@ -3180,12 +3180,12 @@  discard block
 block discarded – undo
3180 3180
         }
3181 3181
 
3182 3182
         if (!empty ($id_session)) {
3183
-            $sql .= ' WHERE session_course.session_id=' . $id_session;
3183
+            $sql .= ' WHERE session_course.session_id='.$id_session;
3184 3184
             if (api_is_multiple_url_enabled())
3185
-            $sql .=  ' AND access_url_id = '.$access_url_id;
3186
-        }  else {
3185
+            $sql .= ' AND access_url_id = '.$access_url_id;
3186
+        } else {
3187 3187
             if (api_is_multiple_url_enabled())
3188
-            $sql .=  ' WHERE access_url_id = '.$access_url_id;
3188
+            $sql .= ' WHERE access_url_id = '.$access_url_id;
3189 3189
         }
3190 3190
 
3191 3191
         $result = Database::query($sql);
@@ -3241,7 +3241,7 @@  discard block
 block discarded – undo
3241 3241
             }
3242 3242
         }
3243 3243
 
3244
-        $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3244
+        $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3245 3245
         $access_url_id = api_get_current_access_url_id();
3246 3246
 
3247 3247
         $sql = "
@@ -3365,7 +3365,7 @@  discard block
 block discarded – undo
3365 3365
             // table definition
3366 3366
             $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
3367 3367
             $tbl_document = Database :: get_course_table(TABLE_DOCUMENT);
3368
-            $course_id	 = $a_course['real_id'];
3368
+            $course_id = $a_course['real_id'];
3369 3369
             if (is_array($student_id)) {
3370 3370
                 $studentList = array_map('intval', $student_id);
3371 3371
                 $condition_user = " AND ip.insert_user_id IN ('".implode(',', $studentList)."') ";
@@ -3418,7 +3418,7 @@  discard block
 block discarded – undo
3418 3418
         $a_course = CourseManager::get_course_information($course_code);
3419 3419
         if (!empty($a_course)) {
3420 3420
             $course_id = $a_course['real_id'];
3421
-            $conditions[]= " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3421
+            $conditions[] = " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3422 3422
         }
3423 3423
 
3424 3424
         // table definition
@@ -3427,14 +3427,14 @@  discard block
 block discarded – undo
3427 3427
 
3428 3428
         if (is_array($student_id)) {
3429 3429
             $studentList = array_map('intval', $student_id);
3430
-            $conditions[]= " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3430
+            $conditions[] = " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3431 3431
         } else {
3432 3432
             $student_id = intval($student_id);
3433
-            $conditions[]= " ip.insert_user_id = '$student_id' ";
3433
+            $conditions[] = " ip.insert_user_id = '$student_id' ";
3434 3434
         }
3435 3435
         if (isset($session_id)) {
3436 3436
             $session_id = intval($session_id);
3437
-            $conditions[]= " pub.session_id = $session_id ";
3437
+            $conditions[] = " pub.session_id = $session_id ";
3438 3438
         }
3439 3439
         $conditionToString = implode('AND', $conditions);
3440 3440
 
@@ -3471,10 +3471,10 @@  discard block
 block discarded – undo
3471 3471
         $conditions = array();
3472 3472
         if (is_array($student_id)) {
3473 3473
             $studentList = array_map('intval', $student_id);
3474
-            $conditions[]= " post.poster_id IN ('".implode("','", $studentList)."') ";
3474
+            $conditions[] = " post.poster_id IN ('".implode("','", $studentList)."') ";
3475 3475
         } else {
3476 3476
             $student_id = intval($student_id);
3477
-            $conditions[]= " post.poster_id = '$student_id' ";
3477
+            $conditions[] = " post.poster_id = '$student_id' ";
3478 3478
         }
3479 3479
 
3480 3480
         $conditionsToString = implode('AND ', $conditions);
@@ -3499,13 +3499,13 @@  discard block
 block discarded – undo
3499 3499
         if (!empty($courseInfo)) {
3500 3500
             $forums = get_forums('', $courseCode, true, $session_id);
3501 3501
             $course_id = $courseInfo['real_id'];
3502
-            $conditions[]= " post.c_id  = $course_id ";
3502
+            $conditions[] = " post.c_id  = $course_id ";
3503 3503
         }
3504 3504
 
3505 3505
         if (!empty($forums)) {
3506 3506
             $idList = array_column($forums, 'forum_id');
3507 3507
             $idListToString = implode("', '", $idList);
3508
-            $conditions[]= " post.forum_id  IN ('$idListToString')";
3508
+            $conditions[] = " post.forum_id  IN ('$idListToString')";
3509 3509
         }
3510 3510
 
3511 3511
         $conditionsToString = implode('AND ', $conditions);
@@ -3540,7 +3540,7 @@  discard block
 block discarded – undo
3540 3540
             $condition_session = '';
3541 3541
             if (isset($session_id)) {
3542 3542
                 $session_id = intval($session_id);
3543
-                $condition_session = api_get_session_condition($session_id, true,  false, 'f.session_id');
3543
+                $condition_session = api_get_session_condition($session_id, true, false, 'f.session_id');
3544 3544
             }
3545 3545
 
3546 3546
             $course_id = $courseInfo['real_id'];
@@ -3596,7 +3596,7 @@  discard block
 block discarded – undo
3596 3596
         $condition_session = '';
3597 3597
         if (isset($session_id)) {
3598 3598
             $session_id = intval($session_id);
3599
-            $condition_session = ' AND f.session_id = '. $session_id;
3599
+            $condition_session = ' AND f.session_id = '.$session_id;
3600 3600
         }
3601 3601
 
3602 3602
         $groupId = intval($groupId);
@@ -3657,7 +3657,7 @@  discard block
 block discarded – undo
3657 3657
         $condition_session = '';
3658 3658
         if (isset($session_id)) {
3659 3659
              $session_id = intval($session_id);
3660
-             $condition_session = ' AND f.session_id = '. $session_id;
3660
+             $condition_session = ' AND f.session_id = '.$session_id;
3661 3661
         }
3662 3662
 
3663 3663
         $groupId = intval($groupId);
@@ -3736,7 +3736,7 @@  discard block
 block discarded – undo
3736 3736
     {
3737 3737
         $student_id = intval($student_id);
3738 3738
         $courseId = intval($courseId);
3739
-        $session_id    = intval($session_id);
3739
+        $session_id = intval($session_id);
3740 3740
         $date_time  = '';
3741 3741
 
3742 3742
         // table definition
@@ -3805,7 +3805,7 @@  discard block
 block discarded – undo
3805 3805
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
3806 3806
 
3807 3807
         $sql = 'SELECT 1
3808
-                FROM ' . $table . '
3808
+                FROM ' . $table.'
3809 3809
                 WHERE down_user_id = '.$student_id.'
3810 3810
                 AND c_id  = "'.$courseId.'"
3811 3811
                 AND down_session_id = '.$session_id.' ';
@@ -3883,30 +3883,30 @@  discard block
 block discarded – undo
3883 3883
                 '.$inner.'
3884 3884
                 WHERE c.id = '.$courseId.'
3885 3885
                 GROUP BY stats_login.user_id
3886
-                HAVING DATE_SUB( "' . $now . '", INTERVAL '.$since.' DAY) > max_date ';
3886
+                HAVING DATE_SUB( "' . $now.'", INTERVAL '.$since.' DAY) > max_date ';
3887 3887
 
3888 3888
         if ($since == 'never') {
3889 3889
             if (empty($session_id)) {
3890 3890
                 $sql = 'SELECT course_user.user_id
3891
-                        FROM ' . $table_course_rel_user . ' course_user
3892
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3891
+                        FROM ' . $table_course_rel_user.' course_user
3892
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3893 3893
                         ON course_user.user_id = stats_login.user_id AND
3894
-                        relation_type<>' . COURSE_RELATION_TYPE_RRHH . '
3895
-                        INNER JOIN ' . $tableCourse . ' c
3894
+                        relation_type<>' . COURSE_RELATION_TYPE_RRHH.'
3895
+                        INNER JOIN ' . $tableCourse.' c
3896 3896
                         ON (c.id = course_user.c_id)
3897 3897
                         WHERE
3898
-                            course_user.c_id = ' . $courseId . ' AND
3898
+                            course_user.c_id = ' . $courseId.' AND
3899 3899
                             stats_login.login_course_date IS NULL
3900 3900
                         GROUP BY course_user.user_id';
3901 3901
             } else {
3902 3902
                 $sql = 'SELECT session_course_user.user_id
3903 3903
                         FROM '.$tbl_session_course_user.' session_course_user
3904
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3904
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3905 3905
                         ON session_course_user.user_id = stats_login.user_id
3906
-                        INNER JOIN ' . $tableCourse . ' c
3906
+                        INNER JOIN ' . $tableCourse.' c
3907 3907
                         ON (c.id = session_course_user.c_id)
3908 3908
                         WHERE
3909
-                            session_course_user.c_id = ' . $courseId . ' AND
3909
+                            session_course_user.c_id = ' . $courseId.' AND
3910 3910
                             stats_login.login_course_date IS NULL
3911 3911
                         GROUP BY session_course_user.user_id';
3912 3912
             }
@@ -3914,7 +3914,7 @@  discard block
 block discarded – undo
3914 3914
 
3915 3915
         $rs = Database::query($sql);
3916 3916
         $inactive_users = array();
3917
-        while($user = Database::fetch_array($rs)) {
3917
+        while ($user = Database::fetch_array($rs)) {
3918 3918
             $inactive_users[] = $user['user_id'];
3919 3919
         }
3920 3920
 
@@ -3936,10 +3936,10 @@  discard block
 block discarded – undo
3936 3936
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
3937 3937
 
3938 3938
         $sql = 'SELECT '.$student_id.'
3939
-                FROM ' . $table . '
3939
+                FROM ' . $table.'
3940 3940
                 WHERE
3941
-                    access_user_id=' . $student_id . ' AND
3942
-                    c_id="' . $courseId . '" AND
3941
+                    access_user_id=' . $student_id.' AND
3942
+                    c_id="' . $courseId.'" AND
3943 3943
                     access_session_id = "'.$session_id.'" ';
3944 3944
 
3945 3945
         $rs = Database::query($sql);
@@ -3957,13 +3957,13 @@  discard block
 block discarded – undo
3957 3957
     {
3958 3958
         $hr_dept_id = intval($hr_dept_id);
3959 3959
         $a_students = array();
3960
-        $tbl_user     = Database :: get_main_table(TABLE_MAIN_USER);
3960
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
3961 3961
 
3962 3962
         $sql = 'SELECT DISTINCT user_id FROM '.$tbl_user.' as user
3963 3963
                 WHERE hr_dept_id='.$hr_dept_id;
3964 3964
         $rs = Database::query($sql);
3965 3965
 
3966
-        while($user = Database :: fetch_array($rs)) {
3966
+        while ($user = Database :: fetch_array($rs)) {
3967 3967
             $a_students[$user['user_id']] = $user['user_id'];
3968 3968
         }
3969 3969
 
@@ -3988,7 +3988,7 @@  discard block
 block discarded – undo
3988 3988
         $condition_session     = '';
3989 3989
         if (isset($session_id)) {
3990 3990
             $session_id = intval($session_id);
3991
-            $condition_session = ' AND access_session_id = '. $session_id;
3991
+            $condition_session = ' AND access_session_id = '.$session_id;
3992 3992
         }
3993 3993
         $sql = "SELECT
3994 3994
                     access_tool,
@@ -4100,7 +4100,7 @@  discard block
 block discarded – undo
4100 4100
             if (!empty($date_from) && !empty($date_to)) {
4101 4101
                 $fieldStartDate = $fields['start_date'];
4102 4102
                 if (!isset($fields['end_date'])) {
4103
-                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to) ;
4103
+                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to);
4104 4104
                 } else {
4105 4105
                     $fieldEndDate = $fields['end_date'];
4106 4106
                     $where .= sprintf(" AND fieldStartDate >= '%s'
@@ -4116,12 +4116,12 @@  discard block
 block discarded – undo
4116 4116
                 $where
4117 4117
                 GROUP BY %s";
4118 4118
             $sql = sprintf($sql,
4119
-                $fields['user'],    //user field
4120
-                $tableName,         //FROM
4121
-                $fields['course'],  //course condition
4122
-                $course['real_id'],    //course condition
4123
-                $fields['user'],    //user condition
4124
-                $userId,            //user condition
4119
+                $fields['user'], //user field
4120
+                $tableName, //FROM
4121
+                $fields['course'], //course condition
4122
+                $course['real_id'], //course condition
4123
+                $fields['user'], //user condition
4124
+                $userId, //user condition
4125 4125
                 $fields['user']     //GROUP BY
4126 4126
                 );
4127 4127
             $rs = Database::query($sql);
@@ -4129,7 +4129,7 @@  discard block
 block discarded – undo
4129 4129
             //iterate query
4130 4130
             if (Database::num_rows($rs) > 0) {
4131 4131
                 while ($row = Database::fetch_array($rs)) {
4132
-                    $data[$row['user']] = (isset($data[$row['user']])) ?  $data[$row['user']] + $row[total]: $row['total'];
4132
+                    $data[$row['user']] = (isset($data[$row['user']])) ? $data[$row['user']] + $row[total] : $row['total'];
4133 4133
                 }
4134 4134
             }
4135 4135
         }
@@ -4152,11 +4152,11 @@  discard block
 block discarded – undo
4152 4152
         $courseId = api_get_course_int_id($course_code);
4153 4153
         $data = array();
4154 4154
 
4155
-        $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4155
+        $TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4156 4156
         $condition_session = '';
4157 4157
         if (isset($session_id)) {
4158 4158
             $session_id = intval($session_id);
4159
-            $condition_session = ' AND down_session_id = '. $session_id;
4159
+            $condition_session = ' AND down_session_id = '.$session_id;
4160 4160
         }
4161 4161
         $sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
4162 4162
                 FROM $TABLETRACK_DOWNLOADS
@@ -4341,7 +4341,7 @@  discard block
 block discarded – undo
4341 4341
 
4342 4342
             $final_course_data = array();
4343 4343
 
4344
-            foreach($my_course_data as $course_id => $value) {
4344
+            foreach ($my_course_data as $course_id => $value) {
4345 4345
                 $final_course_data[$course_id] = $course_list[$course_id];
4346 4346
             }
4347 4347
             $course_in_session[$my_session_id]['course_list'] = $final_course_data;
@@ -4364,7 +4364,7 @@  discard block
 block discarded – undo
4364 4364
                           '.Display::tag('th', get_lang('Course'), array('width'=>'300px')).'
4365 4365
                           '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4366 4366
                           '.Display::tag('th', get_lang('Progress'), array('class'=>'head')).'
4367
-                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')),array('class'=>'head')).'
4367
+                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4368 4368
                           '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4369 4369
                           '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4370 4370
                         </tr>';
@@ -4453,7 +4453,7 @@  discard block
 block discarded – undo
4453 4453
             $all_exercise_start_time = array();
4454 4454
 
4455 4455
             foreach ($course_in_session as $my_session_id => $session_data) {
4456
-                $course_list  = $session_data['course_list'];
4456
+                $course_list = $session_data['course_list'];
4457 4457
                 $user_count = count(SessionManager::get_users_by_session($my_session_id));
4458 4458
                 $exercise_graph_name_list = array();
4459 4459
                 //$user_results = array();
@@ -4498,20 +4498,20 @@  discard block
 block discarded – undo
4498 4498
 
4499 4499
                             $score = 0;
4500 4500
                             if (!empty($user_result_data['exe_weighting']) && intval($user_result_data['exe_weighting']) != 0) {
4501
-                                $score = intval($user_result_data['exe_result']/$user_result_data['exe_weighting'] * 100);
4501
+                                $score = intval($user_result_data['exe_result'] / $user_result_data['exe_weighting'] * 100);
4502 4502
                             }
4503 4503
                             $time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time'], 'UTC') : 0;
4504 4504
                             $all_exercise_start_time[] = $time;
4505 4505
                             $my_results[] = $score;
4506
-                            if (count($exercise_list)<=10) {
4506
+                            if (count($exercise_list) <= 10) {
4507 4507
                                 $title = cut($course_data['title'], 30)." \n ".cut($exercise_data['title'], 30);
4508
-                                $exercise_graph_name_list[]= $title;
4508
+                                $exercise_graph_name_list[] = $title;
4509 4509
                                 $all_exercise_graph_name_list[] = $title;
4510 4510
                             } else {
4511 4511
                                 // if there are more than 10 results, space becomes difficult to find, so only show the title of the exercise, not the tool
4512 4512
                                 $title = cut($exercise_data['title'], 30);
4513
-                                $exercise_graph_name_list[]= $title;
4514
-                                $all_exercise_graph_name_list[]= $title;
4513
+                                $exercise_graph_name_list[] = $title;
4514
+                                $all_exercise_graph_name_list[] = $title;
4515 4515
                             }
4516 4516
                         }
4517 4517
                     }
@@ -4544,7 +4544,7 @@  discard block
 block discarded – undo
4544 4544
             }
4545 4545
 
4546 4546
             $html .= Display::page_subheader(
4547
-                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL) . ' ' . get_lang('Sessions')
4547
+                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL).' '.get_lang('Sessions')
4548 4548
             );
4549 4549
 
4550 4550
             $html .= '<div class="table-responsive">';
@@ -4598,7 +4598,7 @@  discard block
 block discarded – undo
4598 4598
                                 $courseInfo['real_id'],
4599 4599
                                 $my_session_id
4600 4600
                             );
4601
-                            if ($attempts > 1)  {
4601
+                            if ($attempts > 1) {
4602 4602
                                 $answered_exercises++;
4603 4603
                             }
4604 4604
                         }
@@ -4611,7 +4611,7 @@  discard block
 block discarded – undo
4611 4611
                     $all_average += $average;
4612 4612
                 }
4613 4613
 
4614
-                $all_average = $all_average /  count($course_list);
4614
+                $all_average = $all_average / count($course_list);
4615 4615
 
4616 4616
                 if (isset($_GET['session_id']) && $my_session_id == $_GET['session_id']) {
4617 4617
                     $html .= '<tr style="background-color:#FBF09D">';
@@ -4637,16 +4637,16 @@  discard block
 block discarded – undo
4637 4637
             }
4638 4638
             $html .= '</tbody>';
4639 4639
             $html .= '</table></div><br />';
4640
-            $html .= Display::div($main_session_graph, array('id'=>'session_graph','class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
4640
+            $html .= Display::div($main_session_graph, array('id'=>'session_graph', 'class'=>'chart-session', 'style'=>'position:relative; text-align: center;'));
4641 4641
 
4642 4642
             // Checking selected session.
4643 4643
 
4644 4644
             if (isset($_GET['session_id'])) {
4645 4645
                 $session_id_from_get = intval($_GET['session_id']);
4646
-                $session_data 	= $course_in_session[$session_id_from_get];
4647
-                $course_list 	= $session_data['course_list'];
4646
+                $session_data = $course_in_session[$session_id_from_get];
4647
+                $course_list = $session_data['course_list'];
4648 4648
 
4649
-                $html .= Display::tag('h3',$session_data['name'].' - '.get_lang('CourseList'));
4649
+                $html .= Display::tag('h3', $session_data['name'].' - '.get_lang('CourseList'));
4650 4650
 
4651 4651
                 $html .= '<div class="table-responsive">';
4652 4652
                 $html .= '<table class="table table-hover table-striped">';
@@ -4655,15 +4655,15 @@  discard block
 block discarded – undo
4655 4655
                     <thead>
4656 4656
                     <tr>
4657 4657
                       <th width="300px">'.get_lang('Course').'</th>
4658
-                      '.Display::tag('th', get_lang('PublishedExercises'),    	array('class'=>'head')).'
4659
-                      '.Display::tag('th', get_lang('NewExercises'),    		array('class'=>'head')).'
4660
-                      '.Display::tag('th', get_lang('MyAverage'), 				array('class'=>'head')).'
4661
-                      '.Display::tag('th', get_lang('AverageExerciseResult'), 	array('class'=>'head')).'
4662
-                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'),    array('class'=>'head')).'
4663
-                      '.Display::tag('th', get_lang('LPProgress')     ,      	array('class'=>'head')).'
4664
-                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4665
-                      '.Display::tag('th', get_lang('LastConnexion'),         	array('class'=>'head')).'
4666
-                      '.Display::tag('th', get_lang('Details'),               	array('class'=>'head')).'
4658
+                      '.Display::tag('th', get_lang('PublishedExercises'), array('class'=>'head')).'
4659
+                      '.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
4660
+                      '.Display::tag('th', get_lang('MyAverage'), array('class'=>'head')).'
4661
+                      '.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
4662
+                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4663
+                      '.Display::tag('th', get_lang('LPProgress'), array('class'=>'head')).'
4664
+                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4665
+                      '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4666
+                      '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4667 4667
                     </tr>
4668 4668
                     </thead>
4669 4669
                     <tbody>
@@ -4682,14 +4682,14 @@  discard block
 block discarded – undo
4682 4682
                         $count_exercises = count($exercises);
4683 4683
                     }
4684 4684
                     $answered_exercises = 0;
4685
-                    foreach($exercises as $exercise_item) {
4685
+                    foreach ($exercises as $exercise_item) {
4686 4686
                         $attempts = Event::count_exercise_attempts_by_user(
4687 4687
                             api_get_user_id(),
4688 4688
                             $exercise_item['id'],
4689 4689
                             $courseId,
4690 4690
                             $session_id_from_get
4691 4691
                         );
4692
-                        if ($attempts > 1)  {
4692
+                        if ($attempts > 1) {
4693 4693
                             $answered_exercises++;
4694 4694
                         }
4695 4695
                     }
@@ -4698,7 +4698,7 @@  discard block
 block discarded – undo
4698 4698
 
4699 4699
                     // Average
4700 4700
                     $average = ExerciseLib::get_average_score_by_course($courseId, $session_id_from_get);
4701
-                    $my_average	= ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4701
+                    $my_average = ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4702 4702
 
4703 4703
                     $stats_array[$course_code] = array(
4704 4704
                         'exercises' => $count_exercises,
@@ -4775,7 +4775,7 @@  discard block
 block discarded – undo
4775 4775
 
4776 4776
                     if ($course_code == $courseCodeFromGet && $_GET['session_id'] == $session_id_from_get) {
4777 4777
                         $details = '<a href="#">';
4778
-                        $details .=Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4778
+                        $details .= Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4779 4779
                     } else {
4780 4780
                         $details = '<a href="'.api_get_self().'?course='.$course_code.'&session_id='.$session_id_from_get.$extra_params.'">';
4781 4781
                         $details .= Display::return_icon('2rightarrow.png', get_lang('Details'));
@@ -4875,7 +4875,7 @@  discard block
 block discarded – undo
4875 4875
                     );
4876 4876
 
4877 4877
                     $html .= '<tr class="row_even">';
4878
-                    $url = api_get_path(WEB_CODE_PATH) . "exercise/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
4878
+                    $url = api_get_path(WEB_CODE_PATH)."exercise/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
4879 4879
 
4880 4880
                     if ($visible_return['value'] == true) {
4881 4881
                         $exercices['title'] = Display::url(
@@ -4904,7 +4904,7 @@  discard block
 block discarded – undo
4904 4904
                         );
4905 4905
 
4906 4906
                         $latest_attempt_url = '';
4907
-                        $best_score = $position = $percentage_score_result  = '-';
4907
+                        $best_score = $position = $percentage_score_result = '-';
4908 4908
                         $graph = $normal_graph = null;
4909 4909
 
4910 4910
                         // Getting best results
@@ -4936,11 +4936,11 @@  discard block
 block discarded – undo
4936 4936
                                 $weighting      = $exercise_stat['exe_weighting'];
4937 4937
                                 $exe_id         = $exercise_stat['exe_id'];
4938 4938
 
4939
-                                $latest_attempt_url .= api_get_path(WEB_CODE_PATH) . 'exercise/result.php?id='.$exe_id.'&cidReq='.$course_info['code'].'&show_headers=1&id_session='.$session_id;
4939
+                                $latest_attempt_url .= api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$exe_id.'&cidReq='.$course_info['code'].'&show_headers=1&id_session='.$session_id;
4940 4940
                                 $percentage_score_result = Display::url(ExerciseLib::show_score($score, $weighting), $latest_attempt_url);
4941 4941
                                 $my_score = 0;
4942 4942
                                 if (!empty($weighting) && intval($weighting) != 0) {
4943
-                                    $my_score = $score/$weighting;
4943
+                                    $my_score = $score / $weighting;
4944 4944
                                 }
4945 4945
                                 //@todo this function slows the page
4946 4946
                                 if (is_int($user_list)) {
@@ -4954,14 +4954,14 @@  discard block
 block discarded – undo
4954 4954
                         }
4955 4955
                         $html .= Display::div(
4956 4956
                             $normal_graph,
4957
-                            array('id'=>'main_graph_'.$exercices['id'],'class'=>'dialog', 'style'=>'display:none')
4957
+                            array('id'=>'main_graph_'.$exercices['id'], 'class'=>'dialog', 'style'=>'display:none')
4958 4958
                         );
4959 4959
 
4960 4960
                         if (empty($graph)) {
4961 4961
                             $graph = '-';
4962 4962
                         } else {
4963 4963
                             $graph = Display::url(
4964
-                                '<img src="' . $graph . '" >',
4964
+                                '<img src="'.$graph.'" >',
4965 4965
                                 $normal_graph,
4966 4966
                                 array(
4967 4967
                                     'id' => $exercices['id'],
@@ -4995,7 +4995,7 @@  discard block
 block discarded – undo
4995 4995
 
4996 4996
             // LP table results
4997 4997
             $html .= '<div class="table-responsive">';
4998
-            $html .='<table class="table table-striped table-hover">';
4998
+            $html .= '<table class="table table-striped table-hover">';
4999 4999
             $html .= '<thead><tr>';
5000 5000
             $html .= Display::tag('th', get_lang('Learnpaths'), array('class'=>'head', 'style'=>'color:#000'));
5001 5001
             $html .= Display::tag('th', get_lang('LatencyTimeSpent'), array('class'=>'head', 'style'=>'color:#000'));
@@ -5031,7 +5031,7 @@  discard block
 block discarded – undo
5031 5031
                     $time_spent_in_lp = api_time_to_hms($time_spent_in_lp);
5032 5032
 
5033 5033
                     $html .= '<tr class="row_even">';
5034
-                    $url = api_get_path(WEB_CODE_PATH) . "lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
5034
+                    $url = api_get_path(WEB_CODE_PATH)."lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
5035 5035
 
5036 5036
                     if ($learnpath['lp_visibility'] == 0) {
5037 5037
                         $html .= Display::tag('td', $learnpath['lp_name']);
@@ -5050,7 +5050,7 @@  discard block
 block discarded – undo
5050 5050
                     if (!empty($last_connection_in_lp)) {
5051 5051
                         $last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
5052 5052
                     }
5053
-                    $html .= Display::tag('td', $last_connection, array('align'=>'center','width'=>'180px'));
5053
+                    $html .= Display::tag('td', $last_connection, array('align'=>'center', 'width'=>'180px'));
5054 5054
                     $html .= "</tr>";
5055 5055
                 }
5056 5056
             } else {
@@ -5060,7 +5060,7 @@  discard block
 block discarded – undo
5060 5060
                         </td>
5061 5061
                       </tr>';
5062 5062
             }
5063
-            $html .='</tbody></table></div>';
5063
+            $html .= '</tbody></table></div>';
5064 5064
 
5065 5065
             $html .= self::displayUserSkills($user_id, $course_info['id'], $session_id);
5066 5066
         }
@@ -5089,7 +5089,7 @@  discard block
 block discarded – undo
5089 5089
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
5090 5090
         $myData->setSerieDescription('Serie2', get_lang('AverageScore'));
5091 5091
         $myData->setAxisUnit(0, '%');
5092
-        $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5092
+        $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5093 5093
         // Cache definition
5094 5094
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5095 5095
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
@@ -5097,9 +5097,9 @@  discard block
 block discarded – undo
5097 5097
 
5098 5098
         if ($myCache->isInCache($chartHash)) {
5099 5099
             //if we already created the img
5100
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5100
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5101 5101
             $myCache->saveFromCache($chartHash, $imgPath);
5102
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5102
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5103 5103
         } else {
5104 5104
             /* Define width, height and angle */
5105 5105
             $mainWidth = 860;
@@ -5128,7 +5128,7 @@  discard block
 block discarded – undo
5128 5128
             /* Set the default font */
5129 5129
             $myPicture->setFontProperties(
5130 5130
                 array(
5131
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5131
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5132 5132
                     'FontSize' => 10)
5133 5133
             );
5134 5134
             /* Write the chart title */
@@ -5145,7 +5145,7 @@  discard block
 block discarded – undo
5145 5145
             /* Set the default font */
5146 5146
             $myPicture->setFontProperties(
5147 5147
                 array(
5148
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5148
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5149 5149
                     'FontSize' => 6
5150 5150
                 )
5151 5151
             );
@@ -5187,7 +5187,7 @@  discard block
 block discarded – undo
5187 5187
             /* Draw the line chart */
5188 5188
             $myPicture->setFontProperties(
5189 5189
                 array(
5190
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5190
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5191 5191
                     'FontSize' => 10
5192 5192
                 )
5193 5193
             );
@@ -5220,12 +5220,12 @@  discard block
 block discarded – undo
5220 5220
             );
5221 5221
 
5222 5222
             $myCache->writeToCache($chartHash, $myPicture);
5223
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5223
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5224 5224
             $myCache->saveFromCache($chartHash, $imgPath);
5225
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5225
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5226 5226
         }
5227 5227
 
5228
-        $html = '<img src="' . $imgPath . '">';
5228
+        $html = '<img src="'.$imgPath.'">';
5229 5229
 
5230 5230
         return $html;
5231 5231
     }
@@ -5246,12 +5246,12 @@  discard block
 block discarded – undo
5246 5246
 
5247 5247
         foreach ($attempts as $attempt) {
5248 5248
             if (api_get_user_id() == $attempt['exe_user_id']) {
5249
-                if ($attempt['exe_weighting'] != 0 ) {
5250
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5249
+                if ($attempt['exe_weighting'] != 0) {
5250
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5251 5251
                 }
5252 5252
             } else {
5253
-                if ($attempt['exe_weighting'] != 0 ) {
5254
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5253
+                if ($attempt['exe_weighting'] != 0) {
5254
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5255 5255
                 }
5256 5256
             }
5257 5257
         }
@@ -5260,27 +5260,27 @@  discard block
 block discarded – undo
5260 5260
         rsort($my_exercise_result_array);
5261 5261
         $my_exercise_result = 0;
5262 5262
         if (isset($my_exercise_result_array[0])) {
5263
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5263
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5264 5264
         }
5265 5265
 
5266 5266
         $max     = 100;
5267
-        $pieces  = 5 ;
5267
+        $pieces  = 5;
5268 5268
         $part    = round($max / $pieces);
5269 5269
         $x_axis = array();
5270 5270
         $final_array = array();
5271 5271
         $my_final_array = array();
5272 5272
 
5273
-        for ($i=1; $i <=$pieces; $i++) {
5273
+        for ($i = 1; $i <= $pieces; $i++) {
5274 5274
             $sum = 1;
5275 5275
             if ($i == 1) {
5276 5276
                 $sum = 0;
5277 5277
             }
5278
-            $min = ($i-1)*$part + $sum;
5279
-            $max = ($i)*$part;
5280
-            $x_axis[]= $min." - ".$max;
5278
+            $min = ($i - 1) * $part + $sum;
5279
+            $max = ($i) * $part;
5280
+            $x_axis[] = $min." - ".$max;
5281 5281
             $count = 0;
5282
-            foreach($exercise_result as $result) {
5283
-                $percentage = $result*100;
5282
+            foreach ($exercise_result as $result) {
5283
+                $percentage = $result * 100;
5284 5284
                 //echo $percentage.' - '.$min.' - '.$max."<br />";
5285 5285
                 if ($percentage >= $min && $percentage <= $max) {
5286 5286
                     //echo ' is > ';
@@ -5288,7 +5288,7 @@  discard block
 block discarded – undo
5288 5288
                 }
5289 5289
             }
5290 5290
             //echo '<br />';
5291
-            $final_array[]= $count;
5291
+            $final_array[] = $count;
5292 5292
 
5293 5293
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5294 5294
                 $my_final_array[] = 1;
@@ -5298,9 +5298,9 @@  discard block
 block discarded – undo
5298 5298
         }
5299 5299
 
5300 5300
         //Fix to remove the data of the user with my data
5301
-        for($i = 0; $i<=count($my_final_array); $i++) {
5301
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5302 5302
             if (!empty($my_final_array[$i])) {
5303
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5303
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5304 5304
                 $final_array[$i] = 0;
5305 5305
             }
5306 5306
         }
@@ -5310,16 +5310,16 @@  discard block
 block discarded – undo
5310 5310
         $dataSet->addPoints($final_array, 'Serie1');
5311 5311
         $dataSet->addPoints($my_final_array, 'Serie2');
5312 5312
         $dataSet->normalize(100, "%");
5313
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5313
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5314 5314
 
5315 5315
         // Cache definition
5316 5316
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5317 5317
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
5318 5318
         $chartHash = $myCache->getHash($dataSet);
5319 5319
         if ($myCache->isInCache($chartHash)) {
5320
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5320
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5321 5321
             $myCache->saveFromCache($chartHash, $imgPath);
5322
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5322
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5323 5323
         } else {
5324 5324
             /* Create the pChart object */
5325 5325
             $widthSize = 80;
@@ -5335,7 +5335,7 @@  discard block
 block discarded – undo
5335 5335
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5336 5336
 
5337 5337
             /* Set the default font */
5338
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5338
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5339 5339
 
5340 5340
             /* Do not write the chart title */
5341 5341
 
@@ -5399,9 +5399,9 @@  discard block
 block discarded – undo
5399 5399
 
5400 5400
             /* Save and write in cache */
5401 5401
             $myCache->writeToCache($chartHash, $myPicture);
5402
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5402
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5403 5403
             $myCache->saveFromCache($chartHash, $imgPath);
5404
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5404
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5405 5405
         }
5406 5406
 
5407 5407
         return $imgPath;
@@ -5421,12 +5421,12 @@  discard block
 block discarded – undo
5421 5421
         }
5422 5422
         foreach ($attempts as $attempt) {
5423 5423
             if (api_get_user_id() == $attempt['exe_user_id']) {
5424
-                if ($attempt['exe_weighting'] != 0 ) {
5425
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5424
+                if ($attempt['exe_weighting'] != 0) {
5425
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5426 5426
                 }
5427 5427
             } else {
5428
-                if ($attempt['exe_weighting'] != 0 ) {
5429
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5428
+                if ($attempt['exe_weighting'] != 0) {
5429
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5430 5430
                 }
5431 5431
             }
5432 5432
         }
@@ -5435,32 +5435,32 @@  discard block
 block discarded – undo
5435 5435
         rsort($my_exercise_result_array);
5436 5436
         $my_exercise_result = 0;
5437 5437
         if (isset($my_exercise_result_array[0])) {
5438
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5438
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5439 5439
         }
5440 5440
 
5441 5441
         $max = 100;
5442
-        $pieces = 5 ;
5442
+        $pieces = 5;
5443 5443
         $part = round($max / $pieces);
5444 5444
         $x_axis = array();
5445 5445
         $final_array = array();
5446 5446
         $my_final_array = array();
5447 5447
 
5448
-        for ($i=1; $i <=$pieces; $i++) {
5448
+        for ($i = 1; $i <= $pieces; $i++) {
5449 5449
             $sum = 1;
5450 5450
             if ($i == 1) {
5451 5451
                 $sum = 0;
5452 5452
             }
5453
-            $min = ($i-1)*$part + $sum;
5454
-            $max = ($i)*$part;
5455
-            $x_axis[]= $min." - ".$max;
5453
+            $min = ($i - 1) * $part + $sum;
5454
+            $max = ($i) * $part;
5455
+            $x_axis[] = $min." - ".$max;
5456 5456
             $count = 0;
5457
-            foreach($exercise_result as $result) {
5458
-                $percentage = $result*100;
5457
+            foreach ($exercise_result as $result) {
5458
+                $percentage = $result * 100;
5459 5459
                 if ($percentage >= $min && $percentage <= $max) {
5460 5460
                     $count++;
5461 5461
                 }
5462 5462
             }
5463
-            $final_array[]= $count;
5463
+            $final_array[] = $count;
5464 5464
 
5465 5465
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5466 5466
                 $my_final_array[] = 1;
@@ -5471,9 +5471,9 @@  discard block
 block discarded – undo
5471 5471
 
5472 5472
         //Fix to remove the data of the user with my data
5473 5473
 
5474
-        for($i = 0; $i<=count($my_final_array); $i++) {
5474
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5475 5475
             if (!empty($my_final_array[$i])) {
5476
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5476
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5477 5477
                 $final_array[$i] = 0;
5478 5478
             }
5479 5479
         }
@@ -5491,7 +5491,7 @@  discard block
 block discarded – undo
5491 5491
         $dataSet->setXAxisName(get_lang('Score'));
5492 5492
         $dataSet->normalize(100, "%");
5493 5493
 
5494
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5494
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5495 5495
 
5496 5496
         // Cache definition
5497 5497
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -5499,9 +5499,9 @@  discard block
 block discarded – undo
5499 5499
         $chartHash = $myCache->getHash($dataSet);
5500 5500
 
5501 5501
         if ($myCache->isInCache($chartHash)) {
5502
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5502
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5503 5503
             $myCache->saveFromCache($chartHash, $imgPath);
5504
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5504
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5505 5505
         } else {
5506 5506
             /* Create the pChart object */
5507 5507
             $widthSize = 480;
@@ -5517,7 +5517,7 @@  discard block
 block discarded – undo
5517 5517
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5518 5518
 
5519 5519
             /* Set the default font */
5520
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5520
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5521 5521
 
5522 5522
             /* Write the chart title */
5523 5523
             $myPicture->drawText(
@@ -5576,9 +5576,9 @@  discard block
 block discarded – undo
5576 5576
 
5577 5577
             /* Write and save into cache */
5578 5578
             $myCache->writeToCache($chartHash, $myPicture);
5579
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5579
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5580 5580
             $myCache->saveFromCache($chartHash, $imgPath);
5581
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5581
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5582 5582
         }
5583 5583
 
5584 5584
         return $imgPath;
@@ -5705,7 +5705,7 @@  discard block
 block discarded – undo
5705 5705
                         $whereSessionParams .= $sessionIdx.',';
5706 5706
                     }
5707 5707
                 }
5708
-                $whereSessionParams = substr($whereSessionParams,0,-1);
5708
+                $whereSessionParams = substr($whereSessionParams, 0, -1);
5709 5709
             }
5710 5710
 
5711 5711
             if (!empty($exerciseId)) {
@@ -5766,7 +5766,7 @@  discard block
 block discarded – undo
5766 5766
                     qq.position = rq.question_order AND
5767 5767
                     ta.question_id = rq.question_id
5768 5768
                 WHERE
5769
-                    te.c_id = $courseIdx ".(empty($whereSessionParams)?'':"AND te.session_id IN ($whereSessionParams)")."
5769
+                    te.c_id = $courseIdx ".(empty($whereSessionParams) ? '' : "AND te.session_id IN ($whereSessionParams)")."
5770 5770
                     AND q.c_id = $courseIdx
5771 5771
                     $where $order $limit";
5772 5772
             $sql_query = vsprintf($sql, $whereParams);
@@ -5814,7 +5814,7 @@  discard block
 block discarded – undo
5814 5814
             // Now fill users data
5815 5815
             $sqlUsers = "SELECT user_id, username, lastname, firstname
5816 5816
                          FROM $tuser
5817
-                         WHERE user_id IN (".implode(',',$userIds).")";
5817
+                         WHERE user_id IN (".implode(',', $userIds).")";
5818 5818
             $resUsers = Database::query($sqlUsers);
5819 5819
             while ($rowUser = Database::fetch_assoc($resUsers)) {
5820 5820
                 $users[$rowUser['user_id']] = $rowUser;
@@ -5918,7 +5918,7 @@  discard block
 block discarded – undo
5918 5918
                 <table class="table" id="skillList">
5919 5919
                     <thead>
5920 5920
                         <tr>
5921
-                            <th>' . get_lang('AchievedSkills') . '</th>
5921
+                            <th>' . get_lang('AchievedSkills').'</th>
5922 5922
                         </tr>
5923 5923
                     </thead>
5924 5924
                     <tbody>
@@ -5937,10 +5937,10 @@  discard block
 block discarded – undo
5937 5937
 
5938 5938
                 $html .= '
5939 5939
                                             <li class="thumbnail">
5940
-                                                <a href="' . api_get_path(WEB_PATH) . 'badge/' . $userSkill->getId() . '/user/' . $userId . '" target="_blank">
5941
-                                                    <img class="img-responsive" title="' . $skill->getName() . '" src="' . $skill->getWebIconPath() . '" width="64" height="64">
5940
+                                                <a href="' . api_get_path(WEB_PATH).'badge/'.$userSkill->getId().'/user/'.$userId.'" target="_blank">
5941
+                                                    <img class="img-responsive" title="' . $skill->getName().'" src="'.$skill->getWebIconPath().'" width="64" height="64">
5942 5942
                                                     <div class="caption">
5943
-                                                        <p class="text-center">' . $skill->getName() . '</p>
5943
+                                                        <p class="text-center">' . $skill->getName().'</p>
5944 5944
                                                     </div>
5945 5945
                                                 </a>
5946 5946
                                             </li>
@@ -5990,7 +5990,7 @@  discard block
 block discarded – undo
5990 5990
     	        WHERE
5991 5991
                     track_resource.c_id = $course_id AND
5992 5992
                     track_resource.insert_user_id = user.user_id AND
5993
-                    session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5993
+                    session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5994 5994
 
5995 5995
     	if (isset($_GET['keyword'])) {
5996 5996
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6048,7 +6048,7 @@  discard block
 block discarded – undo
6048 6048
                 WHERE
6049 6049
                   track_resource.c_id = $course_id AND
6050 6050
                   track_resource.insert_user_id = user.user_id AND
6051
-                  session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6051
+                  session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6052 6052
 
6053 6053
     	if (isset($_GET['keyword'])) {
6054 6054
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6348,7 +6348,7 @@  discard block
 block discarded – undo
6348 6348
     public static function display_additional_profile_fields()
6349 6349
     {
6350 6350
     	// getting all the extra profile fields that are defined by the platform administrator
6351
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6351
+    	$extra_fields = UserManager :: get_extra_fields(0, 50, 5, 'ASC');
6352 6352
 
6353 6353
     	// creating the form
6354 6354
     	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
@@ -6360,8 +6360,8 @@  discard block
 block discarded – undo
6360 6360
     	$extra_fields_to_show = 0;
6361 6361
     	foreach ($extra_fields as $key=>$field) {
6362 6362
     		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6363
-    		if ($field[6]==1 && $field[8] == 1) {
6364
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6363
+    		if ($field[6] == 1 && $field[8] == 1) {
6364
+    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field']) {
6365 6365
     				$selected = 'selected="selected"';
6366 6366
     			} else {
6367 6367
     				$selected = '';
@@ -6373,8 +6373,8 @@  discard block
 block discarded – undo
6373 6373
     	$return .= '</select>';
6374 6374
 
6375 6375
     	// the form elements for the $_GET parameters (because the form is passed through GET
6376
-    	foreach ($_GET as $key=>$value){
6377
-    		if ($key <> 'additional_profile_field')    {
6376
+    	foreach ($_GET as $key=>$value) {
6377
+    		if ($key <> 'additional_profile_field') {
6378 6378
     			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6379 6379
     		}
6380 6380
     	}
@@ -6411,21 +6411,21 @@  discard block
 block discarded – undo
6411 6411
     	$result_extra_field = UserManager::get_extra_field_information($field_id);
6412 6412
 
6413 6413
     	if (!empty($users)) {
6414
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6415
-    			foreach($users as $user_id) {
6414
+    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG) {
6415
+    			foreach ($users as $user_id) {
6416 6416
     				$user_result = UserManager::get_user_tags($user_id, $field_id);
6417 6417
     				$tag_list = array();
6418
-    				foreach($user_result as $item) {
6418
+    				foreach ($user_result as $item) {
6419 6419
     					$tag_list[] = $item['tag'];
6420 6420
     				}
6421
-    				$return[$user_id][] = implode(', ',$tag_list);
6421
+    				$return[$user_id][] = implode(', ', $tag_list);
6422 6422
     			}
6423 6423
     		} else {
6424 6424
     			$new_user_array = array();
6425 6425
     			foreach ($users as $user_id) {
6426
-    				$new_user_array[]= "'".$user_id."'";
6426
+    				$new_user_array[] = "'".$user_id."'";
6427 6427
     			}
6428
-    			$users = implode(',',$new_user_array);
6428
+    			$users = implode(',', $new_user_array);
6429 6429
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6430 6430
     			// Selecting only the necessary information NOT ALL the user list
6431 6431
     			$sql = "SELECT user.user_id, v.value
@@ -6440,7 +6440,7 @@  discard block
 block discarded – undo
6440 6440
                             user.user_id IN ($users)";
6441 6441
 
6442 6442
     			$result = Database::query($sql);
6443
-    			while($row = Database::fetch_array($result)) {
6443
+    			while ($row = Database::fetch_array($result)) {
6444 6444
     				// get option value for field type double select by id
6445 6445
     				if (!empty($row['value'])) {
6446 6446
     					if ($result_extra_field['field_type'] ==
@@ -6479,7 +6479,7 @@  discard block
 block discarded – undo
6479 6479
 
6480 6480
     public function sort_users_desc($a, $b)
6481 6481
     {
6482
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6482
+    	return strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6483 6483
     }
6484 6484
 
6485 6485
     /**
@@ -6514,7 +6514,7 @@  discard block
 block discarded – undo
6514 6514
     	// get all users data from a course for sortable with limit
6515 6515
     	if (is_array($user_ids)) {
6516 6516
     		$user_ids = array_map('intval', $user_ids);
6517
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6517
+    		$condition_user = " WHERE user.user_id IN (".implode(',', $user_ids).") ";
6518 6518
     	} else {
6519 6519
     		$user_ids = intval($user_ids);
6520 6520
     		$condition_user = " WHERE user.user_id = $user_ids ";
@@ -6522,7 +6522,7 @@  discard block
 block discarded – undo
6522 6522
 
6523 6523
     	if (!empty($_GET['user_keyword'])) {
6524 6524
     		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6525
-    		$condition_user .=  " AND (
6525
+    		$condition_user .= " AND (
6526 6526
                 user.firstname LIKE '%".$keyword."%' OR
6527 6527
                 user.lastname LIKE '%".$keyword."%'  OR
6528 6528
                 user.username LIKE '%".$keyword."%'  OR
@@ -6540,7 +6540,7 @@  discard block
 block discarded – undo
6540 6540
         $invitedUsersCondition = '';
6541 6541
 
6542 6542
         if (!$includeInvitedUsers) {
6543
-            $invitedUsersCondition = " AND user.status != " . INVITEE;
6543
+            $invitedUsersCondition = " AND user.status != ".INVITEE;
6544 6544
         }
6545 6545
 
6546 6546
     	$sql = "SELECT  user.user_id as user_id,
@@ -6551,7 +6551,7 @@  discard block
 block discarded – undo
6551 6551
                 FROM $tbl_user as user $url_table
6552 6552
     	        $condition_user $url_condition $invitedUsersCondition";
6553 6553
 
6554
-    	if (!in_array($direction, array('ASC','DESC'))) {
6554
+    	if (!in_array($direction, array('ASC', 'DESC'))) {
6555 6555
     		$direction = 'ASC';
6556 6556
     	}
6557 6557
 
@@ -6687,7 +6687,7 @@  discard block
 block discarded – undo
6687 6687
     		}
6688 6688
 
6689 6689
             if (empty($session_id)) {
6690
-                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6690
+                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0).' / '.$total_surveys;
6691 6691
             }
6692 6692
 
6693 6693
     		$user['link'] = '<center>
@@ -6699,37 +6699,37 @@  discard block
 block discarded – undo
6699 6699
     		// store columns in array $users
6700 6700
     		$is_western_name_order = api_is_western_name_order();
6701 6701
             $user_row = array();
6702
-            $user_row[]= $user['official_code']; //0
6702
+            $user_row[] = $user['official_code']; //0
6703 6703
             if ($is_western_name_order) {
6704
-                $user_row[]= $user['firstname'];
6705
-                $user_row[]= $user['lastname'];
6704
+                $user_row[] = $user['firstname'];
6705
+                $user_row[] = $user['lastname'];
6706 6706
             } else {
6707
-                $user_row[]= $user['lastname'];
6708
-                $user_row[]= $user['firstname'];
6707
+                $user_row[] = $user['lastname'];
6708
+                $user_row[] = $user['firstname'];
6709 6709
             }
6710
-            $user_row[]= $user['username'];
6711
-            $user_row[]= $user['time'];
6712
-            $user_row[]= $user['average_progress'];
6713
-            $user_row[]= $user['exercise_progress'];
6714
-            $user_row[]= $user['exercise_average_best_attempt'];
6715
-            $user_row[]= $user['student_score'];
6716
-            $user_row[]= $user['count_assignments'];
6717
-            $user_row[]= $user['count_messages'];
6710
+            $user_row[] = $user['username'];
6711
+            $user_row[] = $user['time'];
6712
+            $user_row[] = $user['average_progress'];
6713
+            $user_row[] = $user['exercise_progress'];
6714
+            $user_row[] = $user['exercise_average_best_attempt'];
6715
+            $user_row[] = $user['student_score'];
6716
+            $user_row[] = $user['count_assignments'];
6717
+            $user_row[] = $user['count_messages'];
6718 6718
 
6719 6719
             $userGroupManager = new UserGroup();
6720 6720
             $user_row[] = $userGroupManager->getLabelsFromNameList($user['user_id'], UserGroup::NORMAL_CLASS);
6721 6721
 
6722 6722
             if (empty($session_id)) {
6723
-                $user_row[]= $user['survey'];
6723
+                $user_row[] = $user['survey'];
6724 6724
             }
6725 6725
 
6726
-            $user_row[]= $user['first_connection'];
6727
-            $user_row[]= $user['last_connection'];
6726
+            $user_row[] = $user['first_connection'];
6727
+            $user_row[] = $user['last_connection'];
6728 6728
             if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6729
-                $user_row[]= $user['additional'];
6729
+                $user_row[] = $user['additional'];
6730 6730
             }
6731 6731
 
6732
-            $user_row[]= $user['link'];
6732
+            $user_row[] = $user['link'];
6733 6733
 
6734 6734
             $users[] = $user_row;
6735 6735
 
@@ -6774,8 +6774,8 @@  discard block
 block discarded – undo
6774 6774
 
6775 6775
     	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6776 6776
     	$tempView = $view;
6777
-    	if(substr($view,0,1) == '1') {
6778
-    		$new_view = substr_replace($view,'0',0,1);
6777
+    	if (substr($view, 0, 1) == '1') {
6778
+    		$new_view = substr_replace($view, '0', 0, 1);
6779 6779
     		echo "
6780 6780
                 <tr>
6781 6781
                     <td valign='top'>
@@ -6808,9 +6808,9 @@  discard block
 block discarded – undo
6808 6808
                 </tr>";
6809 6809
     		$total = 0;
6810 6810
     		if (is_array($results)) {
6811
-    			for($j = 0 ; $j < count($results) ; $j++) {
6811
+    			for ($j = 0; $j < count($results); $j++) {
6812 6812
     				echo "<tr>";
6813
-    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6813
+    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0]) - 1].' '.date('Y', $results[$j][0])."</a></td>";
6814 6814
     				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6815 6815
     				echo"</tr>";
6816 6816
     				$total = $total + $results[$j][1];
@@ -6827,7 +6827,7 @@  discard block
 block discarded – undo
6827 6827
     		echo "</table>";
6828 6828
     		echo "</td></tr>";
6829 6829
     	} else {
6830
-    		$new_view = substr_replace($view,'1',0,1);
6830
+    		$new_view = substr_replace($view, '1', 0, 1);
6831 6831
     		echo "
6832 6832
                 <tr>
6833 6833
                     <td valign='top'>
@@ -6850,8 +6850,8 @@  discard block
 block discarded – undo
6850 6850
     {
6851 6851
     	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6852 6852
         $courseId = api_get_course_int_id($courseCode);
6853
-    	if(substr($view,1,1) == '1') {
6854
-    		$new_view = substr_replace($view,'0',1,1);
6853
+    	if (substr($view, 1, 1) == '1') {
6854
+    		$new_view = substr_replace($view, '0', 1, 1);
6855 6855
     		echo "<tr>
6856 6856
                     <td valign='top'>
6857 6857
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>]
@@ -6893,7 +6893,7 @@  discard block
 block discarded – undo
6893 6893
                 </tr>";
6894 6894
 
6895 6895
     		if (is_array($results)) {
6896
-    			for($i = 0; $i < sizeof($results); $i++) {
6896
+    			for ($i = 0; $i < sizeof($results); $i++) {
6897 6897
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6898 6898
     				echo "<tr>\n";
6899 6899
     				echo "<td class='content'>".$results[$i][0]."</td>\n";
@@ -6908,8 +6908,8 @@  discard block
 block discarded – undo
6908 6908
 
6909 6909
     		// The Result of Tests
6910 6910
     		if (is_array($hpresults)) {
6911
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6912
-    				$title = GetQuizName($hpresults[$i][0],'');
6911
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
6912
+    				$title = GetQuizName($hpresults[$i][0], '');
6913 6913
     				if ($title == '')
6914 6914
     				$title = basename($hpresults[$i][0]);
6915 6915
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
@@ -6935,7 +6935,7 @@  discard block
 block discarded – undo
6935 6935
     		echo "</table>";
6936 6936
     		echo "</td>\n</tr>\n";
6937 6937
     	} else {
6938
-    		$new_view = substr_replace($view,'1',1,1);
6938
+    		$new_view = substr_replace($view, '1', 1, 1);
6939 6939
     		echo "
6940 6940
                 <tr>
6941 6941
                     <td valign='top'>
@@ -6954,8 +6954,8 @@  discard block
 block discarded – undo
6954 6954
     	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6955 6955
         $_course = api_get_course_info_by_id($course_id);
6956 6956
 
6957
-    	if (substr($view,2,1) == '1') {
6958
-    		$new_view = substr_replace($view,'0',2,1);
6957
+    	if (substr($view, 2, 1) == '1') {
6958
+    		$new_view = substr_replace($view, '0', 2, 1);
6959 6959
     		echo "<tr>
6960 6960
                     <td valign='top'>
6961 6961
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('WorkUploads')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>]
@@ -6969,7 +6969,7 @@  discard block
 block discarded – undo
6969 6969
                         AND u.c_id = '".intval($course_id)."'
6970 6970
                     ORDER BY u.upload_date DESC";
6971 6971
     		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6972
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6972
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6973 6973
     		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6974 6974
     		echo "<tr>
6975 6975
                     <td class='secLine' width='40%'>
@@ -6983,7 +6983,7 @@  discard block
 block discarded – undo
6983 6983
                     </td>
6984 6984
                 </tr>";
6985 6985
     		if (is_array($results)) {
6986
-    			for($j = 0 ; $j < count($results) ; $j++) {
6986
+    			for ($j = 0; $j < count($results); $j++) {
6987 6987
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6988 6988
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6989 6989
     				echo "<tr>";
@@ -7002,7 +7002,7 @@  discard block
 block discarded – undo
7002 7002
     		echo "</table>";
7003 7003
     		echo "</td></tr>";
7004 7004
     	} else {
7005
-    		$new_view = substr_replace($view,'1',2,1);
7005
+    		$new_view = substr_replace($view, '1', 2, 1);
7006 7006
     		echo "
7007 7007
                 <tr>
7008 7008
                     <td valign='top'>
@@ -7021,8 +7021,8 @@  discard block
 block discarded – undo
7021 7021
     {
7022 7022
     	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7023 7023
         $courseId = api_get_course_int_id($courseCode);
7024
-    	if (substr($view,3,1) == '1') {
7025
-    		$new_view = substr_replace($view,'0',3,1);
7024
+    	if (substr($view, 3, 1) == '1') {
7025
+    		$new_view = substr_replace($view, '0', 3, 1);
7026 7026
     		echo "
7027 7027
                 <tr>
7028 7028
                         <td valign='top'>
@@ -7046,7 +7046,7 @@  discard block
 block discarded – undo
7046 7046
                     </td>
7047 7047
                 </tr>";
7048 7048
     		if (is_array($results)) {
7049
-    			for($j = 0 ; $j < count($results) ; $j++) {
7049
+    			for ($j = 0; $j < count($results); $j++) {
7050 7050
     				echo "<tr>";
7051 7051
     				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
7052 7052
     				echo"</tr>";
@@ -7059,7 +7059,7 @@  discard block
 block discarded – undo
7059 7059
     		echo "</table>";
7060 7060
     		echo "</td></tr>";
7061 7061
     	} else {
7062
-    		$new_view = substr_replace($view,'1',3,1);
7062
+    		$new_view = substr_replace($view, '1', 3, 1);
7063 7063
     		echo "
7064 7064
                 <tr>
7065 7065
                     <td valign='top'>
@@ -7086,8 +7086,8 @@  discard block
 block discarded – undo
7086 7086
     	$session_id = intval($session_id);
7087 7087
 
7088 7088
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7089
-    	if(substr($view,4,1) == '1') {
7090
-    		$new_view = substr_replace($view,'0',4,1);
7089
+    	if (substr($view, 4, 1) == '1') {
7090
+    		$new_view = substr_replace($view, '0', 4, 1);
7091 7091
     		echo "
7092 7092
                 <tr>
7093 7093
                     <td valign='top'>
@@ -7113,7 +7113,7 @@  discard block
 block discarded – undo
7113 7113
                     </td>
7114 7114
                 </tr>";
7115 7115
     		if (is_array($results)) {
7116
-    			for($j = 0 ; $j < count($results) ; $j++) {
7116
+    			for ($j = 0; $j < count($results); $j++) {
7117 7117
     				echo "<tr>";
7118 7118
     				echo "<td class='content'>".$results[$j]."</td>";
7119 7119
     				echo"</tr>";
@@ -7126,7 +7126,7 @@  discard block
 block discarded – undo
7126 7126
     		echo "</table>";
7127 7127
     		echo "</td></tr>";
7128 7128
     	} else {
7129
-    		$new_view = substr_replace($view,'1',4,1);
7129
+    		$new_view = substr_replace($view, '1', 4, 1);
7130 7130
     		echo "
7131 7131
                 <tr>
7132 7132
                     <td valign='top'>
@@ -7160,11 +7160,11 @@  discard block
 block discarded – undo
7160 7160
                    ORDER BY login_date DESC LIMIT 1";
7161 7161
         $ip = '';
7162 7162
         $res_ip = Database::query($sql_ip);
7163
-        if ($res_ip !== false && Database::num_rows($res_ip)>0) {
7163
+        if ($res_ip !== false && Database::num_rows($res_ip) > 0) {
7164 7164
             $row_ip = Database::fetch_row($res_ip);
7165 7165
             if ($return_as_link) {
7166 7166
                 $ip = Display::url(
7167
-                    (empty($body_replace)?$row_ip[1]:$body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7167
+                    (empty($body_replace) ? $row_ip[1] : $body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7168 7168
                     array('title'=>get_lang('TraceIP'), 'target'=>'_blank')
7169 7169
                 );
7170 7170
             } else {
@@ -7200,9 +7200,9 @@  discard block
 block discarded – undo
7200 7200
     	$course_id  = intval($course_id);
7201 7201
 
7202 7202
     	$tempView = $view;
7203
-    	if (substr($view,0,1) == '1') {
7204
-    		$new_view = substr_replace($view,'0',0,1);
7205
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7203
+    	if (substr($view, 0, 1) == '1') {
7204
+    		$new_view = substr_replace($view, '0', 0, 1);
7205
+    		$title[1] = get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7206 7206
     		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7207 7207
                     FROM $track_access_table
7208 7208
                     WHERE access_user_id = $user_id
@@ -7212,20 +7212,20 @@  discard block
 block discarded – undo
7212 7212
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7213 7213
     		//$results = getManyResults2Col($sql);
7214 7214
     		$results = getManyResults3Col($sql);
7215
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7216
-    		$line='';
7215
+    		$title_line = get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7216
+    		$line = '';
7217 7217
     		$total = 0;
7218 7218
     		if (is_array($results)) {
7219
-    			for($j = 0 ; $j < count($results) ; $j++) {
7219
+    			for ($j = 0; $j < count($results); $j++) {
7220 7220
     				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7221 7221
     				$total = $total + $results[$j][1];
7222 7222
     			}
7223 7223
     			$line .= get_lang('Total').";".$total."\n";
7224 7224
     		} else {
7225
-    			$line= get_lang('NoResult')."</center></td>";
7225
+    			$line = get_lang('NoResult')."</center></td>";
7226 7226
     		}
7227 7227
     	} else {
7228
-    		$new_view = substr_replace($view,'1',0,1);
7228
+    		$new_view = substr_replace($view, '1', 0, 1);
7229 7229
     	}
7230 7230
     	return array($title_line, $line);
7231 7231
     }
@@ -7243,8 +7243,8 @@  discard block
 block discarded – undo
7243 7243
     	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7244 7244
         $courseId = api_get_course_int_id($courseCode);
7245 7245
         $userId = intval($userId);
7246
-    	if (substr($view,1,1) == '1') {
7247
-    		$new_view = substr_replace($view,'0',1,1);
7246
+    	if (substr($view, 1, 1) == '1') {
7247
+    		$new_view = substr_replace($view, '0', 1, 1);
7248 7248
     		$title[1] = get_lang('ExercicesDetails');
7249 7249
     		$line = '';
7250 7250
     		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
@@ -7268,7 +7268,7 @@  discard block
 block discarded – undo
7268 7268
     		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7269 7269
 
7270 7270
     		if (is_array($results)) {
7271
-    			for($i = 0; $i < sizeof($results); $i++)
7271
+    			for ($i = 0; $i < sizeof($results); $i++)
7272 7272
     			{
7273 7273
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7274 7274
     				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
@@ -7280,8 +7280,8 @@  discard block
 block discarded – undo
7280 7280
 
7281 7281
     		// The Result of Tests
7282 7282
     		if (is_array($hpresults)) {
7283
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7284
-    				$title = GetQuizName($hpresults[$i][0],'');
7283
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
7284
+    				$title = GetQuizName($hpresults[$i][0], '');
7285 7285
 
7286 7286
     				if ($title == '')
7287 7287
     				$title = basename($hpresults[$i][0]);
@@ -7295,10 +7295,10 @@  discard block
 block discarded – undo
7295 7295
     		}
7296 7296
 
7297 7297
     		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7298
-    			$line=get_lang('NoResult');
7298
+    			$line = get_lang('NoResult');
7299 7299
     		}
7300 7300
     	} else {
7301
-    		$new_view = substr_replace($view,'1',1,1);
7301
+    		$new_view = substr_replace($view, '1', 1, 1);
7302 7302
     	}
7303 7303
     	return array($title_line, $line);
7304 7304
     }
@@ -7314,7 +7314,7 @@  discard block
 block discarded – undo
7314 7314
         $user_id = intval($user_id);
7315 7315
         $course_id = intval($course_id);
7316 7316
 
7317
-    	if (substr($view,2,1) == '1') {
7317
+    	if (substr($view, 2, 1) == '1') {
7318 7318
     		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7319 7319
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7320 7320
                     WHERE
@@ -7322,21 +7322,21 @@  discard block
 block discarded – undo
7322 7322
                         u.upload_user_id = '$user_id' AND
7323 7323
                         u.c_id = '$course_id'
7324 7324
                     ORDER BY u.upload_date DESC";
7325
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7325
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7326 7326
 
7327
-    		$title[1]=get_lang('WorksDetails');
7328
-    		$line='';
7329
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7327
+    		$title[1] = get_lang('WorksDetails');
7328
+    		$line = '';
7329
+    		$title_line = get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7330 7330
 
7331 7331
     		if (is_array($results)) {
7332
-    			for($j = 0 ; $j < count($results) ; $j++) {
7332
+    			for ($j = 0; $j < count($results); $j++) {
7333 7333
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7334 7334
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7335 7335
     				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7336 7336
     			}
7337 7337
 
7338 7338
     		} else {
7339
-    			$line= get_lang('NoResult');
7339
+    			$line = get_lang('NoResult');
7340 7340
     		}
7341 7341
     	}
7342 7342
     	return array($title_line, $line);
@@ -7352,9 +7352,9 @@  discard block
 block discarded – undo
7352 7352
         $courseId = api_get_course_int_id($courseCode);
7353 7353
         $userId = intval($userId);
7354 7354
         $line = null;
7355
-    	if (substr($view,3,1) == '1') {
7356
-    		$new_view = substr_replace($view,'0',3,1);
7357
-    		$title[1]=get_lang('LinksDetails');
7355
+    	if (substr($view, 3, 1) == '1') {
7356
+    		$new_view = substr_replace($view, '0', 3, 1);
7357
+    		$title[1] = get_lang('LinksDetails');
7358 7358
     		$sql = "SELECT cl.title, cl.url
7359 7359
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7360 7360
                         WHERE sl.links_link_id = cl.id
@@ -7362,16 +7362,16 @@  discard block
 block discarded – undo
7362 7362
                             AND sl.links_user_id = $userId
7363 7363
                         GROUP BY cl.title, cl.url";
7364 7364
     		$results = StatsUtils::getManyResults2Col($sql);
7365
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7365
+    		$title_line = get_lang('LinksTitleLinkColumn')."\n";
7366 7366
     		if (is_array($results)) {
7367
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7367
+    			for ($j = 0; $j < count($results); $j++) {
7368 7368
     				$line .= $results[$j][0]."\n";
7369 7369
     			}
7370 7370
     		} else {
7371
-    			$line=get_lang('NoResult');
7371
+    			$line = get_lang('NoResult');
7372 7372
     		}
7373 7373
     	} else {
7374
-    		$new_view = substr_replace($view,'1',3,1);
7374
+    		$new_view = substr_replace($view, '1', 3, 1);
7375 7375
     	}
7376 7376
     	return array($title_line, $line);
7377 7377
     }
@@ -7393,9 +7393,9 @@  discard block
 block discarded – undo
7393 7393
 
7394 7394
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7395 7395
 
7396
-    	if (substr($view,4,1) == '1') {
7397
-    		$new_view = substr_replace($view,'0',4,1);
7398
-    		$title[1]= get_lang('DocumentsDetails');
7396
+    	if (substr($view, 4, 1) == '1') {
7397
+    		$new_view = substr_replace($view, '0', 4, 1);
7398
+    		$title[1] = get_lang('DocumentsDetails');
7399 7399
 
7400 7400
     		$sql = "SELECT down_doc_path
7401 7401
                         FROM $downloads_table
@@ -7408,14 +7408,14 @@  discard block
 block discarded – undo
7408 7408
     		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7409 7409
             $line = null;
7410 7410
     		if (is_array($results)) {
7411
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7411
+    			for ($j = 0; $j < count($results); $j++) {
7412 7412
     				$line .= $results[$j]."\n";
7413 7413
     			}
7414 7414
     		} else {
7415 7415
     			$line = get_lang('NoResult');
7416 7416
     		}
7417 7417
     	} else {
7418
-    		$new_view = substr_replace($view,'1',4,1);
7418
+    		$new_view = substr_replace($view, '1', 4, 1);
7419 7419
     	}
7420 7420
     	return array($title_line, $line);
7421 7421
     }
Please login to merge, or discard this patch.