Completed
Pull Request — 1.11.x (#1458)
by José
138:44 queued 104:05
created
main/exercise/hotspot_actionscript_admin.as.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -98,10 +98,10 @@
 block discarded – undo
98 98
         }*/
99 99
     }
100 100
 
101
-	// This is a good answer, count + 1 for nmbr of clicks
102
-	if ($answers['weighting'][$i] > 0) {
103
-		$nmbrTries++;
104
-	}
101
+    // This is a good answer, count + 1 for nmbr of clicks
102
+    if ($answers['weighting'][$i] > 0) {
103
+        $nmbrTries++;
104
+    }
105 105
 
106 106
     $hotSpot['coord'] = $answers['hotspot_coordinates'][$i];
107 107
     $data['hotspots'][] = $hotSpot;
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 api_protect_course_script(false);
12 12
 
13
-$isAllowedToEdit = api_is_allowed_to_edit(null,true);
13
+$isAllowedToEdit = api_is_allowed_to_edit(null, true);
14 14
 
15 15
 if (!$isAllowedToEdit) {
16 16
     api_not_allowed(true);
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 $objQuestion = Question::read($questionId);
23 23
 $_course = api_get_course_info();
24 24
 
25
-$documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
25
+$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
26 26
 
27 27
 $picturePath = $documentPath.'/images';
28 28
 $pictureName = $objQuestion->selectPicture();
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 $answers = $_SESSION['tmp_answers'];
66 66
 $nbrAnswers = count($answers['answer']);
67 67
 
68
-for ($i=1;$i <= $nbrAnswers; $i++) {
68
+for ($i = 1; $i <= $nbrAnswers; $i++) {
69 69
     $hotSpot = [];
70 70
     $hotSpot['id'] = null;
71
-    $hotSpot['answer']= $answers['answer'][$i];
71
+    $hotSpot['answer'] = $answers['answer'][$i];
72 72
 
73 73
     if ($answer_type == HOT_SPOT_DELINEATION) {
74
-        if ($i==1) {
74
+        if ($i == 1) {
75 75
             $hotSpot['type'] = 'delineation';
76 76
         } else {
77 77
             $hotSpot['type'] = 'oar';
Please login to merge, or discard this patch.
main/exercise/question_list_admin.inc.php 2 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
  * @author Patrick Cool
17 17
  * @author René Haentjens, added CSV file import (October 2004)
18 18
  * @package chamilo.link
19
-
20 19
  */
21 20
 
22 21
 // Including libraries
Please login to merge, or discard this patch.
Spacing   +15 added lines, -16 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             .sortable({
137 137
                 cursor: "move", // works?
138 138
                 update: function(event, ui) {
139
-                    var order = $(this).sortable("serialize") + "&a=update_question_order&exercise_id=<?php echo intval($_GET['exerciseId']);?>";
139
+                    var order = $(this).sortable("serialize") + "&a=update_question_order&exercise_id=<?php echo intval($_GET['exerciseId']); ?>";
140 140
                     $.post("<?php echo $ajax_url ?>", order, function(reponse){
141 141
                         $("#message").html(reponse);
142 142
                     });
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
     echo "<div class='table-responsive'>";
173 173
     echo "<table class='table table-condensed'>";
174 174
     echo "<tr>";
175
-    echo "<th style=\"width: 40%;\">" .get_lang('Questions'). "</th>";
176
-    echo "<th style=\"width: 10%;\">" .get_lang('Type'). "</th>";
177
-    echo "<th style=\"width: 20%;\">" .get_lang('Category'). "</th>";
178
-    echo "<th style=\"width: 10%;\">" .get_lang('Difficulty'). "</th>";
179
-    echo "<th style=\"width: 10%;\">" .get_lang('Score'). "</th>";
180
-    echo "<th style=\"width: 10%;\">" .get_lang('Actions'). "</th>";
175
+    echo "<th style=\"width: 40%;\">".get_lang('Questions')."</th>";
176
+    echo "<th style=\"width: 10%;\">".get_lang('Type')."</th>";
177
+    echo "<th style=\"width: 20%;\">".get_lang('Category')."</th>";
178
+    echo "<th style=\"width: 10%;\">".get_lang('Difficulty')."</th>";
179
+    echo "<th style=\"width: 10%;\">".get_lang('Score')."</th>";
180
+    echo "<th style=\"width: 10%;\">".get_lang('Actions')."</th>";
181 181
     echo "</tr>";
182 182
     echo "</table>";
183 183
     echo "</div>";
@@ -217,15 +217,14 @@  discard block
 block discarded – undo
217 217
                 $question_class = get_class($objQuestionTmp);
218 218
 
219 219
                 $clone_link = '<a href="'.api_get_self().'?'.api_get_cidreq().'&clone_question='.$id.'">'.
220
-                    Display::return_icon('cd.png',get_lang('Copy'), array(), ICON_SIZE_SMALL).'</a>';
220
+                    Display::return_icon('cd.png', get_lang('Copy'), array(), ICON_SIZE_SMALL).'</a>';
221 221
                 $edit_link = ($objQuestionTmp->type == CALCULATED_ANSWER && $objQuestionTmp->isAnswered()) ?
222 222
                     '<a>'.Display::return_icon(
223 223
                         'edit_na.png',
224 224
                         get_lang('QuestionEditionNotAvailableBecauseItIsAlreadyAnsweredHoweverYouCanCopyItAndModifyTheCopy'),
225 225
                         array(),
226 226
                         ICON_SIZE_SMALL
227
-                    ).'</a>' :
228
-                    '<a href="'.api_get_self().'?'.api_get_cidreq().'&type='.
227
+                    ).'</a>' : '<a href="'.api_get_self().'?'.api_get_cidreq().'&type='.
229 228
                     $objQuestionTmp->selectType().'&myid=1&editQuestion='.$id.'">'.
230 229
                     Display::return_icon(
231 230
                         'edit.png',
@@ -235,17 +234,17 @@  discard block
 block discarded – undo
235 234
                     ).'</a>';
236 235
                 $delete_link = null;
237 236
                 if ($objExercise->edit_exercise_in_lp == true) {
238
-                    $delete_link = '<a id="delete_'.$id.'" class="opener"  href="'.api_get_self().'?'.api_get_cidreq().'&exerciseId='.$exerciseId.'&deleteQuestion='.$id.'" >'.Display::return_icon('delete.png',get_lang('RemoveFromTest'), array(), ICON_SIZE_SMALL).'</a>';
237
+                    $delete_link = '<a id="delete_'.$id.'" class="opener"  href="'.api_get_self().'?'.api_get_cidreq().'&exerciseId='.$exerciseId.'&deleteQuestion='.$id.'" >'.Display::return_icon('delete.png', get_lang('RemoveFromTest'), array(), ICON_SIZE_SMALL).'</a>';
239 238
                 }
240 239
                 
241
-                $edit_link = Display::tag('span', $edit_link,   array('class'=>'items'));
242
-                $clone_link = Display::tag('span', $clone_link,  array('class'=>'items'));
240
+                $edit_link = Display::tag('span', $edit_link, array('class'=>'items'));
241
+                $clone_link = Display::tag('span', $clone_link, array('class'=>'items'));
243 242
                 $delete_link = Display::tag('span', $delete_link, array('class'=>'items'));
244
-                $btnActions = Display::tag('td',Display::tag(
243
+                $btnActions = Display::tag('td', Display::tag(
245 244
                     'div',
246 245
                     $edit_link.$clone_link.$delete_link,
247 246
                     array('class'=>'edition')
248
-                ), array ('class'=>'btn-actions'));
247
+                ), array('class'=>'btn-actions'));
249 248
 
250 249
                 $title = Security::remove_XSS($objQuestionTmp->selectTitle());
251 250
                 /* $move = Display::return_icon(
@@ -285,7 +284,7 @@  discard block
 block discarded – undo
285 284
                 $questionScore = Display::tag('td', $objQuestionTmp->selectWeighting(), array('class'=>$styleScore));
286 285
 
287 286
                 echo '<div id="question_id_list_'.$id.'" >';
288
-                echo '<div class="header_operations" data-exercise="' . $objExercise->selectId() . '" data-question="' . $id . '">';
287
+                echo '<div class="header_operations" data-exercise="'.$objExercise->selectId().'" data-question="'.$id.'">';
289 288
                 echo "<div class='table-responsive'>";
290 289
                 echo "<table class='table'>";
291 290
                 echo "<tr>";
Please login to merge, or discard this patch.
main/exercise/evalmathnotation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 get_lang('MultiplicationStar')."\n".
8 8
 get_lang('DivisionSlash')."\n".
9 9
 get_lang('ExponentiationCircumflex')."\n".
10
-get_lang('ModuloPercentage') . "\n" .
10
+get_lang('ModuloPercentage')."\n".
11 11
 "\n".
12 12
 get_lang('SquareRootSqrt')."\n".
13 13
 get_lang('AbsoluteValueAbs')."\n".
Please login to merge, or discard this patch.
main/exercise/calculated_answer.class.php 1 patch
Spacing   +9 added lines, -10 removed lines patch added patch discarded remove patch
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
             ),
134 134
             array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350'));
135 135
 
136
-        $form->addRule('answer', get_lang('GiveText'),'required');
137
-        $form->addRule('answer', get_lang('DefineBlanks'),'regex','/\[.*\]/');
136
+        $form->addRule('answer', get_lang('GiveText'), 'required');
137
+        $form->addRule('answer', get_lang('DefineBlanks'), 'regex', '/\[.*\]/');
138 138
 
139 139
         $form->addElement('label', null, get_lang('IfYouWantOnlyIntegerValuesWriteBothLimitsWithoutDecimals'));
140 140
         $form->addElement('html', '<div id="blanks_weighting"></div>');
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         $form->setDefaults(array('weighting' => '10'));
162 162
 
163 163
         $form->addElement('text', 'answerVariations', get_lang('AnswerVariations'));
164
-        $form->addRule('answerVariations', get_lang('GiveAnswerVariations'),'required');
164
+        $form->addRule('answerVariations', get_lang('GiveAnswerVariations'), 'required');
165 165
         $form->setDefaults(array('answerVariations' => '1'));
166 166
 
167 167
         global $text;
@@ -201,22 +201,21 @@  discard block
 block discarded – undo
201 201
             $answerVariations = $form->getSubmitValue('answerVariations');
202 202
             $this->weighting = $form->getSubmitValue('weighting');
203 203
             // Create as many answers as $answerVariations
204
-            for ($j=0 ; $j < $answerVariations; $j++) {
204
+            for ($j = 0; $j < $answerVariations; $j++) {
205 205
                 $auxAnswer = $answer;
206 206
                 $auxFormula = $formula;
207 207
                 $nb = preg_match_all('/\[[^\]]*\]/', $auxAnswer, $blanks);
208 208
                 if ($nb > 0) {
209
-                    for ($i=0 ; $i < $nb; ++$i) {
209
+                    for ($i = 0; $i < $nb; ++$i) {
210 210
                         $blankItem = $blanks[0][$i];
211 211
                         $replace = array("[", "]");
212 212
                         $newBlankItem = str_replace($replace, "", $blankItem);
213 213
                         $newBlankItem = "[".trim($newBlankItem)."]";
214 214
                         // take random float values when one or both edge values have a decimal point
215 215
                         $randomValue =
216
-                            (strpos($lowestValues[$i],'.') !== false ||
217
-                            strpos($highestValues[$i],'.') !== false) ?
218
-                            mt_rand($lowestValues[$i]*100,$highestValues[$i]*100)/100 :
219
-                            mt_rand($lowestValues[$i],$highestValues[$i]);
216
+                            (strpos($lowestValues[$i], '.') !== false ||
217
+                            strpos($highestValues[$i], '.') !== false) ?
218
+                            mt_rand($lowestValues[$i] * 100, $highestValues[$i] * 100) / 100 : mt_rand($lowestValues[$i], $highestValues[$i]);
220 219
                         $auxAnswer = str_replace($blankItem, $randomValue, $auxAnswer);
221 220
                         $auxFormula = str_replace($blankItem, $randomValue, $auxFormula);
222 221
                     }
@@ -250,7 +249,7 @@  discard block
 block discarded – undo
250 249
     function return_header($feedback_type = null, $counter = null, $score = null)
251 250
     {
252 251
         $header = parent::return_header($feedback_type, $counter, $score);
253
-        $header .= '<table class="'.$this->question_table_class .'">
252
+        $header .= '<table class="'.$this->question_table_class.'">
254 253
             <tr>
255 254
                 <th>'.get_lang("Answer").'</th>
256 255
             </tr>';
Please login to merge, or discard this patch.
main/exercise/hotspot.inc.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@
 block discarded – undo
18 18
 $file = file(api_get_path(SYS_LANG_PATH).'english/hotspot.inc.php');
19 19
 
20 20
 foreach ($file as &$value) {
21
-	$variable = explode('=', $value , 2);
22
-	if (count($variable) > 1) {
23
-		$variable = substr(trim($variable[0]), 1);
24
-		$variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' ';
25
-		echo $variable;
26
-	}
21
+    $variable = explode('=', $value , 2);
22
+    if (count($variable) > 1) {
23
+        $variable = substr(trim($variable[0]), 1);
24
+        $variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' ';
25
+        echo $variable;
26
+    }
27 27
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 $file = file(api_get_path(SYS_LANG_PATH).'english/hotspot.inc.php');
19 19
 
20 20
 foreach ($file as &$value) {
21
-	$variable = explode('=', $value , 2);
21
+	$variable = explode('=', $value, 2);
22 22
 	if (count($variable) > 1) {
23 23
 		$variable = substr(trim($variable[0]), 1);
24 24
 		$variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' ';
Please login to merge, or discard this patch.
main/exercise/overview.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -249,7 +249,7 @@
 block discarded – undo
249 249
             break;
250 250
         case RESULT_DISABLE_SHOW_SCORE_ONLY:
251 251
             if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) {
252
-               $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'));
252
+                $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'));
253 253
             }
254 254
             else {
255 255
                 $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'), get_lang('Details'));
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -250,8 +250,7 @@
 block discarded – undo
250 250
         case RESULT_DISABLE_SHOW_SCORE_ONLY:
251 251
             if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) {
252 252
                $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'));
253
-            }
254
-            else {
253
+            } else {
255 254
                 $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'), get_lang('Details'));
256 255
             }
257 256
             break;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 require_once '../inc/global.inc.php';
14 14
 
15
-$current_course_tool  = TOOL_QUIZ;
15
+$current_course_tool = TOOL_QUIZ;
16 16
 
17 17
 // Clear the exercise session just in case
18 18
 Session::erase('objExercise');
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 if ($time_control) {
49 49
     // Get time left for expiring time
50
-    $time_left = api_strtotime($clock_expired_time,'UTC') - time();
50
+    $time_left = api_strtotime($clock_expired_time, 'UTC') - time();
51 51
 
52 52
     $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/stylesheet/jquery.epiclock.css');
53 53
     $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css');
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 $html = '';
72 72
 $message = '';
73
-$html.= '<div class="exercise">';
73
+$html .= '<div class="exercise">';
74 74
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
75 75
 $edit_link = '';
76 76
 if ($is_allowed_to_edit && $objExercise->sessionId == $sessionId) {
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
 // 2. Exercise button
118 118
 // Notice we not add there the lp_item_view_id because is not already generated
119
-$exercise_url = api_get_path(WEB_CODE_PATH) . 'exercise/exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.$extra_params;
119
+$exercise_url = api_get_path(WEB_CODE_PATH).'exercise/exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.$extra_params;
120 120
 $exercise_url_button = Display::url(
121 121
     $label,
122 122
     $exercise_url,
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
             $attempt_result['exe_result'],
183 183
             $attempt_result['exe_weighting']
184 184
         );
185
-        $attempt_url = api_get_path(WEB_CODE_PATH) . 'exercise/result.php?';
186
-        $attempt_url .= api_get_cidreq() . '&show_headers=1&';
185
+        $attempt_url = api_get_path(WEB_CODE_PATH).'exercise/result.php?';
186
+        $attempt_url .= api_get_cidreq().'&show_headers=1&';
187 187
         $attempt_url .= http_build_query([
188 188
             'id' => $attempt_result['exe_id']
189 189
         ]);
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
             get_lang('Show'),
194 194
             $attempt_url,
195 195
             [
196
-                'class' => $btn_class . 'btn btn-default',
196
+                'class' => $btn_class.'btn btn-default',
197 197
                 'data-title' => get_lang('Show'),
198 198
                 'data-size' => 'lg'
199 199
             ]
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
             ),
212 212
             'userIp' => $attempt_result['user_ip']
213 213
         );
214
-        $attempt_link .= "&nbsp;&nbsp;&nbsp;" . $teacher_revised;
214
+        $attempt_link .= "&nbsp;&nbsp;&nbsp;".$teacher_revised;
215 215
 
216 216
         if (in_array(
217 217
             $objExercise->results_disabled,
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 }
308 308
 
309 309
 if ($time_control) {
310
-    $html.= $objExercise->return_time_left_div();
310
+    $html .= $objExercise->return_time_left_div();
311 311
 }
312 312
 
313 313
 $html .= $message;
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
     $table_content,
328 328
     ['class' => 'table-responsive']
329 329
 );
330
-$html.= '</div>';
330
+$html .= '</div>';
331 331
 echo $html;
332 332
 
333 333
 Display::display_footer();
Please login to merge, or discard this patch.
main/exercise/matching.class.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
                 for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
73 73
                     if ($answer->isCorrect($i)) {
74 74
                         $nb_matches++;
75
-                        $defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i);
76
-                        $defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1);
77
-                        $defaults['matches[' . $nb_matches . ']'] = $answer->correct[$i];
75
+                        $defaults['answer['.$nb_matches.']'] = $answer->selectAnswer($i);
76
+                        $defaults['weighting['.$nb_matches.']'] = float_format($answer->selectWeighting($i), 1);
77
+                        $defaults['matches['.$nb_matches.']'] = $answer->correct[$i];
78 78
                     } else {
79 79
                         $nb_options++;
80
-                        $defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i);
80
+                        $defaults['option['.$nb_options.']'] = $answer->selectAnswer($i);
81 81
                     }
82 82
                 }
83 83
             }
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
         $html = '<table class="table table-striped table-hover">
109 109
             <thead>
110 110
                 <tr>
111
-                    <th width="5%">' . get_lang('Number') . '</th>
112
-                    <th width="70%">' . get_lang('Answer') . '</th>
113
-                    <th width="15%">' . get_lang('MatchesTo') . '</th>
114
-                    <th width="10%">' . get_lang('Weighting') . '</th>
111
+                    <th width="5%">' . get_lang('Number').'</th>
112
+                    <th width="70%">' . get_lang('Answer').'</th>
113
+                    <th width="15%">' . get_lang('MatchesTo').'</th>
114
+                    <th width="10%">' . get_lang('Weighting').'</th>
115 115
                 </tr>
116 116
             </thead>
117 117
             <tbody>';
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
         $html = '<table class="table table-striped table-hover">
163 163
             <thead>
164 164
                 <tr>
165
-                    <th width="15%">' . get_lang('Number') . '</th>
166
-                    <th width="85%">' . get_lang('Answer') . '</th>
165
+                    <th width="15%">' . get_lang('Number').'</th>
166
+                    <th width="85%">' . get_lang('Answer').'</th>
167 167
                 </tr>
168 168
             </thead>
169 169
             <tbody>';
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
             $form->addHtml('<tr>');
187 187
 
188
-            $form->addHtml('<td>' . chr(64 + $i) . '</td>');
188
+            $form->addHtml('<td>'.chr(64 + $i).'</td>');
189 189
             $form->addText("option[$i]", null);
190 190
 
191 191
             $form->addHtml('</tr>');
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
     public function return_header($feedback_type = null, $counter = null, $score = null)
268 268
     {
269 269
         $header = parent::return_header($feedback_type, $counter, $score);
270
-        $header .= '<table class="'.$this->question_table_class .'">';
270
+        $header .= '<table class="'.$this->question_table_class.'">';
271 271
         $header .= '<tr>
272 272
                 <th>'.get_lang('ElementList').'</th>
273 273
                 <th>'.get_lang('CorrespondsTo').'</th>
Please login to merge, or discard this patch.
main/exercise/exercise_reminder.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -223,10 +223,10 @@
 block discarded – undo
223 223
 
224 224
     $counter++;
225 225
     if ($objExercise->type == ONE_PER_PAGE) {
226
-       $question_title = Display::url($counter.'. '.cut($objQuestionTmp->selectTitle(), 40), $url);
227
-       $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
226
+        $question_title = Display::url($counter.'. '.cut($objQuestionTmp->selectTitle(), 40), $url);
227
+        $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
228 228
     } else {
229
-       $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
229
+        $question_title = $counter.'. '.cut($objQuestionTmp->selectTitle(), 40);
230 230
     }
231 231
     //Check if the question doesn't have an answer
232 232
     if (!in_array($questionId, $exercise_result)) {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 // notice for unauthorized people.
18 18
 api_protect_course_script(true);
19 19
 
20
-if ($debug>0) {
20
+if ($debug > 0) {
21 21
     error_log('Entered exercise_result.php: '.print_r($_POST, 1));
22 22
 }
23 23
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 if (isset($_SESSION['exe_id'])) {
98 98
     $exe_id = intval($_SESSION['exe_id']);
99 99
 }
100
-$exercise_stat_info	= $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
100
+$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
101 101
 if (!empty($exercise_stat_info['data_tracking'])) {
102 102
     $question_list = explode(',', $exercise_stat_info['data_tracking']);
103 103
 }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     Display::url(
250 250
         get_lang('ReviewQuestions'),
251 251
         'javascript://',
252
-        array('onclick'=>'review_questions();','class'=>'btn btn-success')
252
+        array('onclick'=>'review_questions();', 'class'=>'btn btn-success')
253 253
     );
254 254
 
255 255
 echo Display::div('', array('class'=>'clear'));
Please login to merge, or discard this patch.
main/exercise/answer.class.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $objExercise->read($exerciseId);
74 74
 
75 75
         if ($objExercise->random_answers == '1') {
76
-            $this->readOrderedBy('rand()', '');// randomize answers
76
+            $this->readOrderedBy('rand()', ''); // randomize answers
77 77
         } else {
78 78
             $this->read(); // natural order
79 79
         }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
                 ORDER BY position";
115 115
 
116 116
         $result = Database::query($sql);
117
-        $i=1;
117
+        $i = 1;
118 118
 
119 119
         // while a record is found
120 120
         while ($object = Database::fetch_object($result)) {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             $this->autoId[$i] = $object->id_auto;
131 131
             $i++;
132 132
         }
133
-        $this->nbrAnswers = $i-1;
133
+        $this->nbrAnswers = $i - 1;
134 134
     }
135 135
 
136 136
     /**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
     {
143 143
         foreach ($this->autoId as $key => $autoId) {
144 144
             if ($autoId == $id) {
145
-                $result =  [
145
+                $result = [
146 146
                     'answer' => $this->answer[$key],
147 147
                     'correct' => $this->correct[$key],
148 148
                     'comment' => $this->comment[$key],
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
         $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
167 167
         $questionId = $this->questionId;
168 168
 
169
-        $sql="SELECT id FROM
169
+        $sql = "SELECT id FROM
170 170
               $TBL_ANSWER
171 171
               WHERE c_id = {$this->course_id} AND question_id ='".$questionId."'";
172 172
 
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
      * @param	string	DESC or ASC
189 189
      * @author 	Frederic Vauthier
190 190
      */
191
-    public function readOrderedBy($field, $order='ASC')
191
+    public function readOrderedBy($field, $order = 'ASC')
192 192
     {
193 193
 		$field = Database::escape_string($field);
194 194
 		if (empty($field)) {
195 195
 			$field = 'position';
196 196
 		}
197 197
 
198
-		if ($order != 'ASC' && $order!='DESC') {
198
+		if ($order != 'ASC' && $order != 'DESC') {
199 199
 			$order = 'ASC';
200 200
 		}
201 201
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                     c_id = {$this->course_id} AND
231 231
                     question_id='".$questionId."'
232 232
                 ORDER BY $field $order";
233
-		$result=Database::query($sql);
233
+		$result = Database::query($sql);
234 234
 
235 235
 		$i = 1;
236 236
 		// while a record is found
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             $this->autoId[$i] = $doubt_data->id_auto;
261 261
             $i++;
262 262
 	    }
263
-        $this->nbrAnswers = $i-1;
263
+        $this->nbrAnswers = $i - 1;
264 264
 	}
265 265
 
266 266
 	/**
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
     public function getGradesList()
403 403
      {
404 404
 	 	$list = array();
405
-	 	for ($i = 0; $i<$this->nbrAnswers;$i++){
406
-	 		if(!empty($this->answer[$i])){
405
+	 	for ($i = 0; $i < $this->nbrAnswers; $i++) {
406
+	 		if (!empty($this->answer[$i])) {
407 407
 	 			$list[$i] = $this->weighting[$i];
408 408
 	 		}
409 409
 	 	}
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	 	$sql = "SELECT type FROM $TBL_QUESTIONS
422 422
 	 	        WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'";
423 423
 	 	$res = Database::query($sql);
424
-	 	if (Database::num_rows($res)<=0){
424
+	 	if (Database::num_rows($res) <= 0) {
425 425
 	 		return null;
426 426
 	 	}
427 427
 	 	$row = Database::fetch_array($res);
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
         $correctList = [];
594 594
         $answerList = [];
595 595
 
596
-		for ($i=1; $i <= $this->new_nbrAnswers; $i++) {
596
+		for ($i = 1; $i <= $this->new_nbrAnswers; $i++) {
597 597
 			$answer = $this->new_answer[$i];
598 598
 			$correct = $this->new_correct[$i];
599 599
 			$comment = $this->new_comment[$i];
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
             $destination_options = Question::readQuestionOption($newQuestionId, $course_info['real_id']);
749 749
             $i = 0;
750 750
             if (!empty($destination_options)) {
751
-                foreach($destination_options as $item) {
751
+                foreach ($destination_options as $item) {
752 752
                     $fixed_list[$new_option_list[$i]] = $item['id'];
753 753
                     $i++;
754 754
                 }
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 			// inserts new answers into data base
761 761
 			$c_id = $course_info['real_id'];
762 762
 
763
-			for ($i=1;$i <= $this->nbrAnswers;$i++) {
763
+			for ($i = 1; $i <= $this->nbrAnswers; $i++) {
764 764
                 if ($this->course['id'] != $course_info['id']) {
765 765
                     $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
766 766
                         $this->answer[$i],
Please login to merge, or discard this patch.
Indentation   +319 added lines, -319 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
     public $new_destination; // id of the next question if feedback option is set to Directfeedback
38 38
     public $course; //Course information
39 39
     public $iid;
40
-	public $questionJSId;
41
-	public $standalone;
40
+    public $questionJSId;
41
+    public $standalone;
42 42
 
43 43
     /**
44 44
      * constructor of the class
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
         return [];
160 160
     }
161 161
 
162
-     /**
163
-     * returns all answer ids from this question Id
164
-     *
165
-     * @author Yoselyn Castillo
166
-     * @return array - $id (answer ids)
167
-     */
162
+        /**
163
+         * returns all answer ids from this question Id
164
+         *
165
+         * @author Yoselyn Castillo
166
+         * @return array - $id (answer ids)
167
+         */
168 168
     public function selectAnswerId()
169 169
     {
170 170
         $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         }
185 185
 
186 186
         return $id;
187
-	}
187
+    }
188 188
 
189 189
     /**
190 190
      * Reads answer information from the data base ordered by parameter
@@ -195,23 +195,23 @@  discard block
 block discarded – undo
195 195
      */
196 196
     public function readOrderedBy($field, $order='ASC')
197 197
     {
198
-		$field = Database::escape_string($field);
199
-		if (empty($field)) {
200
-			$field = 'position';
201
-		}
198
+        $field = Database::escape_string($field);
199
+        if (empty($field)) {
200
+            $field = 'position';
201
+        }
202 202
 
203
-		if ($order != 'ASC' && $order!='DESC') {
204
-			$order = 'ASC';
205
-		}
203
+        if ($order != 'ASC' && $order!='DESC') {
204
+            $order = 'ASC';
205
+        }
206 206
 
207
-		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
208
-		$TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION);
209
-		$questionId = intval($this->questionId);
207
+        $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
208
+        $TBL_QUIZ = Database::get_course_table(TABLE_QUIZ_QUESTION);
209
+        $questionId = intval($this->questionId);
210 210
 
211
-		$sql = "SELECT type FROM $TBL_QUIZ
211
+        $sql = "SELECT type FROM $TBL_QUIZ
212 212
 		        WHERE c_id = {$this->course_id} AND id = $questionId";
213
-		$result_question = Database::query($sql);
214
-		$questionType = Database::fetch_array($result_question);
213
+        $result_question = Database::query($sql);
214
+        $questionType = Database::fetch_array($result_question);
215 215
 
216 216
         if ($questionType['type'] == DRAGGABLE) {
217 217
             // Random is done by submit.js.tpl
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
             return true;
221 221
         }
222 222
 
223
-		$sql = "SELECT
223
+        $sql = "SELECT
224 224
 		            answer,
225 225
 		            correct,
226 226
 		            comment,
@@ -236,16 +236,16 @@  discard block
 block discarded – undo
236 236
                     c_id = {$this->course_id} AND
237 237
                     question_id='".$questionId."'
238 238
                 ORDER BY $field $order";
239
-		$result=Database::query($sql);
240
-
241
-		$i = 1;
242
-		// while a record is found
243
-		$doubt_data = null;
244
-		while ($object = Database::fetch_object($result)) {
245
-		    if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) {
246
-		        $doubt_data = $object;
239
+        $result=Database::query($sql);
240
+
241
+        $i = 1;
242
+        // while a record is found
243
+        $doubt_data = null;
244
+        while ($object = Database::fetch_object($result)) {
245
+            if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && $object->position == 666) {
246
+                $doubt_data = $object;
247 247
                 continue;
248
-		    }
248
+            }
249 249
             $this->answer[$i] = $object->answer;
250 250
             $this->correct[$i] = $object->correct;
251 251
             $this->comment[$i] = $object->comment;
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
             $this->autoId[$i] = $object->id_auto;
258 258
             $this->iid[$i] = $object->iid;
259 259
             $i++;
260
-		}
260
+        }
261 261
 
262
-		if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) {
262
+        if ($questionType['type'] == UNIQUE_ANSWER_NO_OPTION && !empty($doubt_data)) {
263 263
             $this->answer[$i] = $doubt_data->answer;
264 264
             $this->correct[$i] = $doubt_data->correct;
265 265
             $this->comment[$i] = $doubt_data->comment;
@@ -271,88 +271,88 @@  discard block
 block discarded – undo
271 271
             $this->autoId[$i] = $doubt_data->id_auto;
272 272
             $this->iid[$i] = $doubt_data->iid;
273 273
             $i++;
274
-	    }
274
+        }
275 275
         $this->nbrAnswers = $i-1;
276
-	}
277
-
278
-	/**
279
-	 * returns the autoincrement id identificator
280
-	 *
281
-	 * @author Juan Carlos Ra�a
282
-	 * @return integer - answer num
283
-	 */
276
+    }
277
+
278
+    /**
279
+     * returns the autoincrement id identificator
280
+     *
281
+     * @author Juan Carlos Ra�a
282
+     * @return integer - answer num
283
+     */
284 284
     public function selectAutoId($id)
285 285
     {
286
-		return isset($this->autoId[$id]) ? $this->autoId[$id] : 0;
287
-	}
288
-
289
-	/**
290
-	 * returns the number of answers in this question
291
-	 *
292
-	 * @author Olivier Brouckaert
293
-	 * @return integer - number of answers
294
-	 */
295
-	public function selectNbrAnswers()
286
+        return isset($this->autoId[$id]) ? $this->autoId[$id] : 0;
287
+    }
288
+
289
+    /**
290
+     * returns the number of answers in this question
291
+     *
292
+     * @author Olivier Brouckaert
293
+     * @return integer - number of answers
294
+     */
295
+    public function selectNbrAnswers()
296 296
     {
297
-		return $this->nbrAnswers;
298
-	}
299
-
300
-	/**
301
-	 * returns the question ID which the answers belong to
302
-	 *
303
-	 * @author Olivier Brouckaert
304
-	 * @return integer - the question ID
305
-	 */
306
-	public function selectQuestionId()
297
+        return $this->nbrAnswers;
298
+    }
299
+
300
+    /**
301
+     * returns the question ID which the answers belong to
302
+     *
303
+     * @author Olivier Brouckaert
304
+     * @return integer - the question ID
305
+     */
306
+    public function selectQuestionId()
307 307
     {
308
-		return $this->questionId;
309
-	}
310
-
311
-	/**
312
-	 * returns the question ID of the destination question
313
-	 *
314
-	 * @author Julio Montoya
315
-	 * @param integer $id
316
-	 * @return integer - the question ID
317
-	 */
318
-	public function selectDestination($id)
308
+        return $this->questionId;
309
+    }
310
+
311
+    /**
312
+     * returns the question ID of the destination question
313
+     *
314
+     * @author Julio Montoya
315
+     * @param integer $id
316
+     * @return integer - the question ID
317
+     */
318
+    public function selectDestination($id)
319 319
     {
320
-		return isset($this->destination[$id]) ? $this->destination[$id] : null;
321
-	}
320
+        return isset($this->destination[$id]) ? $this->destination[$id] : null;
321
+    }
322 322
 
