Completed
Push — 1.10.x ( 952f4d...2c4d38 )
by Julito
28:28
created
main/survey/survey.lib.php 1 patch
Spacing   +169 added lines, -170 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
@@ -1940,7 +1940,7 @@  discard block
 block discarded – undo
1940 1940
                             SELECT code FROM $table_survey
1941 1941
                             WHERE
1942 1942
                                 c_id = $course_id AND
1943
-                                survey_id = '".(int)$survey_id."'
1943
+                                survey_id = '".(int) $survey_id."'
1944 1944
                         ) AND
1945 1945
 			            user = '".$user_id."'";
1946 1946
             $result = Database::query($sql);
@@ -1972,19 +1972,19 @@  discard block
 block discarded – undo
1972 1972
         // Actions bar
1973 1973
         echo '<div class="actions">';
1974 1974
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.
1975
-            Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
1975
+            Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'), '', ICON_SIZE_MEDIUM).'</a>';
1976 1976
         if (isset($_GET['user'])) {
1977 1977
             if (api_is_allowed_to_edit()) {
1978 1978
                 // The delete link
1979 1979
                 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']).'" >'.
1980
-                    Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_MEDIUM).'</a>';
1980
+                    Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_MEDIUM).'</a>';
1981 1981
             }
1982 1982
 
1983 1983
             // Export the user report
1984 1984
             echo '<a href="javascript: void(0);" onclick="document.form1a.submit();">'.
1985
-                Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
1985
+                Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a> ';
1986 1986
             echo '<a href="javascript: void(0);" onclick="document.form1b.submit();">'.
1987
-                Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> ';
1987
+                Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a> ';
1988 1988
             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']).'">';
1989 1989
             echo '<input type="hidden" name="export_report" value="export_report">';
1990 1990
             echo '<input type="hidden" name="export_format" value="csv">';
@@ -2017,7 +2017,7 @@  discard block
 block discarded – undo
2017 2017
                     $name = $person['invited_user'];
2018 2018
                 }
2019 2019
             } else {
2020
-                $name  = get_lang('Anonymous') . ' ' . ($key + 1);
2020
+                $name = get_lang('Anonymous').' '.($key + 1);
2021 2021
                 $id = $person;
2022 2022
             }
2023 2023
             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).'" ';
@@ -2147,9 +2147,9 @@  discard block
 block discarded – undo
2147 2147
         $singlePage = isset($_GET['single_page']) ? intval($_GET['single_page']) : 0;
2148 2148
         $course_id = api_get_course_int_id();
2149 2149
         // Database table definitions
2150
-        $table_survey_question 			= Database :: get_course_table(TABLE_SURVEY_QUESTION);
2151
-        $table_survey_question_option 	= Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2152
-        $table_survey_answer 			= Database :: get_course_table(TABLE_SURVEY_ANSWER);
2150
+        $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
2151
+        $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2152
+        $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER);
2153 2153
 
2154 2154
         // Determining the offset of the sql statement (the n-th question of the survey)
2155 2155
         $offset = !isset($_GET['question']) ? 0 : intval($_GET['question']);
@@ -2160,7 +2160,7 @@  discard block
 block discarded – undo
2160 2160
 
2161 2161
         echo '<div class="actions">';
2162 2162
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.$surveyId.'">'.
2163
-            Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
2163
+            Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'), '', ICON_SIZE_MEDIUM).'</a>';
2164 2164
         echo '</div>';
2165 2165
 
2166 2166
         if ($survey_data['number_of_questions'] > 0) {
@@ -2168,18 +2168,18 @@  discard block
 block discarded – undo
2168 2168
             if (!$singlePage) {
2169 2169
                 echo '<div id="question_report_questionnumbers" class="pagination">';
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
                 }
2181 2181
                 if ($currentQuestion < ($survey_data['number_of_questions'] - 1)) {
2182
-                    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>';
2182
+                    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>';
2183 2183
                 }
2184 2184
                 echo '</ul>';
2185 2185
                 echo '</div>';
@@ -2216,19 +2216,19 @@  discard block
 block discarded – undo
2216 2216
                 $sql = "SELECT * FROM $table_survey_answer
2217 2217
                         WHERE
2218 2218
                             c_id = $course_id AND
2219
-                            survey_id='" . intval($_GET['survey_id']) . "' AND
2220
-                            question_id = '" . intval($question['question_id']) . "'";
2219
+                            survey_id='".intval($_GET['survey_id'])."' AND
2220
+                            question_id = '" . intval($question['question_id'])."'";
2221 2221
                 $result = Database::query($sql);
2222 2222
                 while ($row = Database::fetch_array($result)) {
2223
-                    echo $row['option_id'] . '<hr noshade="noshade" size="1" />';
2223
+                    echo $row['option_id'].'<hr noshade="noshade" size="1" />';
2224 2224
                 }
2225 2225
             } else {
2226 2226
                 // Getting the options ORDER BY sort ASC
2227 2227
                 $sql = "SELECT * FROM $table_survey_question_option
2228 2228
                         WHERE
2229 2229
                             c_id = $course_id AND
2230
-                            survey_id='" . intval($_GET['survey_id']) . "'
2231
-                            AND question_id = '" . intval($question['question_id']) . "'
2230
+                            survey_id='".intval($_GET['survey_id'])."'
2231
+                            AND question_id = '" . intval($question['question_id'])."'
2232 2232
                         ORDER BY sort ASC";
2233 2233
                 $result = Database::query($sql);
2234 2234
                 while ($row = Database::fetch_array($result)) {
@@ -2239,8 +2239,8 @@  discard block
 block discarded – undo
2239 2239
                 $sql = "SELECT *, count(answer_id) as total FROM $table_survey_answer
2240 2240
                         WHERE
2241 2241
                             c_id = $course_id AND
2242
-                            survey_id='" . intval($_GET['survey_id']) . "'
2243
-                            AND question_id = '" . intval($question['question_id']) . "'
2242
+                            survey_id='".intval($_GET['survey_id'])."'
2243
+                            AND question_id = '" . intval($question['question_id'])."'
2244 2244
                         GROUP BY option_id, value";
2245 2245
                 $result = Database::query($sql);
2246 2246
                 $number_of_answers = array();
@@ -2257,8 +2257,7 @@  discard block
 block discarded – undo
2257 2257
                     $optionText = strip_tags($option['option_text']);
2258 2258
                     $optionText = html_entity_decode($optionText);
2259 2259
                     $votes = isset($data[$option['question_option_id']]['total']) ?
2260
-                        $data[$option['question_option_id']]['total'] :
2261
-                        '0';
2260
+                        $data[$option['question_option_id']]['total'] : '0';
2262 2261
                     array_push($chartData, array('option' => $optionText, 'votes' => $votes));
2263 2262
                 }
2264 2263
                 $chartContainerId = 'chartContainer'.$question['question_id'];
@@ -2270,9 +2269,9 @@  discard block
 block discarded – undo
2270 2269
                 echo '<table class="display-survey table">';
2271 2270
                 echo '	<tr>';
2272 2271
                 echo '		<th>&nbsp;</th>';
2273
-                echo '		<th>' . get_lang('AbsoluteTotal') . '</th>';
2274
-                echo '		<th>' . get_lang('Percentage') . '</th>';
2275
-                echo '		<th>' . get_lang('VisualRepresentation') . '</th>';
2272
+                echo '		<th>'.get_lang('AbsoluteTotal').'</th>';
2273
+                echo '		<th>'.get_lang('Percentage').'</th>';
2274
+                echo '		<th>'.get_lang('VisualRepresentation').'</th>';
2276 2275
                 echo '	<tr>';
2277 2276
 
2278 2277
                 // Displaying the table: the content
@@ -2291,22 +2290,22 @@  discard block
 block discarded – undo
2291 2290
                             $answers_number = $absolute_number / $number_of_answers[$option['question_id']] * 100;
2292 2291
                         }
