Completed
Pull Request — 1.11.x (#1628)
by José
97:30 queued 69:06
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.png').'" 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.png').'" 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);
@@ -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);
@@ -3500,13 +3500,13 @@  discard block
 block discarded – undo
3500 3500
         if (!empty($courseInfo)) {
3501 3501
             $forums = get_forums('', $courseCode, true, $session_id);
3502 3502
             $course_id = $courseInfo['real_id'];
3503
-            $conditions[]= " post.c_id  = $course_id ";
3503
+            $conditions[] = " post.c_id  = $course_id ";
3504 3504
         }
3505 3505
 
3506 3506
         if (!empty($forums)) {
3507 3507
             $idList = array_column($forums, 'forum_id');
3508 3508
             $idListToString = implode("', '", $idList);
3509
-            $conditions[]= " post.forum_id  IN ('$idListToString')";
3509
+            $conditions[] = " post.forum_id  IN ('$idListToString')";
3510 3510
         }
3511 3511
 
3512 3512
         $conditionsToString = implode('AND ', $conditions);
@@ -3541,7 +3541,7 @@  discard block
 block discarded – undo
3541 3541
             $condition_session = '';
3542 3542
             if (isset($session_id)) {
3543 3543
                 $session_id = intval($session_id);
3544
-                $condition_session = api_get_session_condition($session_id, true,  false, 'f.session_id');
3544
+                $condition_session = api_get_session_condition($session_id, true, false, 'f.session_id');
3545 3545
             }
3546 3546
 
3547 3547
             $course_id = $courseInfo['real_id'];
@@ -3597,7 +3597,7 @@  discard block
 block discarded – undo
3597 3597
         $condition_session = '';
3598 3598
         if (isset($session_id)) {
3599 3599
             $session_id = intval($session_id);
3600
-            $condition_session = ' AND f.session_id = '. $session_id;
3600
+            $condition_session = ' AND f.session_id = '.$session_id;
3601 3601
         }
3602 3602
 
3603 3603
         $groupId = intval($groupId);
@@ -3658,7 +3658,7 @@  discard block
 block discarded – undo
3658 3658
         $condition_session = '';
3659 3659
         if (isset($session_id)) {
3660 3660
              $session_id = intval($session_id);
3661
-             $condition_session = ' AND f.session_id = '. $session_id;
3661
+             $condition_session = ' AND f.session_id = '.$session_id;
3662 3662
         }
3663 3663
 
3664 3664
         $groupId = intval($groupId);
@@ -3737,7 +3737,7 @@  discard block
 block discarded – undo
