Completed
Push — 1.10.x ( d91a6d...49fbc2 )
by Julito
66:49 queued 22:44
created
main/tracking/exams.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
 if (!$exportToXLS) {
83 83
     Display :: display_header(get_lang('Reporting'));
84
-    $actionsLeft = $actionsRight ='';
84
+    $actionsLeft = $actionsRight = '';
85 85
     if ($global) {
86 86
 
87 87
         $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'auth/my_progress.php">'.
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
         }
99 99
 
100 100
         $actionsRight .= '<a href="'.api_get_self().'?export=1&score='.$filter_score.'&exercise_id='.$exerciseId.'&'.$courseLink.'">'.
101
-            Display::return_icon('export_excel.png',get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a>';
101
+            Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
102 102
         $actionsRight .= '<a href="javascript: void(0);" onclick="javascript: window.print()">'.
103
-            Display::return_icon('printer.png',get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
103
+            Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).'</a>';
104 104
 
105 105
 
106 106
         $menuItems[] = Display::url(
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     }
148 148
 
149 149
 
150
-    $toolbar = Display::toolbarAction('toolbar-exams', $content = array( 0 => $actionsLeft, 1 => $actionsRight ));
150
+    $toolbar = Display::toolbarAction('toolbar-exams', $content = array(0 => $actionsLeft, 1 => $actionsRight));
151 151
     echo $toolbar;
152 152
 
153 153
     $form->display();
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             $countExercises = Database::store_result($result);
208 208
             $exerciseSessionCount = $countExercises[0]['count'];
209 209
 
210
-            $exerciseCount =  $exerciseCount + $exerciseCount * count($newSessionList) + $exerciseSessionCount;
210
+            $exerciseCount = $exerciseCount + $exerciseCount * count($newSessionList) + $exerciseSessionCount;
211 211
 
212 212
             // Add course and session list.
213 213
             if ($exerciseCount == 0) {
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
         $column++;
425 425
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ExamNotTaken'));
426 426
         $column++;
427
-        $worksheet->setCellValueByColumnAndRow($column, $line, sprintf(get_lang('ExamPassX'), $filter_score) . '%');
427
+        $worksheet->setCellValueByColumnAndRow($column, $line, sprintf(get_lang('ExamPassX'), $filter_score).'%');
428 428
         $column++;
429 429
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ExamFail'));
430 430
         $column++;
@@ -601,10 +601,10 @@  discard block
 block discarded – undo
601 601
         $percentageScore = 0;
602 602
 
603 603
         if ($weighting != 0) {
604
-            $percentageScore = round(($score*100)/$weighting);
604
+            $percentageScore = round(($score * 100) / $weighting);
605 605
         }
606 606
 
607
-        if ($attempts['count'] > 0 ) {
607
+        if ($attempts['count'] > 0) {
608 608
             $taken++;
609 609
         }
610 610
 
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
             } else {
648 648
                 $score = '-';
649 649
                 $userRow .= '<td>';
650
-                $userRow .=  '-';
650
+                $userRow .= '-';
651 651
                 $tempArray[] = '-';
652 652
                 $userRow .= '</td>';
653 653
 
@@ -701,13 +701,13 @@  discard block
 block discarded – undo
701 701
         // Exam taken
702 702
         $html .= '<td>';
703 703
         $html .= $taken;
704
-        $globalRow[]= $taken;
704
+        $globalRow[] = $taken;
705 705
         $html .= '</td>';
706 706
 
707 707
         // Exam NOT taken
708 708
         $html .= '<td>';
709 709
         $html .= $not_taken = $totalStudents - $taken;
710
-        $globalRow[]= $not_taken;
710
+        $globalRow[] = $not_taken;
711 711
         $html .= '</td>';
712 712
 
713 713
         // Exam pass
@@ -718,19 +718,19 @@  discard block
 block discarded – undo
718 718
         }
719 719
 
720 720
         $html .= $total_with_parameter_score;
721
-        $globalRow[]= $total_with_parameter_score;
721
+        $globalRow[] = $total_with_parameter_score;
722 722
         $html .= '</td>';
723 723
 
724 724
         // Exam fail
725 725
         $html .= '<td>';
726 726
 
727 727
         $html .= $fail = $taken - $total_with_parameter_score;
728
-        $globalRow[]= $fail;
728
+        $globalRow[] = $fail;
729 729
         $html .= '</td>';
730 730
 
731 731
         $html .= '<td>';
732 732
         $html .= $totalStudents;
733
-        $globalRow[]= $totalStudents;
733
+        $globalRow[] = $totalStudents;
734 734
 
735 735
         $html .= '</td>';
736 736
 
Please login to merge, or discard this patch.
main/survey/survey.lib.php 1 patch
Spacing   +174 added lines, -175 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
             $result = Database::query($sql);
36 36
             if (Database::num_rows($result)) {
37 37
                 $num++;
38
-                $new_code = $code . $num;
38
+                $new_code = $code.$num;
39 39
             } else {
40 40
                 break;
41 41
             }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $sql = "SELECT survey_invitation_id, survey_code
64 64
                 FROM $table_survey_invitation WHERE user = '$user_id' AND c_id <> 0 ";
65 65
         $result = Database::query($sql);
66
-        while ($row = Database::fetch_array($result ,'ASSOC')){
66
+        while ($row = Database::fetch_array($result, 'ASSOC')) {
67 67
             $survey_invitation_id = $row['survey_invitation_id'];
68 68
             $survey_code = $row['survey_code'];
69 69
             $sql2 = "DELETE FROM $table_survey_invitation
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         $table_survey = Database :: get_course_table(TABLE_SURVEY);
130 130
 
131 131
         if ($shared != 0) {
132
-            $table_survey	= Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION);
132
+            $table_survey = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION);
133 133
             $sql = "SELECT * FROM $table_survey
134 134
                     WHERE survey_id='".intval($survey_id)."' ";
135 135
         } else {
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
         $result = Database::query($sql);
143 143
         $return = array();
144 144
 
145
-        if (Database::num_rows($result)> 0) {
146
-            $return = Database::fetch_array($result,'ASSOC');
145
+        if (Database::num_rows($result) > 0) {
146
+            $return = Database::fetch_array($result, 'ASSOC');
147 147
             if ($simple_return) {
148 148
                 return $return;
149 149
             }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         $course_id = api_get_course_int_id();
188 188
         $session_id = api_get_session_id();
189 189
         $courseCode = api_get_course_id();
190
-        $table_survey 	= Database :: get_course_table(TABLE_SURVEY);
190
+        $table_survey = Database :: get_course_table(TABLE_SURVEY);
191 191
         $shared_survey_id = 0;
192 192
 
193 193
         if (!isset($values['survey_id'])) {
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
                             if ($values[$field] == '') {
234 234
                                 $values[$field] = 0;
235 235
                             }
236
-                            $field_values.= $field.':'.$values[$field].'@';
236
+                            $field_values .= $field.':'.$values[$field].'@';
237 237
                         }
238 238
                     }
239 239
                     $extraParams['form_fields'] = $field_values;
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
             if ($values['anonymous'] == 0) {
386 386
                 $extraParams['show_form_profile'] = $values['show_form_profile'];
387 387
                 if ($values['show_form_profile'] == 1) {
388
-                    $fields = explode(',',$values['input_name_list']);
388
+                    $fields = explode(',', $values['input_name_list']);
389 389
                     $field_values = '';
390 390
                     foreach ($fields as &$field) {
391 391
                         if ($field != '') {
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
                             ) {
395 395
                                 $values[$field] = 0;
396 396
                             }
397
-                            $field_values.= $field.':'.$values[$field].'@';
397
+                            $field_values .= $field.':'.$values[$field].'@';
398 398
                         }
399 399
                     }
400 400
                     $extraParams['form_fields'] = $field_values;
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         $_course = api_get_course_info();
527 527
 
528 528
         // Table definitions
529
-        $table_survey	= Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY);
529
+        $table_survey = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY);
530 530
 
531 531
         if (!$values['survey_id'] ||
532 532
             !is_numeric($values['survey_id']) ||
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
                     '".api_get_utc_datetime()."',
545 545
                     '".$_course['id']."')";
546 546
             Database::query($sql);
547
-            $return	= Database::insert_id();
547
+            $return = Database::insert_id();
548 548
 
549 549
             $sql = "UPDATE $table_survey SET survey_id = $return WHERE iid = $return";
550 550
             Database::query($sql);
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
                         surveythanks	= '".Database::escape_string($values['survey_thanks'])."'
562 562
 					WHERE survey_id = '".Database::escape_string($values['survey_share']['survey_share'])."'";
563 563
             Database::query($sql);
564
-            $return	= $values['survey_share']['survey_share'];
564
+            $return = $values['survey_share']['survey_share'];
565 565
         }
566 566
 
567 567
         return $return;
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
             $params['c_id'] = $targetCourseId;
660 660
             unset($params['survey_id']);
661 661
             $params['session_id'] = api_get_session_id();
662
-            $params['title'] = $params['title'] . ' ' . get_lang('Copy');
662
+            $params['title'] = $params['title'].' '.get_lang('Copy');
663 663
             unset($params['iid']);
664 664
             Database::insert($table_survey, $params);
665 665
             $new_survey_id = Database::insert_id();
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
         $sql = "SELECT * FROM $table_survey_question_group
686 686
                 WHERE c_id = $course_id AND  survey_id='".$survey_id."'";
687 687
         $res = Database::query($sql);
688
-        while($row = Database::fetch_array($res, 'ASSOC')) {
688
+        while ($row = Database::fetch_array($res, 'ASSOC')) {
689 689
             $params = array(
690 690
                 'c_id' =>  $targetCourseId,
691 691
                 'name' => $row['name'],
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
                 WHERE c_id = $course_id AND survey_id='".$survey_id."'";
733 733
 
734 734
         $res = Database::query($sql);
735
-        while ($row = Database::fetch_array($res ,'ASSOC')) {
735
+        while ($row = Database::fetch_array($res, 'ASSOC')) {
736 736
             $params = array(
737 737
                 'c_id' =>  $targetCourseId,
738 738
                 'question_id' => $question_id[$row['question_id']],
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
     {
898 898
         // Table definitions
899 899
         $tbl_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
900
-        $table_survey_question_option 	= Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
900
+        $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
901 901
         $course_id = api_get_course_int_id();
902 902
 
903 903
         $sql = "SELECT * FROM $tbl_survey_question
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
         // Getting the information of the question
924 924
 
925 925
         $result = Database::query($sql);
926
-        $row = Database::fetch_array($result,'ASSOC');
926
+        $row = Database::fetch_array($result, 'ASSOC');
927 927
 
928 928
         $return['survey_id'] = $row['survey_id'];
929 929
         $return['question_id'] = $row['question_id'];
@@ -971,8 +971,8 @@  discard block
 block discarded – undo
971 971
     public static function get_questions($survey_id, $course_id = '')
972 972
     {
973 973
         // Table definitions
974
-        $tbl_survey_question 			= Database :: get_course_table(TABLE_SURVEY_QUESTION);
975
-        $table_survey_question_option 	= Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
974
+        $tbl_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
975
+        $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
976 976
 
977 977
         if (empty($course_id)) {
978 978
             $course_id = api_get_course_int_id();
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 					        FROM $tbl_survey_question
1077 1077
                             WHERE c_id = $course_id AND survey_id='".intval($form_content['survey_id'])."'";
1078 1078
                     $result = Database::query($sql);
1079
-                    $row = Database::fetch_array($result,'ASSOC');
1079
+                    $row = Database::fetch_array($result, 'ASSOC');
1080 1080
                     $max_sort = $row['max_sort'];
1081 1081
 
1082 1082
                     // Some variables defined for survey-test type
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
                     WHERE survey_id='".intval($survey_data['survey_share'])."'
1214 1214
                     AND code='".Database::escape_string($_course['id'])."'";
1215 1215
             $result = Database::query($sql);
1216
-            $row = Database::fetch_array($result,'ASSOC');
1216
+            $row = Database::fetch_array($result, 'ASSOC');
1217 1217
             $max_sort = $row['max_sort'];
1218 1218
 
1219 1219
             // Adding the question to the survey_question table
@@ -1223,11 +1223,11 @@  discard block
 block discarded – undo
1223 1223
                     '".Database::escape_string($form_content['question_comment'])."',
1224 1224
                     '".Database::escape_string($form_content['type'])."',
1225 1225
                     '".Database::escape_string($form_content['horizontalvertical'])."',
1226
-                    '".Database::escape_string($max_sort+1)."',
1226
+                    '".Database::escape_string($max_sort + 1)."',
1227 1227
                     '".Database::escape_string($_course['id'])."')";
1228 1228
             Database::query($sql);
1229 1229
             $shared_question_id = Database::insert_id();
1230
-        }  else {
1230
+        } else {
1231 1231
             // Updating an existing question
1232 1232
             // adding the question to the survey_question table
1233 1233
             $sql = "UPDATE $tbl_survey_question SET
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
     public static function move_survey_question($direction, $survey_question_id, $survey_id)
1258 1258
     {
1259 1259
         // Table definition
1260
-        $table_survey_question 	= Database :: get_course_table(TABLE_SURVEY_QUESTION);
1260
+        $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
1261 1261
         $course_id = api_get_course_int_id();
1262 1262
 
1263 1263
         if ($direction == 'moveup') {
@@ -1309,11 +1309,11 @@  discard block
 block discarded – undo
1309 1309
         $course_id = api_get_course_int_id();
1310 1310
 
1311 1311
         // Table definitions
1312
-        $table_survey_question 	= Database :: get_course_table(TABLE_SURVEY_QUESTION);
1312
+        $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
1313 1313
         $course_condition = " c_id = $course_id AND ";
1314 1314
         if ($shared) {
1315 1315
             $course_condition = "";
1316
-            $table_survey_question 	= Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION);
1316
+            $table_survey_question = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION);
1317 1317
         }
1318 1318
 
1319 1319
         $sql = "DELETE FROM $table_survey_question
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
     {
1347 1347
         $course_id = api_get_course_int_id();
1348 1348
         // Table definitions
1349
-        $table_survey_question 	= Database :: get_course_table(TABLE_SURVEY_QUESTION);
1349
+        $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
1350 1350
         if ($shared) {
1351 1351
             SurveyManager::delete_shared_survey_question($survey_id, $question_id);
1352 1352
         }
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
         $course_id = api_get_course_int_id();
1409 1409
         // A percentage question type has options 1 -> 100
1410 1410
         if ($form_content['type'] == 'percentage') {
1411
-            for($i = 1; $i < 101; $i++) {
1411
+            for ($i = 1; $i < 101; $i++) {
1412 1412
                 $form_content['answers'][] = $i;
1413 1413
             }
1414 1414
         }
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
     {
1589 1589
         $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER);
1590 1590
 
1591
-        $user_id	= intval($user_id);
1591
+        $user_id = intval($user_id);
1592 1592
         $course_id	= intval($course_id);
1593 1593
         $survey_id	= intval($survey_id);
1594 1594
 
@@ -1746,7 +1746,7 @@  discard block
 block discarded – undo
1746 1746
     static function remove_answer($user, $survey_id, $question_id, $course_id) {
1747 1747
         $course_id = intval($course_id);
1748 1748
         // table definition
1749
-        $table_survey_answer 		= Database :: get_course_table(TABLE_SURVEY_ANSWER);
1749
+        $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER);
1750 1750
         $sql = "DELETE FROM $table_survey_answer
1751 1751
 				WHERE
1752 1752
 				    c_id = $course_id AND
@@ -1919,16 +1919,16 @@  discard block
 block discarded – undo
1919 1919
      */
1920 1920
     function delete_user_report($survey_id, $user_id)
1921 1921
     {
1922
-        $table_survey_answer 		= Database :: get_course_table(TABLE_SURVEY_ANSWER);
1923
-        $table_survey_invitation 	= Database :: get_course_table(TABLE_SURVEY_INVITATION);
1924
-        $table_survey 				= Database :: get_course_table(TABLE_SURVEY);
1922
+        $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER);
1923
+        $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION);
1924
+        $table_survey = Database :: get_course_table(TABLE_SURVEY);
1925 1925
 
1926 1926
         $course_id = api_get_course_int_id();
1927 1927
 
1928 1928
         if (!empty($survey_id) && !empty($user_id)) {
1929 1929
             // delete data from survey_answer by user_id and survey_id
1930 1930
             $sql = "DELETE FROM $table_survey_answer
1931
-			        WHERE c_id = $course_id AND survey_id = '".(int)$survey_id."' AND user = '".(int)$user_id."'";
1931
+			        WHERE c_id = $course_id AND survey_id = '".(int) $survey_id."' AND user = '".(int) $user_id."'";
1932 1932
             Database::query($sql);
1933 1933
             // update field answered from survey_invitation by user_id and survey_id
1934 1934
             $sql = "UPDATE $table_survey_invitation SET answered = '0'
@@ -1938,9 +1938,9 @@  discard block
 block discarded – undo
1938 1938
                             SELECT code FROM $table_survey
1939 1939
                             WHERE
1940 1940
                                 c_id = $course_id AND
1941
-                                survey_id = '".(int)$survey_id."'
1941
+                                survey_id = '".(int) $survey_id."'
1942 1942
                         ) AND
1943
-			            user = '".(int)$user_id."'";
1943
+			            user = '".(int) $user_id."'";
1944 1944
             $result = Database::query($sql);
1945 1945
         }
1946 1946
 
@@ -1970,19 +1970,19 @@  discard block
 block discarded – undo
1970 1970
         // Actions bar
1971 1971
         echo '<div class="actions">';
1972 1972
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.
1973
-            Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
1973
+            Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'), '', ICON_SIZE_MEDIUM).'</a>';
1974 1974
         if (isset($_GET['user'])) {
1975 1975
             if (api_is_allowed_to_edit()) {
1976 1976
                 // The delete link
1977 1977
                 echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=deleteuserreport&survey_id='.Security::remove_XSS($_GET['survey_id']).'&user='.Security::remove_XSS($_GET['user']).'" >'.
1978
-                    Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_MEDIUM).'</a>';
1978
+                    Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_MEDIUM).'</a>';
1979 1979
             }
1980 1980
 
1981 1981
             // Export the user report
1982 1982
             echo '<a href="javascript: void(0);" onclick="document.form1a.submit();">'.
1983
-                Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
1983
+                Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a> ';
1984 1984
             echo '<a href="javascript: void(0);" onclick="document.form1b.submit();">'.
1985
-                Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> ';
1985
+                Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a> ';
1986 1986
             echo '<form id="form1a" name="form1a" method="post" action="'.api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&user_id='.Security::remove_XSS($_GET['user']).'">';
1987 1987
             echo '<input type="hidden" name="export_report" value="export_report">';
1988 1988
             echo '<input type="hidden" name="export_format" value="csv">';
@@ -2015,7 +2015,7 @@  discard block
 block discarded – undo
2015 2015
                     $name = $person['invited_user'];
2016 2016
                 }
2017 2017
             } else {
2018
-                $name  = get_lang('Anonymous') . ' ' . ($key + 1);
2018
+                $name = get_lang('Anonymous').' '.($key + 1);
2019 2019
                 $id = $person;
2020 2020
             }
2021 2021
             echo '<option value="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.Security::remove_XSS($_GET['action']).'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&user='.Security::remove_XSS($id).'" ';
@@ -2145,9 +2145,9 @@  discard block
 block discarded – undo
2145 2145
         $singlePage = isset($_GET['single_page']) ? intval($_GET['single_page']) : 0;
2146 2146
         $course_id = api_get_course_int_id();
2147 2147
         // Database table definitions
2148
-        $table_survey_question 			= Database :: get_course_table(TABLE_SURVEY_QUESTION);
2149
-        $table_survey_question_option 	= Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2150
-        $table_survey_answer 			= Database :: get_course_table(TABLE_SURVEY_ANSWER);
2148
+        $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2149
+        $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2150
+        $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER);
2151 2151
 
2152 2152
         // Determining the offset of the sql statement (the n-th question of the survey)
2153 2153
         $offset = !isset($_GET['question']) ? 0 : intval($_GET['question']);
@@ -2158,7 +2158,7 @@  discard block
 block discarded – undo
2158 2158
 
2159 2159
         echo '<div class="actions">';
2160 2160
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.$surveyId.'">'.
2161
-            Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
2161
+            Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'), '', ICON_SIZE_MEDIUM).'</a>';
2162 2162
         echo '</div>';
2163 2163
 
2164 2164
         if ($survey_data['number_of_questions'] > 0) {
@@ -2168,21 +2168,21 @@  discard block
 block discarded – undo
2168 2168
                 /* echo '<ul><li class="disabled"><a href="#">'.get_lang('Question').'</a></li>'; */
2169 2169
 
2170 2170
                 if ($currentQuestion != 0) {
2171
-                    echo '<li><a href="' . api_get_path(WEB_CODE_PATH) . 'survey/reporting.php?action=' . $action . '&' . api_get_cidreq() . '&survey_id=' . $surveyId . '&question=' . ($offset - 1) . '">' . get_lang('PreviousQuestion') . '</a></li>';
2171
+                    echo '<li><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.$action.'&'.api_get_cidreq().'&survey_id='.$surveyId.'&question='.($offset - 1).'">'.get_lang('PreviousQuestion').'</a></li>';
2172 2172
                 }
2173 2173
 
2174 2174
                 for ($i = 1; $i <= $survey_data['number_of_questions']; $i++) {
2175 2175
                     if ($offset != $i - 1) {
2176
-                        echo '<li><a href="' . api_get_path(WEB_CODE_PATH) . 'survey/reporting.php?action=' . $action . '&' . api_get_cidreq() . '&survey_id=' . $surveyId . '&question=' . ($i - 1) . '">' . $i . '</a></li>';
2176
+                        echo '<li><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.$action.'&'.api_get_cidreq().'&survey_id='.$surveyId.'&question='.($i - 1).'">'.$i.'</a></li>';
2177 2177
                     } else {
2178
-                        echo '<li class="disabled"s><a href="#">' . $i . '</a></li>';
2178
+                        echo '<li class="disabled"s><a href="#">'.$i.'</a></li>';
2179 2179
                     }
2180 2180
                     /*if ($i < $survey_data['number_of_questions']) {
2181 2181
                         echo ' | ';
2182 2182
                     }*/
2183 2183
                 }
2184 2184
                 if ($currentQuestion < ($survey_data['number_of_questions'] - 1)) {
2185
-                    echo '<li><a href="' . api_get_path(WEB_CODE_PATH) . 'survey/reporting.php?action=' . $action . '&' . api_get_cidreq() . '&survey_id=' . $surveyId . '&question=' . ($offset + 1) . '">' . get_lang('NextQuestion') . '</li></a>';
2185
+                    echo '<li><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.$action.'&'.api_get_cidreq().'&survey_id='.$surveyId.'&question='.($offset + 1).'">'.get_lang('NextQuestion').'</li></a>';
2186 2186
                 }
2187 2187
                 echo '</ul>';
2188 2188
                 echo '</div>';
@@ -2234,19 +2234,19 @@  discard block
 block discarded – undo
2234 2234
                 $sql = "SELECT * FROM $table_survey_answer
2235 2235
                         WHERE
2236 2236
                             c_id = $course_id AND
2237
-                            survey_id='" . intval($_GET['survey_id']) . "' AND
2238
-                            question_id = '" . intval($question['question_id']) . "'";
2237
+                            survey_id='".intval($_GET['survey_id'])."' AND
2238
+                            question_id = '" . intval($question['question_id'])."'";
2239 2239
                 $result = Database::query($sql);
2240 2240
                 while ($row = Database::fetch_array($result)) {
2241
-                    echo $row['option_id'] . '<hr noshade="noshade" size="1" />';
2241
+                    echo $row['option_id'].'<hr noshade="noshade" size="1" />';
2242 2242
                 }
2243 2243
             } else {
2244 2244
                 // Getting the options ORDER BY sort ASC
2245 2245
                 $sql = "SELECT * FROM $table_survey_question_option
2246 2246
                         WHERE
2247 2247
                             c_id = $course_id AND
2248
-                            survey_id='" . intval($_GET['survey_id']) . "'
2249
-                            AND question_id = '" . intval($question['question_id']) . "'
2248
+                            survey_id='".intval($_GET['survey_id'])."'
2249
+                            AND question_id = '" . intval($question['question_id'])."'
2250 2250
                         ORDER BY sort ASC";
2251 2251
                 $result = Database::query($sql);
2252 2252
                 while ($row = Database::fetch_array($result)) {
@@ -2256,8 +2256,8 @@  discard block
 block discarded – undo
2256 2256
                 $sql = "SELECT *, count(answer_id) as total FROM $table_survey_answer
2257 2257
                         WHERE
2258 2258
                             c_id = $course_id AND
2259
-                            survey_id='" . intval($_GET['survey_id']) . "'
2260
-                            AND question_id = '" . intval($question['question_id']) . "'
2259
+                            survey_id='".intval($_GET['survey_id'])."'
2260
+                            AND question_id = '" . intval($question['question_id'])."'
2261 2261
                         GROUP BY option_id, value";
2262 2262
                 $result = Database::query($sql);
2263 2263
                 $number_of_answers = array();
@@ -2274,8 +2274,7 @@  discard block
 block discarded – undo
2274 2274
                     $optionText = strip_tags($option['option_text']);
2275 2275
                     $optionText = html_entity_decode($optionText);
2276 2276
                     $votes = isset($data[$option['question_option_id']]['total']) ?
2277
-                        $data[$option['question_option_id']]['total'] :
2278
-                        '0';
2277
+                        $data[$option['question_option_id']]['total'] : '0';
2279 2278
                     array_push($chartData, array('option' => $optionText, 'votes' => $votes));
2280 2279
                 }
2281 2280
                 $chartContainerId = 'chartContainer'.$question['question_id'];
@@ -2287,9 +2286,9 @@  discard block
 block discarded – undo
2287 2286
                 echo '<table class="display-survey table">';
2288 2287
                 echo '	<tr>';
2289 2288
                 echo '		<th>&nbsp;</th>';
2290
-                echo '		<th>' . get_lang('AbsoluteTotal') . '</th>';
2291
-                echo '		<th>' . get_lang('Percentage') . '</th>';
2292
-                echo '		<th>' . get_lang('VisualRepresentation') . '</th>';
2289
+                echo '		<th>'.get_lang('AbsoluteTotal').'</th>';
2290
+                echo '		<th>'.get_lang('Percentage').'</th>';
2291
+                echo '		<th>'.get_lang('VisualRepresentation').'</th>';
2293 2292
                 echo '	<tr>';
2294 2293
 
2295 2294
                 // Displaying the table: the content
@@ -2308,22 +2307,22 @@  discard block
 block discarded – undo
2308 2307
                             $answers_number = $absolute_number / $number_of_answers[$option['question_id']] * 100;
2309 2308
                         }
2310 2309
                         echo '	<tr>';
2311
-                        echo '		<td class="center">' . $value['option_text'] . '</td>';
2310
+                        echo '		<td class="center">'.$value['option_text'].'</td>';
2312 2311
                         echo '		<td class="center">';
2313 2312
                         if ($absolute_number != 0) {
2314
-                            echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/reporting.php?action=' . $action . '&survey_id=' . $surveyId . '&question=' . $offset . '&viewoption=' . $value['question_option_id'] . '">' . $absolute_number . '</a>';
2313
+                            echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.$action.'&survey_id='.$surveyId.'&question='.$offset.'&viewoption='.$value['question_option_id'].'">'.$absolute_number.'</a>';
2315 2314
                         } else {
2316 2315
                             echo '0';
2317 2316
                         }
2318 2317
 
2319 2318
                         echo '      </td>';
2320
-                        echo '		<td class="center">' . round($answers_number, 2) . ' %</td>';
2319
+                        echo '		<td class="center">'.round($answers_number, 2).' %</td>';
2321 2320
                         echo '		<td class="center">';
2322 2321
                         $size = $answers_number * 2;
2323 2322
                         if ($size > 0) {
2324
-                            echo '<div style="border:1px solid #264269; background-color:#aecaf4; height:10px; width:' . $size . 'px">&nbsp;</div>';
2323
+                            echo '<div style="border:1px solid #264269; background-color:#aecaf4; height:10px; width:'.$size.'px">&nbsp;</div>';
2325 2324
                         } else {
2326
-                            echo '<div style="text-align: left;">' . get_lang("NoDataAvailable") . '</div>';
2325
+                            echo '<div style="text-align: left;">'.get_lang("NoDataAvailable").'</div>';
2327 2326
                         }
2328 2327
                         echo ' </td>';
2329 2328
                         echo ' </tr>';
@@ -2331,8 +2330,8 @@  discard block
 block discarded – undo
2331 2330
                 }
2332 2331
                 // displaying the table: footer (totals)
2333 2332
                 echo '	<tr>';
2334
-                echo '		<td class="total"><b>' . get_lang('Total') . '</b></td>';
2335
-                echo '		<td class="total"><b>' . ($number_of_answers[$option['question_id']] == 0 ? '0' : $number_of_answers[$option['question_id']]) . '</b></td>';
2333
+                echo '		<td class="total"><b>'.get_lang('Total').'</b></td>';
2334
+                echo '		<td class="total"><b>'.($number_of_answers[$option['question_id']] == 0 ? '0' : $number_of_answers[$option['question_id']]).'</b></td>';
2336 2335
                 echo '		<td class="total">&nbsp;</td>';
2337 2336
                 echo '		<td class="total">&nbsp;</td>';
2338 2337
                 echo '	</tr>';
@@ -2376,8 +2375,8 @@  discard block
 block discarded – undo
2376 2375
     public static function display_question_report_score($survey_data, $question, $offset)
2377 2376
     {
2378 2377
         // Database table definitions
2379
-        $table_survey_question_option 	= Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2380
-        $table_survey_answer 			= Database :: get_course_table(TABLE_SURVEY_ANSWER);
2378
+        $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2379
+        $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER);
2381 2380
 
2382 2381
         $course_id = api_get_course_int_id();
2383 2382
 
@@ -2447,9 +2446,9 @@  discard block
 block discarded – undo
2447 2446
                 echo '		<td>'.$value['option_text'].'</td>';
2448 2447
                 echo '		<td>'.$i.'</td>';
2449 2448
                 echo '		<td><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.$action.'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&question='.Security::remove_XSS($offset).'&viewoption='.$value['question_option_id'].'&value='.$i.'">'.$absolute_number.'</a></td>';
2450
-                echo '		<td>'.round($absolute_number/$number_of_answers*100, 2).' %</td>';
2449
+                echo '		<td>'.round($absolute_number / $number_of_answers * 100, 2).' %</td>';
2451 2450
                 echo '		<td>';
2452
-                $size = ($absolute_number/$number_of_answers*100*2);
2451
+                $size = ($absolute_number / $number_of_answers * 100 * 2);
2453 2452
                 if ($size > 0) {
2454 2453
                     echo '			<div style="border:1px solid #264269; background-color:#aecaf4; height:10px; width:'.$size.'px">&nbsp;</div>';
2455 2454
                 }
@@ -2486,11 +2485,11 @@  discard block
 block discarded – undo
2486 2485
         // Actions bar
2487 2486
         echo '<div class="actions">';
2488 2487
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">
2489
-		'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
2488
+		'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'), '', ICON_SIZE_MEDIUM).'</a>';
2490 2489
         echo '<a class="survey_export_link" href="javascript: void(0);" onclick="document.form1a.submit();">
2491
-		'.Display::return_icon('export_csv.png',get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a>';
2490
+		'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a>';
2492 2491
         echo '<a class="survey_export_link" href="javascript: void(0);" onclick="document.form1b.submit();">
2493
-		'.Display::return_icon('export_excel.png',get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a>';
2492
+		'.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
2494 2493
         echo '</div>';
2495 2494
 
2496 2495
         // The form
@@ -2523,8 +2522,8 @@  discard block
 block discarded – undo
2523 2522
             // Show user fields section with a big th colspan that spans over all fields
2524 2523
             $extra_user_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', false, true);
2525 2524
             $num = count($extra_user_fields);
2526
-            if ($num > 0 ) {
2527
-                echo '<th '.($num>0?' colspan="'.$num.'"':'').'>';
2525
+            if ($num > 0) {
2526
+                echo '<th '.($num > 0 ? ' colspan="'.$num.'"' : '').'>';
2528 2527
                 echo '<label><input type="checkbox" name="fields_filter" value="1" checked="checked"/> ';
2529 2528
                 echo get_lang('UserFields');
2530 2529
                 echo '</label>';
@@ -2589,7 +2588,7 @@  discard block
 block discarded – undo
2589 2588
         if (!(isset($_POST['submit_question_filter']) && $_POST['submit_question_filter'] ||
2590 2589
                 isset($_POST['export_report']) && $_POST['export_report']) || !empty($_POST['fields_filter'])) {
2591 2590
             //show the fields names for user fields
2592
-            foreach($extra_user_fields as & $field) {
2591
+            foreach ($extra_user_fields as & $field) {
2593 2592
                 echo '<th>'.$field[3].'</th>';
2594 2593
             }
2595 2594
         }
@@ -2609,7 +2608,7 @@  discard block
 block discarded – undo
2609 2608
 				ORDER BY sq.sort ASC, sqo.sort ASC";
2610 2609
         $result = Database::query($sql);
2611 2610
 
2612
-        $display_percentage_header = 1;	// in order to display only once the cell option (and not 100 times)
2611
+        $display_percentage_header = 1; // in order to display only once the cell option (and not 100 times)
2613 2612
         while ($row = Database::fetch_array($result)) {
2614 2613
             // We show the options if
2615 2614
             // 1. there is no question filter and the export button has not been clicked
@@ -2669,7 +2668,7 @@  discard block
 block discarded – undo
2669 2668
                     $questions,
2670 2669
                     $display_extra_user_fields
2671 2670
                 );
2672
-                $answers_of_user=array();
2671
+                $answers_of_user = array();
2673 2672
             }
2674 2673
             if (isset($questions[$row['question_id']]) && $questions[$row['question_id']]['type'] != 'open') {
2675 2674
                 $answers_of_user[$row['question_id']][$row['option_id']] = $row;
@@ -2731,7 +2730,7 @@  discard block
 block discarded – undo
2731 2730
                 echo '<th>'.$user.'</th>'; // the user column
2732 2731
             }
2733 2732
         } else {
2734
-            echo '<th>' . get_lang('Anonymous') . ' ' . $user . '</th>';
2733
+            echo '<th>'.get_lang('Anonymous').' '.$user.'</th>';
2735 2734
         }
2736 2735
 
2737 2736
         if ($display_extra_user_fields) {
@@ -2827,10 +2826,10 @@  discard block
 block discarded – undo
2827 2826
                 // We do not show comment and pagebreak question types
2828 2827
                 if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') {
2829 2828
                     if ($row['number_of_options'] == 0 && $row['type'] == 'open') {
2830
-                        $return .= str_replace("\r\n",'  ', api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES)).';';
2829
+                        $return .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES)).';';
2831 2830
                     } else {
2832 2831
                         for ($ii = 0; $ii < $row['number_of_options']; $ii++) {
2833
-                            $return .= str_replace("\r\n",'  ', api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES)).';';
2832
+                            $return .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES)).';';
2834 2833
                         }
2835 2834
                     }