2293 2292
                         echo '	<tr>';
2294
-                        echo '		<td class="center">' . $value['option_text'] . '</td>';
2293
+                        echo '		<td class="center">'.$value['option_text'].'</td>';
2295 2294
                         echo '		<td class="center">';
2296 2295
                         if ($absolute_number != 0) {
2297
-                            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>';
2296
+                            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>';
2298 2297
                         } else {
2299 2298
                             echo '0';
2300 2299
                         }
2301 2300
 
2302 2301
                         echo '      </td>';
2303
-                        echo '		<td class="center">' . round($answers_number, 2) . ' %</td>';
2302
+                        echo '		<td class="center">'.round($answers_number, 2).' %</td>';
2304 2303
                         echo '		<td class="center">';
2305 2304
                         $size = $answers_number * 2;
2306 2305
                         if ($size > 0) {
2307
-                            echo '<div style="border:1px solid #264269; background-color:#aecaf4; height:10px; width:' . $size . 'px">&nbsp;</div>';
2306
+                            echo '<div style="border:1px solid #264269; background-color:#aecaf4; height:10px; width:'.$size.'px">&nbsp;</div>';
2308 2307
                         } else {
2309
-                            echo '<div style="text-align: left;">' . get_lang("NoDataAvailable") . '</div>';
2308
+                            echo '<div style="text-align: left;">'.get_lang("NoDataAvailable").'</div>';
2310 2309
                         }
2311 2310
                         echo ' </td>';
2312 2311
                         echo ' </tr>';
@@ -2314,8 +2313,8 @@  discard block
 block discarded – undo
2314 2313
                 }
2315 2314
                 // displaying the table: footer (totals)
2316 2315
                 echo '	<tr>';
2317
-                echo '		<td class="total"><b>' . get_lang('Total') . '</b></td>';
2318
-                echo '		<td class="total"><b>' . ($number_of_answers[$option['question_id']] == 0 ? '0' : $number_of_answers[$option['question_id']]) . '</b></td>';
2316
+                echo '		<td class="total"><b>'.get_lang('Total').'</b></td>';
2317
+                echo '		<td class="total"><b>'.($number_of_answers[$option['question_id']] == 0 ? '0' : $number_of_answers[$option['question_id']]).'</b></td>';
2319 2318
                 echo '		<td class="total">&nbsp;</td>';
2320 2319
                 echo '		<td class="total">&nbsp;</td>';
2321 2320
                 echo '	</tr>';
@@ -2359,8 +2358,8 @@  discard block
 block discarded – undo
2359 2358
     public static function display_question_report_score($survey_data, $question, $offset)
2360 2359
     {
2361 2360
         // Database table definitions
2362
-        $table_survey_question_option 	= Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2363
-        $table_survey_answer 			= Database :: get_course_table(TABLE_SURVEY_ANSWER);
2361
+        $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
2362
+        $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER);
2364 2363
 
2365 2364
         $course_id = api_get_course_int_id();
2366 2365
 
@@ -2430,9 +2429,9 @@  discard block
 block discarded – undo
2430 2429
                 echo '		<td>'.$value['option_text'].'</td>';
2431 2430
                 echo '		<td>'.$i.'</td>';
2432 2431
                 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>';
2433
-                echo '		<td>'.round($absolute_number/$number_of_answers*100, 2).' %</td>';
2432
+                echo '		<td>'.round($absolute_number / $number_of_answers * 100, 2).' %</td>';
2434 2433
                 echo '		<td>';
2435
-                $size = ($absolute_number/$number_of_answers*100*2);
2434
+                $size = ($absolute_number / $number_of_answers * 100 * 2);
2436 2435
                 if ($size > 0) {
2437 2436
                     echo '			<div style="border:1px solid #264269; background-color:#aecaf4; height:10px; width:'.$size.'px">&nbsp;</div>';
2438 2437
                 }
@@ -2469,11 +2468,11 @@  discard block
 block discarded – undo
2469 2468
         // Actions bar
2470 2469
         echo '<div class="actions">';