3737 3737
     {
3738 3738
         $student_id = intval($student_id);
3739 3739
         $courseId = intval($courseId);
3740
-        $session_id    = intval($session_id);
3740
+        $session_id = intval($session_id);
3741 3741
         $date_time  = '';
3742 3742
 
3743 3743
         // table definition
@@ -3806,7 +3806,7 @@  discard block
 block discarded – undo
3806 3806
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
3807 3807
 
3808 3808
         $sql = 'SELECT 1
3809
-                FROM ' . $table . '
3809
+                FROM ' . $table.'
3810 3810
                 WHERE down_user_id = '.$student_id.'
3811 3811
                 AND c_id  = "'.$courseId.'"
3812 3812
                 AND down_session_id = '.$session_id.' ';
@@ -3884,30 +3884,30 @@  discard block
 block discarded – undo
3884 3884
                 '.$inner.'
3885 3885
                 WHERE c.id = '.$courseId.'
3886 3886
                 GROUP BY stats_login.user_id
3887
-                HAVING DATE_SUB( "' . $now . '", INTERVAL '.$since.' DAY) > max_date ';
3887
+                HAVING DATE_SUB( "' . $now.'", INTERVAL '.$since.' DAY) > max_date ';
3888 3888
 
3889 3889
         if ($since == 'never') {
3890 3890
             if (empty($session_id)) {
3891 3891
                 $sql = 'SELECT course_user.user_id
3892
-                        FROM ' . $table_course_rel_user . ' course_user
3893
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3892
+                        FROM ' . $table_course_rel_user.' course_user
3893
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3894 3894
                         ON course_user.user_id = stats_login.user_id AND
3895
-                        relation_type<>' . COURSE_RELATION_TYPE_RRHH . '
3896
-                        INNER JOIN ' . $tableCourse . ' c
3895
+                        relation_type<>' . COURSE_RELATION_TYPE_RRHH.'
3896
+                        INNER JOIN ' . $tableCourse.' c
3897 3897
                         ON (c.id = course_user.c_id)
3898 3898
                         WHERE
3899
-                            course_user.c_id = ' . $courseId . ' AND
3899
+                            course_user.c_id = ' . $courseId.' AND
3900 3900
                             stats_login.login_course_date IS NULL
3901 3901
                         GROUP BY course_user.user_id';
3902 3902
             } else {
3903 3903
                 $sql = 'SELECT session_course_user.user_id
3904 3904
                         FROM '.$tbl_session_course_user.' session_course_user
3905
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3905
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3906 3906
                         ON session_course_user.user_id = stats_login.user_id
3907
-                        INNER JOIN ' . $tableCourse . ' c
3907
+                        INNER JOIN ' . $tableCourse.' c
3908 3908
                         ON (c.id = session_course_user.c_id)
3909 3909
                         WHERE
3910
-                            session_course_user.c_id = ' . $courseId . ' AND
3910
+                            session_course_user.c_id = ' . $courseId.' AND
3911 3911
                             stats_login.login_course_date IS NULL
3912 3912
                         GROUP BY session_course_user.user_id';
3913 3913
             }
@@ -3915,7 +3915,7 @@  discard block
 block discarded – undo
3915 3915
 
3916 3916
         $rs = Database::query($sql);
3917 3917
         $inactive_users = array();
3918
-        while($user = Database::fetch_array($rs)) {
3918
+        while ($user = Database::fetch_array($rs)) {
3919 3919
             $inactive_users[] = $user['user_id'];
3920 3920
         }
3921 3921
 
@@ -3937,10 +3937,10 @@  discard block
 block discarded – undo
3937 3937
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
3938 3938
 
3939 3939
         $sql = 'SELECT '.$student_id.'
3940
-                FROM ' . $table . '
3940
+                FROM ' . $table.'
3941 3941
                 WHERE
3942
-                    access_user_id=' . $student_id . ' AND
3943
-                    c_id="' . $courseId . '" AND
3942
+                    access_user_id=' . $student_id.' AND
3943
+                    c_id="' . $courseId.'" AND
3944 3944
                     access_session_id = "'.$session_id.'" ';
3945 3945
 
3946 3946
         $rs = Database::query($sql);
@@ -3958,13 +3958,13 @@  discard block
 block discarded – undo
3958 3958
     {
3959 3959
         $hr_dept_id = intval($hr_dept_id);
3960 3960
         $a_students = array();
3961
-        $tbl_user     = Database :: get_main_table(TABLE_MAIN_USER);
3961
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
3962 3962
 
3963 3963
         $sql = 'SELECT DISTINCT user_id FROM '.$tbl_user.' as user
3964 3964
                 WHERE hr_dept_id='.$hr_dept_id;
3965 3965
         $rs = Database::query($sql);
3966 3966
 
3967
-        while($user = Database :: fetch_array($rs)) {
3967
+        while ($user = Database :: fetch_array($rs)) {
3968 3968
             $a_students[$user['user_id']] = $user['user_id'];
3969 3969
         }
3970 3970
 
@@ -3989,7 +3989,7 @@  discard block
 block discarded – undo
3989 3989
         $condition_session     = '';
3990 3990
         if (isset($session_id)) {
3991 3991
             $session_id = intval($session_id);
3992
-            $condition_session = ' AND access_session_id = '. $session_id;
3992
+            $condition_session = ' AND access_session_id = '.$session_id;
3993 3993
         }
3994 3994
         $sql = "SELECT
3995 3995
                     access_tool,
@@ -4101,7 +4101,7 @@  discard block
 block discarded – undo
4101 4101
             if (!empty($date_from) && !empty($date_to)) {
4102 4102
                 $fieldStartDate = $fields['start_date'];
4103 4103
                 if (!isset($fields['end_date'])) {
4104
-                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to) ;
4104
+                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to);
4105 4105
                 } else {
4106 4106
                     $fieldEndDate = $fields['end_date'];
4107 4107
                     $where .= sprintf(" AND fieldStartDate >= '%s'
@@ -4117,12 +4117,12 @@  discard block
 block discarded – undo
4117 4117
                 $where
4118 4118
                 GROUP BY %s";
4119 4119
             $sql = sprintf($sql,
4120
-                $fields['user'],    //user field
4121
-                $tableName,         //FROM
4122
-                $fields['course'],  //course condition
4123
-                $course['real_id'],    //course condition
4124
-                $fields['user'],    //user condition
4125
-                $userId,            //user condition
4120
+                $fields['user'], //user field
4121
+                $tableName, //FROM
4122
+                $fields['course'], //course condition
4123
+                $course['real_id'], //course condition
4124
+                $fields['user'], //user condition
4125
+                $userId, //user condition
4126 4126
                 $fields['user']     //GROUP BY
4127 4127
                 );
4128 4128
             $rs = Database::query($sql);
@@ -4130,7 +4130,7 @@  discard block
 block discarded – undo
4130 4130
             //iterate query
4131 4131
             if (Database::num_rows($rs) > 0) {
4132 4132
                 while ($row = Database::fetch_array($rs)) {
4133
-                    $data[$row['user']] = (isset($data[$row['user']])) ?  $data[$row['user']] + $row[total]: $row['total'];
4133
+                    $data[$row['user']] = (isset($data[$row['user']])) ? $data[$row['user']] + $row[total] : $row['total'];
4134 4134
                 }
4135 4135
             }
4136 4136
         }
@@ -4153,11 +4153,11 @@  discard block
 block discarded – undo
4153 4153
         $courseId = api_get_course_int_id($course_code);
4154 4154
         $data = array();
4155 4155
 
4156
-        $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4156
+        $TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4157 4157
         $condition_session = '';
4158 4158
         $session_id = intval($session_id);
4159 4159
         if (!empty($session_id)) {
4160
-            $condition_session = ' AND down_session_id = '. $session_id;
4160
+            $condition_session = ' AND down_session_id = '.$session_id;
4161 4161
         }
4162 4162
         $sql = "SELECT 
4163 4163
                     down_doc_path, 
@@ -4345,7 +4345,7 @@  discard block
 block discarded – undo
4345 4345
 
4346 4346
             $final_course_data = array();
4347 4347
 
4348
-            foreach($my_course_data as $course_id => $value) {
4348
+            foreach ($my_course_data as $course_id => $value) {
4349 4349
                 $final_course_data[$course_id] = $course_list[$course_id];
4350 4350
             }
4351 4351
             $course_in_session[$my_session_id]['course_list'] = $final_course_data;
@@ -4368,7 +4368,7 @@  discard block
 block discarded – undo
4368 4368
                           '.Display::tag('th', get_lang('Course'), array('width'=>'300px')).'
4369 4369
                           '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4370 4370
                           '.Display::tag('th', get_lang('Progress'), array('class'=>'head')).'
4371
-                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')),array('class'=>'head')).'
4371
+                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4372 4372
                           '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4373 4373
                           '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4374 4374
                         </tr>';
@@ -4457,7 +4457,7 @@  discard block
 block discarded – undo
4457 4457
             $all_exercise_start_time = array();
4458 4458
 
4459 4459
             foreach ($course_in_session as $my_session_id => $session_data) {
4460
-                $course_list  = $session_data['course_list'];
4460
+                $course_list = $session_data['course_list'];
4461 4461
                 $user_count = count(SessionManager::get_users_by_session($my_session_id));
4462 4462
                 $exercise_graph_name_list = array();
4463 4463
                 //$user_results = array();
@@ -4502,20 +4502,20 @@  discard block
 block discarded – undo
4502 4502
 
4503 4503
                             $score = 0;
4504 4504
                             if (!empty($user_result_data['exe_weighting']) && intval($user_result_data['exe_weighting']) != 0) {
4505
-                                $score = intval($user_result_data['exe_result']/$user_result_data['exe_weighting'] * 100);
4505
+                                $score = intval($user_result_data['exe_result'] / $user_result_data['exe_weighting'] * 100);
4506 4506
                             }
4507 4507
                             $time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time'], 'UTC') : 0;
4508 4508
                             $all_exercise_start_time[] = $time;
4509 4509
                             $my_results[] = $score;
4510
-                            if (count($exercise_list)<=10) {
4510
+                            if (count($exercise_list) <= 10) {
4511 4511
                                 $title = cut($course_data['title'], 30)." \n ".cut($exercise_data['title'], 30);
4512
-                                $exercise_graph_name_list[]= $title;
4512
+                                $exercise_graph_name_list[] = $title;
4513 4513
                                 $all_exercise_graph_name_list[] = $title;
4514 4514
                             } else {
4515 4515
                                 // if there are more than 10 results, space becomes difficult to find, so only show the title of the exercise, not the tool
4516 4516
                                 $title = cut($exercise_data['title'], 30);
4517
-                                $exercise_graph_name_list[]= $title;
4518
-                                $all_exercise_graph_name_list[]= $title;
4517
+                                $exercise_graph_name_list[] = $title;
4518
+                                $all_exercise_graph_name_list[] = $title;
4519 4519
                             }
4520 4520
                         }
4521 4521
                     }
@@ -4548,7 +4548,7 @@  discard block
 block discarded – undo
4548 4548
             }
4549 4549
 
4550 4550
             $html .= Display::page_subheader(
4551
-                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL) . ' ' . get_lang('Sessions')
4551
+                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL).' '.get_lang('Sessions')
4552 4552
             );
4553 4553
 
4554 4554
             $html .= '<div class="table-responsive">';
@@ -4602,7 +4602,7 @@  discard block
 block discarded – undo
4602 4602
                                 $courseInfo['real_id'],
4603 4603
                                 $my_session_id
4604 4604
                             );
4605
-                            if ($attempts > 1)  {
4605
+                            if ($attempts > 1) {
4606 4606
                                 $answered_exercises++;
4607 4607
                             }
4608 4608
                         }
@@ -4615,7 +4615,7 @@  discard block
 block discarded – undo
4615 4615
                     $all_average += $average;
4616 4616
                 }
4617 4617
 
4618
-                $all_average = $all_average /  count($course_list);
4618
+                $all_average = $all_average / count($course_list);
4619 4619
 
4620 4620
                 if (isset($_GET['session_id']) && $my_session_id == $_GET['session_id']) {
4621 4621
                     $html .= '<tr style="background-color:#FBF09D">';
@@ -4641,16 +4641,16 @@  discard block
 block discarded – undo
4641 4641
             }
4642 4642
             $html .= '</tbody>';
4643 4643
             $html .= '</table></div><br />';
4644
-            $html .= Display::div($main_session_graph, array('id'=>'session_graph','class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
4644
+            $html .= Display::div($main_session_graph, array('id'=>'session_graph', 'class'=>'chart-session', 'style'=>'position:relative; text-align: center;'));
4645 4645
 
4646 4646
             // Checking selected session.
4647 4647
 
4648 4648
             if (isset($_GET['session_id'])) {
4649 4649
                 $session_id_from_get = intval($_GET['session_id']);
4650
-                $session_data 	= $course_in_session[$session_id_from_get];
4651
-                $course_list 	= $session_data['course_list'];
4650
+                $session_data = $course_in_session[$session_id_from_get];
4651
+                $course_list = $session_data['course_list'];
4652 4652
 
4653
-                $html .= Display::tag('h3',$session_data['name'].' - '.get_lang('CourseList'));
4653
+                $html .= Display::tag('h3', $session_data['name'].' - '.get_lang('CourseList'));
4654 4654
 
4655 4655
                 $html .= '<div class="table-responsive">';
4656 4656
                 $html .= '<table class="table table-hover table-striped">';
@@ -4659,15 +4659,15 @@  discard block
 block discarded – undo
4659 4659
                     <thead>
4660 4660
                     <tr>
4661 4661
                       <th width="300px">'.get_lang('Course').'</th>
4662
-                      '.Display::tag('th', get_lang('PublishedExercises'),    	array('class'=>'head')).'
4663
-                      '.Display::tag('th', get_lang('NewExercises'),    		array('class'=>'head')).'
4664
-                      '.Display::tag('th', get_lang('MyAverage'), 				array('class'=>'head')).'
4665
-                      '.Display::tag('th', get_lang('AverageExerciseResult'), 	array('class'=>'head')).'
4666
-                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'),    array('class'=>'head')).'
4667
-                      '.Display::tag('th', get_lang('LPProgress')     ,      	array('class'=>'head')).'
4668
-                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4669
-                      '.Display::tag('th', get_lang('LastConnexion'),         	array('class'=>'head')).'
4670
-                      '.Display::tag('th', get_lang('Details'),               	array('class'=>'head')).'
4662
+                      '.Display::tag('th', get_lang('PublishedExercises'), array('class'=>'head')).'
4663
+                      '.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
4664
+                      '.Display::tag('th', get_lang('MyAverage'), array('class'=>'head')).'
4665
+                      '.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
4666
+                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4667
+                      '.Display::tag('th', get_lang('LPProgress'), array('class'=>'head')).'
4668
+                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4669
+                      '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4670
+                      '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4671 4671
                     </tr>
4672 4672
                     </thead>
4673 4673
                     <tbody>
@@ -4686,14 +4686,14 @@  discard block
 block discarded – undo
4686 4686
                         $count_exercises = count($exercises);
4687 4687
                     }
4688 4688
                     $answered_exercises = 0;
4689
-                    foreach($exercises as $exercise_item) {
4689
+                    foreach ($exercises as $exercise_item) {
4690 4690
                         $attempts = Event::count_exercise_attempts_by_user(
4691 4691
                             api_get_user_id(),
4692 4692
                             $exercise_item['id'],
4693 4693
                             $courseId,
4694 4694
                             $session_id_from_get
4695 4695
                         );
4696
-                        if ($attempts > 1)  {
4696
+                        if ($attempts > 1) {
4697 4697
                             $answered_exercises++;
4698 4698
                         }
4699 4699
                     }
@@ -4702,7 +4702,7 @@  discard block
 block discarded – undo
4702 4702
 
4703 4703
                     // Average
4704 4704
                     $average = ExerciseLib::get_average_score_by_course($courseId, $session_id_from_get);
4705
-                    $my_average	= ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4705
+                    $my_average = ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4706 4706
 
4707 4707
                     $stats_array[$course_code] = array(
4708 4708
                         'exercises' => $count_exercises,
@@ -4779,7 +4779,7 @@  discard block
 block discarded – undo
4779 4779
 
4780 4780
                     if ($course_code == $courseCodeFromGet && $_GET['session_id'] == $session_id_from_get) {
4781 4781
                         $details = '<a href="#">';
4782
-                        $details .=Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4782
+                        $details .= Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4783 4783
                     } else {
4784 4784
                         $details = '<a href="'.api_get_self().'?course='.$course_code.'&session_id='.$session_id_from_get.$extra_params.'">';
4785 4785
                         $details .= Display::return_icon('2rightarrow.png', get_lang('Details'));
@@ -4879,7 +4879,7 @@  discard block
 block discarded – undo
4879 4879
                     );
4880 4880
 
4881 4881
                     $html .= '<tr class="row_even">';
4882
-                    $url = api_get_path(WEB_CODE_PATH) . "exercise/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
4882
+                    $url = api_get_path(WEB_CODE_PATH)."exercise/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
4883 4883
 
4884 4884
                     if ($visible_return['value'] == true) {
4885 4885
                         $exercices['title'] = Display::url(
@@ -4908,7 +4908,7 @@  discard block
 block discarded – undo
4908 4908
                         );
4909 4909
 
4910 4910
                         $latest_attempt_url = '';
4911
-                        $best_score = $position = $percentage_score_result  = '-';
4911
+                        $best_score = $position = $percentage_score_result = '-';
4912 4912
                         $graph = $normal_graph = null;
4913 4913
 
4914 4914
                         // Getting best results
@@ -4940,11 +4940,11 @@  discard block
 block discarded – undo
4940 4940
                                 $weighting      = $exercise_stat['exe_weighting'];
4941 4941
                                 $exe_id         = $exercise_stat['exe_id'];
4942 4942
 
4943
-                                $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;
4943
+                                $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;
4944 4944
                                 $percentage_score_result = Display::url(ExerciseLib::show_score($score, $weighting), $latest_attempt_url);
4945 4945
                                 $my_score = 0;
4946 4946
                                 if (!empty($weighting) && intval($weighting) != 0) {
4947
-                                    $my_score = $score/$weighting;
4947
+                                    $my_score = $score / $weighting;
4948 4948
                                 }
4949 4949
                                 //@todo this function slows the page
4950 4950
                                 if (is_int($user_list)) {
@@ -4958,14 +4958,14 @@  discard block
 block discarded – undo
4958 4958
                         }
4959 4959
                         $html .= Display::div(
4960 4960
                             $normal_graph,
4961
-                            array('id'=>'main_graph_'.$exercices['id'],'class'=>'dialog', 'style'=>'display:none')
4961
+                            array('id'=>'main_graph_'.$exercices['id'], 'class'=>'dialog', 'style'=>'display:none')
4962 4962
                         );
4963 4963
 
4964 4964
                         if (empty($graph)) {
4965 4965
                             $graph = '-';
4966 4966
                         } else {
4967 4967
                             $graph = Display::url(
4968
-                                '<img src="' . $graph . '" >',
4968
+                                '<img src="'.$graph.'" >',
4969 4969
                                 $normal_graph,
4970 4970
                                 array(
4971 4971
                                     'id' => $exercices['id'],
@@ -4999,7 +4999,7 @@  discard block
 block discarded – undo
4999 4999
 
5000 5000
             // LP table results
5001 5001
             $html .= '<div class="table-responsive">';
5002
-            $html .='<table class="table table-striped table-hover">';
5002
+            $html .= '<table class="table table-striped table-hover">';
5003 5003
             $html .= '<thead><tr>';
5004 5004
             $html .= Display::tag('th', get_lang('Learnpaths'), array('class'=>'head', 'style'=>'color:#000'));
5005 5005
             $html .= Display::tag('th', get_lang('LatencyTimeSpent'), array('class'=>'head', 'style'=>'color:#000'));
@@ -5035,7 +5035,7 @@  discard block
 block discarded – undo
5035 5035
                     $time_spent_in_lp = api_time_to_hms($time_spent_in_lp);
5036 5036
 
5037 5037
                     $html .= '<tr class="row_even">';
5038
-                    $url = api_get_path(WEB_CODE_PATH) . "lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
5038
+                    $url = api_get_path(WEB_CODE_PATH)."lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
5039 5039
 
5040 5040
                     if ($learnpath['lp_visibility'] == 0) {
5041 5041
                         $html .= Display::tag('td', $learnpath['lp_name']);
@@ -5054,7 +5054,7 @@  discard block
 block discarded – undo
5054 5054
                     if (!empty($last_connection_in_lp)) {
5055 5055
                         $last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
5056 5056
                     }
5057
-                    $html .= Display::tag('td', $last_connection, array('align'=>'center','width'=>'180px'));
5057
+                    $html .= Display::tag('td', $last_connection, array('align'=>'center', 'width'=>'180px'));
5058 5058
                     $html .= "</tr>";
5059 5059
                 }
5060 5060
             } else {
@@ -5064,7 +5064,7 @@  discard block
 block discarded – undo
5064 5064
                         </td>
5065 5065
                       </tr>';
5066 5066
             }
5067
-            $html .='</tbody></table></div>';
5067
+            $html .= '</tbody></table></div>';
5068 5068
 
5069 5069
             $html .= self::displayUserSkills($user_id, $course_info['id'], $session_id);
5070 5070
         }
@@ -5093,7 +5093,7 @@  discard block
 block discarded – undo
5093 5093
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
5094 5094
         $myData->setSerieDescription('Serie2', get_lang('AverageScore'));
5095 5095
         $myData->setAxisUnit(0, '%');
5096
-        $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5096
+        $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5097 5097
         // Cache definition
5098 5098
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5099 5099
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
@@ -5101,9 +5101,9 @@  discard block
 block discarded – undo
5101 5101
 
5102 5102
         if ($myCache->isInCache($chartHash)) {
5103 5103
             //if we already created the img
5104
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5104
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5105 5105
             $myCache->saveFromCache($chartHash, $imgPath);
5106
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5106
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5107 5107
         } else {
5108 5108
             /* Define width, height and angle */
5109 5109
             $mainWidth = 860;
@@ -5132,7 +5132,7 @@  discard block
 block discarded – undo
5132 5132
             /* Set the default font */
5133 5133
             $myPicture->setFontProperties(
5134 5134
                 array(
5135
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5135
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5136 5136
                     'FontSize' => 10)
5137 5137
             );
5138 5138
             /* Write the chart title */
@@ -5149,7 +5149,7 @@  discard block
 block discarded – undo
5149 5149
             /* Set the default font */
5150 5150
             $myPicture->setFontProperties(
5151 5151
                 array(
5152
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5152
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5153 5153
                     'FontSize' => 6
5154 5154
                 )
5155 5155
             );
@@ -5191,7 +5191,7 @@  discard block
 block discarded – undo
5191 5191
             /* Draw the line chart */
5192 5192
             $myPicture->setFontProperties(
5193 5193
                 array(
5194
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5194
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5195 5195
                     'FontSize' => 10
5196 5196
                 )
5197 5197
             );
@@ -5224,12 +5224,12 @@  discard block
 block discarded – undo
5224 5224
             );
5225 5225
 
5226 5226
             $myCache->writeToCache($chartHash, $myPicture);
5227
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5227
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5228 5228
             $myCache->saveFromCache($chartHash, $imgPath);
5229
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5229
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5230 5230
         }
5231 5231
 
5232
-        $html = '<img src="' . $imgPath . '">';
5232
+        $html = '<img src="'.$imgPath.'">';
5233 5233
 
5234 5234
         return $html;
5235 5235
     }
@@ -5250,12 +5250,12 @@  discard block
 block discarded – undo
5250 5250
 
5251 5251
         foreach ($attempts as $attempt) {
5252 5252
             if (api_get_user_id() == $attempt['exe_user_id']) {
5253
-                if ($attempt['exe_weighting'] != 0 ) {
5254
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5253
+                if ($attempt['exe_weighting'] != 0) {
5254
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5255 5255
                 }
5256 5256
             } else {
5257
-                if ($attempt['exe_weighting'] != 0 ) {
5258
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5257
+                if ($attempt['exe_weighting'] != 0) {
5258
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5259 5259
                 }
5260 5260
             }
5261 5261
         }
@@ -5264,27 +5264,27 @@  discard block
 block discarded – undo
5264 5264
         rsort($my_exercise_result_array);
5265 5265
         $my_exercise_result = 0;
5266 5266
         if (isset($my_exercise_result_array[0])) {
5267
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5267
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5268 5268
         }
5269 5269
 
5270 5270
         $max     = 100;
5271
-        $pieces  = 5 ;
5271
+        $pieces  = 5;
5272 5272
         $part    = round($max / $pieces);
5273 5273
         $x_axis = array();
5274 5274
         $final_array = array();
5275 5275
         $my_final_array = array();
5276 5276
 
5277
-        for ($i=1; $i <=$pieces; $i++) {
5277
+        for ($i = 1; $i <= $pieces; $i++) {
5278 5278
             $sum = 1;
5279 5279
             if ($i == 1) {
5280 5280
                 $sum = 0;
5281 5281
             }
5282
-            $min = ($i-1)*$part + $sum;
5283
-            $max = ($i)*$part;
5284
-            $x_axis[]= $min." - ".$max;
5282
+            $min = ($i - 1) * $part + $sum;
5283
+            $max = ($i) * $part;
5284
+            $x_axis[] = $min." - ".$max;
5285 5285
             $count = 0;
5286
-            foreach($exercise_result as $result) {
5287
-                $percentage = $result*100;
5286
+            foreach ($exercise_result as $result) {
5287
+                $percentage = $result * 100;
5288 5288
                 //echo $percentage.' - '.$min.' - '.$max."<br />";
5289 5289
                 if ($percentage >= $min && $percentage <= $max) {
5290 5290
                     //echo ' is > ';
@@ -5292,7 +5292,7 @@  discard block
 block discarded – undo
5292 5292
                 }
5293 5293
             }
5294 5294
             //echo '<br />';
5295
-            $final_array[]= $count;
5295
+            $final_array[] = $count;
5296 5296
 
5297 5297
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5298 5298
                 $my_final_array[] = 1;
@@ -5302,9 +5302,9 @@  discard block
 block discarded – undo
5302 5302
         }
5303 5303
 
5304 5304
         //Fix to remove the data of the user with my data
5305
-        for($i = 0; $i<=count($my_final_array); $i++) {
5305
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5306 5306
             if (!empty($my_final_array[$i])) {
5307
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5307
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5308 5308
                 $final_array[$i] = 0;
5309 5309
             }
5310 5310
         }
@@ -5314,16 +5314,16 @@  discard block
 block discarded – undo
5314 5314
         $dataSet->addPoints($final_array, 'Serie1');
5315 5315
         $dataSet->addPoints($my_final_array, 'Serie2');
5316 5316
         $dataSet->normalize(100, "%");
5317
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5317
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5318 5318
 
5319 5319
         // Cache definition
5320 5320
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5321 5321
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
5322 5322
         $chartHash = $myCache->getHash($dataSet);
5323 5323
         if ($myCache->isInCache($chartHash)) {
5324
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5324
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5325 5325
             $myCache->saveFromCache($chartHash, $imgPath);
5326
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5326
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5327 5327
         } else {
5328 5328
             /* Create the pChart object */
5329 5329
             $widthSize = 80;
@@ -5339,7 +5339,7 @@  discard block
 block discarded – undo
5339 5339
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5340 5340
 
5341 5341
             /* Set the default font */
5342
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5342
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5343 5343
 
5344 5344
             /* Do not write the chart title */
5345 5345
 
@@ -5403,9 +5403,9 @@  discard block
 block discarded – undo
5403 5403
 
5404 5404
             /* Save and write in cache */
5405 5405
             $myCache->writeToCache($chartHash, $myPicture);
5406
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5406
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5407 5407
             $myCache->saveFromCache($chartHash, $imgPath);
5408
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5408
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5409 5409
         }
5410 5410
 
5411 5411
         return $imgPath;
@@ -5425,12 +5425,12 @@  discard block
 block discarded – undo
5425 5425
         }
5426 5426
         foreach ($attempts as $attempt) {
5427 5427
             if (api_get_user_id() == $attempt['exe_user_id']) {
5428
-                if ($attempt['exe_weighting'] != 0 ) {
5429
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5428
+                if ($attempt['exe_weighting'] != 0) {
5429
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5430 5430
                 }
5431 5431
             } else {
5432
-                if ($attempt['exe_weighting'] != 0 ) {
5433
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5432
+                if ($attempt['exe_weighting'] != 0) {
5433
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5434 5434
                 }
5435 5435
             }
5436 5436
         }
@@ -5439,32 +5439,32 @@  discard block
 block discarded – undo
5439 5439
         rsort($my_exercise_result_array);
5440 5440
         $my_exercise_result = 0;
5441 5441
         if (isset($my_exercise_result_array[0])) {
5442
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5442
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5443 5443
         }
5444 5444
 
5445 5445
         $max = 100;
5446
-        $pieces = 5 ;
5446
+        $pieces = 5;
5447 5447
         $part = round($max / $pieces);
5448 5448
         $x_axis = array();
5449 5449
         $final_array = array();
5450 5450
         $my_final_array = array();
5451 5451
 
5452
-        for ($i=1; $i <=$pieces; $i++) {
5452
+        for ($i = 1; $i <= $pieces; $i++) {
5453 5453
             $sum = 1;
5454 5454
             if ($i == 1) {
5455 5455
                 $sum = 0;
5456 5456
             }
5457
-            $min = ($i-1)*$part + $sum;
5458
-            $max = ($i)*$part;
5459
-            $x_axis[]= $min." - ".$max;
5457
+            $min = ($i - 1) * $part + $sum;
5458
+            $max = ($i) * $part;
5459
+            $x_axis[] = $min." - ".$max;
5460 5460
             $count = 0;
5461
-            foreach($exercise_result as $result) {
5462
-                $percentage = $result*100;
5461
+            foreach ($exercise_result as $result) {
5462
+                $percentage = $result * 100;
5463 5463
                 if ($percentage >= $min && $percentage <= $max) {
5464 5464
                     $count++;
5465 5465
                 }
5466 5466
             }
5467
-            $final_array[]= $count;
5467
+            $final_array[] = $count;
5468 5468
 
5469 5469
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5470 5470
                 $my_final_array[] = 1;
@@ -5475,9 +5475,9 @@  discard block
 block discarded – undo
5475 5475
 
5476 5476
         //Fix to remove the data of the user with my data
5477 5477
 
5478
-        for($i = 0; $i<=count($my_final_array); $i++) {
5478
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5479 5479
             if (!empty($my_final_array[$i])) {
5480
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5480
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5481 5481
                 $final_array[$i] = 0;
5482 5482
             }
5483 5483
         }
@@ -5495,7 +5495,7 @@  discard block
 block discarded – undo
5495 5495
         $dataSet->setXAxisName(get_lang('Score'));
5496 5496
         $dataSet->normalize(100, "%");
5497 5497
 
5498
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5498
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5499 5499
 
5500 5500
         // Cache definition
5501 5501
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -5503,9 +5503,9 @@  discard block
 block discarded – undo
5503 5503
         $chartHash = $myCache->getHash($dataSet);
5504 5504
 
5505 5505
         if ($myCache->isInCache($chartHash)) {
5506
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5506
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5507 5507
             $myCache->saveFromCache($chartHash, $imgPath);
5508
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5508
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5509 5509
         } else {
5510 5510
             /* Create the pChart object */
5511 5511
             $widthSize = 480;
@@ -5521,7 +5521,7 @@  discard block
 block discarded – undo
5521 5521
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5522 5522
 
5523 5523
             /* Set the default font */
5524
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5524
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5525 5525
 
5526 5526
             /* Write the chart title */
5527 5527
             $myPicture->drawText(
@@ -5580,9 +5580,9 @@  discard block
 block discarded – undo
5580 5580
 
5581 5581
             /* Write and save into cache */
5582 5582
             $myCache->writeToCache($chartHash, $myPicture);
5583
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5583
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5584 5584
             $myCache->saveFromCache($chartHash, $imgPath);
5585
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5585
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5586 5586
         }
5587 5587
 
5588 5588
         return $imgPath;
@@ -5657,7 +5657,7 @@  discard block
 block discarded – undo
5657 5657
         $tquiz_answer = Database::get_course_table(TABLE_QUIZ_ANSWER);
5658 5658
         $tquiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
5659 5659
         $tquiz_rel_question = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
5660
-        $ttrack_exercises  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5660
+        $ttrack_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5661 5661
         $ttrack_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
5662 5662
 
5663 5663
         $sessions = array();
@@ -5709,7 +5709,7 @@  discard block
 block discarded – undo
5709 5709
                         $whereSessionParams .= $sessionIdx.',';
5710 5710
                     }
5711 5711
                 }
5712
-                $whereSessionParams = substr($whereSessionParams,0,-1);
5712
+                $whereSessionParams = substr($whereSessionParams, 0, -1);
5713 5713
             }
5714 5714
 
5715 5715
             if (!empty($exerciseId)) {
@@ -5773,7 +5773,7 @@  discard block
 block discarded – undo
5773 5773
                     qq.position = rq.question_order AND
5774 5774
                     ta.question_id = rq.question_id
5775 5775
                 WHERE
5776
-                    te.c_id = $courseIdx ".(empty($whereSessionParams)?'':"AND te.session_id IN ($whereSessionParams)")."
5776
+                    te.c_id = $courseIdx ".(empty($whereSessionParams) ? '' : "AND te.session_id IN ($whereSessionParams)")."
5777 5777
                     AND q.c_id = $courseIdx
5778 5778
                     $where $order $limit";
5779 5779
             $sql_query = vsprintf($sql, $whereParams);
@@ -5821,7 +5821,7 @@  discard block
 block discarded – undo
5821 5821
             // Now fill users data
5822 5822
             $sqlUsers = "SELECT user_id, username, lastname, firstname
5823 5823
                          FROM $tuser
5824
-                         WHERE user_id IN (".implode(',',$userIds).")";
5824
+                         WHERE user_id IN (".implode(',', $userIds).")";
5825 5825
             $resUsers = Database::query($sqlUsers);
5826 5826
             while ($rowUser = Database::fetch_assoc($resUsers)) {
5827 5827
                 $users[$rowUser['user_id']] = $rowUser;
@@ -5925,7 +5925,7 @@  discard block
 block discarded – undo
5925 5925
                 <table class="table" id="skillList">
5926 5926
                     <thead>
5927 5927
                         <tr>
5928
-                            <th>' . get_lang('AchievedSkills') . '</th>
5928
+                            <th>' . get_lang('AchievedSkills').'</th>
5929 5929
                         </tr>
5930 5930
                     </thead>
5931 5931
                     <tbody>
@@ -5944,10 +5944,10 @@  discard block
 block discarded – undo
5944 5944
 
5945 5945
                 $html .= '
5946 5946
                                             <li class="thumbnail">
5947
-                                                <a href="' . api_get_path(WEB_PATH) . 'badge/' . $userSkill->getId() . '/user/' . $userId . '" target="_blank">
5948
-                                                    <img class="img-responsive" title="' . $skill->getName() . '" src="' . $skill->getWebIconPath() . '" width="64" height="64">
5947
+                                                <a href="' . api_get_path(WEB_PATH).'badge/'.$userSkill->getId().'/user/'.$userId.'" target="_blank">
5948
+                                                    <img class="img-responsive" title="' . $skill->getName().'" src="'.$skill->getWebIconPath().'" width="64" height="64">
5949 5949
                                                     <div class="caption">
5950
-                                                        <p class="text-center">' . $skill->getName() . '</p>
5950
+                                                        <p class="text-center">' . $skill->getName().'</p>
5951 5951
                                                     </div>
5952 5952
                                                 </a>
5953 5953
                                             </li>
@@ -5997,7 +5997,7 @@  discard block
 block discarded – undo
5997 5997
     	        WHERE
5998 5998
                     track_resource.c_id = $course_id AND
5999 5999
                     track_resource.insert_user_id = user.user_id AND
6000
-                    session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6000
+                    session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6001 6001
 
6002 6002
     	if (isset($_GET['keyword'])) {
6003 6003
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6055,7 +6055,7 @@  discard block
 block discarded – undo
6055 6055
                 WHERE
6056 6056
                   track_resource.c_id = $course_id AND
6057 6057
                   track_resource.insert_user_id = user.user_id AND
6058
-                  session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6058
+                  session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6059 6059
 
6060 6060
     	if (isset($_GET['keyword'])) {
6061 6061
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6355,7 +6355,7 @@  discard block
 block discarded – undo
6355 6355
     public static function display_additional_profile_fields()
6356 6356
     {
6357 6357
     	// getting all the extra profile fields that are defined by the platform administrator
6358
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6358
+    	$extra_fields = UserManager :: get_extra_fields(0, 50, 5, 'ASC');
6359 6359
 
6360 6360
     	// creating the form
6361 6361
     	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
@@ -6367,8 +6367,8 @@  discard block
 block discarded – undo
6367 6367
     	$extra_fields_to_show = 0;
6368 6368
     	foreach ($extra_fields as $key=>$field) {
6369 6369
     		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6370
-    		if ($field[6]==1 && $field[8] == 1) {
6371
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6370
+    		if ($field[6] == 1 && $field[8] == 1) {
6371
+    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field']) {
6372 6372
     				$selected = 'selected="selected"';
6373 6373
     			} else {
6374 6374
     				$selected = '';
@@ -6380,8 +6380,8 @@  discard block
 block discarded – undo
6380 6380
     	$return .= '</select>';
6381 6381
 
6382 6382
     	// the form elements for the $_GET parameters (because the form is passed through GET
6383
-    	foreach ($_GET as $key=>$value){
6384
-    		if ($key <> 'additional_profile_field')    {
6383
+    	foreach ($_GET as $key=>$value) {
6384
+    		if ($key <> 'additional_profile_field') {
6385 6385
     			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6386 6386
     		}
6387 6387
     	}
@@ -6418,21 +6418,21 @@  discard block
 block discarded – undo
6418 6418
     	$result_extra_field = UserManager::get_extra_field_information($field_id);
6419 6419
 
6420 6420
     	if (!empty($users)) {
6421
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6422
-    			foreach($users as $user_id) {
6421
+    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG) {
6422
+    			foreach ($users as $user_id) {
6423 6423
     				$user_result = UserManager::get_user_tags($user_id, $field_id);
6424 6424
     				$tag_list = array();
6425
-    				foreach($user_result as $item) {
6425
+    				foreach ($user_result as $item) {
6426 6426
     					$tag_list[] = $item['tag'];
6427 6427
     				}
6428
-    				$return[$user_id][] = implode(', ',$tag_list);
6428
+    				$return[$user_id][] = implode(', ', $tag_list);
6429 6429
     			}
6430 6430
     		} else {
6431 6431
     			$new_user_array = array();
6432 6432
     			foreach ($users as $user_id) {
6433
-    				$new_user_array[]= "'".$user_id."'";
6433
+    				$new_user_array[] = "'".$user_id."'";
6434 6434
     			}
6435
-    			$users = implode(',',$new_user_array);
6435
+    			$users = implode(',', $new_user_array);
6436 6436
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6437 6437
     			// Selecting only the necessary information NOT ALL the user list
6438 6438
     			$sql = "SELECT user.user_id, v.value
@@ -6447,7 +6447,7 @@  discard block
 block discarded – undo
6447 6447
                             user.user_id IN ($users)";
6448 6448
 
6449 6449
     			$result = Database::query($sql);
6450
-    			while($row = Database::fetch_array($result)) {
6450
+    			while ($row = Database::fetch_array($result)) {
6451 6451
     				// get option value for field type double select by id
6452 6452
     				if (!empty($row['value'])) {
6453 6453
     					if ($result_extra_field['field_type'] ==
@@ -6486,7 +6486,7 @@  discard block
 block discarded – undo
6486 6486
 
6487 6487
     public function sort_users_desc($a, $b)
6488 6488
     {
6489
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6489
+    	return strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6490 6490
     }
6491 6491
 
6492 6492
     /**
@@ -6521,7 +6521,7 @@  discard block
 block discarded – undo
6521 6521
     	// get all users data from a course for sortable with limit
6522 6522
     	if (is_array($user_ids)) {
6523 6523
     		$user_ids = array_map('intval', $user_ids);
6524
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6524
+    		$condition_user = " WHERE user.user_id IN (".implode(',', $user_ids).") ";
6525 6525
     	} else {
6526 6526
     		$user_ids = intval($user_ids);
6527 6527
     		$condition_user = " WHERE user.user_id = $user_ids ";
@@ -6529,7 +6529,7 @@  discard block
 block discarded – undo
6529 6529
 
6530 6530
     	if (!empty($_GET['user_keyword'])) {
6531 6531
     		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6532
-    		$condition_user .=  " AND (
6532
+    		$condition_user .= " AND (
6533 6533
                 user.firstname LIKE '%".$keyword."%' OR
6534 6534
                 user.lastname LIKE '%".$keyword."%'  OR
6535 6535
                 user.username LIKE '%".$keyword."%'  OR
@@ -6547,7 +6547,7 @@  discard block
 block discarded – undo
6547 6547
         $invitedUsersCondition = '';
6548 6548
 
6549 6549
         if (!$includeInvitedUsers) {
6550
-            $invitedUsersCondition = " AND user.status != " . INVITEE;
6550
+            $invitedUsersCondition = " AND user.status != ".INVITEE;
6551 6551
         }
6552 6552
 
6553 6553
     	$sql = "SELECT  user.user_id as user_id,
@@ -6558,7 +6558,7 @@  discard block
 block discarded – undo
6558 6558
                 FROM $tbl_user as user $url_table
6559 6559
     	        $condition_user $url_condition $invitedUsersCondition";
6560 6560
 
6561
-    	if (!in_array($direction, array('ASC','DESC'))) {
6561
+    	if (!in_array($direction, array('ASC', 'DESC'))) {
6562 6562
     		$direction = 'ASC';
6563 6563
     	}
6564 6564
 
@@ -6694,7 +6694,7 @@  discard block
 block discarded – undo
6694 6694
     		}
6695 6695
 
6696 6696
             if (empty($session_id)) {
6697
-                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6697
+                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0).' / '.$total_surveys;
6698 6698
             }
6699 6699
 
6700 6700
     		$user['link'] = '<center>
@@ -6706,37 +6706,37 @@  discard block
 block discarded – undo
6706 6706
     		// store columns in array $users
6707 6707
     		$is_western_name_order = api_is_western_name_order();
6708 6708
             $user_row = array();
6709
-            $user_row[]= $user['official_code']; //0
6709
+            $user_row[] = $user['official_code']; //0
6710 6710
             if ($is_western_name_order) {
6711
-                $user_row[]= $user['firstname'];
6712
-                $user_row[]= $user['lastname'];
6711
+                $user_row[] = $user['firstname'];
6712
+                $user_row[] = $user['lastname'];
6713 6713
             } else {
6714
-                $user_row[]= $user['lastname'];
6715
-                $user_row[]= $user['firstname'];
6714
+                $user_row[] = $user['lastname'];
6715
+                $user_row[] = $user['firstname'];
6716 6716
             }
6717
-            $user_row[]= $user['username'];
6718
-            $user_row[]= $user['time'];
6719
-            $user_row[]= $user['average_progress'];
6720
-            $user_row[]= $user['exercise_progress'];
6721
-            $user_row[]= $user['exercise_average_best_attempt'];
6722
-            $user_row[]= $user['student_score'];
6723
-            $user_row[]= $user['count_assignments'];
6724
-            $user_row[]= $user['count_messages'];
6717
+            $user_row[] = $user['username'];
6718
+            $user_row[] = $user['time'];
6719
+            $user_row[] = $user['average_progress'];
6720
+            $user_row[] = $user['exercise_progress'];
6721
+            $user_row[] = $user['exercise_average_best_attempt'];
6722
+            $user_row[] = $user['student_score'];
6723
+            $user_row[] = $user['count_assignments'];
6724
+            $user_row[] = $user['count_messages'];
6725 6725
 
6726 6726
             $userGroupManager = new UserGroup();
6727 6727
             $user_row[] = $userGroupManager->getLabelsFromNameList($user['user_id'], UserGroup::NORMAL_CLASS);
6728 6728
 
6729 6729
             if (empty($session_id)) {
6730
-                $user_row[]= $user['survey'];
6730
+                $user_row[] = $user['survey'];
6731 6731
             }
6732 6732
 
6733
-            $user_row[]= $user['first_connection'];
6734
-            $user_row[]= $user['last_connection'];
6733
+            $user_row[] = $user['first_connection'];
6734
+            $user_row[] = $user['last_connection'];
6735 6735
             if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6736
-                $user_row[]= $user['additional'];
6736
+                $user_row[] = $user['additional'];
6737 6737
             }
6738 6738
 
6739
-            $user_row[]= $user['link'];
6739
+            $user_row[] = $user['link'];
6740 6740
 
6741 6741
             $users[] = $user_row;
6742 6742
 
@@ -6781,8 +6781,8 @@  discard block
 block discarded – undo
6781 6781
 
6782 6782
     	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6783 6783
     	$tempView = $view;
6784
-    	if(substr($view,0,1) == '1') {
6785
-    		$new_view = substr_replace($view,'0',0,1);
6784
+    	if (substr($view, 0, 1) == '1') {
6785
+    		$new_view = substr_replace($view, '0', 0, 1);
6786 6786
     		echo "
6787 6787
                 <tr>
6788 6788
                     <td valign='top'>
@@ -6815,9 +6815,9 @@  discard block
 block discarded – undo
6815 6815
                 </tr>";
6816 6816
     		$total = 0;
6817 6817
     		if (is_array($results)) {
6818
-    			for($j = 0 ; $j < count($results) ; $j++) {
6818
+    			for ($j = 0; $j < count($results); $j++) {
6819 6819
     				echo "<tr>";
6820
-    				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>";
6820
+    				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>";
6821 6821
     				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6822 6822
     				echo"</tr>";
6823 6823
     				$total = $total + $results[$j][1];
@@ -6834,7 +6834,7 @@  discard block
 block discarded – undo
6834 6834
     		echo "</table>";
6835 6835
     		echo "</td></tr>";
6836 6836
     	} else {
6837
-    		$new_view = substr_replace($view,'1',0,1);
6837
+    		$new_view = substr_replace($view, '1', 0, 1);
6838 6838
     		echo "
6839 6839
                 <tr>
6840 6840
                     <td valign='top'>
@@ -6857,8 +6857,8 @@  discard block
 block discarded – undo
6857 6857
     {
6858 6858
     	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6859 6859
         $courseId = api_get_course_int_id($courseCode);
6860
-    	if(substr($view,1,1) == '1') {
6861
-    		$new_view = substr_replace($view,'0',1,1);
6860
+    	if (substr($view, 1, 1) == '1') {
6861
+    		$new_view = substr_replace($view, '0', 1, 1);
6862 6862
     		echo "<tr>
6863 6863
                     <td valign='top'>
6864 6864
                         <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>]
@@ -6900,7 +6900,7 @@  discard block
 block discarded – undo
6900 6900
                 </tr>";
6901 6901
 
6902 6902
     		if (is_array($results)) {
6903
-    			for($i = 0; $i < sizeof($results); $i++) {
6903
+    			for ($i = 0; $i < sizeof($results); $i++) {
6904 6904
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6905 6905
     				echo "<tr>\n";
6906 6906
     				echo "<td class='content'>".$results[$i][0]."</td>\n";
@@ -6915,8 +6915,8 @@  discard block
 block discarded – undo
6915 6915
 
6916 6916
     		// The Result of Tests
6917 6917
     		if (is_array($hpresults)) {
6918
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6919
-    				$title = GetQuizName($hpresults[$i][0],'');
6918
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
6919
+    				$title = GetQuizName($hpresults[$i][0], '');
6920 6920
     				if ($title == '')
6921 6921
     				$title = basename($hpresults[$i][0]);
6922 6922
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
@@ -6942,7 +6942,7 @@  discard block
 block discarded – undo
6942 6942
     		echo "</table>";
6943 6943
     		echo "</td>\n</tr>\n";
6944 6944
     	} else {
6945
-    		$new_view = substr_replace($view,'1',1,1);
6945
+    		$new_view = substr_replace($view, '1', 1, 1);
6946 6946
     		echo "
6947 6947
                 <tr>
6948 6948
                     <td valign='top'>
@@ -6961,8 +6961,8 @@  discard block
 block discarded – undo
6961 6961
     	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6962 6962
         $_course = api_get_course_info_by_id($course_id);
6963 6963
 
6964
-    	if (substr($view,2,1) == '1') {
6965
-    		$new_view = substr_replace($view,'0',2,1);
6964
+    	if (substr($view, 2, 1) == '1') {
6965
+    		$new_view = substr_replace($view, '0', 2, 1);
6966 6966
     		echo "<tr>
6967 6967
                     <td valign='top'>
6968 6968
                     <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>]
@@ -6976,7 +6976,7 @@  discard block
 block discarded – undo
6976 6976
                         AND u.c_id = '".intval($course_id)."'
6977 6977
                     ORDER BY u.upload_date DESC";
6978 6978
     		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6979
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6979
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6980 6980
     		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6981 6981
     		echo "<tr>
6982 6982
                     <td class='secLine' width='40%'>
@@ -6990,7 +6990,7 @@  discard block
 block discarded – undo
6990 6990
                     </td>
6991 6991
                 </tr>";
6992 6992
     		if (is_array($results)) {
6993
-    			for($j = 0 ; $j < count($results) ; $j++) {
6993
+    			for ($j = 0; $j < count($results); $j++) {
6994 6994
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6995 6995
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6996 6996
     				echo "<tr>";
@@ -7009,7 +7009,7 @@  discard block
 block discarded – undo
7009 7009
     		echo "</table>";
7010 7010
     		echo "</td></tr>";
7011 7011
     	} else {
7012
-    		$new_view = substr_replace($view,'1',2,1);
7012
+    		$new_view = substr_replace($view, '1', 2, 1);
7013 7013
     		echo "
7014 7014
                 <tr>
7015 7015
                     <td valign='top'>
@@ -7028,8 +7028,8 @@  discard block
 block discarded – undo
7028 7028
     {
7029 7029
     	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7030 7030
         $courseId = api_get_course_int_id($courseCode);
7031
-    	if (substr($view,3,1) == '1') {
7032
-    		$new_view = substr_replace($view,'0',3,1);
7031
+    	if (substr($view, 3, 1) == '1') {
7032
+    		$new_view = substr_replace($view, '0', 3, 1);
7033 7033
     		echo "
7034 7034
                 <tr>
7035 7035
                         <td valign='top'>
@@ -7053,7 +7053,7 @@  discard block
 block discarded – undo
7053 7053
                     </td>
7054 7054
                 </tr>";
7055 7055
     		if (is_array($results)) {
7056
-    			for($j = 0 ; $j < count($results) ; $j++) {
7056
+    			for ($j = 0; $j < count($results); $j++) {
7057 7057
     				echo "<tr>";
7058 7058
     				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
7059 7059
     				echo"</tr>";
@@ -7066,7 +7066,7 @@  discard block
 block discarded – undo
7066 7066
     		echo "</table>";
7067 7067
     		echo "</td></tr>";
7068 7068
     	} else {
7069
-    		$new_view = substr_replace($view,'1',3,1);
7069
+    		$new_view = substr_replace($view, '1', 3, 1);
7070 7070
     		echo "
7071 7071
                 <tr>
7072 7072
                     <td valign='top'>
@@ -7093,8 +7093,8 @@  discard block
 block discarded – undo
7093 7093
     	$session_id = intval($session_id);
7094 7094
 
7095 7095
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7096
-    	if(substr($view,4,1) == '1') {
7097
-    		$new_view = substr_replace($view,'0',4,1);
7096
+    	if (substr($view, 4, 1) == '1') {
7097
+    		$new_view = substr_replace($view, '0', 4, 1);
7098 7098
     		echo "
7099 7099
                 <tr>
7100 7100
                     <td valign='top'>
@@ -7120,7 +7120,7 @@  discard block
 block discarded – undo
7120 7120
                     </td>
7121 7121
                 </tr>";
7122 7122
     		if (is_array($results)) {
7123
-    			for($j = 0 ; $j < count($results) ; $j++) {
7123
+    			for ($j = 0; $j < count($results); $j++) {
7124 7124
     				echo "<tr>";
7125 7125
     				echo "<td class='content'>".$results[$j]."</td>";
7126 7126
     				echo"</tr>";
@@ -7133,7 +7133,7 @@  discard block
 block discarded – undo
7133 7133
     		echo "</table>";
7134 7134
     		echo "</td></tr>";
7135 7135
     	} else {
7136
-    		$new_view = substr_replace($view,'1',4,1);
7136
+    		$new_view = substr_replace($view, '1', 4, 1);
7137 7137
     		echo "
7138 7138
                 <tr>
7139 7139
                     <td valign='top'>
@@ -7167,11 +7167,11 @@  discard block
 block discarded – undo
7167 7167
                    ORDER BY login_date DESC LIMIT 1";
7168 7168
         $ip = '';
7169 7169
         $res_ip = Database::query($sql_ip);
7170
-        if ($res_ip !== false && Database::num_rows($res_ip)>0) {
7170
+        if ($res_ip !== false && Database::num_rows($res_ip) > 0) {
7171 7171
             $row_ip = Database::fetch_row($res_ip);
7172 7172
             if ($return_as_link) {
7173 7173
                 $ip = Display::url(
7174
-                    (empty($body_replace)?$row_ip[1]:$body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7174
+                    (empty($body_replace) ? $row_ip[1] : $body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7175 7175
                     array('title'=>get_lang('TraceIP'), 'target'=>'_blank')
7176 7176
                 );
7177 7177
             } else {
@@ -7207,9 +7207,9 @@  discard block
 block discarded – undo
7207 7207
     	$course_id  = intval($course_id);
7208 7208
 
7209 7209
     	$tempView = $view;
7210
-    	if (substr($view,0,1) == '1') {
7211
-    		$new_view = substr_replace($view,'0',0,1);
7212
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7210
+    	if (substr($view, 0, 1) == '1') {
7211
+    		$new_view = substr_replace($view, '0', 0, 1);
7212
+    		$title[1] = get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7213 7213
     		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7214 7214
                     FROM $track_access_table
7215 7215
                     WHERE access_user_id = $user_id
@@ -7219,20 +7219,20 @@  discard block
 block discarded – undo
7219 7219
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7220 7220
     		//$results = getManyResults2Col($sql);
7221 7221
     		$results = getManyResults3Col($sql);
7222
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7223
-    		$line='';
7222
+    		$title_line = get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7223
+    		$line = '';
7224 7224
     		$total = 0;
7225 7225
     		if (is_array($results)) {
7226
-    			for($j = 0 ; $j < count($results) ; $j++) {
7226
+    			for ($j = 0; $j < count($results); $j++) {
7227 7227
     				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7228 7228
     				$total = $total + $results[$j][1];
7229 7229
     			}
7230 7230
     			$line .= get_lang('Total').";".$total."\n";
7231 7231
     		} else {
7232
-    			$line= get_lang('NoResult')."</center></td>";
7232
+    			$line = get_lang('NoResult')."</center></td>";
7233 7233
     		}
7234 7234
     	} else {
7235
-    		$new_view = substr_replace($view,'1',0,1);
7235
+    		$new_view = substr_replace($view, '1', 0, 1);
7236 7236
     	}
7237 7237
     	return array($title_line, $line);
7238 7238
     }
@@ -7250,8 +7250,8 @@  discard block
 block discarded – undo
7250 7250
     	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7251 7251
         $courseId = api_get_course_int_id($courseCode);
7252 7252
         $userId = intval($userId);
7253
-    	if (substr($view,1,1) == '1') {
7254
-    		$new_view = substr_replace($view,'0',1,1);
7253
+    	if (substr($view, 1, 1) == '1') {
7254
+    		$new_view = substr_replace($view, '0', 1, 1);
7255 7255
     		$title[1] = get_lang('ExercicesDetails');
7256 7256
     		$line = '';
7257 7257
     		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
@@ -7275,7 +7275,7 @@  discard block
 block discarded – undo
7275 7275
     		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7276 7276
 
7277 7277
     		if (is_array($results)) {
7278
-    			for($i = 0; $i < sizeof($results); $i++)
7278
+    			for ($i = 0; $i < sizeof($results); $i++)
7279 7279
     			{
7280 7280
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7281 7281
     				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
@@ -7287,8 +7287,8 @@  discard block
 block discarded – undo
7287 7287
 
7288 7288
     		// The Result of Tests
7289 7289
     		if (is_array($hpresults)) {
7290
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7291
-    				$title = GetQuizName($hpresults[$i][0],'');
7290
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
7291
+    				$title = GetQuizName($hpresults[$i][0], '');
7292 7292
 
7293 7293
     				if ($title == '')
7294 7294
     				$title = basename($hpresults[$i][0]);
@@ -7302,10 +7302,10 @@  discard block
 block discarded – undo
7302 7302
     		}
7303 7303
 
7304 7304
     		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7305
-    			$line=get_lang('NoResult');
7305
+    			$line = get_lang('NoResult');
7306 7306
     		}
7307 7307
     	} else {
7308
-    		$new_view = substr_replace($view,'1',1,1);
7308
+    		$new_view = substr_replace($view, '1', 1, 1);
7309 7309
     	}
7310 7310
     	return array($title_line, $line);
7311 7311
     }
@@ -7321,7 +7321,7 @@  discard block
 block discarded – undo
7321 7321
         $user_id = intval($user_id);
7322 7322
         $course_id = intval($course_id);
7323 7323
 
7324
-    	if (substr($view,2,1) == '1') {
7324
+    	if (substr($view, 2, 1) == '1') {
7325 7325
     		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7326 7326
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7327 7327
                     WHERE
@@ -7329,21 +7329,21 @@  discard block
 block discarded – undo
7329 7329
                         u.upload_user_id = '$user_id' AND
7330 7330
                         u.c_id = '$course_id'
7331 7331
                     ORDER BY u.upload_date DESC";
7332
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7332
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7333 7333
 
7334
-    		$title[1]=get_lang('WorksDetails');
7335
-    		$line='';
7336
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7334
+    		$title[1] = get_lang('WorksDetails');
7335
+    		$line = '';
7336
+    		$title_line = get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7337 7337
 
7338 7338
     		if (is_array($results)) {
7339
-    			for($j = 0 ; $j < count($results) ; $j++) {
7339
+    			for ($j = 0; $j < count($results); $j++) {
7340 7340
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7341 7341
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7342 7342
     				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7343 7343
     			}
7344 7344
 
7345 7345
     		} else {
7346
-    			$line= get_lang('NoResult');
7346
+    			$line = get_lang('NoResult');
7347 7347
     		}
7348 7348
     	}
7349 7349
     	return array($title_line, $line);
@@ -7359,9 +7359,9 @@  discard block
 block discarded – undo
7359 7359
         $courseId = api_get_course_int_id($courseCode);
7360 7360
         $userId = intval($userId);
7361 7361
         $line = null;
7362
-    	if (substr($view,3,1) == '1') {
7363
-    		$new_view = substr_replace($view,'0',3,1);
7364
-    		$title[1]=get_lang('LinksDetails');
7362
+    	if (substr($view, 3, 1) == '1') {
7363
+    		$new_view = substr_replace($view, '0', 3, 1);
7364
+    		$title[1] = get_lang('LinksDetails');
7365 7365
     		$sql = "SELECT cl.title, cl.url
7366 7366
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7367 7367
                         WHERE sl.links_link_id = cl.id
@@ -7369,16 +7369,16 @@  discard block
 block discarded – undo
7369 7369
                             AND sl.links_user_id = $userId
7370 7370
                         GROUP BY cl.title, cl.url";
7371 7371
     		$results = StatsUtils::getManyResults2Col($sql);
7372
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7372
+    		$title_line = get_lang('LinksTitleLinkColumn')."\n";
7373 7373
     		if (is_array($results)) {
7374
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7374
+    			for ($j = 0; $j < count($results); $j++) {
7375 7375
     				$line .= $results[$j][0]."\n";
7376 7376
     			}
7377 7377
     		} else {
7378
-    			$line=get_lang('NoResult');
7378
+    			$line = get_lang('NoResult');
7379 7379
     		}
7380 7380
     	} else {
7381
-    		$new_view = substr_replace($view,'1',3,1);
7381
+    		$new_view = substr_replace($view, '1', 3, 1);
7382 7382
     	}
7383 7383
     	return array($title_line, $line);
7384 7384
     }
@@ -7400,9 +7400,9 @@  discard block
 block discarded – undo
7400 7400
 
7401 7401
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7402 7402
 
7403
-    	if (substr($view,4,1) == '1') {
7404
-    		$new_view = substr_replace($view,'0',4,1);
7405
-    		$title[1]= get_lang('DocumentsDetails');
7403
+    	if (substr($view, 4, 1) == '1') {
7404
+    		$new_view = substr_replace($view, '0', 4, 1);
7405
+    		$title[1] = get_lang('DocumentsDetails');
7406 7406
 
7407 7407
     		$sql = "SELECT down_doc_path
7408 7408
                         FROM $downloads_table
@@ -7415,14 +7415,14 @@  discard block
 block discarded – undo
7415 7415
     		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7416 7416
             $line = null;
7417 7417
     		if (is_array($results)) {
7418
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7418
+    			for ($j = 0; $j < count($results); $j++) {
7419 7419
     				$line .= $results[$j]."\n";
7420 7420
     			}
7421 7421
     		} else {
7422 7422
     			$line = get_lang('NoResult');
7423 7423
     		}
7424 7424
     	} else {
7425
-    		$new_view = substr_replace($view,'1',4,1);
7425
+    		$new_view = substr_replace($view, '1', 4, 1);
7426 7426
     	}
7427 7427
     	return array($title_line, $line);
7428 7428
     }
Please login to merge, or discard this patch.
plugin/buycourses/src/service_error.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
         Display::return_message($plugin->get_lang('OrderCancelled'), 'error', false)
23 23
     );
24 24
 
25
-    header('Location: '. api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/service_catalog.php');
25
+    header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
26 26
     exit;
27 27
 }
28 28
 
@@ -30,6 +30,6 @@  discard block
 block discarded – undo
30 30
     Display::return_message($plugin->get_lang('ErrorOccurred'), 'error', false)
31 31
 );
32 32
 
33
-header('Location: '. api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/service_catalog.php');
33
+header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
34 34
 
35 35
 exit;
Please login to merge, or discard this patch.
plugin/buycourses/src/service_sales_report.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
     $toolbar .= Display::toolbarButton(
62 62
         $plugin->get_lang('PaypalPayoutCommissions'),
63
-        api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/paypal_payout.php',
63
+        api_get_path(WEB_PLUGIN_PATH).'buycourses/src/paypal_payout.php',
64 64
         'paypal',
65 65
         'primary',
66 66
         ['title' => $plugin->get_lang('PaypalPayoutCommissions')]
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 
75 75
     $toolbar .= Display::toolbarButton(
76 76
         $plugin->get_lang('PayoutReport'),
77
-        api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/payout_report.php',
77
+        api_get_path(WEB_PLUGIN_PATH).'buycourses/src/payout_report.php',
78 78
         'money',
79 79
         'info',
80 80
         ['title' => $plugin->get_lang('PayoutReport')]
Please login to merge, or discard this patch.
plugin/vchamilo/lib/Virtual.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         self::getHostName($_configuration);
30 30
 
31 31
         // We are on physical chamilo. Let original config play
32
-        $virtualChamiloWebRoot = rtrim($_configuration['vchamilo_web_root'], '/') . '/';
32
+        $virtualChamiloWebRoot = rtrim($_configuration['vchamilo_web_root'], '/').'/';
33 33
 
34 34
         $virtualChamilo = [];
35 35
         if ($_configuration['root_web'] == $virtualChamiloWebRoot) {
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
         if (preg_match('#https?://#', $url)) {
225 225
             header('location: '.$url);
226 226
         } else {
227
-            header('location: ' . api_get_path(WEB_PATH).$url);
227
+            header('location: '.api_get_path(WEB_PATH).$url);
228 228
         }
229 229
         exit;
230 230
     }
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
         }
408 408
 
409 409
         // Making the command line (see 'vconfig.php' file for defining the right paths).
410
-        $sqlcmd = $pgm.' -h'.$vchamilodata->db_host.(isset($vchamilodata->db_port) ? ' -P'.$vchamilodata->db_port.' ' : ' ' );
410
+        $sqlcmd = $pgm.' -h'.$vchamilodata->db_host.(isset($vchamilodata->db_port) ? ' -P'.$vchamilodata->db_port.' ' : ' ');
411 411
         $sqlcmd .= '-u'.$vchamilodata->db_user.' '.$databasePassword;
412 412
         $sqlcmd .= '%DATABASE% < ';
413 413
 
@@ -487,10 +487,10 @@  discard block
 block discarded – undo
487 487
         //if ($CFG->ostype == 'WINDOWS') {
488 488
         if (false) {
489 489
             $cmd_main = "-h{$host} -P{$port} -u{$vchamilo->db_user} {$pass} {$vchamilo->main_database}";
490
-            $cmds[] = $cmd_main . ' > ' . $outputfilerad;
490
+            $cmds[] = $cmd_main.' > '.$outputfilerad;
491 491
         } else {
492 492
             $cmd_main = "-h{$host} -P{$port} -u{$vchamilo->db_user} {$pass} {$vchamilo->main_database}";
493
-            $cmds[] = $cmd_main . ' > ' . escapeshellarg($outputfilerad);
493
+            $cmds[] = $cmd_main.' > '.escapeshellarg($outputfilerad);
494 494
         }
495 495
 
496 496
         $mysqldumpcmd = self::getConfig('vchamilo', 'cmd_mysqldump', true);
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
                 Display::return_message('You cannot use the same database as the chamilo master', 'error')
938 938
             );
939 939
 
940
-            return ;
940
+            return;
941 941
         }
942 942
 
943 943
         $databaseName = $data->main_database;
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
                     'error'
952 952
                 )
953 953
             );
954
-            return ;
954
+            return;
955 955
         }
956 956
 
957 957
         $data->root_web = api_add_trailing_slash($data->root_web);
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
                 Display::addFlash(
976 976
                     Display::return_message('Cannot create slug from url: '.$data->root_web, 'error')
977 977
                 );
978
-                return ;
978
+                return;
979 979
             }
980 980
             Database::insert($tablename, (array) $data);
981 981
         }
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
                 $newDatabase->sitename = $siteName;
1118 1118
                 $newDatabase->institution = $institution;
1119 1119
                 $slug = $newDatabase->slug = $data->slug = Virtual::getSlugFromUrl($data->root_web);
1120
-                $id = Database::insert($table, (array)$newDatabase);
1120
+                $id = Database::insert($table, (array) $newDatabase);
1121 1121
             }
1122 1122
         }
1123 1123
 
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
             $id = (int) $id;
1295 1295
             $sql = "SELECT * FROM vchamilo WHERE id = $id";
1296 1296
             $result = Database::query($sql);
1297
-            $vhost =  (object) Database::fetch_array($result, 'ASSOC');
1297
+            $vhost = (object) Database::fetch_array($result, 'ASSOC');
1298 1298
         }
1299 1299
 
1300 1300
         return $vhost;
Please login to merge, or discard this patch.
plugin/buycourses/src/service_information.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 }
30 30
 
31 31
 $template = new Template(false);
32
-$template->assign('pageUrl', api_get_path(WEB_PATH) . "service/{$serviceId}/information/");
32
+$template->assign('pageUrl', api_get_path(WEB_PATH)."service/{$serviceId}/information/");
33 33
 $template->assign('service', $service);
34 34
 $template->assign('essence', Essence\Essence::instance());
35 35
 
Please login to merge, or discard this patch.
plugin/buycourses/src/service_process.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 require_once '../config.php';
14 14
 
15 15
 if (!isset($_REQUEST['t'], $_REQUEST['i'])) {
16
-    header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/service_catalog.php');
16
+    header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
17 17
 }
18 18
 
19 19
 $currentUserId = api_get_user_id();
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 $typeUser = intval($_REQUEST['t']) === BuyCoursesPlugin::SERVICE_TYPE_USER;
38 38
 $typeCourse = intval($_REQUEST['t']) === BuyCoursesPlugin::SERVICE_TYPE_COURSE;
39 39
 $typeSession = intval($_REQUEST['t']) === BuyCoursesPlugin::SERVICE_TYPE_SESSION;
40
-$queryString = 'i=' . intval($_REQUEST['i']) . '&t=' . intval($_REQUEST['t']).$additionalQueryString;
40
+$queryString = 'i='.intval($_REQUEST['i']).'&t='.intval($_REQUEST['t']).$additionalQueryString;
41 41
 
42 42
 $serviceInfo = $plugin->getServices(intval($_REQUEST['i']));
43 43
 $userInfo = api_get_user_info($currentUserId);
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         Display::addFlash(
52 52
             Display::return_message($plugin->get_lang('NeedToSelectPaymentType'), 'error', false)
53 53
         );
54
-        header('Location:' . api_get_self() . '?' . $queryString);
54
+        header('Location:'.api_get_self().'?'.$queryString);
55 55
         exit;
56 56
     }
57 57
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         Display::addFlash(
60 60
             Display::return_message($plugin->get_lang('AdditionalInfoRequired'), 'error', false)
61 61
         );
62
-        header('Location:' . api_get_self() . '?' . $queryString);
62
+        header('Location:'.api_get_self().'?'.$queryString);
63 63
         exit;
64 64
     }
65 65
     
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     if ($serviceSaleId !== false) {
69 69
         $_SESSION['bc_service_sale_id'] = $serviceSaleId;
70 70
 
71
-        header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/service_process_confirm.php');
71
+        header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_process_confirm.php');
72 72
     }
73 73
 
74 74
     exit;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 if ($typeUser) {
87 87
     $users = $em->getRepository('ChamiloUserBundle:User')->findAll();
88
-    $selectOptions[$userInfo['user_id']] = api_get_person_name($userInfo['firstname'], $userInfo['lastname']) . ' (' . get_lang('Myself') . ')';
88
+    $selectOptions[$userInfo['user_id']] = api_get_person_name($userInfo['firstname'], $userInfo['lastname']).' ('.get_lang('Myself').')';
89 89
     if (!empty($users)) {
90 90
         foreach ($users as $user) {
91 91
             if (intval($userInfo['user_id']) !== intval($user->getId())) {
Please login to merge, or discard this patch.
plugin/buycourses/src/service_success.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             Display::return_message($plugin->get_lang('OrderCancelled'), 'error', false)
52 52
         );
53 53
 
54
-        header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/service_catalog.php');
54
+        header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
55 55
         exit;
56 56
     }
57 57
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             Display::return_message($erroMessage, 'error', false)
67 67
         );
68 68
         unset($_SESSION['wizard']);
69
-        header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/service_catalog.php');
69
+        header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
70 70
         exit;
71 71
     }
72 72
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
     unset($_SESSION['bc_service_sale_id']);
152 152
 
153
-    header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/service_catalog.php');
153
+    header('Location: '.api_get_path(WEB_PLUGIN_PATH).'buycourses/src/service_catalog.php');
154 154
 
155 155
     exit;
156 156
 }
Please login to merge, or discard this patch.
main/document/document_slideshow.inc.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
 function sort_files($table)
72 72
 {
73 73
     $tablename_direction = isset($_GET['tablename_direction']) ? Security::remove_XSS($_GET['tablename_direction']) : 'ASC';
74
-    $accepted_extensions = array('.jpg', '.jpeg', '.gif', '.png', '.bmp','.svg');
74
+    $accepted_extensions = array('.jpg', '.jpeg', '.gif', '.png', '.bmp', '.svg');
75 75
     $temp = array();
76 76
 
77 77
     foreach ($table as & $file_array) {
Please login to merge, or discard this patch.
main/install/install.lib.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     if (!is_array($result)) {
409 409
         $result = array();
410 410
         $exceptions = array('.', '..', 'CVS', '.svn');
411
-        $search       = array('_latin',   '_unicode',   '_corporate',   '_org'  , '_KM',   '_');
411
+        $search       = array('_latin', '_unicode', '_corporate', '_org', '_KM', '_');
412 412
         $replace_with = array(' (Latin)', ' (unicode)', ' (corporate)', ' (org)', ' (KM)', ' ');
413 413
         $dirname = api_get_path(SYS_LANG_PATH);
414 414
         $handle = opendir($dirname);
@@ -443,9 +443,9 @@  discard block
 block discarded – undo
443 443
     if ($handle = opendir($directory)) {
444 444
         while (false !== ($file = readdir($handle))) {
445 445
             if ($file != "." && $file != "..") {
446
-                if (is_dir($directory. "/" . $file)) {
447
-                    $array_items = array_merge($array_items, my_directory_to_array($directory. '/' . $file));
448
-                    $file = $directory . "/" . $file;
446
+                if (is_dir($directory."/".$file)) {
447
+                    $array_items = array_merge($array_items, my_directory_to_array($directory.'/'.$file));
448
+                    $file = $directory."/".$file;
449 449
                     $array_items[] = preg_replace("/\/\//si", '/', $file);
450 450
                 }
451 451
             }
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
         // try to recover config file from Chamilo 1.9.x
491 491
         if (file_exists($updatePath.'main/inc/conf/configuration.php')) {
492 492
             $updateFromConfigFile = 'main/inc/conf/configuration.php';
493
-        } elseif (file_exists($updatePath . 'app/config/configuration.php')) {
493
+        } elseif (file_exists($updatePath.'app/config/configuration.php')) {
494 494
             $updateFromConfigFile = 'app/config/configuration.php';
495 495
         } else {
496 496
             // Give up recovering.
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
     <h2><?php get_lang('WelcomeToTheChamiloInstaller'); ?></h2>
652 652
     <div class="RequirementHeading">
653 653
         <h2><?php echo display_step_sequence(); ?>
654
-            <?php echo get_lang('InstallationLanguage');?>
654
+            <?php echo get_lang('InstallationLanguage'); ?>
655 655
         </h2>
656 656
         <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage'); ?>:</p>
657 657
         <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>">
@@ -705,14 +705,14 @@  discard block
 block discarded – undo
705 705
     }
706 706
     echo '</div>';
707 707
 
708
-    $properlyAccessUrl =  checkAccessUrl();
708
+    $properlyAccessUrl = checkAccessUrl();
709 709
 
710 710
     if (!$properlyAccessUrl) {
711 711
         echo '
712 712
             <div class="alert alert-danger">
713
-                ' . Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_MEDIUM) .
714
-            ' ' .
715
-            sprintf(get_lang('InstallMultiURLDetectedNotMainURL'), api_get_configuration_value('root_web')) . '
713
+                ' . Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_MEDIUM).
714
+            ' '.
715
+            sprintf(get_lang('InstallMultiURLDetectedNotMainURL'), api_get_configuration_value('root_web')).'
716 716
             </div>
717 717
         ';
718 718
     }
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
     if (phpversion() < REQUIRED_PHP_VERSION) {
737 737
         echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>';
738 738
     } else {
739
-        echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>';
739
+        echo '<strong><font color="green">'.get_lang('PHPVersionOK').' '.phpversion().'</font></strong>';
740 740
     }
741 741
     echo '</td>
742 742
             </tr>
@@ -1094,9 +1094,9 @@  discard block
 block discarded – undo
1094 1094
         }
1095 1095
 
1096 1096
         $deprecated = [
1097
-            api_get_path(SYS_CODE_PATH) . 'exercice/',
1098
-            api_get_path(SYS_CODE_PATH) . 'newscorm/',
1099
-            api_get_path(SYS_PLUGIN_PATH) . 'ticket/'
1097
+            api_get_path(SYS_CODE_PATH).'exercice/',
1098
+            api_get_path(SYS_CODE_PATH).'newscorm/',
1099
+            api_get_path(SYS_PLUGIN_PATH).'ticket/'
1100 1100
         ];
1101 1101
         $deprecatedToRemove = [];
1102 1102
 
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
 function get_contact_registration_form()
1207 1207
 {
1208 1208
 
1209
-    $html ='
1209
+    $html = '
1210 1210
    <div class="form-horizontal">
1211 1211
     <div class="panel panel-default">
1212 1212
     <div class="panel-body">
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
         <div class="col-sm-9">
1304 1304
             <div class="radio">
1305 1305
                 <label>
1306
-                    <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes') . '
1306
+                    <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes').'
1307 1307
                 </label>
1308 1308
             </div>
1309 1309
             <div class="radio">
@@ -1362,8 +1362,8 @@  discard block
 block discarded – undo
1362 1362
             echo '<input type="hidden" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />';
1363 1363
             echo api_htmlentities($parameterValue);
1364 1364
         } else {
1365
-            echo '<div class="col-sm-5"><input type="' . $inputType . '" class="form-control" size="' . DATABASE_FORM_FIELD_DISPLAY_LENGTH . '" maxlength="' . $maxLength . '" name="' . $formFieldName . '" id="' . $formFieldName . '" value="' . api_htmlentities($parameterValue) . '" />' . "</div>";
1366
-            echo '<div class="col-sm-3">' . $extra_notice . '</div>';
1365
+            echo '<div class="col-sm-5"><input type="'.$inputType.'" class="form-control" size="'.DATABASE_FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.$maxLength.'" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />'."</div>";
1366
+            echo '<div class="col-sm-3">'.$extra_notice.'</div>';
1367 1367
         }
1368 1368
     }
1369 1369
 }
@@ -1397,12 +1397,12 @@  discard block
 block discarded – undo
1397 1397
         $dbNameForm = $_configuration['main_database'];
1398 1398
         $dbPortForm = isset($_configuration['db_port']) ? $_configuration['db_port'] : '';
1399 1399
 
1400
-        echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>';
1400
+        echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>';
1401 1401
         echo '<div class="RequirementContent">';
1402 1402
         echo get_lang('DBSettingUpgradeIntro');
1403 1403
         echo '</div>';
1404 1404
     } else {
1405
-        echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>';
1405
+        echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>';
1406 1406
         echo '<div class="RequirementContent">';
1407 1407
         echo get_lang('DBSettingIntro');
1408 1408
         echo '</div>';
@@ -1412,12 +1412,12 @@  discard block
 block discarded – undo
1412 1412
         <div class="panel-body">
1413 1413
         <div class="form-group">
1414 1414
             <label class="col-sm-4"><?php echo get_lang('DBHost'); ?> </label>
1415
-            <?php if ($installType == 'update'){ ?>
1415
+            <?php if ($installType == 'update') { ?>
1416 1416
             <div class="col-sm-5">
1417 1417
                 <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?>
1418 1418
             </div>
1419 1419
             <div class="col-sm-3"></div>
1420
-            <?php }else{ ?>
1420
+            <?php } else { ?>
1421 1421
             <div class="col-sm-5">
1422 1422
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" />
1423 1423
             </div>
@@ -1426,12 +1426,12 @@  discard block
 block discarded – undo
1426 1426
         </div>
1427 1427
         <div class="form-group">
1428 1428
             <label class="col-sm-4"><?php echo get_lang('DBPort'); ?> </label>
1429
-            <?php if ($installType == 'update'){ ?>
1429
+            <?php if ($installType == 'update') { ?>
1430 1430
             <div class="col-sm-5">
1431 1431
                 <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?>
1432 1432
             </div>
1433 1433
             <div class="col-sm-3"></div>
1434
-            <?php }else{ ?>
1434
+            <?php } else { ?>
1435 1435
             <div class="col-sm-5">
1436 1436
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" />
1437 1437
             </div>
@@ -1457,7 +1457,7 @@  discard block
 block discarded – undo
1457 1457
             <?php
1458 1458
             //Database Name fix replace weird chars
1459 1459
             if ($installType != INSTALL_TYPE_UPDATE) {
1460
-                $dbNameForm = str_replace(array('-','*', '$', ' ', '.'), '', $dbNameForm);
1460
+                $dbNameForm = str_replace(array('-', '*', '$', ' ', '.'), '', $dbNameForm);
1461 1461
             }
1462 1462
 
1463 1463
             displayDatabaseParameter(
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
     if (!empty($title)) {
1551 1551
         $panelTitle = Display::div($title, array('class' => 'panel-heading'));
1552 1552
         $panelBody = Display::div($content, array('class' => 'panel-body'));
1553
-        $panelParent = Display::div($panelTitle . $panelBody, array('id' => $id, 'class' => 'panel panel-'.$style));
1553
+        $panelParent = Display::div($panelTitle.$panelBody, array('id' => $id, 'class' => 'panel panel-'.$style));
1554 1554
     } else {
1555 1555
         $panelBody = Display::div($html, array('class' => 'panel-body'));
1556 1556
         $panelParent = Display::div($panelBody, array('id' => $id, 'class' => 'panel panel-'.$style));
@@ -1576,9 +1576,9 @@  discard block
 block discarded – undo
1576 1576
     $displayWhenUpdate = 'true'
1577 1577
 ) {
1578 1578
     $html = '<div class="form-group">';
1579
-    $html .= '<label class="col-sm-6 control-label">' . $parameterName . '</label>';
1579
+    $html .= '<label class="col-sm-6 control-label">'.$parameterName.'</label>';
1580 1580
     if ($installType == INSTALL_TYPE_UPDATE && $displayWhenUpdate) {
1581
-        $html .= '<input type="hidden" name="' . $formFieldName . '" value="'. api_htmlentities($parameterValue, ENT_QUOTES). '" />' . $parameterValue;
1581
+        $html .= '<input type="hidden" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'.$parameterValue;
1582 1582
     } else {
1583 1583
         $html .= '<div class="col-sm-6"><input class="form-control" type="text" size="'.FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'."</div>";
1584 1584
     }
@@ -1626,7 +1626,7 @@  discard block
 block discarded – undo
1626 1626
         $languageForm = $_SESSION['install_language'];
1627 1627
     }
1628 1628
     echo '<div class="RequirementHeading">';
1629
-    echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>";
1629
+    echo "<h2>".display_step_sequence().get_lang("CfgSetting")."</h2>";
1630 1630
     echo '</div>';
1631 1631
 
1632 1632
     echo '<p>'.get_lang('ConfigSettingsInfo').' <strong>app/config/configuration.php</strong></p>';
@@ -1644,14 +1644,14 @@  discard block
 block discarded – undo
1644 1644
 
1645 1645
     // Parameters 3 and 4: administrator's names
1646 1646
 
1647
-    $html .=  display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
1648
-    $html .=  display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
1647
+    $html .= display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
1648
+    $html .= display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
1649 1649
 
1650 1650
     //Parameter 3: administrator's email
1651
-    $html .=  display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm);
1651
+    $html .= display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm);
1652 1652
 
1653 1653
     //Parameter 6: administrator's telephone
1654
-    $html .=  display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm);
1654
+    $html .= display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm);
1655 1655
 
1656 1656
 
1657 1657
     echo panel($html, get_lang('Administrator'), 'administrator');
@@ -1670,12 +1670,12 @@  discard block
 block discarded – undo
1670 1670
         $html .= display_language_selection_box('languageForm', $languageForm);
1671 1671
         $html .= '</div>';
1672 1672
     }
1673
-    $html.= "</div>";
1673
+    $html .= "</div>";
1674 1674
 
1675 1675
 
1676 1676
     //Second parameter: Chamilo URL
1677 1677
     $html .= '<div class="form-group">';
1678
-    $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL') .get_lang('ThisFieldIsRequired').'</label>';
1678
+    $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL').get_lang('ThisFieldIsRequired').'</label>';
1679 1679
 
1680 1680
 
1681 1681
 
@@ -1699,34 +1699,34 @@  discard block
 block discarded – undo
1699 1699
 
1700 1700
 
1701 1701
     $html .= '<div class="form-group">
1702
-            <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass") . '</label>
1702
+            <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass").'</label>
1703 1703
         <div class="col-sm-6">';
1704 1704
     if ($installType == 'update') {
1705
-        $html .= '<input type="hidden" name="encryptPassForm" value="'. $encryptPassForm .'" />'. $encryptPassForm;
1705
+        $html .= '<input type="hidden" name="encryptPassForm" value="'.$encryptPassForm.'" />'.$encryptPassForm;
1706 1706
     } else {
1707 1707
 
1708 1708
         $html .= '<div class="checkbox">
1709 1709
                     <label>
1710
-                        <input  type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ':'') .'/> bcrypt
1710
+                        <input  type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ' : '').'/> bcrypt
1711 1711
                     </label>';
1712 1712
 
1713 1713
         $html .= '<label>
1714
-                        <input  type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ':'') .'/> sha1
1714
+                        <input  type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ' : '').'/> sha1
1715 1715
                     </label>';
1716 1716
 
1717 1717
         $html .= '<label>
1718
-                        <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ':'') .'/> md5
1718
+                        <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ' : '').'/> md5
1719 1719
                     </label>';
1720 1720
 
1721 1721
         $html .= '<label>
1722
-                        <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ':'') .'/>'. get_lang('None').'
1722
+                        <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ' : '').'/>'.get_lang('None').'
1723 1723
                     </label>';
1724 1724
         $html .= '</div>';
1725 1725
     }
1726 1726
     $html .= '</div></div>';
1727 1727
 
1728 1728
     $html .= '<div class="form-group">
1729
-            <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg') . '</label>
1729
+            <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg').'</label>
1730 1730
             <div class="col-sm-6">';
1731 1731
     if ($installType == 'update') {
1732 1732
         if ($allowSelfReg == 'true') {
@@ -1736,17 +1736,17 @@  discard block
 block discarded – undo
1736 1736
         } else {
1737 1737
             $label = get_lang('AfterApproval');
1738 1738
         }
1739
-        $html .= '<input type="hidden" name="allowSelfReg" value="'. $allowSelfReg .'" />'. $label;
1739
+        $html .= '<input type="hidden" name="allowSelfReg" value="'.$allowSelfReg.'" />'.$label;
1740 1740
     } else {
1741 1741
         $html .= '<div class="control-group">';
1742 1742
         $html .= '<label class="checkbox-inline">
1743
-                        <input type="radio" name="allowSelfReg" value="true" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '') . ' /> '. get_lang('Yes') .'
1743
+                        <input type="radio" name="allowSelfReg" value="true" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '').' /> '.get_lang('Yes').'
1744 1744
                     </label>';
1745 1745
         $html .= '<label class="checkbox-inline">
1746
-                        <input type="radio" name="allowSelfReg" value="false" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .'
1746
+                        <input type="radio" name="allowSelfReg" value="false" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ').' /> '.get_lang('No').'
1747 1747
                     </label>';
1748 1748
          $html .= '<label class="checkbox-inline">
1749
-                    <input type="radio" name="allowSelfReg" value="approval" id="allowSelfReg2" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .'
1749
+                    <input type="radio" name="allowSelfReg" value="approval" id="allowSelfReg2" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ').' /> '.get_lang('AfterApproval').'
1750 1750
                 </label>';
1751 1751
         $html .= '</div>';
1752 1752
     }
@@ -1754,7 +1754,7 @@  discard block
 block discarded – undo
1754 1754
     $html .= '</div>';
1755 1755
 
1756 1756
     $html .= '<div class="form-group">';
1757
-    $html .= '<label class="col-sm-6 control-label">'. get_lang('AllowSelfRegProf') .'</label>
1757
+    $html .= '<label class="col-sm-6 control-label">'.get_lang('AllowSelfRegProf').'</label>
1758 1758
         <div class="col-sm-6">';
1759 1759
     if ($installType == 'update') {
1760 1760
         if ($allowSelfRegProf == 'true') {
@@ -1762,16 +1762,16 @@  discard block
 block discarded – undo
1762 1762
         } else {
1763 1763
             $label = get_lang('No');
1764 1764
         }
1765
-        $html .= '<input type="hidden" name="allowSelfRegProf" value="'. $allowSelfRegProf.'" />'. $label;
1765
+        $html .= '<input type="hidden" name="allowSelfRegProf" value="'.$allowSelfRegProf.'" />'.$label;
1766 1766
     } else {
1767 1767
         $html .= '<div class="control-group">
1768 1768
                 <label class="checkbox-inline">
1769
-                    <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '') .'/>
1770
-                ' . get_lang('Yes') .'
1769
+                    <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '').'/>
1770
+                ' . get_lang('Yes').'
1771 1771
                 </label>';
1772 1772
         $html .= '<label class="checkbox-inline">
1773
-                    <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ') .' />
1774
-                   '. get_lang('No') .'
1773
+                    <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ').' />
1774
+                   '. get_lang('No').'
1775 1775
                 </label>';
1776 1776
         $html .= '</div>';
1777 1777
     }
@@ -1836,7 +1836,7 @@  discard block
 block discarded – undo
1836 1836
         "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar",
1837 1837
         "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway",
1838 1838
         "Oman",
1839
-        "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland","Portugal",
1839
+        "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal",
1840 1840
         "Qatar",
1841 1841
         "Romania", "Russia", "Rwanda",
1842 1842
         "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria",
@@ -1883,11 +1883,11 @@  discard block
 block discarded – undo
1883 1883
     $permissions_for_new_directories = isset($_SESSION['permissions_for_new_directories']) ? $_SESSION['permissions_for_new_directories'] : 0770;
1884 1884
     $permissions_for_new_files = isset($_SESSION['permissions_for_new_files']) ? $_SESSION['permissions_for_new_files'] : 0660;
1885 1885
     // use decoct() to store as string
1886
-    $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_directories) . "'
1886
+    $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_directories)."'
1887 1887
               WHERE variable  = 'permissions_for_new_directories'";
1888 1888
     Database::query($sql);
1889 1889
 
1890
-    $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_files) . "' WHERE variable  = 'permissions_for_new_files'";
1890
+    $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_files)."' WHERE variable  = 'permissions_for_new_files'";
1891 1891
     Database::query($sql);
1892 1892
 
1893 1893
     if (isset($_SESSION['permissions_for_new_directories'])) {
@@ -1907,8 +1907,8 @@  discard block
 block discarded – undo
1907 1907
 function compare_setting_values($current_value, $wanted_value)
1908 1908
 {
1909 1909
     $current_value_string = $current_value;
1910
-    $current_value = (float)$current_value;
1911
-    $wanted_value = (float)$wanted_value;
1910
+    $current_value = (float) $current_value;
1911
+    $wanted_value = (float) $wanted_value;
1912 1912
 
1913 1913
     if ($current_value >= $wanted_value) {
1914 1914
         return Display::label($current_value_string, 'success');
@@ -1971,7 +1971,7 @@  discard block
 block discarded – undo
1971 1971
 
1972 1972
                     fwrite($fp, $out);
1973 1973
                     while (!feof($fp)) {
1974
-                        $result = str_replace("\r\n", '',fgets($fp, 128));
1974
+                        $result = str_replace("\r\n", '', fgets($fp, 128));
1975 1975
                         if (!empty($result) && $result == '123') {
1976 1976
                             $output = true;
1977 1977
                         }
@@ -1994,7 +1994,7 @@  discard block
 block discarded – undo
1994 1994
                     curl_setopt($ch, CURLOPT_URL, $url);
1995 1995
                     //curl_setopt($ch, CURLOPT_TIMEOUT, 30);
1996 1996
                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1997
-                    $result = curl_exec ($ch);
1997
+                    $result = curl_exec($ch);
1998 1998
                     if (!empty($result) && $result == '123') {
1999 1999
                         $output = true;
2000 2000
                     }
@@ -2755,12 +2755,12 @@  discard block
 block discarded – undo
2755 2755
         $adminPhoneForm,
2756 2756
         '', //$picture_uri = '',
2757 2757
         PLATFORM_AUTH_SOURCE,
2758
-        '',//$expirationDate,
2758
+        '', //$expirationDate,
2759 2759
         1,
2760 2760
         0,
2761 2761
         null,
2762 2762
         '',
2763
-        false,  //$send_mail = false,
2763
+        false, //$send_mail = false,
2764 2764
         true //$isAdmin = false
2765 2765
     );
2766 2766
 
@@ -2782,7 +2782,7 @@  discard block
 block discarded – undo
2782 2782
         0,
2783 2783
         null,
2784 2784
         '',
2785
-        false,  //$send_mail = false,
2785
+        false, //$send_mail = false,
2786 2786
         false //$isAdmin = false
2787 2787
     );
2788 2788
 
@@ -2817,7 +2817,7 @@  discard block
 block discarded – undo
2817 2817
     Database::query($sql);
2818 2818
 
2819 2819
     foreach ($files as $version) {
2820
-        $version = str_replace(['Version',  '.php' ], '', $version->getFilename());
2820
+        $version = str_replace(['Version', '.php'], '', $version->getFilename());
2821 2821
         $sql = "INSERT INTO version (version) VALUES ('$version')";
2822 2822
         Database::query($sql);
2823 2823
     }
@@ -2863,7 +2863,7 @@  discard block
 block discarded – undo
2863 2863
                 SET selected_value = '".$param->selected_value."'
2864 2864
                 WHERE variable = '".$param->variable."'";
2865 2865
         if (!empty($param->subkey)) {
2866
-            $sql .= " AND subkey='" . $param->subkey . "'";
2866
+            $sql .= " AND subkey='".$param->subkey."'";
2867 2867
         }
2868 2868
         Database::query($sql);
2869 2869
     }
Please login to merge, or discard this patch.