2836 2835
                 }
@@ -2844,7 +2843,7 @@  discard block
 block discarded – undo
2844 2843
         // Show the fields names for user fields
2845 2844
         if (!empty($extra_user_fields)) {
2846 2845
             foreach ($extra_user_fields as & $field) {
2847
-                $return .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES)).'";';
2846
+                $return .= '"'.str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES)).'";';
2848 2847
             }
2849 2848
         }
2850 2849
 
@@ -2879,7 +2878,7 @@  discard block
 block discarded – undo
2879 2878
             ) {
2880 2879
                 // We do not show comment and pagebreak question types
2881 2880
                 if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') {
2882
-                    $row['option_text'] = str_replace(array("\r","\n"),array('',''),$row['option_text']);
2881
+                    $row['option_text'] = str_replace(array("\r", "\n"), array('', ''), $row['option_text']);
2883 2882
                     $return .= api_html_entity_decode(strip_tags($row['option_text']), ENT_QUOTES).';';
2884 2883
                     $possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id'];
2885 2884
                     $possible_answers_type[$row['question_id']] = $row['type'];
@@ -2909,9 +2908,9 @@  discard block
 block discarded – undo
2909 2908
                     $old_user,
2910 2909
                     true
2911 2910
                 );
2912
-                $answers_of_user=array();
2911
+                $answers_of_user = array();
2913 2912
             }