2471 2470
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">
2472
-		'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
2471
+		'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'), '', ICON_SIZE_MEDIUM).'</a>';
2473 2472
         echo '<a class="survey_export_link" href="javascript: void(0);" onclick="document.form1a.submit();">
2474
-		'.Display::return_icon('export_csv.png',get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a>';
2473
+		'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a>';
2475 2474
         echo '<a class="survey_export_link" href="javascript: void(0);" onclick="document.form1b.submit();">
2476
-		'.Display::return_icon('export_excel.png',get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a>';
2475
+		'.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
2477 2476
         echo '</div>';
2478 2477
 
2479 2478
         // The form
@@ -2506,8 +2505,8 @@  discard block
 block discarded – undo
2506 2505
             // Show user fields section with a big th colspan that spans over all fields
2507 2506
             $extra_user_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', false, true);
2508 2507
             $num = count($extra_user_fields);
2509
-            if ($num > 0 ) {
2510
-                echo '<th '.($num>0?' colspan="'.$num.'"':'').'>';
2508
+            if ($num > 0) {
2509
+                echo '<th '.($num > 0 ? ' colspan="'.$num.'"' : '').'>';
2511 2510
                 echo '<label><input type="checkbox" name="fields_filter" value="1" checked="checked"/> ';
2512 2511
                 echo get_lang('UserFields');
2513 2512
                 echo '</label>';
@@ -2572,7 +2571,7 @@  discard block
 block discarded – undo
2572 2571
         if (!(isset($_POST['submit_question_filter']) && $_POST['submit_question_filter'] ||
2573 2572
                 isset($_POST['export_report']) && $_POST['export_report']) || !empty($_POST['fields_filter'])) {
2574 2573
             //show the fields names for user fields
2575
-            foreach($extra_user_fields as & $field) {
2574
+            foreach ($extra_user_fields as & $field) {
2576 2575
                 echo '<th>'.$field[3].'</th>';
2577 2576
             }
2578 2577
         }
@@ -2592,7 +2591,7 @@  discard block
 block discarded – undo
2592 2591
 				ORDER BY sq.sort ASC, sqo.sort ASC";
2593 2592
         $result = Database::query($sql);
2594 2593
 
2595
-        $display_percentage_header = 1;	// in order to display only once the cell option (and not 100 times)
2594
+        $display_percentage_header = 1; // in order to display only once the cell option (and not 100 times)
2596 2595
         while ($row = Database::fetch_array($result)) {
2597 2596
             // We show the options if
2598 2597
             // 1. there is no question filter and the export button has not been clicked
@@ -2652,7 +2651,7 @@  discard block
 block discarded – undo
2652 2651
                     $questions,
2653 2652
                     $display_extra_user_fields
2654 2653
                 );
2655
-                $answers_of_user=array();
2654
+                $answers_of_user = array();
2656 2655
             }
2657 2656
             if (isset($questions[$row['question_id']]) && $questions[$row['question_id']]['type'] != 'open') {
2658 2657
                 $answers_of_user[$row['question_id']][$row['option_id']] = $row;
@@ -2714,7 +2713,7 @@  discard block
 block discarded – undo
2714 2713
                 echo '<th>'.$user.'</th>'; // the user column
2715 2714
             }
2716 2715
         } else {
2717
-            echo '<th>' . get_lang('Anonymous') . ' ' . $user . '</th>';
2716
+            echo '<th>'.get_lang('Anonymous').' '.$user.'</th>';
2718 2717
         }
2719 2718
 
2720 2719
         if ($display_extra_user_fields) {
@@ -2810,10 +2809,10 @@  discard block
 block discarded – undo
2810 2809
                 // We do not show comment and pagebreak question types
2811 2810
                 if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') {
2812 2811
                     if ($row['number_of_options'] == 0 && $row['type'] == 'open') {
2813
-                        $return .= str_replace("\r\n",'  ', api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES)).';';
2812
+                        $return .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES)).';';
2814 2813
                     } else {
2815 2814
                         for ($ii = 0; $ii < $row['number_of_options']; $ii++) {
2816
-                            $return .= str_replace("\r\n",'  ', api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES)).';';
2815
+                            $return .= str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES)).';';
2817 2816
                         }
2818 2817
                     }
2819 2818
                 }
@@ -2827,7 +2826,7 @@  discard block
 block discarded – undo
2827 2826
         // Show the fields names for user fields
2828 2827
         if (!empty($extra_user_fields)) {
2829 2828
             foreach ($extra_user_fields as & $field) {
2830
-                $return .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES)).'";';
2829
+                $return .= '"'.str_replace("\r\n", '  ', api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES)).'";';
2831 2830
             }
2832 2831
         }
2833 2832
 
@@ -2862,7 +2861,7 @@  discard block
 block discarded – undo
2862 2861
             ) {
2863 2862
                 // We do not show comment and pagebreak question types
2864 2863
                 if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') {
2865
-                    $row['option_text'] = str_replace(array("\r","\n"),array('',''),$row['option_text']);
2864
+                    $row['option_text'] = str_replace(array("\r", "\n"), array('', ''), $row['option_text']);
2866 2865
                     $return .= api_html_entity_decode(strip_tags($row['option_text']), ENT_QUOTES).';';
2867 2866
                     $possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id'];
2868 2867
                     $possible_answers_type[$row['question_id']] = $row['type'];
@@ -2892,9 +2891,9 @@  discard block
 block discarded – undo
2892 2891
                     $old_user,
2893 2892
                     true
2894 2893
                 );
2895
-                $answers_of_user=array();
2894
+                $answers_of_user = array();
2896 2895
             }