323 323
     /**
324
-	 * returns the answer title
325
-	 *
326
-	 * @author Olivier Brouckaert
327
-	 * @param - integer $id - answer ID
328
-	 * @return string - answer title
329
-	 */
330
-	public function selectAnswer($id)
331
-	{
332
-		return isset($this->answer[$id]) ? $this->answer[$id] : null;
333
-	}
334
-
335
-	/**
336
-	 * return array answer by id else return a bool
337
-	 * @param integer $auto_id
338
-	 */
339
-	public function selectAnswerByAutoId($auto_id)
340
-	{
341
-		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
342
-
343
-		$auto_id = intval($auto_id);
344
-		$sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
324
+     * returns the answer title
325
+     *
326
+     * @author Olivier Brouckaert
327
+     * @param - integer $id - answer ID
328
+     * @return string - answer title
329
+     */
330
+    public function selectAnswer($id)
331
+    {
332
+        return isset($this->answer[$id]) ? $this->answer[$id] : null;
333
+    }
334
+
335
+    /**
336
+     * return array answer by id else return a bool
337
+     * @param integer $auto_id
338
+     */
339
+    public function selectAnswerByAutoId($auto_id)
340
+    {
341
+        $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
342
+
343
+        $auto_id = intval($auto_id);
344
+        $sql = "SELECT id, answer, id_auto FROM $TBL_ANSWER
345 345
 				WHERE c_id = {$this->course_id} AND id_auto='$auto_id'";
346
-		$rs = Database::query($sql);
346
+        $rs = Database::query($sql);
347 347
 
348
-		if (Database::num_rows($rs) > 0) {
349
-			$row = Database::fetch_array($rs, 'ASSOC');
348
+        if (Database::num_rows($rs) > 0) {
349
+            $row = Database::fetch_array($rs, 'ASSOC');
350 350
 
351
-			return $row;
352
-		}
351
+            return $row;
352
+        }
353 353
 
354
-		return false;
355
-	}
354
+        return false;
355
+    }
356 356
 