2914
-            if($possible_answers_type[$row['question_id']] == 'open') {
2913
+            if ($possible_answers_type[$row['question_id']] == 'open') {
2915 2914
                 $temp_id = 'open'.$open_question_iterator;
2916 2915
                 $answers_of_user[$row['question_id']][$temp_id] = $row;
2917 2916
                 $open_question_iterator++;
@@ -2970,7 +2969,7 @@  discard block
 block discarded – undo
2970 2969
 
2971 2970
         if ($display_extra_user_fields) {
2972 2971
             // Show user fields data, if any, for this user
2973
-            $user_fields_values = UserManager::get_extra_user_data($user,false,false, false, true);
2972
+            $user_fields_values = UserManager::get_extra_user_data($user, false, false, false, true);
2974 2973
             foreach ($user_fields_values as & $value) {
2975 2974
                 $return .= '"'.str_replace('"', '""', api_html_entity_decode(strip_tags($value), ENT_QUOTES)).'";';
2976 2975
             }
@@ -3067,9 +3066,9 @@  discard block
 block discarded – undo
3067 3066
                                 ENT_QUOTES
3068 3067
                             )
3069 3068
                         );
3070
-                        $column ++;
3069
+                        $column++;
3071 3070
                     } else {
3072
-                        for ($ii = 0; $ii < $row['number_of_options']; $ii ++) {
3071
+                        for ($ii = 0; $ii < $row['number_of_options']; $ii++) {
3073 3072
                             $worksheet->setCellValueByColumnAndRow(
3074 3073
                                 $column,
3075 3074
                                 $line,
@@ -3078,7 +3077,7 @@  discard block
 block discarded – undo
3078 3077
                                     ENT_QUOTES
3079 3078
                                 )
3080 3079
                             );
3081
-                            $column ++;
3080
+                            $column++;
3082 3081
                         }
3083 3082
                     }
3084 3083
                 }
@@ -3138,7 +3137,7 @@  discard block
 block discarded – undo
3138 3137
         }
3139 3138
 
3140 3139
         // Getting all the answers of the users
3141
-        $line ++;
3140
+        $line++;
3142 3141
         $column = 0;
3143 3142
         $old_user = '';
3144 3143
         $answers_of_user = array();
@@ -3147,7 +3146,7 @@  discard block
 block discarded – undo
3147 3146
         if ($user_id != 0) {
3148 3147
             $sql .= "AND user='".intval($user_id)."' ";
3149 3148
         }
3150
-        $sql .=	"ORDER BY user ASC";
3149
+        $sql .= "ORDER BY user ASC";
3151 3150
 
3152 3151
         $open_question_iterator = 1;
3153 3152
         $result = Database::query($sql);
@@ -3222,7 +3221,7 @@  discard block
 block discarded – undo
3222 3221
                         FROM '.Database::get_main_table(TABLE_MAIN_USER).'
3223 3222
                         WHERE user_id='.intval($user);
3224 3223
                 $rs = Database::query($sql);
3225
-                if($row = Database::fetch_array($rs)) {
3224
+                if ($row = Database::fetch_array($rs)) {
3226 3225
                     $user_displayed = api_get_person_name($row['firstname'], $row['lastname']);
3227 3226
                 } else {
3228 3227
                     $user_displayed = '-';
@@ -3237,8 +3236,8 @@  discard block
 block discarded – undo
3237 3236
 
3238 3237
         if ($display_extra_user_fields) {
3239 3238
             //show user fields data, if any, for this user
3240
-            $user_fields_values = UserManager::get_extra_user_data(intval($user),false,false, false, true);
3241
-            foreach($user_fields_values as $value) {
3239
+            $user_fields_values = UserManager::get_extra_user_data(intval($user), false, false, false, true);
3240
+            foreach ($user_fields_values as $value) {
3242 3241
                 $return[] = api_html_entity_decode(strip_tags($value), ENT_QUOTES);
3243 3242
             }
3244 3243
         }
@@ -3297,7 +3296,7 @@  discard block
 block discarded – undo
3297 3296
         // Actions bar
3298 3297
         echo '<div class="actions">';
3299 3298
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.intval($_GET['survey_id']).'">'.
3300
-                Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
3299
+                Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'), '', ICON_SIZE_MEDIUM).'</a>';
3301 3300
         echo '</div>';
3302 3301
 
3303 3302
         // Displaying an information message that only the questions with predefined answers can be used in a comparative report
@@ -3362,25 +3361,25 @@  discard block
 block discarded – undo
3362 3361
 
3363 3362
             $xOptions = array();
3364 3363
             // The header
3365
-            $tableHtml .=  '	<tr>';
3364
+            $tableHtml .= '	<tr>';
3366 3365
             for ($ii = 0; $ii <= count($question_x['answers']); $ii++) {
3367 3366
                 if ($ii == 0) {
3368
-                    $tableHtml .=  '		<th>&nbsp;</th>';
3367
+                    $tableHtml .= '		<th>&nbsp;</th>';
3369 3368
                 } else {
3370 3369
                     if ($question_x['type'] == 'score') {
3371 3370
                         for ($x = 1; $x <= $question_x['maximum_score']; $x++) {
3372
-                            $tableHtml .= '		<th>'.$question_x['answers'][($ii-1)].'<br />'.$x.'</th>';
3371
+                            $tableHtml .= '		<th>'.$question_x['answers'][($ii - 1)].'<br />'.$x.'</th>';
3373 3372
                         }
3374 3373
                         $x = '';
3375 3374
                     } else {
3376
-                        $tableHtml .= '		<th>'.$question_x['answers'][($ii-1)].'</th>';
3375
+                        $tableHtml .= '		<th>'.$question_x['answers'][($ii - 1)].'</th>';
3377 3376
                     }
3378
-                    $optionText = strip_tags($question_x['answers'][$ii-1]);
3377
+                    $optionText = strip_tags($question_x['answers'][$ii - 1]);
3379 3378
                     $optionText = html_entity_decode($optionText);
3380 3379
                     array_push($xOptions, trim($optionText));
3381 3380
                 }
3382 3381
             }
3383
-            $tableHtml .=  '	</tr>';
3382
+            $tableHtml .= '	</tr>';
3384 3383
             $chartData = array();
3385 3384
 
3386 3385
             // The main part
@@ -3390,15 +3389,15 @@  discard block
 block discarded – undo
3390 3389
                 // The Y axis is a scoring question type so we have more rows than the options (actually options * maximum score)
3391 3390
                 if ($question_y['type'] == 'score') {
3392 3391
                     for ($y = 1; $y <= $question_y['maximum_score']; $y++) {
3393
-                        $tableHtml .=  '	<tr>';
3392
+                        $tableHtml .= '	<tr>';
3394 3393
                         for ($ii = 0; $ii <= count($question_x['answers']); $ii++) {
3395 3394
                             if ($question_x['type'] == 'score') {
3396 3395
                                 for ($x = 1; $x <= $question_x['maximum_score']; $x++) {
3397 3396
                                     if ($ii == 0) {
3398
-                                        $tableHtml .=  ' <th>'.$question_y['answers'][($ij)].' '.$y.'</th>';
3397
+                                        $tableHtml .= ' <th>'.$question_y['answers'][($ij)].' '.$y.'</th>';
3399 3398
                                         break;
3400 3399
                                     } else {
3401
-                                        $tableHtml .=  ' <td align="center">';
3400
+                                        $tableHtml .= ' <td align="center">';
3402 3401
                                         $votes = SurveyUtil::comparative_check(
3403 3402
                                             $answers_x,
3404 3403
                                             $answers_y,
@@ -3407,23 +3406,23 @@  discard block
 block discarded – undo
3407 3406
                                             $x,
3408 3407
                                             $y
3409 3408
                                         );
3410
-                                        $tableHtml .=  $votes;
3409
+                                        $tableHtml .= $votes;
3411 3410
                                         array_push(
3412 3411
                                             $chartData,
3413 3412
                                             array(
3414
-                                                'serie' => array($currentYQuestion, $xOptions[$ii-1]),
3413
+                                                'serie' => array($currentYQuestion, $xOptions[$ii - 1]),
3415 3414
                                                 'option' => $x,
3416 3415
                                                 'votes' => $votes
3417 3416
                                             )
3418 3417
                                         );
3419
-                                        $tableHtml .=  '</td>';
3418
+                                        $tableHtml .= '</td>';
3420 3419
                                     }
3421 3420
                                 }
3422 3421
                             } else {
3423 3422
                                 if ($ii == 0) {
3424
-                                    $tableHtml .=  '<th>'.$question_y['answers'][$ij].' '.$y.'</th>';
3423
+                                    $tableHtml .= '<th>'.$question_y['answers'][$ij].' '.$y.'</th>';
3425 3424
                                 } else {
3426
-                                    $tableHtml .=  '<td align="center">';
3425
+                                    $tableHtml .= '<td align="center">';
3427 3426
                                     $votes = SurveyUtil::comparative_check(
3428 3427
                                         $answers_x,
3429 3428
                                         $answers_y,
@@ -3436,65 +3435,65 @@  discard block
 block discarded – undo
3436 3435
                                     array_push(
3437 3436
                                         $chartData,
3438 3437
                                         array(
3439
-                                            'serie' => array($currentYQuestion, $xOptions[$ii-1]),
3438
+                                            'serie' => array($currentYQuestion, $xOptions[$ii - 1]),
3440 3439
                                             'option' => $y,
3441 3440
                                             'votes' => $votes
3442 3441
                                         )
3443 3442
                                     );
3444
-                                    $tableHtml .=  '</td>';
3443
+                                    $tableHtml .= '</td>';
3445 3444
                                 }
3446 3445
                             }
3447 3446
                         }
3448
-                        $tableHtml .=  '	</tr>';
3447
+                        $tableHtml .= '	</tr>';
3449 3448
                     }
3450 3449
                 }
3451 3450
                 // The Y axis is NOT a score question type so the number of rows = the number of options
3452 3451
                 else {
3453
-                    $tableHtml .=  '	<tr>';
3452
+                    $tableHtml .= '	<tr>';
3454 3453
                     for ($ii = 0; $ii <= count($question_x['answers']); $ii++) {
3455 3454
                         if ($question_x['type'] == 'score') {
3456 3455
                             for ($x = 1; $x <= $question_x['maximum_score']; $x++) {
3457 3456
                                 if ($ii == 0) {
3458
-                                    $tableHtml .=  '		<th>'.$question_y['answers'][$ij].'</th>';
3457
+                                    $tableHtml .= '		<th>'.$question_y['answers'][$ij].'</th>';
3459 3458
                                     break;
3460 3459
                                 } else {
3461
-                                    $tableHtml .=  '		<td align="center">';
3462
-                                    $votes =  SurveyUtil::comparative_check($answers_x, $answers_y, $question_x['answersid'][($ii-1)], $question_y['answersid'][($ij)], $x, 0);
3460
+                                    $tableHtml .= '		<td align="center">';
3461
+                                    $votes = SurveyUtil::comparative_check($answers_x, $answers_y, $question_x['answersid'][($ii - 1)], $question_y['answersid'][($ij)], $x, 0);
3463 3462
                                     $tableHtml .= $votes;
3464 3463
                                     array_push(
3465 3464
                                         $chartData,
3466 3465
                                         array(
3467
-                                            'serie' => array($currentYQuestion, $xOptions[$ii-1]),
3466
+                                            'serie' => array($currentYQuestion, $xOptions[$ii - 1]),
3468 3467
                                             'option' => $x,
3469 3468
                                             'votes' => $votes
3470 3469
                                         )
3471 3470
                                     );
3472
-                                    $tableHtml .=  '</td>';
3471
+                                    $tableHtml .= '</td>';
3473 3472
                                 }
3474 3473
                             }
3475 3474
                         } else {
3476 3475
                             if ($ii == 0) {
3477
-                                $tableHtml .=  '		<th>'.$question_y['answers'][($ij)].'</th>';
3476
+                                $tableHtml .= '		<th>'.$question_y['answers'][($ij)].'</th>';
3478 3477
                             } else {
3479
-                                $tableHtml .=  '		<td align="center">';
3480
-                                $votes = SurveyUtil::comparative_check($answers_x, $answers_y, $question_x['answersid'][($ii-1)], $question_y['answersid'][($ij)]);
3478
+                                $tableHtml .= '		<td align="center">';
3479
+                                $votes = SurveyUtil::comparative_check($answers_x, $answers_y, $question_x['answersid'][($ii - 1)], $question_y['answersid'][($ij)]);
3481 3480
                                 $tableHtml .= $votes;
3482 3481
                                 array_push(
3483 3482
                                     $chartData,
3484 3483
                                     array(
3485
-                                        'serie' => $xOptions[$ii-1],
3484
+                                        'serie' => $xOptions[$ii - 1],
3486 3485
                                         'option' => $currentYQuestion,
3487 3486
                                         'votes' => $votes
3488 3487
                                     )
3489 3488
                                 );
3490
-                                $tableHtml .=  '</td>';
3489
+                                $tableHtml .= '</td>';
3491 3490
                             }
3492 3491
                         }
3493 3492
                     }
3494
-                    $tableHtml .=  '	</tr>';
3493
+                    $tableHtml .= '	</tr>';
3495 3494
                 }
3496 3495
             }
3497
-            $tableHtml .=  '</table>';
3496
+            $tableHtml .= '</table>';
3498 3497
             echo '<div id="chartContainer" class="col-md-12">';
3499 3498
             echo self::drawChart($chartData, true);
3500 3499
             echo '</div>';
@@ -3634,7 +3633,7 @@  discard block
 block discarded – undo
3634 3633
                     survey_id='".intval($_GET['survey_id'])."' AND
3635 3634
                     session_id='".api_get_session_id()."' ";
3636 3635
         $res = Database::query($sql);
3637
-        $row = Database::fetch_array($res,'ASSOC');
3636
+        $row = Database::fetch_array($res, 'ASSOC');
3638 3637
 
3639 3638
         return $row['total'];
3640 3639
     }
@@ -3709,7 +3708,7 @@  discard block
 block discarded – undo
3709 3708
             $exclude_users = SurveyManager::get_people_who_filled_survey($_GET['survey_id']);
3710 3709
         }
3711 3710
 
3712
-        $counter = 0;  // Nr of invitations "sent" (if sendmail option)
3711
+        $counter = 0; // Nr of invitations "sent" (if sendmail option)
3713 3712
         $course_id = api_get_course_int_id();
3714 3713
         $session_id = api_get_session_id();
3715 3714
 
@@ -3865,7 +3864,7 @@  discard block
 block discarded – undo
3865 3864
         $text_link = '<a href="'.$survey_link.'">'.get_lang('ClickHereToAnswerTheSurvey')."</a><br />\r\n<br />\r\n".get_lang('OrCopyPasteTheFollowingUrl')." <br />\r\n ".$survey_link;
3866 3865
 
3867 3866
         $replace_count = 0;
3868
-        $full_invitation_text = api_str_ireplace('**link**', $text_link ,$invitation_text, $replace_count);
3867
+        $full_invitation_text = api_str_ireplace('**link**', $text_link, $invitation_text, $replace_count);
3869 3868
         if ($replace_count < 1) {
3870 3869
             $full_invitation_text = $full_invitation_text."<br />\r\n<br />\r\n".$text_link;
3871 3870
         }
@@ -3937,8 +3936,8 @@  discard block
 block discarded – undo
3937 3936
         $course_id = api_get_course_int_id();
3938 3937
 
3939 3938
         // Database table definition
3940
-        $table_survey_invitation 	= Database :: get_course_table(TABLE_SURVEY_INVITATION);
3941
-        $table_survey 				= Database :: get_course_table(TABLE_SURVEY);
3939
+        $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION);
3940
+        $table_survey = Database :: get_course_table(TABLE_SURVEY);
3942 3941
 