2897
-            if($possible_answers_type[$row['question_id']] == 'open') {
2896
+            if ($possible_answers_type[$row['question_id']] == 'open') {
2898 2897
                 $temp_id = 'open'.$open_question_iterator;
2899 2898
                 $answers_of_user[$row['question_id']][$temp_id] = $row;
2900 2899
                 $open_question_iterator++;
@@ -2953,7 +2952,7 @@  discard block
 block discarded – undo
2953 2952
 
2954 2953
         if ($display_extra_user_fields) {
2955 2954
             // Show user fields data, if any, for this user
2956
-            $user_fields_values = UserManager::get_extra_user_data($user,false,false, false, true);
2955
+            $user_fields_values = UserManager::get_extra_user_data($user, false, false, false, true);
2957 2956
             foreach ($user_fields_values as & $value) {
2958 2957
                 $return .= '"'.str_replace('"', '""', api_html_entity_decode(strip_tags($value), ENT_QUOTES)).'";';
2959 2958
             }
@@ -3050,9 +3049,9 @@  discard block
 block discarded – undo
3050 3049
                                 ENT_QUOTES
3051 3050
                             )
3052 3051
                         );
3053
-                        $column ++;
3052
+                        $column++;
3054 3053
                     } else {
3055
-                        for ($ii = 0; $ii < $row['number_of_options']; $ii ++) {
3054
+                        for ($ii = 0; $ii < $row['number_of_options']; $ii++) {
3056 3055
                             $worksheet->setCellValueByColumnAndRow(
3057 3056
                                 $column,
3058 3057
                                 $line,
@@ -3061,7 +3060,7 @@  discard block
 block discarded – undo
3061 3060
                                     ENT_QUOTES
3062 3061
                                 )
3063 3062
                             );
3064
-                            $column ++;
3063
+                            $column++;
3065 3064
                         }
3066 3065
                     }
3067 3066
                 }
@@ -3121,7 +3120,7 @@  discard block
 block discarded – undo
3121 3120
         }
3122 3121
 
3123 3122
         // Getting all the answers of the users
3124
-        $line ++;
3123
+        $line++;
3125 3124
         $column = 0;
3126 3125
         $old_user = '';
3127 3126
         $answers_of_user = array();
@@ -3130,7 +3129,7 @@  discard block
 block discarded – undo
3130 3129
         if ($user_id != 0) {
3131 3130
             $sql .= "AND user='".intval($user_id)."' ";
3132 3131
         }
3133
-        $sql .=	"ORDER BY user ASC";
3132
+        $sql .= "ORDER BY user ASC";
3134 3133
 
3135 3134
         $open_question_iterator = 1;
3136 3135
         $result = Database::query($sql);
@@ -3205,7 +3204,7 @@  discard block
 block discarded – undo
3205 3204
                         FROM '.Database::get_main_table(TABLE_MAIN_USER).'
3206 3205
                         WHERE user_id='.intval($user);
3207 3206
                 $rs = Database::query($sql);