357 357
     /**
358 358
      * returns the answer title from an answer's position
@@ -361,18 +361,18 @@  discard block
 block discarded – undo
361 361
      * @param - integer $id - answer ID
362 362
      * @return bool - answer title
363 363
      */
364
-	public function selectAnswerIdByPosition($pos)
365
-	{
366
-		foreach ($this->position as $k => $v) {
367
-			if ($v != $pos) {
368
-				continue;
369
-			}
364
+    public function selectAnswerIdByPosition($pos)
365
+    {
366
+        foreach ($this->position as $k => $v) {
367
+            if ($v != $pos) {
368
+                continue;
369
+            }
370 370
 
371
-			return $k;
372
-		}
371
+            return $k;
372
+        }
373 373
 
374
-		return false;
375
-	}
374
+        return false;
375
+    }
376 376
 
377 377
     /**
378 378
      * Returns a list of answers
@@ -381,18 +381,18 @@  discard block
 block discarded – undo
381 381
      * of (id, answer, comment, grade) and grade=weighting
382 382
      */
383 383
     public function getAnswersList($decode = false)
384
-     {
385
-	 	$list = array();
386
-         for ($i = 1; $i <= $this->nbrAnswers; $i++) {
387
-             if (!empty($this->answer[$i])) {
388
-
389
-	 			//Avoid problems when parsing elements with accents
390
-	 			if ($decode) {
391
-	        		$this->answer[$i] 	= api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding());
392
-	        		$this->comment[$i]	= api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding());
393
-	 			}
394
-
395
-	 			$list[] = array(
384
+        {
385
+            $list = array();
386
+            for ($i = 1; $i <= $this->nbrAnswers; $i++) {
387
+                if (!empty($this->answer[$i])) {
388
+
389
+                    //Avoid problems when parsing elements with accents
390
+                    if ($decode) {
391
+                    $this->answer[$i] 	= api_html_entity_decode($this->answer[$i], ENT_QUOTES, api_get_system_encoding());
392
+                    $this->comment[$i]	= api_html_entity_decode($this->comment[$i], ENT_QUOTES, api_get_system_encoding());
393
+                    }
394
+
395
+                    $list[] = array(
396 396
                     'id' => $i,
397 397
                     'answer' => $this->answer[$i],
398 398
                     'comment' => $this->comment[$i],
@@ -401,137 +401,137 @@  discard block
 block discarded – undo
401 401
                     'hotspot_type' => $this->hotspot_type[$i],
402 402
                     'correct' => $this->correct[$i],
403 403
                     'destination' => $this->destination[$i]
404
-				);
404
+                );
405
+            }
405 406
             }
406
-	 	}
407 407
 
408
-	 	return $list;
409
-	 }
408
+            return $list;
409
+        }
410 410
 