3943 3942
         // Counting the number of people that are invited
3944 3943
         $sql = "SELECT count(user) as total
@@ -4052,7 +4051,7 @@  discard block
 block discarded – undo
4052 4051
     {
4053 4052
         $course_id = api_get_course_int_id();
4054 4053
         // Database table definition
4055
-        $table_survey_invitation 	= Database :: get_course_table(TABLE_SURVEY_INVITATION);
4054
+        $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION);
4056 4055
 
4057 4056
         $sql = "SELECT * FROM $table_survey_invitation
4058 4057
 		        WHERE
@@ -4188,7 +4187,7 @@  discard block
 block discarded – undo
4188 4187
     function display_survey_list_for_coach()
4189 4188
     {
4190 4189
         $parameters = array();
4191
-        $parameters['cidReq']=api_get_course_id();
4190
+        $parameters['cidReq'] = api_get_course_id();
4192 4191
         if (isset($_GET['do_search'])) {
4193 4192
             $message = get_lang('DisplaySearchResults').'<br />';
4194 4193
             $message .= '<a href="'.api_get_self().'?'.api_get_cidreq().'">'.get_lang('DisplayAll').'</a>';
@@ -4232,17 +4231,17 @@  discard block
 block discarded – undo
4232 4231
 
4233 4232
         if ($drh) {
4234 4233
             return '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.
4235
-            Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_SMALL).'</a>';
4234
+            Display::return_icon('stats.png', get_lang('Reporting'), '', ICON_SIZE_SMALL).'</a>';
4236 4235
         }
4237 4236
 
4238 4237
         // Coach can see that only if the survey is in his session
4239 4238
         if (api_is_allowed_to_edit() ||
4240 4239
             api_is_element_in_the_session(TOOL_SURVEY, $survey_id)
4241 4240
         ) {
4242
-            $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&action=edit&survey_id='.$survey_id.'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
4241
+            $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&action=edit&survey_id='.$survey_id.'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
4243 4242
             if (SurveyManager::survey_generation_hash_available()) {
4244
-                $return .=  Display::url(
4245
-                    Display::return_icon('new_link.png', get_lang('GenerateSurveyAccessLink'),'',ICON_SIZE_SMALL),
4243
+                $return .= Display::url(
4244
+                    Display::return_icon('new_link.png', get_lang('GenerateSurveyAccessLink'), '', ICON_SIZE_SMALL),
4246 4245
                     api_get_path(WEB_CODE_PATH).'survey/generate_link.php?survey_id='.$survey_id.'&'.api_get_cidreq()
4247 4246
                 );
4248 4247
             }
@@ -4252,20 +4251,20 @@  discard block
 block discarded – undo
4252 4251
             );
4253 4252
 
4254 4253
             $return .= ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&action=empty&survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("EmptySurvey").'?')).'\')) return false;">'.