3208
-                if($row = Database::fetch_array($rs)) {
3207
+                if ($row = Database::fetch_array($rs)) {
3209 3208
                     $user_displayed = api_get_person_name($row['firstname'], $row['lastname']);
3210 3209
                 } else {
3211 3210
                     $user_displayed = '-';
@@ -3220,8 +3219,8 @@  discard block
 block discarded – undo
3220 3219
 
3221 3220
         if ($display_extra_user_fields) {
3222 3221
             //show user fields data, if any, for this user
3223
-            $user_fields_values = UserManager::get_extra_user_data(intval($user),false,false, false, true);
3224
-            foreach($user_fields_values as $value) {
3222
+            $user_fields_values = UserManager::get_extra_user_data(intval($user), false, false, false, true);
3223
+            foreach ($user_fields_values as $value) {
3225 3224
                 $return[] = api_html_entity_decode(strip_tags($value), ENT_QUOTES);
3226 3225
             }
3227 3226
         }
@@ -3280,7 +3279,7 @@  discard block
 block discarded – undo
3280 3279
         // Actions bar
3281 3280
         echo '<div class="actions">';
3282 3281
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.intval($_GET['survey_id']).'">'.
3283
-                Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
3282
+                Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'), '', ICON_SIZE_MEDIUM).'</a>';
3284 3283
         echo '</div>';
3285 3284
 
3286 3285
         // Displaying an information message that only the questions with predefined answers can be used in a comparative report
@@ -3345,25 +3344,25 @@  discard block
 block discarded – undo
3345 3344
 
3346 3345
             $xOptions = array();
3347 3346
             // The header
3348
-            $tableHtml .=  '	<tr>';
3347
+            $tableHtml .= '	<tr>';
3349 3348
             for ($ii = 0; $ii <= count($question_x['answers']); $ii++) {
3350 3349
                 if ($ii == 0) {
3351
-                    $tableHtml .=  '		<th>&nbsp;</th>';
3350
+                    $tableHtml .= '		<th>&nbsp;</th>';
3352 3351
                 } else {
3353 3352
                     if ($question_x['type'] == 'score') {
3354 3353
                         for ($x = 1; $x <= $question_x['maximum_score']; $x++) {
3355
-                            $tableHtml .= '		<th>'.$question_x['answers'][($ii-1)].'<br />'.$x.'</th>';
3354
+                            $tableHtml .= '		<th>'.$question_x['answers'][($ii - 1)].'<br />'.$x.'</th>';
3356 3355
                         }
3357 3356
                         $x = '';
3358 3357
                     } else {
3359
-                        $tableHtml .= '		<th>'.$question_x['answers'][($ii-1)].'</th>';
3358
+                        $tableHtml .= '		<th>'.$question_x['answers'][($ii - 1)].'</th>';
3360 3359
                     }
3361
-                    $optionText = strip_tags($question_x['answers'][$ii-1]);
3360
+                    $optionText = strip_tags($question_x['answers'][$ii - 1]);
3362 3361
                     $optionText = html_entity_decode($optionText);
3363 3362
                     array_push($xOptions, trim($optionText));
3364 3363
                 }
3365 3364
             }
3366
-            $tableHtml .=  '	</tr>';
3365
+            $tableHtml .= '	</tr>';
3367 3366
             $chartData = array();
3368 3367
 
3369 3368
             // The main part
@@ -3373,15 +3372,15 @@  discard block
 block discarded – undo
3373 3372
                 // The Y axis is a scoring question type so we have more rows than the options (actually options * maximum score)
3374 3373
                 if ($question_y['type'] == 'score') {
3375 3374
                     for ($y = 1; $y <= $question_y['maximum_score']; $y++) {
3376
-                        $tableHtml .=  '	<tr>';
3375
+                        $tableHtml .= '	<tr>';
3377 3376
                         for ($ii = 0; $ii <= count($question_x['answers']); $ii++) {
3378 3377
                             if ($question_x['type'] == 'score') {
3379 3378
                                 for ($x = 1; $x <= $question_x['maximum_score']; $x++) {
3380 3379
                                     if ($ii == 0) {
3381
-                                        $tableHtml .=  ' <th>'.$question_y['answers'][($ij)].' '.$y.'</th>';
3380
+                                        $tableHtml .= ' <th>'.$question_y['answers'][($ij)].' '.$y.'</th>';
3382 3381
                                         break;
3383 3382
                                     } else {
3384
-                                        $tableHtml .=  ' <td align="center">';
3383
+                                        $tableHtml .= ' <td align="center">';
3385 3384
                                         $votes = SurveyUtil::comparative_check(
3386 3385
                                             $answers_x,
3387 3386
                                             $answers_y,
@@ -3390,23 +3389,23 @@  discard block
 block discarded – undo
3390 3389
                                             $x,
3391 3390
                                             $y
3392 3391
                                         );
3393
-                                        $tableHtml .=  $votes;
3392
+                                        $tableHtml .= $votes;
3394 3393
                                         array_push(
3395 3394
                                             $chartData,
3396 3395
                                             array(
3397
-                                                'serie' => array($currentYQuestion, $xOptions[$ii-1]),
3396
+                                                'serie' => array($currentYQuestion, $xOptions[$ii - 1]),
3398 3397
                                                 'option' => $x,
3399 3398
                                                 'votes' => $votes
3400 3399
                                             )
3401 3400
                                         );
3402
-                                        $tableHtml .=  '</td>';
3401
+                                        $tableHtml .= '</td>';
3403 3402
                                     }
3404 3403
                                 }
3405 3404
                             } else {
3406 3405
                                 if ($ii == 0) {
3407
-                                    $tableHtml .=  '<th>'.$question_y['answers'][$ij].' '.$y.'</th>';
3406
+                                    $tableHtml .= '<th>'.$question_y['answers'][$ij].' '.$y.'</th>';
3408 3407
                                 } else {
3409
-                                    $tableHtml .=  '<td align="center">';
3408
+                                    $tableHtml .= '<td align="center">';
3410 3409
                                     $votes = SurveyUtil::comparative_check(
3411 3410
                                         $answers_x,
3412 3411
                                         $answers_y,
@@ -3419,65 +3418,65 @@  discard block
 block discarded – undo
3419 3418
                                     array_push(
3420 3419
                                         $chartData,
3421 3420
                                         array(
3422
-                                            'serie' => array($currentYQuestion, $xOptions[$ii-1]),
3421
+                                            'serie' => array($currentYQuestion, $xOptions[$ii - 1]),
3423 3422
                                             'option' => $y,
3424 3423
                                             'votes' => $votes
3425 3424
                                         )
3426 3425
                                     );
3427
-                                    $tableHtml .=  '</td>';
3426
+                                    $tableHtml .= '</td>';
3428 3427
                                 }
3429 3428
                             }
3430 3429
                         }
3431
-                        $tableHtml .=  '	</tr>';
3430
+                        $tableHtml .= '	</tr>';
3432 3431
                     }
3433 3432
                 }
3434 3433
                 // The Y axis is NOT a score question type so the number of rows = the number of options
3435 3434
                 else {
3436
-                    $tableHtml .=  '	<tr>';
3435
+                    $tableHtml .= '	<tr>';
3437 3436
                     for ($ii = 0; $ii <= count($question_x['answers']); $ii++) {
3438 3437
                         if ($question_x['type'] == 'score') {
3439 3438
                             for ($x = 1; $x <= $question_x['maximum_score']; $x++) {
3440 3439
                                 if ($ii == 0) {
3441
-                                    $tableHtml .=  '		<th>'.$question_y['answers'][$ij].'</th>';
3440
+                                    $tableHtml .= '		<th>'.$question_y['answers'][$ij].'</th>';
3442 3441
                                     break;
3443 3442
                                 } else {
3444
-                                    $tableHtml .=  '		<td align="center">';
3445
-                                    $votes =  SurveyUtil::comparative_check($answers_x, $answers_y, $question_x['answersid'][($ii-1)], $question_y['answersid'][($ij)], $x, 0);
3443
+                                    $tableHtml .= '		<td align="center">';
3444
+                                    $votes = SurveyUtil::comparative_check($answers_x, $answers_y, $question_x['answersid'][($ii - 1)], $question_y['answersid'][($ij)], $x, 0);
3446 3445
                                     $tableHtml .= $votes;
3447 3446
                                     array_push(
3448 3447
                                         $chartData,
3449 3448
                                         array(
3450
-                                            'serie' => array($currentYQuestion, $xOptions[$ii-1]),
3449
+                                            'serie' => array($currentYQuestion, $xOptions[$ii - 1]),
3451 3450
                                             'option' => $x,
3452 3451
                                             'votes' => $votes
3453 3452
                                         )
3454 3453
                                     );
3455
-                                    $tableHtml .=  '</td>';
3454
+                                    $tableHtml .= '</td>';
3456 3455
                                 }
3457 3456
                             }
3458 3457
                         } else {
3459 3458
                             if ($ii == 0) {
3460
-                                $tableHtml .=  '		<th>'.$question_y['answers'][($ij)].'</th>';
3459
+                                $tableHtml .= '		<th>'.$question_y['answers'][($ij)].'</th>';
3461 3460
                             } else {
3462
-                                $tableHtml .=  '		<td align="center">';
3463
-                                $votes = SurveyUtil::comparative_check($answers_x, $answers_y, $question_x['answersid'][($ii-1)], $question_y['answersid'][($ij)]);
3461
+                                $tableHtml .= '		<td align="center">';
3462
+                                $votes = SurveyUtil::comparative_check($answers_x, $answers_y, $question_x['answersid'][($ii - 1)], $question_y['answersid'][($ij)]);
3464 3463
                                 $tableHtml .= $votes;
3465 3464
                                 array_push(
3466 3465
                                     $chartData,
3467 3466
                                     array(
3468
-                                        'serie' => $xOptions[$ii-1],
3467
+                                        'serie' => $xOptions[$ii - 1],
3469 3468
                                         'option' => $currentYQuestion,
3470 3469
                                         'votes' => $votes
3471 3470
                                     )
3472 3471
                                 );
3473
-                                $tableHtml .=  '</td>';
3472
+                                $tableHtml .= '</td>';
3474 3473
                             }
3475 3474
                         }
3476 3475
                     }
3477
-                    $tableHtml .=  '	</tr>';
3476
+                    $tableHtml .= '	</tr>';
3478 3477
                 }
3479 3478
             }
3480
-            $tableHtml .=  '</table>';
3479
+            $tableHtml .= '</table>';
3481 3480
             echo '<div id="chartContainer" class="col-md-12">';
3482 3481
             echo self::drawChart($chartData, true);
3483 3482
             echo '</div>';
@@ -3617,7 +3616,7 @@  discard block
 block discarded – undo
3617 3616
                     survey_id='".intval($_GET['survey_id'])."' AND
3618 3617
                     session_id='".api_get_session_id()."' ";
3619 3618
         $res = Database::query($sql);
3620
-        $row = Database::fetch_array($res,'ASSOC');
3619
+        $row = Database::fetch_array($res, 'ASSOC');
3621 3620
 
3622 3621
         return $row['total'];
3623 3622
     }
@@ -3692,7 +3691,7 @@  discard block
 block discarded – undo
3692 3691
             $exclude_users = SurveyManager::get_people_who_filled_survey($_GET['survey_id']);
3693 3692
         }
3694 3693
 
3695
-        $counter = 0;  // Nr of invitations "sent" (if sendmail option)
3694
+        $counter = 0; // Nr of invitations "sent" (if sendmail option)
3696 3695
         $course_id = api_get_course_int_id();
3697 3696
         $session_id = api_get_session_id();
3698 3697
 
@@ -3848,7 +3847,7 @@  discard block
 block discarded – undo
3848 3847
         $text_link = '<a href="'.$survey_link.'">'.get_lang('ClickHereToAnswerTheSurvey')."</a><br />\r\n<br />\r\n".get_lang('OrCopyPasteTheFollowingUrl')." <br />\r\n ".$survey_link;
3849 3848
 
3850 3849
         $replace_count = 0;
3851
-        $full_invitation_text = api_str_ireplace('**link**', $text_link ,$invitation_text, $replace_count);
3850
+        $full_invitation_text = api_str_ireplace('**link**', $text_link, $invitation_text, $replace_count);
3852 3851
         if ($replace_count < 1) {
3853 3852
             $full_invitation_text = $full_invitation_text."<br />\r\n<br />\r\n".$text_link;
3854 3853
         }
@@ -3920,8 +3919,8 @@  discard block
 block discarded – undo
3920 3919
         $course_id = api_get_course_int_id();
3921 3920
 
3922 3921
         // Database table definition
3923
-        $table_survey_invitation 	= Database :: get_course_table(TABLE_SURVEY_INVITATION);
3924
-        $table_survey 				= Database :: get_course_table(TABLE_SURVEY);
3922
+        $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION);
3923
+        $table_survey = Database :: get_course_table(TABLE_SURVEY);
3925 3924
 