411
-	/**
412
-	 * Returns a list of grades
413
-	 * @author Yannick Warnier <[email protected]>
414
-	 * @return array	List of grades where grade=weighting (?)
415
-	 */
411
+    /**
412
+     * Returns a list of grades
413
+     * @author Yannick Warnier <[email protected]>
414
+     * @return array	List of grades where grade=weighting (?)
415
+     */
416 416
     public function getGradesList()
417
-     {
418
-	 	$list = array();
419
-	 	for ($i = 0; $i<$this->nbrAnswers;$i++){
420
-	 		if(!empty($this->answer[$i])){
421
-	 			$list[$i] = $this->weighting[$i];
422
-	 		}
423
-	 	}
424
-	 	return $list;
425
-	 }
426
-
427
-	 /**
428
-	  * Returns the question type
429
-	  * @author	Yannick Warnier <[email protected]>
430
-	  * @return	integer	The type of the question this answer is bound to
431
-	  */
417
+        {
418
+            $list = array();
419
+            for ($i = 0; $i<$this->nbrAnswers;$i++){
420
+                if(!empty($this->answer[$i])){
421
+                    $list[$i] = $this->weighting[$i];
422
+                }
423
+            }
424
+            return $list;
425
+        }
426
+
427
+        /**
428
+         * Returns the question type
429
+         * @author	Yannick Warnier <[email protected]>
430
+         * @return	integer	The type of the question this answer is bound to
431
+         */
432 432
     public function getQuestionType()