4255
-                Display::return_icon('clean.png', get_lang('EmptySurvey'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
4254
+                Display::return_icon('clean.png', get_lang('EmptySurvey'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
4256 4255
         }
4257 4256
         $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.
4258
-            Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
4257
+            Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
4259 4258
         $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.
4260
-            Display::return_icon('mail_send.png', get_lang('Publish'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
4259
+            Display::return_icon('mail_send.png', get_lang('Publish'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
4261 4260
         $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.
4262
-            Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_SMALL).'</a>';
4261
+            Display::return_icon('stats.png', get_lang('Reporting'), '', ICON_SIZE_SMALL).'</a>';
4263 4262
 
4264 4263
         if (api_is_allowed_to_edit() ||
4265 4264
             api_is_element_in_the_session(TOOL_SURVEY, $survey_id)
4266 4265
         ) {
4267 4266
             $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurvey").'?', ENT_QUOTES)).'\')) return false;">'.
4268
-                Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
4267
+                Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
4269 4268
         }
4270 4269
 
4271 4270
         return $return;
@@ -4278,9 +4277,9 @@  discard block
 block discarded – undo
4278 4277
         //$return .= '<a href="survey_list.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurvey").'?', ENT_QUOTES)).'\')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
4279 4278
         //$return .= '<a href="create_survey_in_another_language.php?id_survey='.$survey_id.'">'.Display::return_icon('copy.gif', get_lang('Copy')).'</a>';
4280 4279
         //$return .= '<a href="survey.php?survey_id='.$survey_id.'">'.Display::return_icon('add.gif', get_lang('Add')).'</a>';
4281
-        $return = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
4282
-        $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('mail_send.png', get_lang('Publish'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
4283
-        $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&action=empty&survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("EmptySurvey").'?', ENT_QUOTES)).'\')) return false;">'.Display::return_icon('clean.png', get_lang('EmptySurvey'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
4280
+        $return = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
4281
+        $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('mail_send.png', get_lang('Publish'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
4282
+        $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&action=empty&survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("EmptySurvey").'?', ENT_QUOTES)).'\')) return false;">'.Display::return_icon('clean.png', get_lang('EmptySurvey'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
4284 4283
         //$return .= '<a href="reporting.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a>';
4285 4284
         return $return;
4286 4285
     }
@@ -4435,7 +4434,7 @@  discard block
 block discarded – undo
4435 4434
 
4436 4435
             // Validation when belonging to a session
4437 4436
             $session_img = api_get_session_image($survey['session_id'], $_user['status']);
4438
-            $array[2] = $survey[2] . $session_img;
4437
+            $array[2] = $survey[2].$session_img;
4439 4438
             $array[3] = $survey[3];
4440 4439
             $array[4] = $survey[4];
4441 4440
             $array[5] = $survey[5];
@@ -4469,10 +4468,10 @@  discard block
 block discarded – undo
4469 4468
         $last_version_surveys = $survey_tree->get_last_children_from_branch($survey_tree->surveylist);
4470 4469
         $list = array();
4471 4470
         foreach ($last_version_surveys as & $survey) {
4472
-            $list[]=$survey['id'];
4471
+            $list[] = $survey['id'];
4473 4472
         }
4474 4473
         if (count($list) > 0) {
4475
-            $list_condition = " AND survey.survey_id IN (".implode(',',$list).") ";
4474
+            $list_condition = " AND survey.survey_id IN (".implode(',', $list).") ";
4476 4475
         } else {
4477 4476
             $list_condition = '';
4478 4477
         }
@@ -4484,9 +4483,9 @@  discard block
 block discarded – undo
4484 4483
             $direction = 'asc';
4485 4484
         }
4486 4485
 
4487
-        $table_survey 			= Database :: get_course_table(TABLE_SURVEY);
4488
-        $table_survey_question 	= Database :: get_course_table(TABLE_SURVEY_QUESTION);
4489
-        $table_user 			= Database :: get_main_table(TABLE_MAIN_USER);
4486
+        $table_survey = Database :: get_course_table(TABLE_SURVEY);
4487
+        $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
4488
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
4490 4489
 
4491 4490
         $course_id = api_get_course_int_id();
4492 4491
 
@@ -4601,16 +4600,16 @@  discard block
 block discarded – undo
4601 4600
                     )
4602 4601
             ";
4603 4602
             $result_answer = Database::query($sql);
4604
-            $row_answer = Database::fetch_array($result_answer,'ASSOC');
4603
+            $row_answer = Database::fetch_array($result_answer, 'ASSOC');
4605 4604
             echo '<tr>';
4606 4605
             if ($row['answered'] == 0) {
4607 4606
                 echo '<td>';
4608
-                echo Display::return_icon('statistics.png', get_lang('CreateNewSurvey'),array('style'=>'inline-block'),ICON_SIZE_TINY);
4607
+                echo Display::return_icon('statistics.png', get_lang('CreateNewSurvey'), array('style'=>'inline-block'), ICON_SIZE_TINY);
4609 4608
                 echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?course='.$_course['sysCode'].'&invitationcode='.$row['invitation_code'].'&cidReq='.$_course['sysCode'].'">'.$row['title'].'</a></td>';
4610 4609
             } else {
4611 4610
                 //echo '<td>'.$row['title'].'</td>';
4612 4611
                 echo '<td>';
4613
-                echo Display::return_icon('statistics_na.png', get_lang('CreateNewSurvey'),array('style'=>'inline-block'),ICON_SIZE_TINY);
4612
+                echo Display::return_icon('statistics_na.png', get_lang('CreateNewSurvey'), array('style'=>'inline-block'), ICON_SIZE_TINY);
4614 4613
                 echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=questionreport&cidReq='.$_course['sysCode'].'&id_session='.$row['session_id'].'&gidReq='.'0'.'&origin='.''.'&survey_id='.$row['survey_id'].'">'.$row['title'].'</a></td>';
4615 4614
             }
4616 4615
             echo '<td class="center">';
@@ -4622,7 +4621,7 @@  discard block
 block discarded – undo
4622 4621
             } else {
4623 4622
                 $current_user_id = api_get_user_id();
4624 4623
             }
4625
-            $link_available = self::show_link_available(api_get_user_id(),$row['code'],$current_user_id);
4624
+            $link_available = self::show_link_available(api_get_user_id(), $row['code'], $current_user_id);
4626 4625
             //todo check this link
4627 4626
             if ($link_add === true && $link_available === true) {
4628 4627
                 //echo '<tr><td><a href="fillsurvey.php?user_id='.api_get_user_id().'&course='.$_course['sysCode'].'&invitationcode='.$row['invitation_code'].'&cidReq='.$_course['sysCode'].'">'.get_lang('CompleteTheSurveysQuestions').'</a></td><td></td></tr>';
@@ -4767,7 +4766,7 @@  discard block
 block discarded – undo
4767 4766
                     if ($field_details[7] == 0) {
4768 4767
                         $field_list_array['extra_'.$field_details[1]]['visibility'] = 0;
4769 4768
                     } else {
4770
-                        $field_list_array['extra_'.$field_details[1]]['visibility']=1;
4769
+                        $field_list_array['extra_'.$field_details[1]]['visibility'] = 1;
4771 4770
                     }
4772 4771
                     break;
4773 4772
                 case UserManager::USER_FIELD_TYPE_DIVIDER:
@@ -4834,7 +4833,7 @@  discard block
 block discarded – undo
4834 4833
         $htmlChart = '';
4835 4834
         if (api_browser_support("svg")) {
4836 4835
             $htmlChart .= api_get_js("d3/d3.v3.5.4.min.js");
4837
-            $htmlChart .= api_get_js("dimple.v2.1.2.min.js") . '
4836
+            $htmlChart .= api_get_js("dimple.v2.1.2.min.js").'
4838 4837
             <script type="text/javascript">
4839 4838
             var svg = dimple.newSvg("#'.$chartContainerId.'", "100%", 400);
4840 4839
             var data = [';
@@ -4843,40 +4842,40 @@  discard block
 block discarded – undo
4843 4842
             foreach ($chartData as $chartDataElement) {
4844 4843
                 $htmlChart .= '{"';
4845 4844
                 if (!$hasSerie) {
4846
-                    $htmlChart .= get_lang("Option") . '":"' . $chartDataElement['option'] . '", "';
4845
+                    $htmlChart .= get_lang("Option").'":"'.$chartDataElement['option'].'", "';
4847 4846
                     array_push($order, $chartDataElement['option']);
4848 4847
                 } else {
4849 4848
                     if (!is_array($chartDataElement['serie'])) {
4850
-                        $htmlChart .= get_lang("Option") . '":"' . $chartDataElement['serie'] . '", "' .
4851
-                            get_lang("Score") . '":"' . $chartDataElement['option'] . '", "';
4849
+                        $htmlChart .= get_lang("Option").'":"'.$chartDataElement['serie'].'", "'.
4850
+                            get_lang("Score").'":"'.$chartDataElement['option'].'", "';
4852 4851
                         array_push($serie, $chartDataElement['serie']);
4853 4852
                     } else {
4854
-                        $htmlChart .= get_lang("Serie") . '":"' . $chartDataElement['serie'][0] . '", "' .
4855
-                            get_lang("Option") . '":"' . $chartDataElement['serie'][1] . '", "' .
4856
-                            get_lang("Score") . '":"' . $chartDataElement['option'] . '", "';
4853
+                        $htmlChart .= get_lang("Serie").'":"'.$chartDataElement['serie'][0].'", "'.
4854
+                            get_lang("Option").'":"'.$chartDataElement['serie'][1].'", "'.
4855
+                            get_lang("Score").'":"'.$chartDataElement['option'].'", "';
4857 4856
                     }
4858 4857
                 }
4859
-                $htmlChart .= get_lang("Votes") . '":"' . $chartDataElement['votes'] .
4858
+                $htmlChart .= get_lang("Votes").'":"'.$chartDataElement['votes'].
4860 4859
                     '"},';
4861 4860
             }
4862 4861
             rtrim($htmlChart, ",");
4863 4862
             $htmlChart .= '];
4864 4863
                 var myChart = new dimple.chart(svg, data);
4865
-                myChart.addMeasureAxis("y", "' . get_lang("Votes") . '");';
4864
+                myChart.addMeasureAxis("y", "' . get_lang("Votes").'");';
4866 4865
             if (!$hasSerie) {
4867
-                $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", "' . get_lang("Option") . '");
4868
-                    xAxisCategory.addOrderRule(' . json_encode($order) . ');
4869
-                    myChart.addSeries("' . get_lang("Option") . '", dimple.plot.bar);';
4866
+                $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", "'.get_lang("Option").'");
4867
+                    xAxisCategory.addOrderRule(' . json_encode($order).');
4868
+                    myChart.addSeries("' . get_lang("Option").'", dimple.plot.bar);';
4870 4869
             } else {
4871 4870
                 if (!is_array($chartDataElement['serie'])) {
4872 4871
                     $serie = array_values(array_unique($serie));
4873
-                    $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", ["' . get_lang("Option") . '","' . get_lang("Score") . '"]);
4874
-                        xAxisCategory.addOrderRule(' . json_encode($serie) . ');
4875
-                        xAxisCategory.addGroupOrderRule("' . get_lang("Score") . '");
4876
-                        myChart.addSeries("' . get_lang("Option") . '", dimple.plot.bar);';
4872
+                    $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", ["'.get_lang("Option").'","'.get_lang("Score").'"]);
4873
+                        xAxisCategory.addOrderRule(' . json_encode($serie).');
4874
+                        xAxisCategory.addGroupOrderRule("' . get_lang("Score").'");
4875
+                        myChart.addSeries("' . get_lang("Option").'", dimple.plot.bar);';
4877 4876
                 } else {
4878
-                    $htmlChart .= 'myChart.addCategoryAxis("x", ["' . get_lang("Option") . '","' . get_lang("Score") . '"]);
4879
-                        myChart.addSeries("' . get_lang("Serie") . '", dimple.plot.bar);';
4877
+                    $htmlChart .= 'myChart.addCategoryAxis("x", ["'.get_lang("Option").'","'.get_lang("Score").'"]);
4878
+                        myChart.addSeries("' . get_lang("Serie").'", dimple.plot.bar);';
4880 4879
                 }
4881 4880
             }
4882 4881
             $htmlChart .= 'myChart.draw();
Please login to merge, or discard this patch.
main/gradebook/lib/gradebook_result.class.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     /**
15 15
      * constructor of the class
16 16
      */
17
-    public function __construct($get_questions=false,$get_answers=false)
17
+    public function __construct($get_questions = false, $get_answers = false)
18 18
     {
19 19
     }
20 20
 
@@ -36,21 +36,21 @@  discard block
 block discarded – undo
36 36
         //titles
37 37
 
38 38
         foreach ($dato[0] as $header_col) {
39
-            if(!empty($header_col)) {
40
-                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($header_col))).';';
39
+            if (!empty($header_col)) {
40
+                $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($header_col))).';';
41 41
             }
42 42
         }
43 43
 
44
-        $data .="\r\n";
44
+        $data .= "\r\n";
45 45
         $cant_students = count($dato[1]);
46 46
         //print_r($data);		exit();
47 47
 
48
-        for($i=0;$i<$cant_students;$i++) {
48
+        for ($i = 0; $i < $cant_students; $i++) {
49 49
             $column = 0;
50
-            foreach($dato[1][$i] as $col_name) {
51
-                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($col_name))).';';
50
+            foreach ($dato[1][$i] as $col_name) {
51
+                $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($col_name))).';';
52 52
             }
53
-            $data .="\r\n";
53
+            $data .= "\r\n";
54 54
         }
55 55
 
56 56
         //output the results
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function exportCompleteReportDOC($data)
123 123
     {
124
-        $filename = 'gradebook_results_'.api_get_local_time() . '.docx';
124
+        $filename = 'gradebook_results_'.api_get_local_time().'.docx';
125 125
 
126 126
         $doc = new \PhpOffice\PhpWord\PhpWord();
127 127
         $section = $doc->addSection(['orientation' => 'landscape']);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             }
141 141
         }
142 142
 
143
-        $file = api_get_path(SYS_ARCHIVE_PATH) . api_replace_dangerous_char($filename);
143
+        $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
144 144
         $doc->save($file, 'Word2007');
145 145
 
146 146
         DocumentManager::file_send_for_download($file, true, $filename);
Please login to merge, or discard this patch.
main/mySpace/current_courses.php 1 patch
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $filename = 'reporting.xls';
13 13
 
14 14
 if (!api_is_allowed_to_create_course()) {
15
-	api_not_allowed(true);
15
+    api_not_allowed(true);
16 16
 }
17 17
 
18 18
 $user_id = api_get_user_id();
@@ -23,222 +23,222 @@  discard block
 block discarded – undo
23 23
 $session_id = 0;
24 24
 
25 25
 if (!empty($my_courses)) {
26
-	foreach ($my_courses as $course) {
27
-		$course_code = $course['code'];
28
-		$course_id = $course['real_id'];
29
-		$course_info = api_get_course_info($course_code);
30
-
31
-		//Only show open courses
32
-		if ($course_info['visibility'] == 0) {
33
-			continue;
34
-		}
35
-
36
-		$teachers = CourseManager::get_teacher_list_from_course_code($course_code);
37
-		$teacher_list =  array();
38
-
39
-		if (!empty($teachers)) {
40
-			foreach($teachers as $teacher) {
41
-				$teacher_list[]= $teacher['firstname'].' '.$teacher['lastname'];
42
-			}
43
-		}
44
-
45
-		$tmp_students = CourseManager :: get_student_list_from_course_code($course_code, false);
46
-
47
-		//Cleaning students only REAL students
48
-		$students = array();
49
-		foreach ($tmp_students  as $student) {
50
-			$user_info = api_get_user_info($student['user_id']);
51
-			if ($user_info['status'] != STUDENT) {
52
-				continue;
53
-			}
54
-			$students[] = $student['user_id'];
55
-		}
56
-
57
-		$t_lp 	= Database :: get_course_table(TABLE_LP_MAIN);
58
-		$sql_lp = "SELECT lp.name, lp.id FROM $t_lp lp
26
+    foreach ($my_courses as $course) {
27
+        $course_code = $course['code'];
28
+        $course_id = $course['real_id'];
29
+        $course_info = api_get_course_info($course_code);
30
+
31
+        //Only show open courses
32
+        if ($course_info['visibility'] == 0) {
33
+            continue;
34
+        }
35
+
36
+        $teachers = CourseManager::get_teacher_list_from_course_code($course_code);
37
+        $teacher_list =  array();
38
+
39
+        if (!empty($teachers)) {
40
+            foreach($teachers as $teacher) {
41
+                $teacher_list[]= $teacher['firstname'].' '.$teacher['lastname'];
42
+            }
43
+        }
44
+
45
+        $tmp_students = CourseManager :: get_student_list_from_course_code($course_code, false);
46
+
47
+        //Cleaning students only REAL students
48
+        $students = array();
49
+        foreach ($tmp_students  as $student) {
50
+            $user_info = api_get_user_info($student['user_id']);
51
+            if ($user_info['status'] != STUDENT) {
52
+                continue;
53
+            }
54
+            $students[] = $student['user_id'];
55
+        }
56
+
57
+        $t_lp 	= Database :: get_course_table(TABLE_LP_MAIN);
58
+        $sql_lp = "SELECT lp.name, lp.id FROM $t_lp lp
59 59
 				   WHERE c_id = $course_id AND lp.session_id = 0";
60
-		$rs_lp 	= Database::query($sql_lp);
61
-		$t_lpi 	= Database :: get_course_table(TABLE_LP_ITEM);
62
-		$t_news = Database :: get_course_table(TABLE_ANNOUNCEMENT);
63
-
64
-		$total_tools_list = Tracking::get_tools_most_used_by_course(
65
-			$course_id,
66
-			$session_id
67
-		);
68
-
69
-		$total_tools = 0;
70
-		foreach($total_tools_list as $tool) {
71
-			$total_tools += $tool['count_access_tool'];
72
-		}
73
-
74
-		if (Database :: num_rows($rs_lp) > 0) {
75
-			while ($learnpath = Database :: fetch_array($rs_lp)) {
76
-				$lp_id = $learnpath['id'];
77
-
78
-				$lp_items =
79
-				$array[$i]['lp'] = '<a href="'.api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$course_code.'&amp;action=view&amp;lp_id='.$lp_id.'" target="_blank">'.$learnpath['name'].'</a>';
80
-
81
-				$array[$i]['teachers'] = '';
82
-				if (!empty($teacher_list)) {
83
-					$array[$i]['teachers'] = implode(', ', $teacher_list);
84
-				}
85
-
86
-				$array[$i]['course_name'] = $course['title'];
87
-				$count_students_accessing = 0;
88
-				$count_students_complete_all_activities = 0;
89
-				$count_students_complete_all_activities_at_50 = 0;
90
-				$total_time_spent = 0;
91
-				$total_average_progress = 0;
92
-
93
-				if (!empty($students)) {
94
-					foreach ($students  as $student_id) {
95
-						$avg_student_progress   = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
96
-						$myavg_temp 			= Tracking::get_avg_student_score($student_id, $course_code, array($lp_id), $session_id);
97
-						$avg_progress_in_course = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
98
-
99
-						if (intval($avg_progress_in_course) == 100) {
100
-							$count_students_complete_all_activities++;
101
-						}
102
-						if (intval($avg_progress_in_course) > 0 && intval($avg_progress_in_course) <= 50) {
103
-							$count_students_complete_all_activities_at_50 ++;
104
-						}
105
-						$total_average_progress +=$avg_progress_in_course;
106
-
107
-						$time_spent = Tracking::get_time_spent_on_the_course($student_id, $course_id, $session_id);
108
-						$total_time_spent += $time_spent;
109
-						if (!empty($time_spent)) {
110
-							$count_students_accessing++;
111
-						}
112
-					}
113
-					//$total_tools += $nb_assignments +  $messages + $links + $chat_last_connection + $documents;
114
-				}
115
-
116
-				$student_count = count($students);
117
-
118
-				$array[$i]['count_students'] = $student_count;
119
-				$array[$i]['count_students_accessing'] = 0;
120
-				$array[$i]['count_students_accessing_percentage'] = 0;
121
-				$array[$i]['count_students_complete_all_activities_at_50'] = 0;
122
-				$array[$i]['count_students_complete_all_activities'] = 0;
123
-				$array[$i]['average_percentage_activities_completed_per_student'] = 0;
124
-				$array[$i]['total_time_spent'] = 0;
125
-				$array[$i]['average_time_spent_per_student'] = 0;
126
-				$array[$i]['total_time_spent'] = 0;
127
-				$array[$i]['average_time_spent_per_student'] = 0;
128
-				//$array[$i]['tools_used'] = 0;
129
-				$array[$i]['learnpath_docs'] = 0;
130
-				$array[$i]['learnpath_exercises'] = 0;
131
-				$array[$i]['learnpath_links'] = 0;
132
-				$array[$i]['learnpath_forums'] = 0;
133
-				$array[$i]['learnpath_assignments'] = 0;
134
-
135
-				//registering the number of each category of
136
-				//items in learning path
137
-				$sql_lpi = "SELECT lpi.item_type FROM $t_lpi lpi
60
+        $rs_lp 	= Database::query($sql_lp);
61
+        $t_lpi 	= Database :: get_course_table(TABLE_LP_ITEM);
62
+        $t_news = Database :: get_course_table(TABLE_ANNOUNCEMENT);
63
+
64
+        $total_tools_list = Tracking::get_tools_most_used_by_course(
65
+            $course_id,
66
+            $session_id
67
+        );
68
+
69
+        $total_tools = 0;
70
+        foreach($total_tools_list as $tool) {
71
+            $total_tools += $tool['count_access_tool'];
72
+        }
73
+
74
+        if (Database :: num_rows($rs_lp) > 0) {
75
+            while ($learnpath = Database :: fetch_array($rs_lp)) {
76
+                $lp_id = $learnpath['id'];
77
+
78
+                $lp_items =
79
+                $array[$i]['lp'] = '<a href="'.api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?cidReq='.$course_code.'&amp;action=view&amp;lp_id='.$lp_id.'" target="_blank">'.$learnpath['name'].'</a>';
80
+
81
+                $array[$i]['teachers'] = '';
82
+                if (!empty($teacher_list)) {
83
+                    $array[$i]['teachers'] = implode(', ', $teacher_list);
84
+                }
85
+
86
+                $array[$i]['course_name'] = $course['title'];
87
+                $count_students_accessing = 0;
88
+                $count_students_complete_all_activities = 0;
89
+                $count_students_complete_all_activities_at_50 = 0;
90
+                $total_time_spent = 0;
91
+                $total_average_progress = 0;
92
+
93
+                if (!empty($students)) {
94
+                    foreach ($students  as $student_id) {
95
+                        $avg_student_progress   = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
96
+                        $myavg_temp 			= Tracking::get_avg_student_score($student_id, $course_code, array($lp_id), $session_id);
97
+                        $avg_progress_in_course = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
98
+
99
+                        if (intval($avg_progress_in_course) == 100) {
100
+                            $count_students_complete_all_activities++;
101
+                        }
102
+                        if (intval($avg_progress_in_course) > 0 && intval($avg_progress_in_course) <= 50) {
103
+                            $count_students_complete_all_activities_at_50 ++;
104
+                        }
105
+                        $total_average_progress +=$avg_progress_in_course;
106
+
107
+                        $time_spent = Tracking::get_time_spent_on_the_course($student_id, $course_id, $session_id);
108
+                        $total_time_spent += $time_spent;
109
+                        if (!empty($time_spent)) {
110
+                            $count_students_accessing++;
111
+                        }
112
+                    }
113
+                    //$total_tools += $nb_assignments +  $messages + $links + $chat_last_connection + $documents;
114
+                }
115
+
116
+                $student_count = count($students);
117
+
118
+                $array[$i]['count_students'] = $student_count;
119
+                $array[$i]['count_students_accessing'] = 0;
120
+                $array[$i]['count_students_accessing_percentage'] = 0;
121
+                $array[$i]['count_students_complete_all_activities_at_50'] = 0;
122
+                $array[$i]['count_students_complete_all_activities'] = 0;
123
+                $array[$i]['average_percentage_activities_completed_per_student'] = 0;
124
+                $array[$i]['total_time_spent'] = 0;
125
+                $array[$i]['average_time_spent_per_student'] = 0;
126
+                $array[$i]['total_time_spent'] = 0;
127
+                $array[$i]['average_time_spent_per_student'] = 0;
128
+                //$array[$i]['tools_used'] = 0;
129
+                $array[$i]['learnpath_docs'] = 0;
130
+                $array[$i]['learnpath_exercises'] = 0;
131
+                $array[$i]['learnpath_links'] = 0;
132
+                $array[$i]['learnpath_forums'] = 0;
133
+                $array[$i]['learnpath_assignments'] = 0;
134
+
135
+                //registering the number of each category of
136
+                //items in learning path
137
+                $sql_lpi = "SELECT lpi.item_type FROM $t_lpi lpi
138 138
 						    WHERE c_id = $course_id AND lpi.lp_id = $lp_id
139 139
 						    ORDER BY item_type";
140
-				$res_lpi = Database::query($sql_lpi);
141
-				while ($row_lpi = Database::fetch_array($res_lpi)) {
142
-					switch($row_lpi['item_type']) {
143
-						case 'document':
144
-							$array[$i]['learnpath_docs']++;
145
-							break;
146
-						case 'quiz':
147
-							$array[$i]['learnpath_exercises']++;
148
-							break;
149
-						case 'link':
150
-							$array[$i]['learnpath_links']++;
151
-							break;
152
-						case 'forum':
153
-						case 'thread':
154
-							$array[$i]['learnpath_forums']++;
155
-							break;
156
-						case 'student_publication':
157
-							$array[$i]['learnpath_assignments']++;
158
-							break;
159
-					}
160
-				}
161
-				// Count announcements
162
-				$array[$i]['total_announcements'] = 0;
163
-				$sql_news = "SELECT count(id) FROM $t_news WHERE c_id = $course_id ";
164
-				$res_news = Database::query($sql_news);
165
-				while ($row_news = Database::fetch_array($res_news)) {
166
-					$array[$i]['total_announcements'] = $row_news[0];
167
-				}
168
-
169
-				//@todo don't know what means this value
170
-				$count_students_complete_all_activities_at_50 = 0;
171
-
172
-				if (!empty($student_count)) {
173
-					$array[$i]['count_students_accessing'] = $count_students_accessing;
174
-					$array[$i]['count_students_accessing_percentage'] = round($count_students_accessing / $student_count *100 , 0);
175
-					$array[$i]['count_students_complete_all_activities_at_50'] = $count_students_complete_all_activities;
176
-					$array[$i]['count_students_complete_all_activities'] = round($count_students_complete_all_activities / $student_count *100 , 0);;
177
-					$array[$i]['average_percentage_activities_completed_per_student'] = round($count_students_complete_all_activities/$student_count*100,2);
178
-					$array[$i]['total_time_spent'] = 0;
179
-					$array[$i]['average_time_spent_per_student'] = 0;
180
-
181
-					if (!empty($total_time_spent)) {
182
-						$array[$i]['total_time_spent'] = api_time_to_hms($total_time_spent);
183
-						$array[$i]['average_time_spent_per_student'] = api_time_to_hms($total_time_spent / $student_count);
184
-					}
185
-					//$array[$i]['tools_used'] = $total_tools;
186
-				}
187
-				$i++;
188
-			}
189
-		}
190
-	}
140
+                $res_lpi = Database::query($sql_lpi);
141
+                while ($row_lpi = Database::fetch_array($res_lpi)) {
142
+                    switch($row_lpi['item_type']) {
143
+                        case 'document':
144
+                            $array[$i]['learnpath_docs']++;
145
+                            break;
146
+                        case 'quiz':
147
+                            $array[$i]['learnpath_exercises']++;
148
+                            break;
149
+                        case 'link':
150
+                            $array[$i]['learnpath_links']++;
151
+                            break;
152
+                        case 'forum':
153
+                        case 'thread':
154
+                            $array[$i]['learnpath_forums']++;
155
+                            break;
156
+                        case 'student_publication':
157
+                            $array[$i]['learnpath_assignments']++;
158
+                            break;
159
+                    }
160
+                }
161
+                // Count announcements
162
+                $array[$i]['total_announcements'] = 0;
163
+                $sql_news = "SELECT count(id) FROM $t_news WHERE c_id = $course_id ";
164
+                $res_news = Database::query($sql_news);
165
+                while ($row_news = Database::fetch_array($res_news)) {
166
+                    $array[$i]['total_announcements'] = $row_news[0];
167
+                }
168
+
169
+                //@todo don't know what means this value
170
+                $count_students_complete_all_activities_at_50 = 0;
171
+
172
+                if (!empty($student_count)) {
173
+                    $array[$i]['count_students_accessing'] = $count_students_accessing;
174
+                    $array[$i]['count_students_accessing_percentage'] = round($count_students_accessing / $student_count *100 , 0);
175
+                    $array[$i]['count_students_complete_all_activities_at_50'] = $count_students_complete_all_activities;
176
+                    $array[$i]['count_students_complete_all_activities'] = round($count_students_complete_all_activities / $student_count *100 , 0);;
177
+                    $array[$i]['average_percentage_activities_completed_per_student'] = round($count_students_complete_all_activities/$student_count*100,2);
178
+                    $array[$i]['total_time_spent'] = 0;
179
+                    $array[$i]['average_time_spent_per_student'] = 0;
180
+
181
+                    if (!empty($total_time_spent)) {
182
+                        $array[$i]['total_time_spent'] = api_time_to_hms($total_time_spent);
183
+                        $array[$i]['average_time_spent_per_student'] = api_time_to_hms($total_time_spent / $student_count);
184
+                    }
185
+                    //$array[$i]['tools_used'] = $total_tools;
186
+                }
187
+                $i++;
188
+            }
189
+        }
190
+    }
191 191
 }
192 192
 
193 193
 $headers = array(
194
-	get_lang('LearningPath'),
195
-	get_lang('Teachers'),
196
-	get_lang('Courses'),
197
-	get_lang('NumberOfStudents'),
198
-	get_lang('NumberStudentsAccessingCourse'),
199
-	get_lang('PercentageStudentsAccessingCourse'),
200
-	get_lang('NumberStudentsCompleteAllActivities'),
201
-	get_lang('PercentageStudentsCompleteAllActivities'),
202
-	get_lang('AverageOfActivitiesCompletedPerStudent'),
203
-	get_lang('TotalTimeSpentInTheCourse'),
204
-	get_lang('AverageTimePerStudentInCourse'),
205
-	get_lang('NumberOfDocumentsInLearnpath'),
206
-	get_lang('NumberOfExercisesInLearnpath'),
207
-	get_lang('NumberOfLinksInLearnpath'),
208
-	get_lang('NumberOfForumsInLearnpath'),
209
-	get_lang('NumberOfAssignmentsInLearnpath'),
210
-	get_lang('NumberOfAnnouncementsInCourse'),
194
+    get_lang('LearningPath'),
195
+    get_lang('Teachers'),
196
+    get_lang('Courses'),
197
+    get_lang('NumberOfStudents'),
198
+    get_lang('NumberStudentsAccessingCourse'),
199
+    get_lang('PercentageStudentsAccessingCourse'),
200
+    get_lang('NumberStudentsCompleteAllActivities'),
201
+    get_lang('PercentageStudentsCompleteAllActivities'),
202
+    get_lang('AverageOfActivitiesCompletedPerStudent'),
203
+    get_lang('TotalTimeSpentInTheCourse'),
204
+    get_lang('AverageTimePerStudentInCourse'),
205
+    get_lang('NumberOfDocumentsInLearnpath'),
206
+    get_lang('NumberOfExercisesInLearnpath'),
207
+    get_lang('NumberOfLinksInLearnpath'),
208
+    get_lang('NumberOfForumsInLearnpath'),
209
+    get_lang('NumberOfAssignmentsInLearnpath'),
210
+    get_lang('NumberOfAnnouncementsInCourse'),
211 211
 );
212 212
 
213 213
 if (isset($_GET['export'])) {
214
-	global $charset;
214
+    global $charset;
215 215
     $spreadsheet = new PHPExcel();
216 216
     $spreadsheet->setActiveSheetIndex(0);
217 217
     $worksheet = $spreadsheet->getActiveSheet();
218 218
 
219
-	$line = 0;
220
-	$column = 0; //skip the first column (row titles)
221
-
222
-	foreach ($headers as $header) {
223
-		$worksheet->setCellValueByColumnAndRow($column, $line, $header);
224
-		$column++;
225
-	}
226
-	$line++;
227
-	foreach ($array as $row) {
228
-		$column = 0;
229
-		foreach ($row as $item) {
230
-			$worksheet->setCellValueByColumnAndRow($column, $line, html_entity_decode(strip_tags($item)));
231
-			$column++;
232
-		}
233
-		$line++;
234
-	}
235
-	$line++;
219
+    $line = 0;
220
+    $column = 0; //skip the first column (row titles)
221
+
222
+    foreach ($headers as $header) {
223
+        $worksheet->setCellValueByColumnAndRow($column, $line, $header);
224
+        $column++;
225
+    }
226
+    $line++;
227
+    foreach ($array as $row) {
228
+        $column = 0;
229
+        foreach ($row as $item) {
230
+            $worksheet->setCellValueByColumnAndRow($column, $line, html_entity_decode(strip_tags($item)));
231
+            $column++;
232
+        }
233
+        $line++;
234
+    }
235
+    $line++;
236 236
 
237 237
     $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
238 238
     $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
239 239
     $writer->save($file);
240 240
     DocumentManager::file_send_for_download($file, true, $filename);
241
-	exit;
241
+    exit;
242 242
 }
243 243
 
244 244
 $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('MySpace'));
@@ -249,20 +249,20 @@  discard block
 block discarded – undo
249 249
 $row = 0;
250 250
 $column = 0;
251 251
 foreach ($headers as $header) {
252
-	$table->setHeaderContents($row, $column, $header);
253
-	$column++;
252
+    $table->setHeaderContents($row, $column, $header);
253
+    $column++;
254 254
 }
255 255
 $row++;
256 256
 
257 257
 foreach ($array as $row_table) {
258
-	$column = 0;
259
-	foreach ($row_table as $cell) {
260
-		$table->setCellContents($row, $column, $cell);
261
-		//$table->updateCellAttributes($row, $column, 'align="center"');
262
-		$column++;
263
-	}
264
-	$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
265
-	$row++;
258
+    $column = 0;
259
+    foreach ($row_table as $cell) {
260
+        $table->setCellContents($row, $column, $cell);
261
+        //$table->updateCellAttributes($row, $column, 'align="center"');
262
+        $column++;
263
+    }
264
+    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
265
+    $row++;
266 266
 }
267 267
 
268 268
 echo '<div class="actions">';
Please login to merge, or discard this patch.
main/exercice/exercise_result.class.php 2 patches
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 */
10 10
 class ExerciseResult
11 11
 {
12
-	private $results = array();
12
+    private $results = array();
13 13
     public $includeAllUsers = false;
14 14
     public $onlyBestAttempts = false;
15 15
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $exercise_id = 0,
47 47
         $hotpotato_name = null
48 48
     ) {
49
-		$return = array();
49
+        $return = array();
50 50
 
51 51
         $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
52 52
         $TBL_TABLE_LP_MAIN = Database::get_course_table(TABLE_LP_MAIN);
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
             $session_id_and .= " AND exe_exo_id = $exercise_id ";
67 67
         }
68 68
 
69
-		if (empty($user_id)) {
69
+        if (empty($user_id)) {
70 70
             $user_id_and = null;
71
-			$sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
71
+            $sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
72 72
 			            official_code,
73 73
                         ce.title as extitle,
74 74
                         te.exe_result as exresult ,
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
                     te.status != 'incomplete' AND
92 92
                     te.c_id = ce.c_id $user_id_and  $session_id_and AND
93 93
                     ce.active <>-1";
94
-		} else {
94
+        } else {
95 95
             $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
96
-			// get only this user's results
96
+            // get only this user's results
97 97
             $sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
98 98
                     official_code,
99 99
                     ce.title as extitle,
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
                         te.c_id = ce.c_id $user_id_and $session_id_and AND
120 120
                         ce.active <>-1 AND
121 121
                     ORDER BY userpart2, te.c_id ASC, ce.title ASC, te.exe_date DESC";
122
-		}
122
+        }
123 123
 
124
-		$results = array();
125
-		$resx = Database::query($sql);
124
+        $results = array();
125
+        $resx = Database::query($sql);
126 126
         $bestAttemptPerUser = array();
127
-		while ($rowx = Database::fetch_array($resx,'ASSOC')) {
127
+        while ($rowx = Database::fetch_array($resx,'ASSOC')) {
128 128
             if ($this->onlyBestAttempts) {
129 129
                 if (!isset($bestAttemptPerUser[$rowx['excruid']])) {
130 130
                     $bestAttemptPerUser[$rowx['excruid']] = $rowx;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             } else {
137 137
                 $results[] = $rowx;
138 138
             }
139
-		}
139
+        }
140 140
 
141 141
         if ($this->onlyBestAttempts) {
142 142
             $results = $bestAttemptPerUser;
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
                     continue;
191 191
                 }
192 192
 
193
-				$return[$i] = array();
194
-				if (empty($user_id)) {
193
+                $return[$i] = array();
194
+                if (empty($user_id)) {
195 195
                     $return[$i]['official_code']   = $result['official_code'];
196 196
                     if (api_is_western_name_order()) {
197 197
                         $return[$i]['first_name']   = $results[$i]['userpart1'];
@@ -200,15 +200,15 @@  discard block
 block discarded – undo
200 200
                         $return[$i]['first_name']   = $results[$i]['userpart2'];
201 201
                         $return[$i]['last_name']    = $results[$i]['userpart1'];
202 202
                     }
203
-					$return[$i]['user_id']      = $results[$i]['excruid'];
204
-					$return[$i]['email']        = $results[$i]['exemail'];
205
-				}
206
-				$return[$i]['title'] = $result['extitle'];
207
-				$return[$i]['start_date'] = api_get_local_time($result['exstart']);
203
+                    $return[$i]['user_id']      = $results[$i]['excruid'];
204
+                    $return[$i]['email']        = $results[$i]['exemail'];
205
+                }
206
+                $return[$i]['title'] = $result['extitle'];
207
+                $return[$i]['start_date'] = api_get_local_time($result['exstart']);
208 208
                 $return[$i]['end_date'] = api_get_local_time($result['exdate']);
209 209
                 $return[$i]['duration'] = $result['duration'];
210
-				$return[$i]['result'] = $result['exresult'];
211
-				$return[$i]['max'] = $result['exweight'];
210
+                $return[$i]['result'] = $result['exresult'];
211
+                $return[$i]['max'] = $result['exweight'];
212 212
                 $return[$i]['status'] = $revised ? get_lang('Validated') : get_lang('NotValidated');
213 213
                 $return[$i]['lp_id'] = $result['orig_lp_id'];
214 214
                 $return[$i]['lp_name'] = $result['lp_name'];
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 
222 222
                 $userWithResults[$result['excruid']] = 1;
223 223
                 $i++;
224
-			}
225
-		}
224
+            }
225
+        }
226 226
 