3926 3925
         // Counting the number of people that are invited
3927 3926
         $sql = "SELECT count(user) as total
@@ -4035,7 +4034,7 @@  discard block
 block discarded – undo
4035 4034
     {
4036 4035
         $course_id = api_get_course_int_id();
4037 4036
         // Database table definition
4038
-        $table_survey_invitation 	= Database :: get_course_table(TABLE_SURVEY_INVITATION);
4037
+        $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION);
4039 4038
 
4040 4039
         $sql = "SELECT * FROM $table_survey_invitation
4041 4040
 		        WHERE
@@ -4171,7 +4170,7 @@  discard block
 block discarded – undo
4171 4170
     function display_survey_list_for_coach()
4172 4171
     {
4173 4172
         $parameters = array();
4174
-        $parameters['cidReq']=api_get_course_id();
4173
+        $parameters['cidReq'] = api_get_course_id();
4175 4174
         if (isset($_GET['do_search'])) {
4176 4175
             $message = get_lang('DisplaySearchResults').'<br />';
4177 4176
             $message .= '<a href="'.api_get_self().'?'.api_get_cidreq().'">'.get_lang('DisplayAll').'</a>';
@@ -4215,17 +4214,17 @@  discard block
 block discarded – undo
4215 4214
 
4216 4215
         if ($drh) {
4217 4216
             return '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.
4218
-            Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_SMALL).'</a>';
4217
+            Display::return_icon('stats.png', get_lang('Reporting'), '', ICON_SIZE_SMALL).'</a>';
4219 4218
         }
4220 4219
 
4221 4220
         // Coach can see that only if the survey is in his session
4222 4221
         if (api_is_allowed_to_edit() ||
4223 4222
             api_is_element_in_the_session(TOOL_SURVEY, $survey_id)
4224 4223
         ) {
4225
-            $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>';
4224
+            $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>';
4226 4225
             if (SurveyManager::survey_generation_hash_available()) {
4227
-                $return .=  Display::url(
4228
-                    Display::return_icon('new_link.png', get_lang('GenerateSurveyAccessLink'),'',ICON_SIZE_SMALL),
4226
+                $return .= Display::url(
4227
+                    Display::return_icon('new_link.png', get_lang('GenerateSurveyAccessLink'), '', ICON_SIZE_SMALL),
4229 4228
                     api_get_path(WEB_CODE_PATH).'survey/generate_link.php?survey_id='.$survey_id.'&'.api_get_cidreq()
4230 4229
                 );
4231 4230
             }
@@ -4235,20 +4234,20 @@  discard block
 block discarded – undo
4235 4234
             );
4236 4235
 
4237 4236
             $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;">'.
4238
-                Display::return_icon('clean.png', get_lang('EmptySurvey'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
4237
+                Display::return_icon('clean.png', get_lang('EmptySurvey'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
4239 4238
         }
4240 4239
         $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.
4241
-            Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
4240
+            Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
4242 4241
         $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.
4243
-            Display::return_icon('mail_send.png', get_lang('Publish'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
4242
+            Display::return_icon('mail_send.png', get_lang('Publish'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
4244 4243
         $return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.
4245
-            Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_SMALL).'</a>';
4244
+            Display::return_icon('stats.png', get_lang('Reporting'), '', ICON_SIZE_SMALL).'</a>';
4246 4245
 
4247 4246
         if (api_is_allowed_to_edit() ||
4248 4247
             api_is_element_in_the_session(TOOL_SURVEY, $survey_id)
4249 4248
         ) {
4250 4249
             $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;">'.
4251
-                Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
4250
+                Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
4252 4251
         }
4253 4252
 
4254 4253
         return $return;
@@ -4261,9 +4260,9 @@  discard block
 block discarded – undo
4261 4260
         //$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>';
4262 4261
         //$return .= '<a href="create_survey_in_another_language.php?id_survey='.$survey_id.'">'.Display::return_icon('copy.gif', get_lang('Copy')).'</a>';
4263 4262
         //$return .= '<a href="survey.php?survey_id='.$survey_id.'">'.Display::return_icon('add.gif', get_lang('Add')).'</a>';
4264
-        $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;';
4265
-        $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;';
4266
-        $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;';
4263
+        $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;';
4264
+        $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;';
4265
+        $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;';
4267 4266
         //$return .= '<a href="reporting.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a>';
4268 4267
         return $return;
4269 4268
     }
@@ -4418,7 +4417,7 @@  discard block
 block discarded – undo
4418 4417
 
4419 4418
             // Validation when belonging to a session
4420 4419
             $session_img = api_get_session_image($survey['session_id'], $_user['status']);
4421
-            $array[2] = $survey[2] . $session_img;
4420
+            $array[2] = $survey[2].$session_img;
4422 4421
             $array[3] = $survey[3];
4423 4422
             $array[4] = $survey[4];
4424 4423
             $array[5] = $survey[5];
@@ -4452,10 +4451,10 @@  discard block
 block discarded – undo
4452 4451
         $last_version_surveys = $survey_tree->get_last_children_from_branch($survey_tree->surveylist);
4453 4452
         $list = array();
4454 4453
         foreach ($last_version_surveys as & $survey) {
4455
-            $list[]=$survey['id'];
4454
+            $list[] = $survey['id'];
4456 4455
         }
4457 4456
         if (count($list) > 0) {
4458
-            $list_condition = " AND survey.survey_id IN (".implode(',',$list).") ";
4457
+            $list_condition = " AND survey.survey_id IN (".implode(',', $list).") ";
4459 4458
         } else {
4460 4459
             $list_condition = '';
4461 4460
         }
@@ -4467,9 +4466,9 @@  discard block
 block discarded – undo
4467 4466
             $direction = 'asc';
4468 4467
         }
4469 4468
 
4470
-        $table_survey 			= Database :: get_course_table(TABLE_SURVEY);
4471
-        $table_survey_question 	= Database :: get_course_table(TABLE_SURVEY_QUESTION);
4472
-        $table_user 			= Database :: get_main_table(TABLE_MAIN_USER);
4469
+        $table_survey = Database :: get_course_table(TABLE_SURVEY);
4470
+        $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
4471
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
4473 4472
 
4474 4473
         $course_id = api_get_course_int_id();
4475 4474
 
@@ -4584,16 +4583,16 @@  discard block
 block discarded – undo
4584 4583
                     )
4585 4584
             ";
4586 4585
             $result_answer = Database::query($sql);
4587
-            $row_answer = Database::fetch_array($result_answer,'ASSOC');
4586
+            $row_answer = Database::fetch_array($result_answer, 'ASSOC');
4588 4587
             echo '<tr>';
4589 4588
             if ($row['answered'] == 0) {
4590 4589
                 echo '<td>';
4591
-                echo Display::return_icon('statistics.png', get_lang('CreateNewSurvey'),array('style'=>'inline-block'),ICON_SIZE_TINY);
4590
+                echo Display::return_icon('statistics.png', get_lang('CreateNewSurvey'), array('style'=>'inline-block'), ICON_SIZE_TINY);
4592 4591
                 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>';
4593 4592
             } else {
4594 4593
                 //echo '<td>'.$row['title'].'</td>';
4595 4594
                 echo '<td>';
4596
-                echo Display::return_icon('statistics_na.png', get_lang('CreateNewSurvey'),array('style'=>'inline-block'),ICON_SIZE_TINY);
4595
+                echo Display::return_icon('statistics_na.png', get_lang('CreateNewSurvey'), array('style'=>'inline-block'), ICON_SIZE_TINY);
4597 4596
                 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>';
4598 4597
             }
4599 4598
             echo '<td class="center">';
@@ -4605,7 +4604,7 @@  discard block
 block discarded – undo
4605 4604
             } else {
4606 4605
                 $current_user_id = api_get_user_id();
4607 4606
             }
4608
-            $link_available = self::show_link_available(api_get_user_id(),$row['code'],$current_user_id);
4607
+            $link_available = self::show_link_available(api_get_user_id(), $row['code'], $current_user_id);
4609 4608
             //todo check this link
4610 4609
             if ($link_add === true && $link_available === true) {
4611 4610
                 //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>';
@@ -4750,7 +4749,7 @@  discard block
 block discarded – undo
4750 4749
                     if ($field_details[7] == 0) {
4751 4750
                         $field_list_array['extra_'.$field_details[1]]['visibility'] = 0;
4752 4751
                     } else {
4753
-                        $field_list_array['extra_'.$field_details[1]]['visibility']=1;
4752
+                        $field_list_array['extra_'.$field_details[1]]['visibility'] = 1;
4754 4753
                     }
4755 4754
                     break;
4756 4755
                 case UserManager::USER_FIELD_TYPE_DIVIDER:
@@ -4817,7 +4816,7 @@  discard block
 block discarded – undo
4817 4816
         $htmlChart = '';
4818 4817
         if (api_browser_support("svg")) {
4819 4818
             $htmlChart .= api_get_js("d3/d3.v3.5.4.min.js");
4820
-            $htmlChart .= api_get_js("dimple.v2.1.2.min.js") . '
4819
+            $htmlChart .= api_get_js("dimple.v2.1.2.min.js").'
4821 4820
             <script type="text/javascript">
4822 4821
             var svg = dimple.newSvg("#'.$chartContainerId.'", "100%", 400);
4823 4822
             var data = [';
@@ -4826,40 +4825,40 @@  discard block
 block discarded – undo
4826 4825
             foreach ($chartData as $chartDataElement) {
4827 4826
                 $htmlChart .= '{"';
4828 4827
                 if (!$hasSerie) {
4829
-                    $htmlChart .= get_lang("Option") . '":"' . $chartDataElement['option'] . '", "';
4828
+                    $htmlChart .= get_lang("Option").'":"'.$chartDataElement['option'].'", "';
4830 4829
                     array_push($order, $chartDataElement['option']);
4831 4830
                 } else {
4832 4831
                     if (!is_array($chartDataElement['serie'])) {
4833
-                        $htmlChart .= get_lang("Option") . '":"' . $chartDataElement['serie'] . '", "' .
4834
-                            get_lang("Score") . '":"' . $chartDataElement['option'] . '", "';
4832
+                        $htmlChart .= get_lang("Option").'":"'.$chartDataElement['serie'].'", "'.
4833
+                            get_lang("Score").'":"'.$chartDataElement['option'].'", "';
4835 4834
                         array_push($serie, $chartDataElement['serie']);
4836 4835
                     } else {
4837
-                        $htmlChart .= get_lang("Serie") . '":"' . $chartDataElement['serie'][0] . '", "' .
4838
-                            get_lang("Option") . '":"' . $chartDataElement['serie'][1] . '", "' .
4839
-                            get_lang("Score") . '":"' . $chartDataElement['option'] . '", "';
4836
+                        $htmlChart .= get_lang("Serie").'":"'.$chartDataElement['serie'][0].'", "'.
4837
+                            get_lang("Option").'":"'.$chartDataElement['serie'][1].'", "'.
4838
+                            get_lang("Score").'":"'.$chartDataElement['option'].'", "';
4840 4839
                     }
4841 4840
                 }
4842
-                $htmlChart .= get_lang("Votes") . '":"' . $chartDataElement['votes'] .
4841
+                $htmlChart .= get_lang("Votes").'":"'.$chartDataElement['votes'].
4843 4842
                     '"},';
4844 4843
             }
4845 4844
             rtrim($htmlChart, ",");
4846 4845
             $htmlChart .= '];
4847 4846
                 var myChart = new dimple.chart(svg, data);
4848
-                myChart.addMeasureAxis("y", "' . get_lang("Votes") . '");';
4847
+                myChart.addMeasureAxis("y", "' . get_lang("Votes").'");';
4849 4848
             if (!$hasSerie) {
4850
-                $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", "' . get_lang("Option") . '");
4851
-                    xAxisCategory.addOrderRule(' . json_encode($order) . ');
4852
-                    myChart.addSeries("' . get_lang("Option") . '", dimple.plot.bar);';
4849
+                $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", "'.get_lang("Option").'");
4850
+                    xAxisCategory.addOrderRule(' . json_encode($order).');
4851
+                    myChart.addSeries("' . get_lang("Option").'", dimple.plot.bar);';
4853 4852
             } else {
4854 4853
                 if (!is_array($chartDataElement['serie'])) {
4855 4854
                     $serie = array_values(array_unique($serie));
4856
-                    $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", ["' . get_lang("Option") . '","' . get_lang("Score") . '"]);
4857
-                        xAxisCategory.addOrderRule(' . json_encode($serie) . ');
4858
-                        xAxisCategory.addGroupOrderRule("' . get_lang("Score") . '");
4859
-                        myChart.addSeries("' . get_lang("Option") . '", dimple.plot.bar);';
4855
+                    $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", ["'.get_lang("Option").'","'.get_lang("Score").'"]);
4856
+                        xAxisCategory.addOrderRule(' . json_encode($serie).');
4857
+                        xAxisCategory.addGroupOrderRule("' . get_lang("Score").'");
4858
+                        myChart.addSeries("' . get_lang("Option").'", dimple.plot.bar);';
4860 4859
                 } else {
4861
-                    $htmlChart .= 'myChart.addCategoryAxis("x", ["' . get_lang("Option") . '","' . get_lang("Score") . '"]);
4862
-                        myChart.addSeries("' . get_lang("Serie") . '", dimple.plot.bar);';
4860
+                    $htmlChart .= 'myChart.addCategoryAxis("x", ["'.get_lang("Option").'","'.get_lang("Score").'"]);
4861
+                        myChart.addSeries("' . get_lang("Serie").'", dimple.plot.bar);';
4863 4862
                 }
4864 4863
             }
4865 4864
             $htmlChart .= 'myChart.draw();
Please login to merge, or discard this patch.