433
-     {
434
-	 	$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
435
-	 	$sql = "SELECT type FROM $TBL_QUESTIONS
433
+        {
434
+            $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
435
+            $sql = "SELECT type FROM $TBL_QUESTIONS
436 436
 	 	        WHERE c_id = {$this->course_id} AND id = '".$this->questionId."'";
437
-	 	$res = Database::query($sql);
438
-	 	if (Database::num_rows($res)<=0){
439
-	 		return null;
440
-	 	}
441
-	 	$row = Database::fetch_array($res);
442
-
443
-	 	return $row['type'];
444
-	 }
445
-
446
-
447
-	/**
448
-	 * tells if answer is correct or not
449
-	 *
450
-	 * @author Olivier Brouckaert
451
-	 * @param - integer $id - answer ID
452
-	 * @return integer - 0 if bad answer, not 0 if good answer
453
-	 */
437
+            $res = Database::query($sql);
438
+            if (Database::num_rows($res)<=0){
439
+                return null;
440
+            }
441
+            $row = Database::fetch_array($res);
442
+
443
+            return $row['type'];
444
+        }
445
+
446
+
447
+    /**
448
+     * tells if answer is correct or not
449
+     *
450
+     * @author Olivier Brouckaert
451
+     * @param - integer $id - answer ID
452
+     * @return integer - 0 if bad answer, not 0 if good answer
453
+     */
454 454
     public function isCorrect($id)