227 227
         if ($this->includeAllUsers) {
228 228
             $latestId = count($return);
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
             }
266 266
         }
267 267
 
268
-		$this->results = $return;
268
+        $this->results = $return;
269 269
 
270
-		return true;
271
-	}
270
+        return true;
271
+    }
272 272
 
273
-	/**
274
-	 * Exports the complete report as a CSV file
275
-	 * @param	string		Document path inside the document tool
276
-	 * @param	integer		Optional user ID
277
-	 * @param	boolean		Whether to include user fields or not
278
-	 * @return	boolean		False on error
279
-	 */
273
+    /**
274
+     * Exports the complete report as a CSV file
275
+     * @param	string		Document path inside the document tool
276
+     * @param	integer		Optional user ID
277
+     * @param	boolean		Whether to include user fields or not
278
+     * @return	boolean		False on error
279
+     */
280 280
     public function exportCompleteReportCSV(
281 281
         $document_path = '',
282 282
         $user_id = null,
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
         $exercise_id = 0,
286 286
         $hotpotato_name = null
287 287
     ) {
288
-		global $charset;
289
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
290
-
291
-		$filename = 'exercise_results_'.date('YmdGis').'.csv';
292
-		if(!empty($user_id)) {
293
-			$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
294
-		}
295
-		$data = '';
288
+        global $charset;
289
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
290
+
291
+        $filename = 'exercise_results_'.date('YmdGis').'.csv';
292
+        if(!empty($user_id)) {
293
+            $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
294
+        }
295
+        $data = '';
296 296
         if (api_is_western_name_order()) {
297 297
             if(!empty($this->results[0]['first_name'])) {
298 298
                 $data .= get_lang('FirstName').';';
@@ -316,28 +316,28 @@  discard block
 block discarded – undo
316 316
         $data .= get_lang('Email').';';
317 317
         $data .= get_lang('Groups').';';
318 318
 
319
-		if ($export_user_fields) {
320
-			//show user fields section with a big th colspan that spans over all fields
321
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
322
-			$num = count($extra_user_fields);
323
-			foreach($extra_user_fields as $field) {
324
-				$data .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
325
-			}
326
-		}
327
-
328
-		$data .= get_lang('Title').';';
329
-		$data .= get_lang('StartDate').';';
319
+        if ($export_user_fields) {
320
+            //show user fields section with a big th colspan that spans over all fields
321
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
322
+            $num = count($extra_user_fields);
323
+            foreach($extra_user_fields as $field) {
324
+                $data .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
325
+            }
326
+        }
327
+
328
+        $data .= get_lang('Title').';';
329
+        $data .= get_lang('StartDate').';';
330 330
         $data .= get_lang('EndDate').';';
331 331
         $data .= get_lang('Duration'). ' ('.get_lang('MinMinutes').') ;';
332
-		$data .= get_lang('Score').';';
333
-		$data .= get_lang('Total').';';
332
+        $data .= get_lang('Score').';';
333
+        $data .= get_lang('Total').';';
334 334
         $data .= get_lang('Status').';';
335 335
         $data .= get_lang('ToolLearnpath').';';
336 336
         $data .= get_lang('UserIsCurrentlySubscribed').';';
337
-		$data .= "\n";
337
+        $data .= "\n";
338 338
 
339
-		//results
340
-		foreach ($this->results as $row) {
339
+        //results
340
+        foreach ($this->results as $row) {
341 341
 
342 342
             if (api_is_western_name_order()) {
343 343
                 $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
@@ -354,51 +354,51 @@  discard block
 block discarded – undo
354 354
             $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
355 355
             $data .= str_replace("\r\n",'  ',implode(", ", GroupManager :: get_user_group_name($row['user_id']))).';';
356 356
 
357
-			if ($export_user_fields) {
358
-				//show user fields data, if any, for this user
359
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
360
-				foreach($user_fields_values as $value) {
361
-					$data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
362
-				}
363
-			}
357
+            if ($export_user_fields) {
358
+                //show user fields data, if any, for this user
359
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
360
+                foreach($user_fields_values as $value) {
361
+                    $data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
362
+                }
363
+            }
364 364
 
365
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
366
-			$data .= str_replace("\r\n",'  ',$row['start_date']).';';
365
+            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
366
+            $data .= str_replace("\r\n",'  ',$row['start_date']).';';
367 367
             $data .= str_replace("\r\n",'  ',$row['end_date']).';';
368 368
             $data .= str_replace("\r\n",'  ',$row['duration']).';';
369
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
370
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
369
+            $data .= str_replace("\r\n",'  ',$row['result']).';';
370
+            $data .= str_replace("\r\n",'  ',$row['max']).';';
371 371
             $data .= str_replace("\r\n",'  ',$row['status']).';';
372 372
             $data .= str_replace("\r\n",'  ',$row['lp_name']).';';
373 373
             $data .= str_replace("\r\n",'  ',$row['is_user_subscribed']).';';
374
-			$data .= "\n";
375
-		}
376
-
377
-		//output the results
378
-		$len = strlen($data);
379
-		header('Content-type: application/octet-stream');
380
-		header('Content-Type: application/force-download');
381
-		header('Content-length: '.$len);
382
-		if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
383
-			header('Content-Disposition: filename= '.$filename);
384
-		} else {
385
-			header('Content-Disposition: attachment; filename= '.$filename);
386
-		}
387
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
388
-			header('Pragma: ');
389
-			header('Cache-Control: ');
390
-			header('Cache-Control: public'); // IE cannot download from sessions without a cache
391
-		}
392
-		header('Content-Description: '.$filename);
393
-		header('Content-transfer-encoding: binary');
394
-		echo $data;
395
-		return true;
396
-	}
397
-
398
-	/**
399
-	 * Exports the complete report as an XLS file
400
-	 * @return	boolean		False on error
401
-	 */
374
+            $data .= "\n";
375
+        }
376
+
377
+        //output the results
378
+        $len = strlen($data);
379
+        header('Content-type: application/octet-stream');
380
+        header('Content-Type: application/force-download');
381
+        header('Content-length: '.$len);
382
+        if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
383
+            header('Content-Disposition: filename= '.$filename);
384
+        } else {
385
+            header('Content-Disposition: attachment; filename= '.$filename);
386
+        }
387
+        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
388
+            header('Pragma: ');
389
+            header('Cache-Control: ');
390
+            header('Cache-Control: public'); // IE cannot download from sessions without a cache
391
+        }
392
+        header('Content-Description: '.$filename);
393
+        header('Content-transfer-encoding: binary');
394
+        echo $data;
395
+        return true;
396
+    }
397
+
398
+    /**
399
+     * Exports the complete report as an XLS file
400
+     * @return	boolean		False on error
401
+     */
402 402
     public function exportCompleteReportXLS(
403 403
         $document_path = '',
404 404
         $user_id = null,
@@ -407,35 +407,35 @@  discard block
 block discarded – undo
407 407
         $exercise_id = 0,
408 408
         $hotpotato_name = null
409 409
     ) {
410
-		global $charset;
411
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
412
-		$filename = 'exercise_results_'.api_get_local_time().'.xls';
413
-		if (!empty($user_id)) {
414
-			$filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
415
-		}
410
+        global $charset;
411
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
412
+        $filename = 'exercise_results_'.api_get_local_time().'.xls';
413
+        if (!empty($user_id)) {
414
+            $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
415
+        }
416 416
 
417 417
         $spreadsheet = new PHPExcel();
418 418
         $spreadsheet->setActiveSheetIndex(0);
419 419
         $worksheet = $spreadsheet->getActiveSheet();
420 420
 
421
-		$line = 0;
422
-		$column = 0; //skip the first column (row titles)
421
+        $line = 0;
422
+        $column = 0; //skip the first column (row titles)
423 423
 
424
-		// check if exists column 'user'
425
-		$with_column_user = false;
426
-		foreach ($this->results as $result) {
427
-			if (!empty($result['last_name']) && !empty($result['first_name'])) {
428
-				$with_column_user = true;
429
-				break;
430
-			}
431
-		}
424
+        // check if exists column 'user'
425
+        $with_column_user = false;
426
+        foreach ($this->results as $result) {
427
+            if (!empty($result['last_name']) && !empty($result['first_name'])) {
428
+                $with_column_user = true;
429
+                break;
430
+            }
431
+        }
432 432
 
433 433
         $officialCodeInList = api_get_setting('show_official_code_exercise_result_list');
434 434
 
435
-		if ($with_column_user) {
435
+        if ($with_column_user) {
436 436
             if (api_is_western_name_order()) {
437
-    			$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
438
-    			$column++;
437
+                $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
438
+                $column++;
439 439
                 $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName'));
440 440
                 $column++;
441 441
             } else {
@@ -451,17 +451,17 @@  discard block
 block discarded – undo
451 451
             }
452 452
 
453 453
             $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email'));
454
-		    $column++;
455
-		}
454
+            $column++;
455
+        }
456 456
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Groups'));
457
-	    $column++;
457
+        $column++;
458 458
 
459
-		if ($export_user_fields) {
460
-			//show user fields section with a big th colspan that spans over all fields
461
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
459
+        if ($export_user_fields) {
460
+            //show user fields section with a big th colspan that spans over all fields
461
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
462 462
 
463
-			//show the fields names for user fields
464
-			foreach ($extra_user_fields as $field) {
463
+            //show the fields names for user fields
464
+            foreach ($extra_user_fields as $field) {
465 465
                 $worksheet->setCellValueByColumnAndRow(
466 466
                     $column,
467 467
                     $line,
@@ -471,31 +471,31 @@  discard block
 block discarded – undo
471 471
                         $charset
472 472
                     )
473 473
                 );
474
-				$column++;
475
-			}
476
-		}
474
+                $column++;
475
+            }
476
+        }
477 477
 