455
-	{
456
-		return isset($this->correct[$id]) ? $this->correct[$id] : null;
457
-	}
458
-
459
-	/**
460
-	 * returns answer comment
461
-	 *
462
-	 * @author Olivier Brouckaert
463
-	 * @param - integer $id - answer ID
464
-	 * @return string - answer comment
465
-	 */
455
+    {
456
+        return isset($this->correct[$id]) ? $this->correct[$id] : null;
457
+    }
458
+
459
+    /**
460
+     * returns answer comment
461
+     *
462
+     * @author Olivier Brouckaert
463
+     * @param - integer $id - answer ID
464
+     * @return string - answer comment
465
+     */
466 466
     public function selectComment($id)
467
-	{
467
+    {
468 468
         return isset($this->comment[$id]) ? $this->comment[$id] : null;
469
-	}
470
-
471
-	/**
472
-	 * returns answer weighting
473
-	 *
474
-	 * @author Olivier Brouckaert
475
-	 * @param - integer $id - answer ID
476
-	 * @param integer $id
477
-	 * @return integer - answer weighting
478
-	 */
469
+    }
470
+
471
+    /**
472
+     * returns answer weighting
473
+     *
474
+     * @author Olivier Brouckaert
475
+     * @param - integer $id - answer ID
476
+     * @param integer $id
477
+     * @return integer - answer weighting
478
+     */
479 479
     public function selectWeighting($id)
480
-	{
481
-		return isset($this->weighting[$id]) ? $this->weighting[$id] : null;
482
-	}
483
-
484
-	/**
485
-	 * returns answer position
486
-	 *
487
-	 * @author Olivier Brouckaert
488
-	 * @param - integer $id - answer ID
489
-	 * @return integer - answer position
490
-	 */
491
-	function selectPosition($id)
492
-	{
493
-		return isset($this->position[$id]) ? $this->position[$id] : null;
494
-	}
495
-
496
-	/**
497
-	 * returns answer hotspot coordinates
498
-	 *
499
-	 * @author	Olivier Brouckaert
500
-	 * @param	integer	Answer ID
501
-	 * @param integer $id
502
-	 * @return	integer	Answer position
503
-	 */
480
+    {
481
+        return isset($this->weighting[$id]) ? $this->weighting[$id] : null;
482
+    }
483
+
484
+    /**
485
+     * returns answer position
486
+     *
487
+     * @author Olivier Brouckaert
488
+     * @param - integer $id - answer ID
489
+     * @return integer - answer position
490
+     */
491
+    function selectPosition($id)
492
+    {
493
+        return isset($this->position[$id]) ? $this->position[$id] : null;
494
+    }
495
+
496
+    /**
497
+     * returns answer hotspot coordinates
498
+     *
499
+     * @author	Olivier Brouckaert
500
+     * @param	integer	Answer ID
501
+     * @param integer $id
502
+     * @return	integer	Answer position
503
+     */
504 504
     public function selectHotspotCoordinates($id)
505
-	{
506
-		return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null;
507
-	}
508
-
509
-	/**
510
-	 * returns answer hotspot type
511
-	 *
512
-	 * @author	Toon Keppens
513
-	 * @param	integer		Answer ID
514
-	 * @param integer $id
515
-	 * @return	integer		Answer position
516
-	 */
505
+    {
506
+        return isset($this->hotspot_coordinates[$id]) ? $this->hotspot_coordinates[$id] : null;
507
+    }
508
+
509
+    /**
510
+     * returns answer hotspot type
511
+     *
512
+     * @author	Toon Keppens
513
+     * @param	integer		Answer ID
514
+     * @param integer $id
515
+     * @return	integer		Answer position
516
+     */
517 517
     public function selectHotspotType($id)
518
-	{
519
-		return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null;
520
-	}
521
-
522
-	/**
523
-	 * Creates a new answer
524
-	 *
525
-	 * @author Olivier Brouckaert
526
-	 * @param string 	$answer answer title
527
-	 * @param integer 	$correct 0 if bad answer, not 0 if good answer
528
-	 * @param string 	$comment answer comment
529
-	 * @param integer 	$weighting answer weighting
530
-	 * @param integer 	$position answer position
531
-	 * @param array    $new_hotspot_coordinates Coordinates for hotspot exercises (optional)
532
-	 * @param integer	$new_hotspot_type Type for hotspot exercises (optional)
518
+    {
519
+        return isset($this->hotspot_type[$id]) ? $this->hotspot_type[$id] : null;
520
+    }
521
+
522
+    /**
523
+     * Creates a new answer
524
+     *
525
+     * @author Olivier Brouckaert
526
+     * @param string 	$answer answer title
527
+     * @param integer 	$correct 0 if bad answer, not 0 if good answer
528
+     * @param string 	$comment answer comment
529
+     * @param integer 	$weighting answer weighting
530
+     * @param integer 	$position answer position
531
+     * @param array    $new_hotspot_coordinates Coordinates for hotspot exercises (optional)
532
+     * @param integer	$new_hotspot_type Type for hotspot exercises (optional)
533 533
      * @param string   $destination
534
-	 */
534
+     */
535 535
     public function createAnswer(
536 536
         $answer,
537 537
         $correct,
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
         $new_hotspot_type = null,
543 543
         $destination = ''
544 544
     ) {
545
-		$this->new_nbrAnswers++;
545
+        $this->new_nbrAnswers++;
546 546
         $id = $this->new_nbrAnswers;
547 547
         $this->new_answer[$id] = $answer;
548 548
         $this->new_correct[$id] = $correct;
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
         $this->new_hotspot_coordinates[$id] = $new_hotspot_coordinates;
553 553
         $this->new_hotspot_type[$id] = $new_hotspot_type;
554 554
         $this->new_destination[$id] = $destination;
555
-	}
555
+    }
556 556
 
557 557
     /**
558 558
      * Updates an answer
@@ -595,32 +595,32 @@  discard block
 block discarded – undo
595 595
 
596 596
         $em->merge($quizAnswer);
597 597
         $em->flush();
598
-	}
598
+    }
599 599
 
600
-	/**
601
-	 * Records answers into the data base
602
-	 *
603
-	 * @author Olivier Brouckaert
604
-	 */
600
+    /**
601
+     * Records answers into the data base
602
+     *
603
+     * @author Olivier Brouckaert
604
+     */
605 605
     public function save()
606 606
     {
607
-		$answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER);
607
+        $answerTable = Database::get_course_table(TABLE_QUIZ_ANSWER);
608 608
         $em = Database::getManager();
609
-		$questionId = intval($this->questionId);
609
+        $questionId = intval($this->questionId);
610 610
 
611
-		$c_id = $this->course['real_id'];
611
+        $c_id = $this->course['real_id'];
612 612
         $correctList = [];
613 613
         $answerList = [];
614 614
 