478
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title'));
479
-		$column++;
480
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate'));
478
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title'));
479
+        $column++;
480
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate'));
481 481
         $column++;
482 482
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('EndDate'));
483 483
         $column++;
484 484
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Duration').' ('.get_lang('MinMinutes').')');
485
-		$column++;
486
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score'));
487
-		$column++;
488
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total'));
489
-		$column++;
485
+        $column++;
486
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score'));
487
+        $column++;
488
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total'));
489
+        $column++;
490 490
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Status'));
491
-		$column++;
491
+        $column++;
492 492
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('ToolLearnpath'));
493 493
         $column++;
494 494
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('UserIsCurrentlySubscribed'));
495
-		$line++;
495
+        $line++;
496 496
 
497
-		foreach ($this->results as $row) {
498
-			$column = 0;
497
+        foreach ($this->results as $row) {
498
+            $column = 0;
499 499
 
500 500
             if ($with_column_user) {
501 501
                 if (api_is_western_name_order()) {
@@ -517,15 +517,15 @@  discard block
 block discarded – undo
517 517
 
518 518
                 $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
519 519
                 $column++;
520
-			}
520
+            }
521 521
 
522 522
             $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags(implode(", ", GroupManager :: get_user_group_name($row['user_id']))), ENT_QUOTES, $charset));
523 523
             $column++;
524 524
 
525
-			if ($export_user_fields) {
526
-				//show user fields data, if any, for this user
527
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
528
-				foreach($user_fields_values as $value) {
525
+            if ($export_user_fields) {
526
+                //show user fields data, if any, for this user
527
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
528
+                foreach($user_fields_values as $value) {
529 529
                     $worksheet->setCellValueByColumnAndRow(
530 530
                         $column,
531 531
                         $line,
@@ -535,12 +535,12 @@  discard block
 block discarded – undo
535 535
                             $charset
536 536
                         )
537 537
                     );
538
-					$column++;
539
-				}
540
-			}
538
+                    $column++;
539
+                }
540
+            }
541 541
 
542
-			$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
543
-			$column++;
542
+            $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
543
+            $column++;
544 544
             $worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']);
545 545
             $column++;
546 546
             $worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']);
@@ -556,14 +556,14 @@  discard block
 block discarded – undo
556 556
             $worksheet->setCellValueByColumnAndRow($column, $line, $row['lp_name']);
557 557
             $column++;
558 558
             $worksheet->setCellValueByColumnAndRow($column, $line, $row['is_user_subscribed']);
559
-			$line++;
560
-		}
559
+            $line++;
560
+        }
561 561
 
562 562
         $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
563 563
         $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
564 564
         $writer->save($file);
565 565
         DocumentManager::file_send_for_download($file, true, $filename);
566 566
 
567
-		return true;
568
-	}
567
+        return true;
568
+    }
569 569
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $course_id = api_get_course_int_id();
60 60
         $user_id = intval($user_id);
61 61
         $sessionId = api_get_session_id();
62
-        $session_id_and = ' AND te.session_id = ' . $sessionId . ' ';
62
+        $session_id_and = ' AND te.session_id = '.$sessionId.' ';
63 63
         $exercise_id = intval($exercise_id);
64 64
 