615
-		for ($i=1; $i <= $this->new_nbrAnswers; $i++) {
616
-			$answer = $this->new_answer[$i];
617
-			$correct = isset($this->new_correct[$i]) ? $this->new_correct[$i] : '';
618
-			$comment = isset($this->new_comment[$i]) ? $this->new_comment[$i] : '';
619
-			$weighting = isset($this->new_weighting[$i]) ? $this->new_weighting[$i] : '';
620
-			$position = isset($this->new_position[$i]) ? $this->new_position[$i] : '';
621
-			$hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : '';
622
-			$hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : '';
623
-			$destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : '';
615
+        for ($i=1; $i <= $this->new_nbrAnswers; $i++) {
616
+            $answer = $this->new_answer[$i];
617
+            $correct = isset($this->new_correct[$i]) ? $this->new_correct[$i] : '';
618
+            $comment = isset($this->new_comment[$i]) ? $this->new_comment[$i] : '';
619
+            $weighting = isset($this->new_weighting[$i]) ? $this->new_weighting[$i] : '';
620
+            $position = isset($this->new_position[$i]) ? $this->new_position[$i] : '';
621
+            $hotspot_coordinates = isset($this->new_hotspot_coordinates[$i]) ? $this->new_hotspot_coordinates[$i] : '';
622
+            $hotspot_type = isset($this->new_hotspot_type[$i]) ? $this->new_hotspot_type[$i] : '';
623
+            $destination = isset($this->new_destination[$i]) ? $this->new_destination[$i] : '';
624 624
             $autoId = $this->selectAutoId($i);
625 625
             $iid = isset($this->iid[$i]) ? $this->iid[$i] : 0;
626 626
 
@@ -663,11 +663,11 @@  discard block
 block discarded – undo
663 663
 
664 664
                         $correctAnswerId = $answer->selectAnswerIdByPosition($correct);
665 665
 
666
-						// Continue to avoid matching question bug if $correctAnswerId returns false
667
-						// See : https://support.chamilo.org/issues/8334
668
-						if ($questionType == MATCHING && !$correctAnswerId) {
669
-							continue;
670
-						}
666
+                        // Continue to avoid matching question bug if $correctAnswerId returns false
667
+                        // See : https://support.chamilo.org/issues/8334
668
+                        if ($questionType == MATCHING && !$correctAnswerId) {
669
+                            continue;
670
+                        }
671 671
 
672 672
                         $correctAnswerAutoId = $answer->selectAutoId($correct);
673 673
 
@@ -734,28 +734,28 @@  discard block
 block discarded – undo
734 734
             }
735 735
         }
736 736
 
737
-		// moves $new_* arrays
738
-		$this->answer = $this->new_answer;
739
-		$this->correct = $this->new_correct;
740
-		$this->comment = $this->new_comment;
741
-		$this->weighting = $this->new_weighting;
742
-		$this->position = $this->new_position;
743
-		$this->hotspot_coordinates = $this->new_hotspot_coordinates;
744
-		$this->hotspot_type = $this->new_hotspot_type;
745
-		$this->nbrAnswers = $this->new_nbrAnswers;
746
-		$this->destination = $this->new_destination;
747
-
748
-		$this->cancel();
749
-	}
750
-
751
-	/**
752
-	 * Duplicates answers by copying them into another question
753
-	 *
754
-	 * @author Olivier Brouckaert
755
-	 * @param  int question id
737
+        // moves $new_* arrays
738
+        $this->answer = $this->new_answer;
739
+        $this->correct = $this->new_correct;
740
+        $this->comment = $this->new_comment;
741
+        $this->weighting = $this->new_weighting;
742
+        $this->position = $this->new_position;
743
+        $this->hotspot_coordinates = $this->new_hotspot_coordinates;
744
+        $this->hotspot_type = $this->new_hotspot_type;
745
+        $this->nbrAnswers = $this->new_nbrAnswers;
746
+        $this->destination = $this->new_destination;
747
+
748
+        $this->cancel();
749
+    }
750
+
751
+    /**
752
+     * Duplicates answers by copying them into another question
753
+     *
754
+     * @author Olivier Brouckaert
755
+     * @param  int question id
756 756
      * @param  array destination course info (result of the function api_get_course_info() )
757 757
      * @param string $newQuestionId
758
-	 */
758
+     */
759 759
     public function duplicate($newQuestionId, $course_info = null)
760 760
     {
761 761
         if (empty($course_info)) {
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 
776 776
             if (!empty($origin_options)) {
777 777
                 foreach ($origin_options as $item) {
778
-            	   $new_option_list[] = $item['id'];
778
+                    $new_option_list[] = $item['id'];
779 779
                 }
780 780
             }
781 781
 
@@ -789,12 +789,12 @@  discard block
 block discarded – undo
789 789
             }
790 790
         }
791 791
 
792
-		// if at least one answer
793
-		if ($this->nbrAnswers) {
794
-			// inserts new answers into data base
795
-			$c_id = $course_info['real_id'];
792
+        // if at least one answer
793
+        if ($this->nbrAnswers) {
794
+            // inserts new answers into data base
795
+            $c_id = $course_info['real_id'];
796 796
 
797
-			for ($i=1;$i <= $this->nbrAnswers;$i++) {
797
+            for ($i=1;$i <= $this->nbrAnswers;$i++) {
798 798
                 if ($this->course['id'] != $course_info['id']) {
799 799
                     $this->answer[$i] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
800 800
                         $this->answer[$i],
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
                     );
809 809
                 }
810 810
 
811
-				$correct = $this->correct[$i];
811
+                $correct = $this->correct[$i];
812 812
 
813 813
                 if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
814 814
                     self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE
@@ -840,9 +840,9 @@  discard block
 block discarded – undo
840 840
 
841 841
                 $em->merge($quizAnswer);
842 842
                 $em->flush();
843
-			}
843
+            }
844 844
         }
845
-	}
845
+    }
846 846
 
847 847
     /**
848 848
      * Get the necessary JavaScript for some answers
@@ -860,25 +860,25 @@  discard block
 block discarded – undo
860 860
             </script>";
861 861
     }
862 862
 
863
-	/**
864
-	 * Check if a answer is correct by an answer auto id
865
-	 * @param $needle int The answer auto id
866
-	 * @return bool
867
-	 */
868
-	public function isCorrectByAutoId($needle)
869
-	{
870
-		$key = 0;
871
-
872
-		foreach ($this->autoId as $autoIdKey => $autoId) {
873
-			if ($autoId == $needle) {
874
-				$key = $autoIdKey;
875
-			}
876
-		}
877
-
878
-		if (!$key) {
879
-			return false;
880
-		}
881
-
882
-		return $this->isCorrect($key) ? true : false;
883
-	}
863
+    /**
864
+     * Check if a answer is correct by an answer auto id
865
+     * @param $needle int The answer auto id
866
+     * @return bool
867
+     */
868
+    public function isCorrectByAutoId($needle)
869
+    {
870
+        $key = 0;
871
+
872
+        foreach ($this->autoId as $autoIdKey => $autoId) {
873
+            if ($autoId == $needle) {
874
+                $key = $autoIdKey;
875
+            }
876
+        }
877
+
878
+        if (!$key) {
879
+            return false;
880
+        }
881
+
882
+        return $this->isCorrect($key) ? true : false;
883
+    }
884 884
 }
Please login to merge, or discard this patch.