65 65
         if (!empty($exercise_id)) {
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
                     te.c_id = ce.c_id $user_id_and  $session_id_and AND
93 93
                     ce.active <>-1";
94 94
 		} else {
95
-            $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
95
+            $user_id_and = ' AND te.exe_user_id = '.api_get_user_id().' ';
96 96
 			// get only this user's results
97
-            $sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
97
+            $sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
98 98
                     official_code,
99 99
                     ce.title as extitle,
100 100
                     te.exe_result as exresult,
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		$results = array();
125 125
 		$resx = Database::query($sql);
126 126
         $bestAttemptPerUser = array();
127
-		while ($rowx = Database::fetch_array($resx,'ASSOC')) {
127
+		while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
128 128
             if ($this->onlyBestAttempts) {
129 129
                 if (!isset($bestAttemptPerUser[$rowx['excruid']])) {
130 130
                     $bestAttemptPerUser[$rowx['excruid']] = $rowx;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 				$return[$i] = array();
194 194
 				if (empty($user_id)) {
195
-                    $return[$i]['official_code']   = $result['official_code'];
195
+                    $return[$i]['official_code'] = $result['official_code'];
196 196
                     if (api_is_western_name_order()) {
197 197
                         $return[$i]['first_name']   = $results[$i]['userpart1'];
198 198
                         $return[$i]['last_name']    = $results[$i]['userpart2'];
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
                         $isWestern = api_is_western_name_order();
237 237
 
238 238
                         if (empty($user_id)) {
239
-                            $return[$i]['official_code']   = $student['official_code'];
239
+                            $return[$i]['official_code'] = $student['official_code'];
240 240
                             if ($isWestern) {
241 241
                                 $return[$i]['first_name']   = $student['firstname'];
242 242
                                 $return[$i]['last_name']    = $student['lastname'];
@@ -289,22 +289,22 @@  discard block
 block discarded – undo
289 289
 		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
290 290
 
291 291
 		$filename = 'exercise_results_'.date('YmdGis').'.csv';
292
-		if(!empty($user_id)) {
292
+		if (!empty($user_id)) {
293 293
 			$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
294 294
 		}
295 295
 		$data = '';
296 296
         if (api_is_western_name_order()) {
297
-            if(!empty($this->results[0]['first_name'])) {
297
+            if (!empty($this->results[0]['first_name'])) {
298 298
                 $data .= get_lang('FirstName').';';
299 299
             }
300
-            if(!empty($this->results[0]['last_name'])) {
300
+            if (!empty($this->results[0]['last_name'])) {
301 301
                 $data .= get_lang('LastName').';';
302 302
             }
303 303
         } else {
304
-            if(!empty($this->results[0]['last_name'])) {
304
+            if (!empty($this->results[0]['last_name'])) {
305 305
                 $data .= get_lang('LastName').';';
306 306
             }
307
-            if(!empty($this->results[0]['first_name'])) {
307
+            if (!empty($this->results[0]['first_name'])) {
308 308
                 $data .= get_lang('FirstName').';';
309 309
             }
310 310
         }
@@ -318,17 +318,17 @@  discard block
 block discarded – undo
318 318
 
319 319
 		if ($export_user_fields) {
320 320
 			//show user fields section with a big th colspan that spans over all fields
321
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
321
+			$extra_user_fields = UserManager::get_extra_fields(0, 1000, 5, 'ASC', false, 1);
322 322
 			$num = count($extra_user_fields);
323
-			foreach($extra_user_fields as $field) {
324
-				$data .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
323
+			foreach ($extra_user_fields as $field) {
324
+				$data .= '"'.str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
325 325
 			}
326 326
 		}
327 327
 
328 328
 		$data .= get_lang('Title').';';
329 329
 		$data .= get_lang('StartDate').';';
330 330
         $data .= get_lang('EndDate').';';
331
-        $data .= get_lang('Duration'). ' ('.get_lang('MinMinutes').') ;';
331
+        $data .= get_lang('Duration').' ('.get_lang('MinMinutes').') ;';
332 332
 		$data .= get_lang('Score').';';
333 333
 		$data .= get_lang('Total').';';
334 334
         $data .= get_lang('Status').';';
@@ -340,37 +340,37 @@  discard block
 block discarded – undo
340 340
 		foreach ($this->results as $row) {
341 341
 
342 342
             if (api_is_western_name_order()) {
343
-                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
344
-                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
343
+                $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
344
+                $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
345 345
             } else {
346
-                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
347
-                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
346
+                $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
347
+                $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
348 348
             }
349 349
 
350 350
             if ($officialCodeInList) {
351 351
                 $data .= $row['official_code'].';';
352 352
             }
353 353
 
354
-            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
355
-            $data .= str_replace("\r\n",'  ',implode(", ", GroupManager :: get_user_group_name($row['user_id']))).';';
354
+            $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
355
+            $data .= str_replace("\r\n", '  ', implode(", ", GroupManager :: get_user_group_name($row['user_id']))).';';
356 356
 
357 357
 			if ($export_user_fields) {
358 358
 				//show user fields data, if any, for this user
359
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
360
-				foreach($user_fields_values as $value) {
361
-					$data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
359
+				$user_fields_values = UserManager::get_extra_user_data($row['user_id'], false, false, false, true);
360
+				foreach ($user_fields_values as $value) {
361
+					$data .= '"'.str_replace('"', '""', api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
362 362
 				}
363 363
 			}
364 364
 
365
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
366
-			$data .= str_replace("\r\n",'  ',$row['start_date']).';';
367
-            $data .= str_replace("\r\n",'  ',$row['end_date']).';';
368
-            $data .= str_replace("\r\n",'  ',$row['duration']).';';
369
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
370
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
371
-            $data .= str_replace("\r\n",'  ',$row['status']).';';
372
-            $data .= str_replace("\r\n",'  ',$row['lp_name']).';';
373
-            $data .= str_replace("\r\n",'  ',$row['is_user_subscribed']).';';
365
+			$data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
366
+			$data .= str_replace("\r\n", '  ', $row['start_date']).';';
367
+            $data .= str_replace("\r\n", '  ', $row['end_date']).';';
368
+            $data .= str_replace("\r\n", '  ', $row['duration']).';';
369
+			$data .= str_replace("\r\n", '  ', $row['result']).';';
370
+			$data .= str_replace("\r\n", '  ', $row['max']).';';
371
+            $data .= str_replace("\r\n", '  ', $row['status']).';';
372
+            $data .= str_replace("\r\n", '  ', $row['lp_name']).';';
373
+            $data .= str_replace("\r\n", '  ', $row['is_user_subscribed']).';';
374 374
 			$data .= "\n";
375 375
 		}
376 376
 
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 
459 459
 		if ($export_user_fields) {
460 460
 			//show user fields section with a big th colspan that spans over all fields
461
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
461
+			$extra_user_fields = UserManager::get_extra_fields(0, 1000, 5, 'ASC', false, 1);
462 462
 
463 463
 			//show the fields names for user fields
464 464
 			foreach ($extra_user_fields as $field) {
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
 
525 525
 			if ($export_user_fields) {
526 526
 				//show user fields data, if any, for this user
527
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
528
-				foreach($user_fields_values as $value) {
527
+				$user_fields_values = UserManager::get_extra_user_data($row['user_id'], false, false, false, true);
528
+				foreach ($user_fields_values as $value) {
529 529
                     $worksheet->setCellValueByColumnAndRow(
530 530
                         $column,
531 531
                         $line,
Please login to merge, or discard this patch.
main/exercice/hotpotatoes_exercise_result.class.php 2 patches
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
     //stores the results
15 15
     private $results = array();
16 16
 
17
-	/**
18
-	 * Gets the results of all students (or just one student if access is limited)
19
-	 * @param	string		The document path (for HotPotatoes retrieval)
20
-	 * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
-	 * @param string $document_path
22
-	 */
23
-	public function getExercisesReporting($document_path, $hotpotato_name)
17
+    /**
18
+     * Gets the results of all students (or just one student if access is limited)
19
+     * @param	string		The document path (for HotPotatoes retrieval)
20
+     * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
+     * @param string $document_path
22
+     */
23
+    public function getExercisesReporting($document_path, $hotpotato_name)
24 24
     {
25
-		$return = array();
25
+        $return = array();
26 26
         $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
27 27
         $TBL_TRACK_HOTPOTATOES	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
28 28
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $hotpotato_name  = Database::escape_string($hotpotato_name);
35 35
 
36 36
         if (!empty($exercise_id)) {
37
-          $session_id_and .= " AND exe_exo_id = $exercise_id ";
37
+            $session_id_and .= " AND exe_exo_id = $exercise_id ";
38 38
         }
39 39
 
40 40
         if (empty($user_id)) {
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
         $this->results = $return;
112 112
 
113 113
         return true;
114
-	}
114
+    }
115 115
 
116 116
 
117
-	/**
118
-	 * Exports the complete report as a CSV file
119
-	 * @param	string		Document path inside the document tool
120
-	 * @param	integer		Optional user ID
121
-	 * @param	boolean		Whether to include user fields or not
122
-	 * @return	boolean		False on error
123
-	 */
124
-	public function exportCompleteReportCSV($document_path = '', $hotpotato_name)
117
+    /**
118
+     * Exports the complete report as a CSV file
119
+     * @param	string		Document path inside the document tool
120
+     * @param	integer		Optional user ID
121
+     * @param	boolean		Whether to include user fields or not
122
+     * @return	boolean		False on error
123
+     */
124
+    public function exportCompleteReportCSV($document_path = '', $hotpotato_name)
125 125
     {
126
-		global $charset;
127
-		$this->getExercisesReporting($document_path, $hotpotato_name);
128
-		$filename = 'exercise_results_'.date('YmdGis').'.csv';
129
-		if (!empty($user_id)) {
130
-			$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
131
-		}
132
-		$data = '';
126
+        global $charset;
127
+        $this->getExercisesReporting($document_path, $hotpotato_name);
128
+        $filename = 'exercise_results_'.date('YmdGis').'.csv';
129
+        if (!empty($user_id)) {
130
+            $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
131
+        }
132
+        $data = '';
133 133
 
134 134
         if (api_is_western_name_order()) {
135 135
             if(!empty($this->results[0]['first_name'])) {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         }
149 149
         $data .= get_lang('Email').';';
150 150
 
151
-		/*if ($export_user_fields) {
151
+        /*if ($export_user_fields) {
152 152
 			//show user fields section with a big th colspan that spans over all fields
153 153
 			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
154 154
 			$num = count($extra_user_fields);
@@ -157,25 +157,25 @@  discard block
 block discarded – undo
157 157
 			}
158 158
 		}*/
159 159
 
160
-		$data .= get_lang('Title').';';
161
-		$data .= get_lang('StartDate').';';
162
-		$data .= get_lang('Score').';';
163
-		$data .= get_lang('Total').';';
164
-		$data .= "\n";
160
+        $data .= get_lang('Title').';';
161
+        $data .= get_lang('StartDate').';';
162
+        $data .= get_lang('Score').';';
163
+        $data .= get_lang('Total').';';
164
+        $data .= "\n";
165 165
 
166
-		//results
167
-		foreach($this->results as $row) {
166
+        //results
167
+        foreach($this->results as $row) {
168 168
             if (api_is_western_name_order()) {
169
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
170
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
169
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
170
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
171 171
             } else {
172
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
173
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
172
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
173
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
174 174
             }
175 175
 
176 176
             $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
177 177
 
178
-			/*if ($export_user_fields) {
178
+            /*if ($export_user_fields) {
179 179
 				//show user fields data, if any, for this user
180 180
 				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
181 181
 				foreach($user_fields_values as $value) {
@@ -183,40 +183,40 @@  discard block
 block discarded – undo
183 183
 				}
184 184
 			}*/
185 185
 
186
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
187
-			$data .= str_replace("\r\n",'  ',$row['exe_date']).';';
188
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
189
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
190
-			$data .= "\n";
191
-		}
192
-
193
-		//output the results
194
-		$len = strlen($data);
195
-		header('Content-type: application/octet-stream');
196
-		header('Content-Type: application/force-download');
197
-		header('Content-length: '.$len);
198
-		if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
199
-			header('Content-Disposition: filename= '.$filename);
200
-		} else {
201
-			header('Content-Disposition: attachment; filename= '.$filename);
202
-		}
203
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
204
-			header('Pragma: ');
205
-			header('Cache-Control: ');
206
-			header('Cache-Control: public'); // IE cannot download from sessions without a cache
207
-		}
208
-		header('Content-Description: '.$filename);
209
-		header('Content-transfer-encoding: binary');
210
-		// @todo add this utf-8 header for all csv files
211
-		echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
212
-		echo $data;
213
-		return true;
214
-	}
215
-
216
-	/**
217
-	 * Exports the complete report as an XLS file
218
-	 * @return	boolean		False on error
219
-	 */
186
+            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
187
+            $data .= str_replace("\r\n",'  ',$row['exe_date']).';';
188
+            $data .= str_replace("\r\n",'  ',$row['result']).';';
189
+            $data .= str_replace("\r\n",'  ',$row['max']).';';
190
+            $data .= "\n";
191
+        }
192
+
193
+        //output the results
194
+        $len = strlen($data);
195
+        header('Content-type: application/octet-stream');
196
+        header('Content-Type: application/force-download');
197
+        header('Content-length: '.$len);
198
+        if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
199
+            header('Content-Disposition: filename= '.$filename);
200
+        } else {
201
+            header('Content-Disposition: attachment; filename= '.$filename);
202
+        }
203
+        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
204
+            header('Pragma: ');
205
+            header('Cache-Control: ');
206
+            header('Cache-Control: public'); // IE cannot download from sessions without a cache
207
+        }
208
+        header('Content-Description: '.$filename);
209
+        header('Content-transfer-encoding: binary');
210
+        // @todo add this utf-8 header for all csv files
211
+        echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
212
+        echo $data;
213
+        return true;
214
+    }
215
+
216
+    /**
217
+     * Exports the complete report as an XLS file
218
+     * @return	boolean		False on error
219
+     */
220 220
     public function exportCompleteReportXLS(
221 221
         $document_path = '',
222 222
         $user_id = null,
@@ -225,37 +225,37 @@  discard block
 block discarded – undo
225 225
         $exercise_id = 0,
226 226
         $hotpotato_name = null
227 227
     ) {
228
-		global $charset;
229
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
230
-		$filename = 'exercise_results_'.api_get_local_time().'.xls';
231
-		if (!empty($user_id)) {
232
-			$filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
233
-		}
228
+        global $charset;
229
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
230
+        $filename = 'exercise_results_'.api_get_local_time().'.xls';
231
+        if (!empty($user_id)) {
232
+            $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
233
+        }
234 234
 
235 235
         $spreadsheet = new PHPExcel();
236 236
         $spreadsheet->setActiveSheetIndex(0);
237 237
         $worksheet = $spreadsheet->getActiveSheet();
238 238
 
239 239
 
240
-		$line = 0;
241
-		$column = 0; //skip the first column (row titles)
240
+        $line = 0;
241
+        $column = 0; //skip the first column (row titles)
242 242
 
243
-		// check if exists column 'user'
244
-		$with_column_user = false;
245
-		foreach ($this->results as $result) {
246
-			if (!empty($result['last_name']) && !empty($result['first_name'])) {
247
-				$with_column_user = true;
248
-				break;
249
-			}
250
-		}
243
+        // check if exists column 'user'
244
+        $with_column_user = false;
245
+        foreach ($this->results as $result) {
246
+            if (!empty($result['last_name']) && !empty($result['first_name'])) {
247
+                $with_column_user = true;
248
+                break;
249
+            }
250
+        }
251 251
 
252
-		if ($with_column_user) {
253
-		    $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email'));
254
-		    $column++;
252
+        if ($with_column_user) {
253
+            $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email'));
254
+            $column++;
255 255
 
256 256
             if (api_is_western_name_order()) {
257
-    			$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
258
-    			$column++;
257
+                $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
258
+                $column++;
259 259
                 $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName'));
260 260
                 $column++;
261 261
             } else {
@@ -264,36 +264,36 @@  discard block
 block discarded – undo
264 264
                 $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
265 265
                 $column++;
266 266
             }
267
-		}
267
+        }
268 268
 
269
-		if ($export_user_fields) {
270
-			//show user fields section with a big th colspan that spans over all fields
271
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
269
+        if ($export_user_fields) {
270
+            //show user fields section with a big th colspan that spans over all fields
271
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
272 272
 
273
-			//show the fields names for user fields
274
-			foreach ($extra_user_fields as $field) {
275
-				$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
276
-				$column++;
277
-			}
278
-		}
273
+            //show the fields names for user fields
274
+            foreach ($extra_user_fields as $field) {
275
+                $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
276
+                $column++;
277
+            }
278
+        }
279 279
 
280
-		$worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Title'));
281
-		$column++;
282
-		$worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('StartDate'));
280
+        $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Title'));
281
+        $column++;
282
+        $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('StartDate'));
283 283
         $column++;
284 284
         $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('EndDate'));
285 285
         $column++;
286 286
         $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Duration').' ('.get_lang('MinMinutes').')');
287
-		$column++;
288
-		$worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Score'));
289
-		$column++;
290
-		$worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Total'));
291
-		$column++;
287
+        $column++;
288
+        $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Score'));
289
+        $column++;
290
+        $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Total'));
291
+        $column++;
292 292
         $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Status'));
293
-		$line++;
293
+        $line++;
294 294
 
295
-		foreach ($this->results as $row) {
296
-			$column = 0;
295
+        foreach ($this->results as $row) {
296
+            $column = 0;
297 297
 
298 298
             if ($with_column_user) {
299 299
                 $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
@@ -310,38 +310,38 @@  discard block
 block discarded – undo
310 310
                     $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
311 311
                     $column++;
312 312
                 }
313
-			}
313
+            }
314 314
 
315
-			if ($export_user_fields) {
316
-				//show user fields data, if any, for this user
317
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
318
-				foreach($user_fields_values as $value) {
319
-					$worksheet->setCellValueByColumnAndRow($column, $line,  api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
320
-					$column++;
321
-				}
322
-			}
315
+            if ($export_user_fields) {
316
+                //show user fields data, if any, for this user
317
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
318
+                foreach($user_fields_values as $value) {
319
+                    $worksheet->setCellValueByColumnAndRow($column, $line,  api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
320
+                    $column++;
321
+                }
322
+            }
323 323
 
324
-			$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
325
-			$column++;
326
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']);
324
+            $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
325
+            $column++;
326
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']);
327 327
             $column++;
328
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']);
328
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']);
329
+            $column++;
330
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']);
331
+            $column++;
332
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['result']);
333
+            $column++;
334
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['max']);
329 335
             $column++;
330
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']);
331
-			$column++;
332
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['result']);
333
-			$column++;
334
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['max']);
335
-			$column++;
336 336
             $worksheet->setCellValueByColumnAndRow($column, $line, $row['status']);
337
-			$line++;
338
-		}
337
+            $line++;
338
+        }
339 339
 
340 340
         $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
341 341
         $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
342 342
         $writer->save($file);
343 343
         DocumentManager::file_send_for_download($file, true, $filename);
344 344
 
345
-		return true;
346
-	}
345
+        return true;
346
+    }
347 347
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
     {
25 25
 		$return = array();
26 26
         $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
27
-        $TBL_TRACK_HOTPOTATOES	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
27
+        $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
28 28
 
29 29
         $cid             = api_get_course_id();
30 30
         $course_id       = api_get_course_int_id();
31 31
         //$user_id         = intval($user_id);
32 32
         $user_id = null;
33
-        $session_id_and  = ' AND te.session_id = ' . api_get_session_id() . ' ';
33
+        $session_id_and  = ' AND te.session_id = '.api_get_session_id().' ';
34 34
         $hotpotato_name  = Database::escape_string($hotpotato_name);
35 35
 
36 36
         if (!empty($exercise_id)) {
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         }
39 39
 
40 40
         if (empty($user_id)) {
41
-            $sql="SELECT firstname as userpart1, lastname as userpart2 ,
41
+            $sql = "SELECT firstname as userpart1, lastname as userpart2 ,
42 42
                     email,
43 43
                     tth.exe_name,
44 44
                     tth.exe_result,
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
                             tth.exe_name = '$hotpotato_name'
51 51
                     ORDER BY tth.c_id ASC, tth.exe_date ASC";
52 52
         } else {
53
-            $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
53
+            $user_id_and = ' AND te.exe_user_id = '.api_get_user_id().' ';
54 54
             // get only this user's results
55 55
 
56 56
             $sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date
57 57
                     FROM $TBL_TRACK_HOTPOTATOES
58 58
                     WHERE
59
-                        exe_user_id = '" . $user_id . "' AND
59
+                        exe_user_id = '".$user_id."' AND
60 60
                         c_id = $course_id AND
61 61
                         tth.exe_name = '$hotpotato_name'
62 62
                     ORDER BY c_id ASC, exe_date ASC";
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
         $results = array();
66 66
 
67 67
         $resx = Database::query($sql);
68
-        while ($rowx = Database::fetch_array($resx,'ASSOC')) {
68
+        while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
69 69
             $results[] = $rowx;
70 70
         }
71 71
 
72 72
         $hpresults = array();
73 73
         $resx = Database::query($sql);
74
-        while ($rowx = Database::fetch_array($resx,'ASSOC')) {
74
+        while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
75 75
             $hpresults[] = $rowx;
76 76
         }
77 77
 
@@ -90,19 +90,19 @@  discard block
 block discarded – undo
90 90
 
91 91
         // Print the Result of Hotpotatoes Tests
92 92
         if (is_array($hpresults)) {
93
-            for($i = 0; $i < sizeof($hpresults); $i++) {
93
+            for ($i = 0; $i < sizeof($hpresults); $i++) {
94 94
                 $return[$i] = array();
95 95
                 $title = GetQuizName($hpresults[$i]['exe_name'], $document_path);
96
-                if ($title =='') {
96
+                if ($title == '') {
97 97
                     $title = basename($hpresults[$i]['exe_name']);
98 98
                 }
99
-                if(empty($user_id)) {
99
+                if (empty($user_id)) {
100 100
                 $return[$i]['email'] = $hpresults[$i]['email'];
101 101
                     $return[$i]['first_name'] = $hpresults[$i]['userpart1'];
102 102
                     $return[$i]['last_name'] = $hpresults[$i]['userpart2'];
103 103
                 }
104 104
                 $return[$i]['title'] = $title;
105
-                $return[$i]['exe_date']  = $hpresults[$i]['exe_date'];
105
+                $return[$i]['exe_date'] = $hpresults[$i]['exe_date'];
106 106
 
107 107
                 $return[$i]['result'] = $hpresults[$i]['exe_result'];
108 108
                 $return[$i]['max'] = $hpresults[$i]['exe_weighting'];
@@ -132,17 +132,17 @@  discard block
 block discarded – undo
132 132
 		$data = '';
133 133
 
134 134
         if (api_is_western_name_order()) {
135
-            if(!empty($this->results[0]['first_name'])) {
135
+            if (!empty($this->results[0]['first_name'])) {
136 136
                 $data .= get_lang('FirstName').';';
137 137
             }
138
-            if(!empty($this->results[0]['last_name'])) {
138
+            if (!empty($this->results[0]['last_name'])) {
139 139
                 $data .= get_lang('LastName').';';
140 140
             }
141 141
         } else {
142
-            if(!empty($this->results[0]['last_name'])) {
142
+            if (!empty($this->results[0]['last_name'])) {
143 143
                 $data .= get_lang('LastName').';';
144 144
             }
145
-            if(!empty($this->results[0]['first_name'])) {
145
+            if (!empty($this->results[0]['first_name'])) {
146 146
                 $data .= get_lang('FirstName').';';
147 147
             }
148 148
         }
@@ -164,16 +164,16 @@  discard block
 block discarded – undo
164 164
 		$data .= "\n";
165 165
 
166 166
 		//results
167
-		foreach($this->results as $row) {
167
+		foreach ($this->results as $row) {
168 168
             if (api_is_western_name_order()) {
169
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
170
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
169
+              $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
170
+              $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
171 171
             } else {
172
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
173
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
172
+              $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
173
+              $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
174 174
             }
175 175
 
176
-            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
176
+            $data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
177 177
 
178 178
 			/*if ($export_user_fields) {
179 179
 				//show user fields data, if any, for this user
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
 				}
184 184
 			}*/
185 185
 
186
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
187
-			$data .= str_replace("\r\n",'  ',$row['exe_date']).';';
188
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
189
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
186
+			$data .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
187
+			$data .= str_replace("\r\n", '  ', $row['exe_date']).';';
188
+			$data .= str_replace("\r\n", '  ', $row['result']).';';
189
+			$data .= str_replace("\r\n", '  ', $row['max']).';';
190 190
 			$data .= "\n";
191 191
 		}
192 192
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		header('Content-Description: '.$filename);
209 209
 		header('Content-transfer-encoding: binary');
210 210
 		// @todo add this utf-8 header for all csv files
211
-		echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
211
+		echo "\xEF\xBB\xBF"; // force utf-8 header of csv file
212 212
 		echo $data;
213 213
 		return true;
214 214
 	}
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 
269 269
 		if ($export_user_fields) {
270 270
 			//show user fields section with a big th colspan that spans over all fields
271
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
271
+			$extra_user_fields = UserManager::get_extra_fields(0, 1000, 5, 'ASC', false, 1);
272 272
 
273 273
 			//show the fields names for user fields
274 274
 			foreach ($extra_user_fields as $field) {
@@ -277,19 +277,19 @@  discard block
 block discarded – undo
277 277
 			}
278 278
 		}
279 279
 
280
-		$worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Title'));
280
+		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title'));
281 281
 		$column++;
282
-		$worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('StartDate'));
282
+		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate'));
283 283
         $column++;
284
-        $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('EndDate'));
284
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('EndDate'));
285 285
         $column++;
286
-        $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Duration').' ('.get_lang('MinMinutes').')');
286
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Duration').' ('.get_lang('MinMinutes').')');
287 287
 		$column++;
288
-		$worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Score'));
288
+		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score'));
289 289
 		$column++;
290
-		$worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Total'));
290
+		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total'));
291 291
 		$column++;
292
-        $worksheet->setCellValueByColumnAndRow($column, $line,  get_lang('Status'));
292
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Status'));
293 293
 		$line++;
294 294
 
295 295
 		foreach ($this->results as $row) {
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
 
315 315
 			if ($export_user_fields) {
316 316
 				//show user fields data, if any, for this user
317
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
318
-				foreach($user_fields_values as $value) {
319
-					$worksheet->setCellValueByColumnAndRow($column, $line,  api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
317
+				$user_fields_values = UserManager::get_extra_user_data($row['user_id'], false, false, false, true);
318
+				foreach ($user_fields_values as $value) {
319
+					$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
320 320
 					$column++;
321 321
 				}
322 322
 			}
Please login to merge, or discard this patch.