Completed
Push — 1.10.x ( f4c996...07002c )
by Angel Fernando Quiroz
259:08 queued 216:10
created
main/inc/ajax/exercise.ajax.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
         $exercise_id = intval($_GET['exercise_id']);
31 31
         $page = intval($_REQUEST['page']); //page
32 32
         $limit = intval($_REQUEST['rows']); //quantity of rows
33
-        $sidx = $_REQUEST['sidx'];         //index to filter
34
-        $sord = $_REQUEST['sord'];         //asc or desc
33
+        $sidx = $_REQUEST['sidx']; //index to filter
34
+        $sord = $_REQUEST['sord']; //asc or desc
35 35
 
36
-        if (!in_array($sord, array('asc','desc'))) {
36
+        if (!in_array($sord, array('asc', 'desc'))) {
37 37
             $sord = 'desc';
38 38
         }
39 39
         // get index row - i.e. user click to sort $sord = $_GET['sord'];
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         $total_pages = 0;
63 63
         if ($count > 0) {
64 64
             if (!empty($limit)) {
65
-                $total_pages = ceil($count/$limit);
65
+                $total_pages = ceil($count / $limit);
66 66
             }
67 67
         }
68 68
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         $response->page = $page;
125 125
         $response->total = $total_pages;
126 126
         $response->records = $count;
127
-        $i=0;
127
+        $i = 0;
128 128
 
129 129
         if (!empty($results)) {
130 130
             foreach ($results as $row) {
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
                             GROUP by question_id
139 139
                         ) as count_table";
140 140
                 $result_count = Database::query($sql);
141
-                $count_questions = Database::fetch_array($result_count,'ASSOC');
141
+                $count_questions = Database::fetch_array($result_count, 'ASSOC');
142 142
                 $count_questions = $count_questions['count_question_id'];
143 143
 
144 144
                 $row['count_questions'] = $count_questions;
145 145
 
146 146
                 $response->rows[$i]['id'] = $row['exe_id'];
147
-                $remaining = strtotime($row['start_date'])+($oExe->expired_time*60) - strtotime(api_get_utc_datetime(time()));
148
-                $h = floor($remaining/3600);
149
-                $m = floor(($remaining - ($h*3600))/60);
150
-                $s = ($remaining - ($h*3600) - ($m*60));
147
+                $remaining = strtotime($row['start_date']) + ($oExe->expired_time * 60) - strtotime(api_get_utc_datetime(time()));
148
+                $h = floor($remaining / 3600);
149
+                $m = floor(($remaining - ($h * 3600)) / 60);
150
+                $s = ($remaining - ($h * 3600) - ($m * 60));
151 151
                 $array = array(
152 152
                     $row['firstname'],
153 153
                     $row['lastname'],
154
-                    api_format_date($row['start_date'], DATE_TIME_FORMAT_LONG).' ['.($h>0?$h.':':'').sprintf("%02d",$m).':'.sprintf("%02d",$s).']',
154
+                    api_format_date($row['start_date'], DATE_TIME_FORMAT_LONG).' ['.($h > 0 ? $h.':' : '').sprintf("%02d", $m).':'.sprintf("%02d", $s).']',
155 155
                     $row['count_questions'],
156
-                    round($row['score']*100).'%'
156
+                    round($row['score'] * 100).'%'
157 157
                 );
158 158
                 $response->rows[$i]['cell'] = $array;
159 159
                 $i++;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         break;
210 210
     case 'add_question_to_reminder':
211 211
         /** @var Exercise $objExercise */
212
-        $objExercise  = $_SESSION['objExercise'];
212
+        $objExercise = $_SESSION['objExercise'];
213 213
         if (empty($objExercise)) {
214 214
             echo 0;
215 215
             exit;
@@ -362,8 +362,8 @@  discard block
 block discarded – undo
362 362
                 $objQuestionTmp = Question::read($my_question_id, $course_id);
363 363
 
364 364
                 // Getting free choice data.
365
-                if ($objQuestionTmp->type  == FREE_ANSWER && $type == 'all') {
366
-                    $my_choice = isset($_REQUEST['free_choice'][$my_question_id]) && !empty($_REQUEST['free_choice'][$my_question_id]) ? $_REQUEST['free_choice'][$my_question_id]: null;
365
+                if ($objQuestionTmp->type == FREE_ANSWER && $type == 'all') {
366
+                    $my_choice = isset($_REQUEST['free_choice'][$my_question_id]) && !empty($_REQUEST['free_choice'][$my_question_id]) ? $_REQUEST['free_choice'][$my_question_id] : null;
367 367
                 }
368 368
 
369 369
                 if ($type == 'all') {
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
                         $session_id,
408 408
                         $my_question_id
409 409
                     );
410
-                    if ($objQuestionTmp->type  == HOT_SPOT) {
410
+                    if ($objQuestionTmp->type == HOT_SPOT) {
411 411
                         Event::delete_attempt_hotspot(
412 412
                             $exe_id,
413 413
                             api_get_user_id(),
Please login to merge, or discard this patch.
main/inc/lib/exercise.lib.php 1 patch
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
                 if ($show_title) {
68 68
                     TestCategory::displayCategoryAndTitle($objQuestionTmp->id);
69 69
                     echo Display::div(
70
-                        $current_item . '. ' . $objQuestionTmp->selectTitle(),
70
+                        $current_item.'. '.$objQuestionTmp->selectTitle(),
71 71
                         array('class' => 'question_title')
72 72
                     );
73 73
                 }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                         <div class="clearfix">
113 113
                         <ul class="exercise-draggable-answer ui-helper-reset ui-helper-clearfix">';
114 114
                 } else {
115
-                    $s .= '<div id="drag' . $questionId . '_question" class="drag_question">
115
+                    $s .= '<div id="drag'.$questionId.'_question" class="drag_question">
116 116
                            <table class="data_table">';
117 117
                 }
118 118
 
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
             } elseif ($answerType == FREE_ANSWER) {
160 160
                 $fck_content = isset($user_choice[0]) && !empty($user_choice[0]['answer']) ? $user_choice[0]['answer'] : null;
161 161
 
162
-                $form = new FormValidator('free_choice_' . $questionId);
162
+                $form = new FormValidator('free_choice_'.$questionId);
163 163
                 $config = array(
164 164
                     'ToolbarSet' => 'TestFreeAnswer'
165 165
                 );
166
-                $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config);
167
-                $form->setDefaults(array("choice[" . $questionId . "]" => $fck_content));
166
+                $form->addHtmlEditor("choice[".$questionId."]", null, false, false, $config);
167
+                $form->setDefaults(array("choice[".$questionId."]" => $fck_content));
168 168
                 $s .= $form->returnForm();
169 169
             } elseif ($answerType == ORAL_EXPRESSION) {
170 170
                 // Add nanog
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
                     echo $nano->show_button();
190 190
                 }
191 191
 
192
-                $form = new FormValidator('free_choice_' . $questionId);
192
+                $form = new FormValidator('free_choice_'.$questionId);
193 193
                 $config = array(
194 194
                     'ToolbarSet' => 'TestFreeAnswer'
195 195
                 );
196
-                $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config);
196
+                $form->addHtmlEditor("choice[".$questionId."]", null, false, false, $config);
197 197
                 //$form->setDefaults(array("choice[" . $questionId . "]" => $fck_content));
198 198
                 $s .= $form->returnForm();
199 199
             }
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
                     case UNIQUE_ANSWER_NO_OPTION:
279 279
                         //no break
280 280
                     case UNIQUE_ANSWER_IMAGE:
281
-                        $input_id = 'choice-' . $questionId . '-' . $answerId;
281
+                        $input_id = 'choice-'.$questionId.'-'.$answerId;
282 282
 
283 283
                         if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) {
284 284
                             $attributes = array(
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
                         if ($answerType == UNIQUE_ANSWER_IMAGE) {
305 305
                             if ($show_comment) {
306 306
                                 if (empty($comment)) {
307
-                                    $s .= '<div id="answer' . $questionId . $numAnswer . '" '
307
+                                    $s .= '<div id="answer'.$questionId.$numAnswer.'" '
308 308
                                         . 'class="exercise-unique-answer-image" style="text-align: center">';
309 309
                                 } else {
310
-                                    $s .= '<div id="answer' . $questionId . $numAnswer . '" '
310
+                                    $s .= '<div id="answer'.$questionId.$numAnswer.'" '
311 311
                                         . 'class="exercise-unique-answer-image col-xs-6 col-sm-12" style="text-align: center">';
312 312
                                 }
313 313
                             } else {
314
-                                $s .= '<div id="answer' . $questionId . $numAnswer . '" '
314
+                                $s .= '<div id="answer'.$questionId.$numAnswer.'" '
315 315
                                     . 'class="exercise-unique-answer-image col-xs-6 col-md-3" style="text-align: center">';
316 316
                             }
317 317
                         }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                         $answer = Security::remove_XSS($answer, STUDENT);
320 320
                         $s .= Display::input(
321 321
                             'hidden',
322
-                            'choice2[' . $questionId . ']',
322
+                            'choice2['.$questionId.']',
323 323
                             '0'
324 324
                         );
325 325
 
@@ -327,13 +327,13 @@  discard block
 block discarded – undo
327 327
 
328 328
                         if ($answerType == UNIQUE_ANSWER_IMAGE) {
329 329
                             $attributes['style'] = 'display: none;';
330
-                            $answer = '<div class="thumbnail">' . $answer . '</div>';
330
+                            $answer = '<div class="thumbnail">'.$answer.'</div>';
331 331
                         }
332 332
 
333 333
                         $answer_input .= '<label class="radio">';
334 334
                         $answer_input .= Display::input(
335 335
                             'radio',
336
-                            'choice[' . $questionId . ']',
336
+                            'choice['.$questionId.']',
337 337
                             $numAnswer,
338 338
                             $attributes
339 339
                         );
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
                     case MULTIPLE_ANSWER_TRUE_FALSE:
361 361
                         //no break
362 362
                     case GLOBAL_MULTIPLE_ANSWER:
363
-                        $input_id = 'choice-' . $questionId . '-' . $answerId;
363
+                        $input_id = 'choice-'.$questionId.'-'.$answerId;
364 364
                         $answer = Security::remove_XSS($answer, STUDENT);
365 365
 
366 366
                         if (in_array($numAnswer, $user_choice_array)) {
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
                         }
382 382
 
383 383
                         if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
384
-                            $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />';
384
+                            $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
385 385
 
386 386
                             $answer_input = '<label class="checkbox">';
387 387
                             $answer_input .= Display::input(
388 388
                                 'checkbox',
389
-                                'choice[' . $questionId . '][' . $numAnswer . ']',
389
+                                'choice['.$questionId.']['.$numAnswer.']',
390 390
                                 $numAnswer,
391 391
                                 $attributes
392 392
                             );
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
                                         'td',
440 440
                                         Display::input(
441 441
                                             'radio',
442
-                                            'choice[' . $questionId . '][' . $numAnswer . ']',
442
+                                            'choice['.$questionId.']['.$numAnswer.']',
443 443
                                             $id,
444 444
                                             $attributes
445 445
                                         ),
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
                         break;
459 459
                     case MULTIPLE_ANSWER_COMBINATION:
460 460
                         // multiple answers
461
-                        $input_id = 'choice-' . $questionId . '-' . $answerId;
461
+                        $input_id = 'choice-'.$questionId.'-'.$answerId;
462 462
 
463 463
                         if (in_array($numAnswer, $user_choice_array)) {
464 464
                             $attributes = array(
@@ -478,11 +478,11 @@  discard block
 block discarded – undo
478 478
                         }
479 479
 
480 480
                         $answer = Security::remove_XSS($answer, STUDENT);
481
-                        $answer_input = '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />';
481
+                        $answer_input = '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
482 482
                         $answer_input .= '<label class="checkbox">';
483 483
                         $answer_input .= Display::input(
484 484
                             'checkbox',
485
-                            'choice[' . $questionId . '][' . $numAnswer . ']',
485
+                            'choice['.$questionId.']['.$numAnswer.']',
486 486
                             1,
487 487
                             $attributes
488 488
                         );
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
                         }
504 504
                         break;
505 505
                     case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
506
-                        $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />';
506
+                        $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
507 507
 
508 508
                         $my_choice = array();
509 509
                         if (!empty($user_choice_array)) {
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
                                 'td',
539 539
                                 Display::input(
540 540
                                     'radio',
541
-                                    'choice[' . $questionId . '][' . $numAnswer . ']',
541
+                                    'choice['.$questionId.']['.$numAnswer.']',
542 542
                                     $key,
543 543
                                     $attributes
544 544
                                 )
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
                                     // may be "" if student viewed the question, but did not fill the blanks
596 596
                                     $correctItem = $studentAnswerList[$i];
597 597
                                 }
598
-                                $attributes["style"] = "width:" . $listAnswerInformations["tabinputsize"][$i] . "px";
598
+                                $attributes["style"] = "width:".$listAnswerInformations["tabinputsize"][$i]."px";
599 599
                                 $answer .= FillBlanks::getFillTheBlankHtml($separatorStartRegexp, $separatorEndRegexp, $correctItemRegexp, $questionId, $correctItem, $attributes, $answer, $listAnswerInformations, $displayForStudent, $i);
600 600
                             }
601 601
                             // display the last common word
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
                                 // display the common words
610 610
                                 $answer .= $listAnswerInformations["commonwords"][$i];
611 611
                                 // display the blank word
612
-                                $attributes["style"] = "width:" . $listAnswerInformations["tabinputsize"][$i] . "px";
612
+                                $attributes["style"] = "width:".$listAnswerInformations["tabinputsize"][$i]."px";
613 613
                                 $correctItem = $listAnswerInformations["tabwords"][$i];
614 614
                                 $correctItemRegexp = $correctItem;
615 615
                                 // replace / with \/ to allow the preg_replace bellow and all the regexp char
@@ -635,8 +635,8 @@  discard block
 block discarded – undo
635 635
                             $trackAttempts = Database::get_main_table(
636 636
                                 TABLE_STATISTIC_TRACK_E_ATTEMPT
637 637
                             );
638
-                            $sql = 'SELECT answer FROM ' . $trackAttempts . '
639
-                                WHERE exe_id=' . $exe_id . ' AND question_id=' . $questionId;
638
+                            $sql = 'SELECT answer FROM '.$trackAttempts.'
639
+                                WHERE exe_id=' . $exe_id.' AND question_id='.$questionId;
640 640
                             $rsLastAttempt = Database::query($sql);
641 641
                             $rowLastAttempt = Database::fetch_array($rsLastAttempt);
642 642
                             $answer = $rowLastAttempt['answer'];
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
                                     '',
694 694
                                     $answerCorrected
695 695
                                 );
696
-                                $answerCorrected = '[' . $answerCorrected . ']';
696
+                                $answerCorrected = '['.$answerCorrected.']';
697 697
                                 $studentAnswerList[] = $answerCorrected;
698 698
                             }
699 699
                         }
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
                         */
715 715
                         $tabComments = api_preg_split(
716 716
                             '/\[[^]]+\]/',
717
-                            ' ' . $answer . ' '
717
+                            ' '.$answer.' '
718 718
                         );
719 719
                         if (!empty($correctAnswerList) && !empty($studentAnswerList)) {
720 720
                             $answer = "";
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
                                     $size
732 732
                                 );
733 733
 
734
-                                $answer .= $tabComments[$i] .
734
+                                $answer .= $tabComments[$i].
735 735
                                     Display::input(
736 736
                                         'text',
737 737
                                         "choice[$questionId][]",
@@ -778,12 +778,12 @@  discard block
 block discarded – undo
778 778
                             $s .= '<tr><td width="45%" valign="top">';
779 779
                             $parsed_answer = $answer;
780 780
                             //left part questions
781
-                            $s .= '<p class="indent">' . $lines_count . '.&nbsp;' . $parsed_answer . '</p></td>';
781
+                            $s .= '<p class="indent">'.$lines_count.'.&nbsp;'.$parsed_answer.'</p></td>';
782 782
                             //middle part (matches selects)
783 783
 
784 784
                             $s .= '<td width="10%" valign="top" align="center" >
785 785
                                 <div class="select-matching">
786
-                                <select name="choice[' . $questionId . '][' . $numAnswer . ']">';
786
+                                <select name="choice[' . $questionId.']['.$numAnswer.']">';
787 787
 
788 788
                             // fills the list-box
789 789
                             foreach ($select_items as $key => $val) {
@@ -799,14 +799,14 @@  discard block
 block discarded – undo
799 799
                                 if (isset($user_choice_array_position[$numAnswer]) && $val['id'] == $user_choice_array_position[$numAnswer]) {
800 800
                                     $selected = 'selected="selected"';
801 801
                                 }
802
-                                $s .= '<option value="' . $val['id'] . '" ' . $selected . '>' . $val['letter'] . '</option>';
802
+                                $s .= '<option value="'.$val['id'].'" '.$selected.'>'.$val['letter'].'</option>';
803 803
 
804 804
                             }  // end foreach()
805 805
 
806 806
                             $s .= '</select></div></td><td width="5%" class="separate">&nbsp;</td>';
807 807
                             $s .= '<td width="40%" valign="top" >';
808 808
                             if (isset($select_items[$lines_count])) {
809
-                                $s .= '<div class="text-right"><p class="indent">' . $select_items[$lines_count]['letter'] . '.&nbsp; ' . $select_items[$lines_count]['answer'] . '</p></div>';
809
+                                $s .= '<div class="text-right"><p class="indent">'.$select_items[$lines_count]['letter'].'.&nbsp; '.$select_items[$lines_count]['answer'].'</p></div>';
810 810
                             } else {
811 811
                                 $s .= '&nbsp;';
812 812
                             }
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
                                     $s .= '<tr>
822 822
                                       <td colspan="2"></td>
823 823
                                       <td valign="top">';
824
-                                    $s .= '<b>' . $select_items[$lines_count]['letter'] . '.</b> ' . $select_items[$lines_count]['answer'];
824
+                                    $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'];
825 825
                                     $s .= "</td>
826 826
                                 </tr>";
827 827
                                     $lines_count++;
@@ -838,9 +838,9 @@  discard block
 block discarded – undo
838 838
                             $data = $objAnswerTmp->getAnswerByAutoId($data['correct']);
839 839
                             $lines_count = $data['answer'];*/
840 840
 
841
-                            $windowId = $questionId . '_' . $lines_count;
841
+                            $windowId = $questionId.'_'.$lines_count;
842 842
 
843
-                            $s .= '<li class="touch-items" id="' . $windowId . '">';
843
+                            $s .= '<li class="touch-items" id="'.$windowId.'">';
844 844
                             $s .= Display::div(
845 845
                                 $parsed_answer,
846 846
                                 [
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
                                     Display::tag(
899 899
                                         'b',
900 900
                                         $select_items[$lines_count]['letter']
901
-                                    ) . $select_items[$lines_count]['answer'],
901
+                                    ).$select_items[$lines_count]['answer'],
902 902
                                     [
903 903
                                         'id' => "window_{$windowId}_answer",
904 904
                                         'style' => 'display: none;'
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 
1070 1070
                 for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
1071 1071
                     $answerCorrect = $objAnswerTmp->isCorrect($answerId);
1072
-                    $windowId = $questionId . '_' . $counterAnswer;
1072
+                    $windowId = $questionId.'_'.$counterAnswer;
1073 1073
 
1074 1074
                     if ($answerCorrect) {
1075 1075
                         $s .= Display::div(
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
                 $course = api_get_course_info();
1115 1115
                 $doc_id = DocumentManager::get_document_id(
1116 1116
                     $course,
1117
-                    '/images/' . $pictureName
1117
+                    '/images/'.$pictureName
1118 1118
                 );
1119 1119
                 if (is_numeric($doc_id)) {
1120 1120
                     $images_folder_visibility = api_get_item_visibility(
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
                 echo "
1140 1140
                     <script>
1141 1141
                         $(document).on('ready', function () {
1142
-                            new " . ($answerType == HOT_SPOT ? "HotspotQuestion" : "DelineationQuestion") . "({
1142
+                            new " . ($answerType == HOT_SPOT ? "HotspotQuestion" : "DelineationQuestion")."({
1143 1143
                                 questionId: $questionId,
1144 1144
                                 exerciseId: $exerciseId,
1145 1145
                                 selector: '#hotspot-preview-$questionId',
@@ -1173,7 +1173,7 @@  discard block
 block discarded – undo
1173 1173
             if ($answerType != HOT_SPOT_DELINEATION) {
1174 1174
                 $answerList = '
1175 1175
                     <div class="well well-sm">
1176
-                        <h5 class="page-header">' . get_lang('HotspotZones') . '</h5>
1176
+                        <h5 class="page-header">' . get_lang('HotspotZones').'</h5>
1177 1177
                         <ol>
1178 1178
                 ';
1179 1179
 
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
             if (!$only_questions) {
1199 1199
                 if ($show_title) {
1200 1200
                     TestCategory::displayCategoryAndTitle($objQuestionTmp->id);
1201
-                    echo '<div class="question_title">' . $current_item . '. ' . $questionName . '</div>';
1201
+                    echo '<div class="question_title">'.$current_item.'. '.$questionName.'</div>';
1202 1202
                 }
1203 1203
                 //@todo I need to the get the feedback type
1204 1204
                 echo <<<HOTSPOT
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
                                 <div class=\"hotspot-image\"></div>
1216 1216
                                 <script>
1217 1217
                                     $(document).on('ready', function () {
1218
-                                        new " . ($answerType == HOT_SPOT_DELINEATION ? 'DelineationQuestion' : 'HotspotQuestion') . "({
1218
+                                        new " . ($answerType == HOT_SPOT_DELINEATION ? 'DelineationQuestion' : 'HotspotQuestion')."({
1219 1219
                                             questionId: $questionId,
1220 1220
                                             exerciseId: $exe_id,
1221 1221
                                             selector: '#question_div_' + $questionId + ' .hotspot-image',
@@ -1336,11 +1336,11 @@  discard block
 block discarded – undo
1336 1336
         $lp_id = intval($lp_id);
1337 1337
         $lp_item_id = intval($lp_item_id);
1338 1338
         return
1339
-            api_get_course_int_id() . '_' .
1340
-            api_get_session_id() . '_' .
1341
-            $exercise_id . '_' .
1342
-            api_get_user_id() . '_' .
1343
-            $lp_id . '_' .
1339
+            api_get_course_int_id().'_'.
1340
+            api_get_session_id().'_'.
1341
+            $exercise_id.'_'.
1342
+            api_get_user_id().'_'.
1343
+            $lp_id.'_'.
1344 1344
             $lp_item_id;
1345 1345
     }
1346 1346
 
@@ -1454,14 +1454,14 @@  discard block
 block discarded – undo
1454 1454
         $res = Database::query($sql);
1455 1455
         $result = array();
1456 1456
         $apiIsAllowedToEdit = api_is_allowed_to_edit();
1457
-        $urlBase = api_get_path(WEB_CODE_PATH) .
1458
-            'exercice/hotpotatoes_exercise_report.php?action=delete&' .
1459
-            api_get_cidreq() . '&id=';
1457
+        $urlBase = api_get_path(WEB_CODE_PATH).
1458
+            'exercice/hotpotatoes_exercise_report.php?action=delete&'.
1459
+            api_get_cidreq().'&id=';
1460 1460
         while ($data = Database::fetch_array($res)) {
1461 1461
             $actions = null;
1462 1462
 
1463 1463
             if ($apiIsAllowedToEdit) {
1464
-                $url = $urlBase . $data['id'] . '&path=' . $data['exe_name'];
1464
+                $url = $urlBase.$data['id'].'&path='.$data['exe_name'];
1465 1465
                 $actions = Display::url(
1466 1466
                     Display::return_icon('delete.png', get_lang('Delete')),
1467 1467
                     $url
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
                     GroupManager::get_user_group_name($data['user_id'])
1478 1478
                 ),
1479 1479
                 'exe_date' => $data['exe_date'],
1480
-                'score' => $data['exe_result'] . ' / ' . $data['exe_weighting'],
1480
+                'score' => $data['exe_result'].' / '.$data['exe_weighting'],
1481 1481
                 'actions' => $actions,
1482 1482
             );
1483 1483
         }
@@ -1562,18 +1562,18 @@  discard block
 block discarded – undo
1562 1562
         $TBL_TRACK_HOTPOTATOES = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
1563 1563
         $TBL_TRACK_ATTEMPT_RECORDING = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
1564 1564
 
1565
-        $session_id_and = ' AND te.session_id = ' . $sessionId . ' ';
1565
+        $session_id_and = ' AND te.session_id = '.$sessionId.' ';
1566 1566
         $exercise_id = intval($exercise_id);
1567 1567
 
1568 1568
         $exercise_where = '';
1569 1569
         if (!empty($exercise_id)) {
1570
-            $exercise_where .= ' AND te.exe_exo_id = ' . $exercise_id . '  ';
1570
+            $exercise_where .= ' AND te.exe_exo_id = '.$exercise_id.'  ';
1571 1571
         }
1572 1572
 
1573 1573
         $hotpotatoe_where = '';
1574 1574
         if (!empty($_GET['path'])) {
1575 1575
             $hotpotatoe_path = Database::escape_string($_GET['path']);
1576
-            $hotpotatoe_where .= ' AND exe_name = "' . $hotpotatoe_path . '"  ';
1576
+            $hotpotatoe_where .= ' AND exe_name = "'.$hotpotatoe_path.'"  ';
1577 1577
         }
1578 1578
 
1579 1579
         // sql for chamilo-type tests for teacher / tutor view
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
             WHERE
1586 1586
                 c_id = $course_id AND
1587 1587
                 exe_exo_id = $exercise_id AND
1588
-                ttte.session_id = " . $sessionId . "
1588
+                ttte.session_id = ".$sessionId."
1589 1589
         )";
1590 1590
 
1591 1591
         if ($is_allowedToEdit) {
@@ -1608,9 +1608,9 @@  discard block
 block discarded – undo
1608 1608
                         g.id as group_id
1609 1609
                     FROM $TBL_USER u
1610 1610
                     INNER JOIN $TBL_GROUP_REL_USER gru
1611
-                    ON (gru.user_id = u.user_id AND gru.c_id=" . $course_id . ")
1611
+                    ON (gru.user_id = u.user_id AND gru.c_id=".$course_id.")
1612 1612
                     INNER JOIN $TBL_GROUP g
1613
-                    ON (gru.group_id = g.id AND g.c_id=" . $course_id . ")
1613
+                    ON (gru.group_id = g.id AND g.c_id=".$course_id.")
1614 1614
                 )";
1615 1615
             }
1616 1616
 
@@ -1672,9 +1672,9 @@  discard block
 block discarded – undo
1672 1672
                     g.id as group_id
1673 1673
                 FROM $TBL_USER u
1674 1674
                 LEFT OUTER JOIN $TBL_GROUP_REL_USER gru
1675
-                ON ( gru.user_id = u.user_id AND gru.c_id=" . $course_id . " )
1675
+                ON ( gru.user_id = u.user_id AND gru.c_id=".$course_id." )
1676 1676
                 LEFT OUTER JOIN $TBL_GROUP g
1677
-                ON (gru.group_id = g.id AND g.c_id = " . $course_id . ")
1677
+                ON (gru.group_id = g.id AND g.c_id = ".$course_id.")
1678 1678
             )";
1679 1679
             }
1680 1680
 
@@ -1687,12 +1687,12 @@  discard block
 block discarded – undo
1687 1687
             (
1688 1688
                 SELECT u.user_id, firstname, lastname, email, username, ' ' as group_name, '' as group_id, official_code
1689 1689
                 FROM $TBL_USER u
1690
-                WHERE u.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ")
1690
+                WHERE u.status NOT IN(".api_get_users_status_ignored_in_reports('string').")
1691 1691
             )";
1692 1692
             }
1693 1693
 
1694 1694
             $sqlFromOption = " , $TBL_GROUP_REL_USER AS gru ";
1695
-            $sqlWhereOption = "  AND gru.c_id = " . $course_id . " AND gru.user_id = user.user_id ";
1695
+            $sqlWhereOption = "  AND gru.c_id = ".$course_id." AND gru.user_id = user.user_id ";
1696 1696
             $first_and_last_name = api_is_western_name_order() ? "firstname, lastname" : "lastname, firstname";
1697 1697
 
1698 1698
             if ($get_count) {
@@ -1729,8 +1729,8 @@  discard block
 block discarded – undo
1729 1729
                 ON (user.user_id = exe_user_id)
1730 1730
                 WHERE
1731 1731
                     te.status != 'incomplete' AND
1732
-                    te.c_id = " . $course_id . " $session_id_and AND
1733
-                    ce.active <>-1 AND ce.c_id = " . $course_id . "
1732
+                    te.c_id = ".$course_id." $session_id_and AND
1733
+                    ce.active <>-1 AND ce.c_id = ".$course_id."
1734 1734
                     $exercise_where
1735 1735
                     $extra_where_conditions
1736 1736
                 ";
@@ -1757,12 +1757,12 @@  discard block
 block discarded – undo
1757 1757
                     $sqlFromOption
1758 1758
                 WHERE
1759 1759
                     user.user_id=tth.exe_user_id
1760
-                    AND tth.c_id = " . $course_id . "
1760
+                    AND tth.c_id = ".$course_id."
1761 1761
                     $hotpotatoe_where
1762 1762
                     $sqlWhereOption
1763
-                    AND user.status NOT IN(" . api_get_users_status_ignored_in_reports(
1763
+                    AND user.status NOT IN(".api_get_users_status_ignored_in_reports(
1764 1764
                     'string'
1765
-                ) . ")
1765
+                ).")
1766 1766
                 ORDER BY
1767 1767
                     tth.c_id ASC,
1768 1768
                     tth.exe_date DESC";
@@ -1835,12 +1835,12 @@  discard block
 block discarded – undo
1835 1835
 
1836 1836
                     if ($from_gradebook && ($is_allowedToEdit)) {
1837 1837
                         if (in_array(
1838
-                            $results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'],
1838
+                            $results[$i]['username'].$results[$i]['firstname'].$results[$i]['lastname'],
1839 1839
                             $users_array_id
1840 1840
                         )) {
1841 1841
                             continue;
1842 1842
                         }
1843
-                        $users_array_id[] = $results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'];
1843
+                        $users_array_id[] = $results[$i]['username'].$results[$i]['firstname'].$results[$i]['lastname'];
1844 1844
                     }
1845 1845
 
1846 1846
                     $lp_obj = isset($results[$i]['orig_lp_id']) && isset($lp_list[$results[$i]['orig_lp_id']]) ? $lp_list[$results[$i]['orig_lp_id']] : null;
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
                     if ($lp_obj) {
1850 1850
                         $url = api_get_path(
1851 1851
                                 WEB_CODE_PATH
1852
-                            ) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $results[$i]['orig_lp_id'];
1852
+                            ).'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$results[$i]['orig_lp_id'];
1853 1853
                         $lp_name = Display::url(
1854 1854
                             $lp_obj['lp_name'],
1855 1855
                             $url,
@@ -1867,7 +1867,7 @@  discard block
 block discarded – undo
1867 1867
                         );
1868 1868
 
1869 1869
                         foreach ($group_list as $id) {
1870
-                            $group_name_list .= $clean_group_list[$id] . '<br/>';
1870
+                            $group_name_list .= $clean_group_list[$id].'<br/>';
1871 1871
                         }
1872 1872
                         $results[$i]['group_name'] = $group_name_list;
1873 1873
                     }
@@ -1923,7 +1923,7 @@  discard block
 block discarded – undo
1923 1923
                                 }
1924 1924
                             }
1925 1925
                             if ($revised) {
1926
-                                $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=edit&id=$id'>" .
1926
+                                $actions .= "<a href='exercise_show.php?".api_get_cidreq()."&action=edit&id=$id'>".
1927 1927
                                     Display:: return_icon(
1928 1928
                                         'edit.png',
1929 1929
                                         get_lang('Edit'),
@@ -1932,7 +1932,7 @@  discard block
 block discarded – undo
1932 1932
                                     );
1933 1933
                                 $actions .= '&nbsp;';
1934 1934
                             } else {
1935
-                                $actions .= "<a href='exercise_show.php?" . api_get_cidreq() . "&action=qualify&id=$id'>" .
1935
+                                $actions .= "<a href='exercise_show.php?".api_get_cidreq()."&action=qualify&id=$id'>".
1936 1936
                                     Display:: return_icon(
1937 1937
                                         'quiz.gif',
1938 1938
                                         get_lang('Qualify')
@@ -1942,11 +1942,11 @@  discard block
 block discarded – undo
1942 1942
                             $actions .= "</a>";
1943 1943
 
1944 1944
                             if ($filter == 2) {
1945
-                                $actions .= ' <a href="exercise_history.php?' . api_get_cidreq() . '&exe_id=' . $id . '">' .
1945
+                                $actions .= ' <a href="exercise_history.php?'.api_get_cidreq().'&exe_id='.$id.'">'.
1946 1946
                                     Display:: return_icon(
1947 1947
                                         'history.gif',
1948 1948
                                         get_lang('ViewHistoryChange')
1949
-                                    ) . '</a>';
1949
+                                    ).'</a>';
1950 1950
                             }
1951 1951
 
1952 1952
                             //Admin can always delete the attempt
@@ -1957,31 +1957,31 @@  discard block
 block discarded – undo
1957 1957
                                     date('Y-m-d h:i:s'),
1958 1958
                                     false
1959 1959
                                 );
1960
-                                $actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip=' . $ip . '" target="_blank">
1961
-                                ' . Display::return_icon('info.png', $ip) . '
1960
+                                $actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip='.$ip.'" target="_blank">
1961
+                                ' . Display::return_icon('info.png', $ip).'
1962 1962
                                 </a>';
1963 1963
 
1964
-                                $delete_link = '<a href="exercise_report.php?' . api_get_cidreq() . '&filter_by_user=' . intval($_GET['filter_by_user']) . '&filter=' . $filter . '&exerciseId=' . $exercise_id . '&delete=delete&did=' . $id . '"
1964
+                                $delete_link = '<a href="exercise_report.php?'.api_get_cidreq().'&filter_by_user='.intval($_GET['filter_by_user']).'&filter='.$filter.'&exerciseId='.$exercise_id.'&delete=delete&did='.$id.'"
1965 1965
                                 onclick="javascript:if(!confirm(\'' . sprintf(
1966 1966
                                         get_lang('DeleteAttempt'),
1967 1967
                                         $results[$i]['username'],
1968 1968
                                         $dt
1969
-                                    ) . '\')) return false;">' . Display:: return_icon(
1969
+                                    ).'\')) return false;">'.Display:: return_icon(
1970 1970
                                         'delete.png',
1971 1971
                                         get_lang('Delete')
1972
-                                    ) . '</a>';
1972
+                                    ).'</a>';
1973 1973
                                 $delete_link = utf8_encode($delete_link);
1974 1974
 
1975 1975
                                 if (api_is_drh() && !api_is_platform_admin()) {
1976 1976
                                     $delete_link = null;
1977 1977
                                 }
1978
-                                $actions .= $delete_link . '&nbsp;';
1978
+                                $actions .= $delete_link.'&nbsp;';
1979 1979
                             }
1980 1980
 
1981 1981
                         } else {
1982 1982
                             $attempt_url = api_get_path(
1983 1983
                                     WEB_CODE_PATH
1984
-                                ) . 'exercice/result.php?' . api_get_cidreq() . '&id=' . $results[$i]['exe_id'] . '&id_session=' . $sessionId;
1984
+                                ).'exercice/result.php?'.api_get_cidreq().'&id='.$results[$i]['exe_id'].'&id_session='.$sessionId;
1985 1985
                             $attempt_link = Display::url(
1986 1986
                                 get_lang('Show'),
1987 1987
                                 $attempt_url,
@@ -2038,7 +2038,7 @@  discard block
 block discarded – undo
2038 2038
                     $hp_result = round(
2039 2039
                             ($hpresults[$i][4] / ($hpresults[$i][5] != 0 ? $hpresults[$i][5] : 1)) * 100,
2040 2040
                             2
2041
-                        ) . '% (' . $hpresults[$i][4] . ' / ' . $hpresults[$i][5] . ')';
2041
+                        ).'% ('.$hpresults[$i][4].' / '.$hpresults[$i][5].')';
2042 2042
                     if ($is_allowedToEdit) {
2043 2043
                         $list_info[] = array(
2044 2044
                             $hpresults[$i][0],
@@ -2112,13 +2112,13 @@  discard block
 block discarded – undo
2112 2112
 
2113 2113
         $html = null;
2114 2114
         if ($show_percentage) {
2115
-            $parent = '(' . $score . ' / ' . $weight . ')';
2116
-            $html = $percentage . "%  $parent";
2115
+            $parent = '('.$score.' / '.$weight.')';
2116
+            $html = $percentage."%  $parent";
2117 2117
             if ($show_only_percentage) {
2118
-                $html = $percentage . "% ";
2118
+                $html = $percentage."% ";
2119 2119
             }
2120 2120
         } else {
2121
-            $html = $score . ' / ' . $weight;
2121
+            $html = $score.' / '.$weight;
2122 2122
         }
2123 2123
         $html = Display::span($html, array('class' => 'score_exercise'));
2124 2124
 
@@ -2212,7 +2212,7 @@  discard block
 block discarded – undo
2212 2212
     {
2213 2213
         $return = '-';
2214 2214
         if ($value != '') {
2215
-            $return = float_format($value * 100, 1) . ' %';
2215
+            $return = float_format($value * 100, 1).' %';
2216 2216
         }
2217 2217
         return $return;
2218 2218
     }
@@ -2291,7 +2291,7 @@  discard block
 block discarded – undo
2291 2291
         }
2292 2292
 
2293 2293
         $needle_where = !empty($search) ? " AND title LIKE '?' " : '';
2294
-        $needle = !empty($search) ? "%" . $search . "%" : '';
2294
+        $needle = !empty($search) ? "%".$search."%" : '';
2295 2295
 
2296 2296
         // Show courses by active status
2297 2297
         $active_sql = '';
@@ -2306,7 +2306,7 @@  discard block
 block discarded – undo
2306 2306
         if ($search_all_sessions == true) {
2307 2307
             $conditions = array(
2308 2308
                 'where' => array(
2309
-                    $active_sql . ' c_id = ? ' . $needle_where . $time_conditions => array(
2309
+                    $active_sql.' c_id = ? '.$needle_where.$time_conditions => array(
2310 2310
                         $course_id,
2311 2311
                         $needle
2312 2312
                     )
@@ -2317,7 +2317,7 @@  discard block
 block discarded – undo
2317 2317
             if ($session_id == 0) {
2318 2318
                 $conditions = array(
2319 2319
                     'where' => array(
2320
-                        $active_sql . ' session_id = ? AND c_id = ? ' . $needle_where . $time_conditions => array(
2320
+                        $active_sql.' session_id = ? AND c_id = ? '.$needle_where.$time_conditions => array(
2321 2321
                             $session_id,
2322 2322
                             $course_id,
2323 2323
                             $needle
@@ -2328,7 +2328,7 @@  discard block
 block discarded – undo
2328 2328
             } else {
2329 2329
                 $conditions = array(
2330 2330
                     'where' => array(
2331
-                        $active_sql . ' (session_id = 0 OR session_id = ? ) AND c_id = ? ' . $needle_where . $time_conditions => array(
2331
+                        $active_sql.' (session_id = 0 OR session_id = ? ) AND c_id = ? '.$needle_where.$time_conditions => array(
2332 2332
                             $session_id,
2333 2333
                             $course_id,
2334 2334
                             $needle
@@ -2509,7 +2509,7 @@  discard block
 block discarded – undo
2509 2509
 
2510 2510
             if ($return_string) {
2511 2511
                 if (!empty($position) && !empty($my_ranking)) {
2512
-                    $return_value = $position . '/' . count($my_ranking);
2512
+                    $return_value = $position.'/'.count($my_ranking);
2513 2513
                 } else {
2514 2514
                     $return_value = '-';
2515 2515
                 }
@@ -2590,7 +2590,7 @@  discard block
 block discarded – undo
2590 2590
 
2591 2591
             if ($return_string) {
2592 2592
                 if (!empty($position) && !empty($my_ranking)) {
2593
-                    return $position . '/' . count($my_ranking);
2593
+                    return $position.'/'.count($my_ranking);
2594 2594
                 }
2595 2595
             }
2596 2596
             return $return_value;
@@ -2996,7 +2996,7 @@  discard block
 block discarded – undo
2996 2996
             $courseCondition = "
2997 2997
             INNER JOIN $courseUser cu
2998 2998
             ON cu.c_id = c.id AND cu.user_id  = exe_user_id";
2999
-            $courseConditionWhere = " AND relation_type <> 2 AND cu.status = " . STUDENT;
2999
+            $courseConditionWhere = " AND relation_type <> 2 AND cu.status = ".STUDENT;
3000 3000
         } else {
3001 3001
             $courseCondition = "
3002 3002
             INNER JOIN $courseUserSession cu
@@ -3072,7 +3072,7 @@  discard block
 block discarded – undo
3072 3072
             $courseCondition = "
3073 3073
             INNER JOIN $courseUser cu
3074 3074
             ON cu.c_id = c.id AND cu.user_id  = exe_user_id";
3075
-            $courseConditionWhere = " AND relation_type <> 2 AND cu.status = " . STUDENT;
3075
+            $courseConditionWhere = " AND relation_type <> 2 AND cu.status = ".STUDENT;
3076 3076
         } else {
3077 3077
             $courseCondition = "
3078 3078
             INNER JOIN $courseUserSession cu
@@ -3165,7 +3165,7 @@  discard block
 block discarded – undo
3165 3165
             $courseCondition = "
3166 3166
             INNER JOIN $courseUser cu
3167 3167
             ON cu.c_id = c.id AND cu.user_id  = exe_user_id";
3168
-            $courseConditionWhere = " AND relation_type <> 2 AND cu.status = " . STUDENT;
3168
+            $courseConditionWhere = " AND relation_type <> 2 AND cu.status = ".STUDENT;
3169 3169
         } else {
3170 3170
             $courseCondition = "
3171 3171
             INNER JOIN $courseUserSession cu
@@ -3347,7 +3347,7 @@  discard block
 block discarded – undo
3347 3347
                 }
3348 3348
             }
3349 3349
             // adds the correct word, followed by ] to close the blank
3350
-            $answer .= ' / <font color="green"><b>' . $real_correct_tags[$i] . '</b></font>]';
3350
+            $answer .= ' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]';
3351 3351
             if (isset ($real_text[$i + 1])) {
3352 3352
                 $answer .= $real_text[$i + 1];
3353 3353
             }
@@ -3407,13 +3407,13 @@  discard block
 block discarded – undo
3407 3407
         // check the default value of option
3408 3408
         $tabSelected = array($in_default => " selected='selected' ");
3409 3409
         $res = "";
3410
-        $res .= "<select name='$in_name' id='$in_name' onchange='" . $in_onchange . "' >";
3411
-        $res .= "<option value='-1'" . $tabSelected["-1"] . ">-- " . get_lang(
3410
+        $res .= "<select name='$in_name' id='$in_name' onchange='".$in_onchange."' >";
3411
+        $res .= "<option value='-1'".$tabSelected["-1"].">-- ".get_lang(
3412 3412
                 'AllGroups'
3413
-            ) . " --</option>";
3414
-        $res .= "<option value='0'" . $tabSelected["0"] . ">- " . get_lang(
3413
+            )." --</option>";
3414
+        $res .= "<option value='0'".$tabSelected["0"].">- ".get_lang(
3415 3415
                 'NotInAGroup'
3416
-            ) . " -</option>";
3416
+            )." -</option>";
3417 3417
         $tabGroups = GroupManager::get_group_list();
3418 3418
         $currentCatId = 0;
3419 3419
         for ($i = 0; $i < count($tabGroups); $i++) {
@@ -3421,10 +3421,10 @@  discard block
 block discarded – undo
3421 3421
                 $tabGroups[$i]["id"]
3422 3422
             );
3423 3423
             if ($tabCategory["id"] != $currentCatId) {
3424
-                $res .= "<option value='-1' disabled='disabled'>" . $tabCategory["title"] . "</option>";
3424
+                $res .= "<option value='-1' disabled='disabled'>".$tabCategory["title"]."</option>";
3425 3425
                 $currentCatId = $tabCategory["id"];
3426 3426
             }
3427
-            $res .= "<option " . $tabSelected[$tabGroups[$i]["id"]] . "style='margin-left:40px' value='" . $tabGroups[$i]["id"] . "'>" . $tabGroups[$i]["name"] . "</option>";
3427
+            $res .= "<option ".$tabSelected[$tabGroups[$i]["id"]]."style='margin-left:40px' value='".$tabGroups[$i]["id"]."'>".$tabGroups[$i]["name"]."</option>";
3428 3428
         }
3429 3429
         $res .= "</select>";
3430 3430
         return $res;
@@ -3657,14 +3657,14 @@  discard block
 block discarded – undo
3657 3657
                 if ($show_results) {
3658 3658
                     $comnt = Event::get_comments($exe_id, $questionId);
3659 3659
                     if (!empty($comnt)) {
3660
-                        echo '<b>' . get_lang('Feedback') . '</b>';
3661
-                        echo '<div id="question_feedback">' . $comnt . '</div>';
3660
+                        echo '<b>'.get_lang('Feedback').'</b>';
3661
+                        echo '<div id="question_feedback">'.$comnt.'</div>';
3662 3662
                     }
3663 3663
                 }
3664 3664
 
3665 3665
                 if ($show_results) {
3666 3666
                     $score = array(
3667
-                        'result' => get_lang('Score') . " : " . self::show_score(
3667
+                        'result' => get_lang('Score')." : ".self::show_score(
3668 3668
                                 $my_total_score,
3669 3669
                                 $my_total_weight,
3670 3670
                                 false,
@@ -3732,9 +3732,9 @@  discard block
 block discarded – undo
3732 3732
         }
3733 3733
 
3734 3734
         if ($show_all_but_expected_answer) {
3735
-            $exercise_content .= "<div class='normal-message'>" . get_lang(
3735
+            $exercise_content .= "<div class='normal-message'>".get_lang(
3736 3736
                     "ExerciseWithFeedbackWithoutCorrectionComment"
3737
-                ) . "</div>";
3737
+                )."</div>";
3738 3738
         }
3739 3739
         // Remove audio auto play from questions on results page - refs BT#7939
3740 3740
         $exercise_content = preg_replace(
@@ -3834,11 +3834,11 @@  discard block
 block discarded – undo
3834 3834
                     $ribbon_total_success_or_error = ' ribbon-total-error';
3835 3835
                 }
3836 3836
             }
3837
-            $ribbon .= '<div class="total ' . $ribbon_total_success_or_error . '">';
3837
+            $ribbon .= '<div class="total '.$ribbon_total_success_or_error.'">';
3838 3838
         } else {
3839 3839
             $ribbon .= '<div class="total">';
3840 3840
         }
3841
-        $ribbon .= '<h3>' . get_lang('YourTotalScore') . ":&nbsp;";
3841
+        $ribbon .= '<h3>'.get_lang('YourTotalScore').":&nbsp;";
3842 3842
         $ribbon .= self::show_score($score, $weight, false, true);
3843 3843
         $ribbon .= '</h3>';
3844 3844
         $ribbon .= '</div>';
Please login to merge, or discard this patch.
main/exercice/exercise_show.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 // General parameters passed via POST/GET
36 36
 if ($debug) {
37
-    error_log('Entered exercise_result.php: ' . print_r($_POST, 1));
37
+    error_log('Entered exercise_result.php: '.print_r($_POST, 1));
38 38
 }
39 39
 
40 40
 if (empty($formSent)) {
@@ -131,19 +131,19 @@  discard block
 block discarded – undo
131 131
 }
132 132
 
133 133
 if (!empty($gradebook) && $gradebook == 'view') {
134
-    $interbreadcrumb[] = array('url' => '../gradebook/' . $_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
134
+    $interbreadcrumb[] = array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
135 135
 }
136 136
 
137 137
 $fromlink = '';
138 138
 
139
-$interbreadcrumb[] = array("url" => "exercise.php?" . api_get_cidreq(), "name" => get_lang('Exercises'));
140
-$interbreadcrumb[] = array("url" => "overview.php?exerciseId=" . $exercise_id . '&' . api_get_cidreq(), "name" => $objExercise->name);
139
+$interbreadcrumb[] = array("url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises'));
140
+$interbreadcrumb[] = array("url" => "overview.php?exerciseId=".$exercise_id.'&'.api_get_cidreq(), "name" => $objExercise->name);
141 141
 $interbreadcrumb[] = array("url" => "#", "name" => get_lang('Result'));
142 142
 
143 143
 $this_section = SECTION_COURSES;
144 144
 
145
-$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
146
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
145
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
146
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
147 147
 
148 148
 if ($origin != 'learnpath') {
149 149
     Display::display_header('');
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
                       <tr>
213 213
                         <td colspan="2">';
214 214
                 Display::display_warning_message(
215
-                    get_lang('ThankYouForPassingTheTest') . '<br /><br /><a href="exercise.php">' . (get_lang('BackToExercisesList')) . '</a>',
215
+                    get_lang('ThankYouForPassingTheTest').'<br /><br /><a href="exercise.php">'.(get_lang('BackToExercisesList')).'</a>',
216 216
                     false
217 217
                 );
218 218
                 echo '</td>
@@ -276,29 +276,29 @@  discard block
 block discarded – undo
276 276
 $i = $totalScore = $totalWeighting = 0;
277 277
 
278 278
 if ($debug > 0) {
279
-    error_log("ExerciseResult: " . print_r($exerciseResult, 1));
280
-    error_log("QuestionList: " . print_r($questionList, 1));
279
+    error_log("ExerciseResult: ".print_r($exerciseResult, 1));
280
+    error_log("QuestionList: ".print_r($questionList, 1));
281 281
 }
282 282
 
283 283
 $arrques = array();
284 284
 $arrans = array();
285 285
 
286
-$user_restriction = $is_allowedToEdit ? '' : "AND user_id=" . intval($student_id) . " ";
286
+$user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($student_id)." ";
287 287
 $sql = "SELECT attempts.question_id, answer
288 288
         FROM $TBL_TRACK_ATTEMPT as attempts
289
-        INNER JOIN " . $TBL_TRACK_EXERCISES . " AS stats_exercises
289
+        INNER JOIN ".$TBL_TRACK_EXERCISES." AS stats_exercises
290 290
         ON stats_exercises.exe_id=attempts.exe_id
291 291
         INNER JOIN $TBL_EXERCISE_QUESTION AS quizz_rel_questions
292 292
         ON
293 293
             quizz_rel_questions.exercice_id=stats_exercises.exe_exo_id AND
294 294
             quizz_rel_questions.question_id = attempts.question_id AND
295
-            quizz_rel_questions.c_id=" . api_get_course_int_id() . "
296
-        INNER JOIN " . $TBL_QUESTIONS . " AS questions
295
+            quizz_rel_questions.c_id=".api_get_course_int_id()."
296
+        INNER JOIN " . $TBL_QUESTIONS." AS questions
297 297
         ON
298 298
             questions.id=quizz_rel_questions.question_id AND
299
-            questions.c_id = " . api_get_course_int_id() . "
299
+            questions.c_id = " . api_get_course_int_id()."
300 300
         WHERE
301
-            attempts.exe_id = " . intval($id) . " $user_restriction
301
+            attempts.exe_id = " . intval($id)." $user_restriction
302 302
 		GROUP BY quizz_rel_questions.question_order, attempts.question_id";
303 303
 
304 304
 $result = Database::query($sql);
@@ -527,26 +527,26 @@  discard block
 block discarded – undo
527 527
                 $table_resume = '<table class="data_table">
528 528
                     <tr class="row_odd" >
529 529
                     <td></td>
530
-                    <td ><b>' . get_lang('Requirements') . '</b></td>
531
-                    <td><b>' . get_lang('YourAnswer') . '</b></td>
530
+                    <td ><b>' . get_lang('Requirements').'</b></td>
531
+                    <td><b>' . get_lang('YourAnswer').'</b></td>
532 532
                     </tr>
533 533
         
534 534
                     <tr class="row_even">
535
-                    <td><b>' . get_lang('Overlap') . '</b></td>
536
-                    <td>' . get_lang('Min') . ' ' . $threadhold1 . '</td>
537
-                        <td><div style="color:' . $overlap_color . '">' . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '</div></td>
535
+                    <td><b>' . get_lang('Overlap').'</b></td>
536
+                    <td>' . get_lang('Min').' '.$threadhold1.'</td>
537
+                        <td><div style="color:' . $overlap_color.'">'.(($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td>
538 538
                     </tr>
539 539
         
540 540
                     <tr>
541
-                        <td><b>' . get_lang('Excess') . '</b></td>
542
-                        <td>' . get_lang('Max') . ' ' . $threadhold2 . '</td>
543
-                        <td><div style="color:' . $excess_color . '">' . (($final_excess < 0) ? 0 : intval($final_excess)) . '</div></td>
541
+                        <td><b>' . get_lang('Excess').'</b></td>
542
+                        <td>' . get_lang('Max').' '.$threadhold2.'</td>
543
+                        <td><div style="color:' . $excess_color.'">'.(($final_excess < 0) ? 0 : intval($final_excess)).'</div></td>
544 544
                     </tr>
545 545
         
546 546
                     <tr class="row_even">
547
-                        <td><b>' . get_lang('Missing') . '</b></td>
548
-                        <td>' . get_lang('Max') . ' ' . $threadhold3 . '</td>
549
-                        <td><div style="color:' . $missing_color . '">' . (($final_missing < 0) ? 0 : intval($final_missing)) . '</div></td>
547
+                        <td><b>' . get_lang('Missing').'</b></td>
548
+                        <td>' . get_lang('Max').' '.$threadhold3.'</td>
549
+                        <td><div style="color:' . $missing_color.'">'.(($final_missing < 0) ? 0 : intval($final_missing)).'</div></td>
550 550
                     </tr></table>';
551 551
 
552 552
                 if ($answerType != HOT_SPOT_DELINEATION) {
@@ -570,24 +570,24 @@  discard block
 block discarded – undo
570 570
                     }
571 571
                 }
572 572
 
573
-                echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1>';
573
+                echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
574 574
                 if ($answerType == HOT_SPOT_DELINEATION) {
575 575
                     if ($organs_at_risk_hit > 0) {
576
-                        $message = '<br />' . get_lang('ResultIs') . ' <b>' . $result_comment . '</b><br />';
577
-                        $message .= '<p style="color:#DC0A0A;"><b>' . get_lang('OARHit') . '</b></p>';
576
+                        $message = '<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
577
+                        $message .= '<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
578 578
                     } else {
579
-                        $message = '<p>' . get_lang('YourDelineation') . '</p>';
579
+                        $message = '<p>'.get_lang('YourDelineation').'</p>';
580 580
                         $message .= $table_resume;
581
-                        $message .= '<br />' . get_lang('ResultIs') . ' <b>' . $result_comment . '</b><br />';
581
+                        $message .= '<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
582 582
                     }
583
-                    $message .= '<p>' . $comment . '</p>';
583
+                    $message .= '<p>'.$comment.'</p>';
584 584
                     echo $message;
585 585
                 } else {
586
-                    echo '<p>' . $comment . '</p>';
586
+                    echo '<p>'.$comment.'</p>';
587 587
                 }
588 588
 
589 589
                 //showing the score
590
-                $queryfree = "select marks from " . $TBL_TRACK_ATTEMPT . " WHERE exe_id = " . intval($id) . " and question_id= " . intval($questionId) . "";
590
+                $queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." WHERE exe_id = ".intval($id)." and question_id= ".intval($questionId)."";
591 591
                 $resfree = Database::query($queryfree);
592 592
                 $questionScore = Database::result($resfree, 0, "marks");
593 593
                 $totalScore += $questionScore;
@@ -643,8 +643,8 @@  discard block
 block discarded – undo
643 643
         $marksname = '';
644 644
 
645 645
         if ($isFeedbackAllowed) {
646
-            $name = "fckdiv" . $questionId;
647
-            $marksname = "marksName" . $questionId;
646
+            $name = "fckdiv".$questionId;
647
+            $marksname = "marksName".$questionId;
648 648
             if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
649 649
                 $url_name = get_lang('EditCommentsAndMarks');
650 650
             } else {
@@ -655,32 +655,32 @@  discard block
 block discarded – undo
655 655
                 }
656 656
             }
657 657
             echo '<br />';
658
-            echo Display::url($url_name, 'javascript://', array('class' => 'btn', 'onclick' => "showfck('" . $name . "', '" . $marksname . "');"));
658
+            echo Display::url($url_name, 'javascript://', array('class' => 'btn', 'onclick' => "showfck('".$name."', '".$marksname."');"));
659 659
             echo '<br />';
660 660
 
661
-            echo '<div id="feedback_' . $name . '" style="width:100%">';
661
+            echo '<div id="feedback_'.$name.'" style="width:100%">';
662 662
             $comnt = trim(Event::get_comments($id, $questionId));
663 663
             if (empty($comnt)) {
664 664
                 echo '<br />';
665 665
             } else {
666
-                echo '<div id="question_feedback">' . $comnt . '</div>';
666
+                echo '<div id="question_feedback">'.$comnt.'</div>';
667 667
             }
668 668
             echo '</div>';
669 669
 
670
-            echo '<div id="' . $name . '" style="display:none">';
670
+            echo '<div id="'.$name.'" style="display:none">';
671 671
             $arrid[] = $questionId;
672
-            $feedback_form = new FormValidator('frmcomments' . $questionId, 'post', '');
672
+            $feedback_form = new FormValidator('frmcomments'.$questionId, 'post', '');
673 673
             $feedback_form->addElement('html', '<br>');
674
-            $renderer =& $feedback_form->defaultRenderer();
674
+            $renderer = & $feedback_form->defaultRenderer();
675 675
             $renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>');
676 676
             $renderer->setCustomElementTemplate('<div align="left">{element}</div>');
677 677
             $comnt = Event::get_comments($id, $questionId);
678
-            $default = array('comments_' . $questionId => $comnt);
678
+            $default = array('comments_'.$questionId => $comnt);
679 679
 
680 680
             if ($useAdvancedEditor) {
681 681
                 $feedback_form->addElement(
682 682
                     'html_editor',
683
-                    'comments_' . $questionId,
683
+                    'comments_'.$questionId,
684 684
                     null,
685 685
                     null,
686 686
                     array(
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
                     )
691 691
                 );
692 692
             } else {
693
-                $feedback_form->addElement('textarea', 'comments_' . $questionId);
693
+                $feedback_form->addElement('textarea', 'comments_'.$questionId);
694 694
             }
695 695
             $feedback_form->addElement('html', '<br>');
696 696
             $feedback_form->setDefaults($default);
@@ -701,21 +701,21 @@  discard block
 block discarded – undo
701 701
             $comnt = Event::get_comments($id, $questionId);
702 702
             echo '<br />';
703 703
             if (!empty($comnt)) {
704
-                echo '<b>' . get_lang('Feedback') . '</b>';
705
-                echo '<div id="question_feedback">' . $comnt . '</div>';
704
+                echo '<b>'.get_lang('Feedback').'</b>';
705
+                echo '<div id="question_feedback">'.$comnt.'</div>';
706 706
             }
707 707
         }
708 708
 
709 709
         if ($is_allowedToEdit && $isFeedbackAllowed) {
710 710
             if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
711
-                $marksname = "marksName" . $questionId;
712
-                echo '<div id="' . $marksname . '" style="display:none">';
713
-                echo '<form name="marksform_' . $questionId . '" method="post" action="">';
711
+                $marksname = "marksName".$questionId;
712
+                echo '<div id="'.$marksname.'" style="display:none">';
713
+                echo '<form name="marksform_'.$questionId.'" method="post" action="">';
714 714
                 $arrmarks[] = $questionId;
715 715
                 echo get_lang("AssignMarks");
716 716
                 echo "&nbsp;<select name='marks' id='marks'>";
717 717
                 for ($i = 0; $i <= $questionWeighting; $i++) {
718
-                    echo '<option ' . (($i == $questionScore) ? "selected='selected'" : '') . '>' . $i . '</option>';
718
+                    echo '<option '.(($i == $questionScore) ? "selected='selected'" : '').'>'.$i.'</option>';
719 719
                 }
720 720
                 echo '</select>';
721 721
                 echo '</form><br /></div>';
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
                 }
727 727
             } else {
728 728
                 $arrmarks[] = $questionId;
729
-                echo '<div id="' . $marksname . '" style="display:none"><form name="marksform_' . $questionId . '" method="post" action="">
730
-					  <select name="marks" id="marks" style="display:none;"><option>' . $questionScore . '</option></select></form><br/ ></div>';
729
+                echo '<div id="'.$marksname.'" style="display:none"><form name="marksform_'.$questionId.'" method="post" action="">
730
+					  <select name="marks" id="marks" style="display:none;"><option>' . $questionScore.'</option></select></form><br/ ></div>';
731 731
             }
732 732
         } else {
733 733
             if ($questionScore == -1) {
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 
784 784
     $score = array();
785 785
     if ($show_results) {
786
-        $score['result'] = get_lang('Score') . " : " . ExerciseLib::show_score(
786
+        $score['result'] = get_lang('Score')." : ".ExerciseLib::show_score(
787 787
             $my_total_score,
788 788
             $my_total_weight,
789 789
             false,
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 
856 856
 if ($isFeedbackAllowed) {
857 857
     if (in_array($origin, array('tracking_course', 'user_course', 'correct_exercise_in_lp'))) {
858
-        $formUrl = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&';
858
+        $formUrl = api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&';
859 859
         $formUrl .= http_build_query([
860 860
             'exerciseId' => $exercise_id,
861 861
             'filter' => 2,
@@ -867,14 +867,14 @@  discard block
 block discarded – undo
867 867
         ]);
868 868
         $formUrl .= $fromlink;
869 869
 
870
-        echo '<form name="myform" id="myform" action="' . $formUrl . '" method="post">';
871
-        echo '<input type = "hidden" name="lp_item_id"       value="' . $learnpath_id . '">';
872
-        echo '<input type = "hidden" name="lp_item_view_id"  value="' . $lp_item_view_id . '">';
873
-        echo '<input type = "hidden" name="student_id"       value="' . $student_id . '">';
874
-        echo '<input type = "hidden" name="total_score"      value="' . $totalScore . '"> ';
875
-        echo '<input type = "hidden" name="my_exe_exo_id"    value="' . $exercise_id . '"> ';
870
+        echo '<form name="myform" id="myform" action="'.$formUrl.'" method="post">';
871
+        echo '<input type = "hidden" name="lp_item_id"       value="'.$learnpath_id.'">';
872
+        echo '<input type = "hidden" name="lp_item_view_id"  value="'.$lp_item_view_id.'">';
873
+        echo '<input type = "hidden" name="student_id"       value="'.$student_id.'">';
874
+        echo '<input type = "hidden" name="total_score"      value="'.$totalScore.'"> ';
875
+        echo '<input type = "hidden" name="my_exe_exo_id"    value="'.$exercise_id.'"> ';
876 876
     } else {
877
-        $formUrl = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&';
877
+        $formUrl = api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&';
878 878
         $formUrl .= http_build_query([
879 879
             'exerciseId' => $exercise_id,
880 880
             'filter' => 1,
@@ -882,11 +882,11 @@  discard block
 block discarded – undo
882 882
             'exeid' => $id
883 883
         ]);
884 884
 
885
-        echo ' <form name="myform" id="myform" action="' . $formUrl . '" method="post">';
885
+        echo ' <form name="myform" id="myform" action="'.$formUrl.'" method="post">';
886 886
     }
887 887
 
888 888
     if ($origin != 'learnpath' && $origin != 'student_progress') {
889
-        echo '<label><input type= "checkbox" name="send_notification"> ' . get_lang('SendEmail') . '</label>';
889
+        echo '<label><input type= "checkbox" name="send_notification"> '.get_lang('SendEmail').'</label>';
890 890
         ?>
891 891
         <br/>
892 892
         <button type="submit" class="btn btn-primary" value="<?php echo get_lang('Ok'); ?>"
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 } else {
920 920
     if (!isset($_GET['fb_type'])) {
921 921
         $lp_mode = $_SESSION['lp_mode'];
922
-        $url = '../newscorm/lp_controller.php?' . api_get_cidreq() . '&';
922
+        $url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&';
923 923
         $url .= http_build_url([
924 924
             'action' => 'view',
925 925
             'lp_id' => $learnpath_id,
@@ -927,13 +927,13 @@  discard block
 block discarded – undo
927 927
             'exeId' => $exeId,
928 928
             'fb_type' => $feedback_type
929 929
         ]);
930
-        $href = ($lp_mode == 'fullscreen') ? ' window.opener.location.href="' . $url . '" ' : ' top.location.href="' . $url . '" ';
931
-        echo '<script type="text/javascript">' . $href . '</script>';
930
+        $href = ($lp_mode == 'fullscreen') ? ' window.opener.location.href="'.$url.'" ' : ' top.location.href="'.$url.'" ';
931
+        echo '<script type="text/javascript">'.$href.'</script>';
932 932
         // Record the results in the learning path, using the SCORM interface (API)
933 933
         echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>";
934 934
         echo '</body></html>';
935 935
     } else {
936
-        Display::display_normal_message(get_lang('ExerciseFinished') . ' ' . get_lang('ToContinueUseMenu'));
936
+        Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu'));
937 937
         echo '<br />';
938 938
     }
939 939
 }
Please login to merge, or discard this patch.
main/exercice/exercise.class.php 1 patch
Spacing   +339 added lines, -339 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     public $feedback_type;
28 28
     public $end_time;
29 29
     public $start_time;
30
-    public $questionList;  // array with the list of this exercise's questions
30
+    public $questionList; // array with the list of this exercise's questions
31 31
     /* including question list of the media */
32 32
     public $questionListUncompressed;
33 33
     public $results_disabled;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
131 131
         $table_lp_item = Database::get_course_table(TABLE_LP_ITEM);
132 132
 
133
-        $id  = intval($id);
133
+        $id = intval($id);
134 134
         if (empty($this->course_id)) {
135 135
 
136 136
             return false;
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
             }
191 191
 
192 192
             if ($object->end_time != '0000-00-00 00:00:00') {
193
-                $this->end_time 	= $object->end_time;
193
+                $this->end_time = $object->end_time;
194 194
             }
195 195
             if ($object->start_time != '0000-00-00 00:00:00') {
196
-                $this->start_time 	= $object->start_time;
196
+                $this->start_time = $object->start_time;
197 197
             }
198 198
 
199 199
             //control time
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
      */
479 479
     public function isRandom()
480 480
     {
481
-        if($this->random > 0 || $this->random == -1) {
481
+        if ($this->random > 0 || $this->random == -1) {
482 482
             return true;
483 483
         } else {
484 484
             return false;
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
                     $question_media = null;
640 640
                     if (!empty($objQuestionTmp->parent_id)) {
641 641
                         $objQuestionMedia = Question::read($objQuestionTmp->parent_id);
642
-                        $question_media  = Question::getMediaLabel($objQuestionMedia->question);
642
+                        $question_media = Question::getMediaLabel($objQuestionMedia->question);
643 643
                     }
644 644
 
645 645
                     $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), ICON_SIZE_MEDIUM).$question_media);
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
             foreach ($questions_by_category as $categoryId => $questionList) {
1034 1034
                 $cat = new TestCategory($categoryId);
1035
-                $cat = (array)$cat;
1035
+                $cat = (array) $cat;
1036 1036
                 $cat['iid'] = $cat['id'];
1037 1037
                 //*$cat['name'] = $cat['name'];
1038 1038
 
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
     {
1098 1098
         if ($this->specialCategoryOrders == false) {
1099 1099
             if ($from_db && !empty($this->id)) {
1100
-                $TBL_EXERCISE_QUESTION  = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
1100
+                $TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
1101 1101
                 $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
1102 1102
 
1103 1103
                 $sql = "SELECT DISTINCT e.question_order
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
                 $question_list = array();
1125 1125
 
1126 1126
                 while ($new_object = Database::fetch_object($result)) {
1127
-                    $question_list[$new_object->question_order]=  $new_object->question_id;
1127
+                    $question_list[$new_object->question_order] = $new_object->question_id;
1128 1128
                     $temp_question_list[$counter] = $new_object->question_id;
1129 1129
                     $counter++;
1130 1130
                 }
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
     public function isInList($questionId)
1269 1269
     {
1270 1270
         if (is_array($this->questionList))
1271
-            return in_array($questionId,$this->questionList);
1271
+            return in_array($questionId, $this->questionList);
1272 1272
         else
1273 1273
             return false;
1274 1274
     }
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
      */
1282 1282
     public function updateTitle($title)
1283 1283
     {
1284
-        $this->exercise=$title;
1284
+        $this->exercise = $title;
1285 1285
     }
1286 1286
 
1287 1287
     /**
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
      */
1292 1292
     public function updateAttempts($attempts)
1293 1293
     {
1294
-        $this->attempts=$attempts;
1294
+        $this->attempts = $attempts;
1295 1295
     }
1296 1296
 
1297 1297
     /**
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
      */
1302 1302
     public function updateFeedbackType($feedback_type)
1303 1303
     {
1304
-        $this->feedback_type=$feedback_type;
1304
+        $this->feedback_type = $feedback_type;
1305 1305
     }
1306 1306
 
1307 1307
     /**
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
      */
1313 1313
     public function updateDescription($description)
1314 1314
     {
1315
-        $this->description=$description;
1315
+        $this->description = $description;
1316 1316
     }
1317 1317
 
1318 1318
     /**
@@ -1442,23 +1442,23 @@  discard block
 block discarded – undo
1442 1442
      * @param string $sound - exercise sound file
1443 1443
      * @param string $delete - ask to delete the file
1444 1444
      */
1445
-    public function updateSound($sound,$delete)
1445
+    public function updateSound($sound, $delete)
1446 1446
     {
1447 1447
         global $audioPath, $documentPath;
1448 1448
         $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
1449 1449
 
1450
-        if ($sound['size'] && (strstr($sound['type'],'audio') || strstr($sound['type'],'video'))) {
1451
-            $this->sound=$sound['name'];
1450
+        if ($sound['size'] && (strstr($sound['type'], 'audio') || strstr($sound['type'], 'video'))) {
1451
+            $this->sound = $sound['name'];
1452 1452
 
1453
-            if (@move_uploaded_file($sound['tmp_name'],$audioPath.'/'.$this->sound)) {
1453
+            if (@move_uploaded_file($sound['tmp_name'], $audioPath.'/'.$this->sound)) {
1454 1454
                 $query = "SELECT 1 FROM $TBL_DOCUMENT
1455
-                        WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath,'',$audioPath).'/'.$this->sound."'";
1456
-                $result=Database::query($query);
1455
+                        WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath, '', $audioPath).'/'.$this->sound."'";
1456
+                $result = Database::query($query);
1457 1457
 
1458 1458
                 if (!Database::num_rows($result)) {
1459 1459
                     $id = add_document(
1460 1460
                         $this->course,
1461
-                        str_replace($documentPath,'',$audioPath).'/'.$this->sound,
1461
+                        str_replace($documentPath, '', $audioPath).'/'.$this->sound,
1462 1462
                         'file',
1463 1463
                         $sound['size'],
1464 1464
                         $sound['name']
@@ -1477,8 +1477,8 @@  discard block
 block discarded – undo
1477 1477
                     );
1478 1478
                 }
1479 1479
             }
1480
-        } elseif($delete && is_file($audioPath.'/'.$this->sound)) {
1481
-            $this->sound='';
1480
+        } elseif ($delete && is_file($audioPath.'/'.$this->sound)) {
1481
+            $this->sound = '';
1482 1482
         }
1483 1483
     }
1484 1484
 
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
      */
1491 1491
     public function updateType($type)
1492 1492
     {
1493
-        $this->type=$type;
1493
+        $this->type = $type;
1494 1494
     }
1495 1495
 
1496 1496
     /**
@@ -1526,7 +1526,7 @@  discard block
 block discarded – undo
1526 1526
      */
1527 1527
     public function enable()
1528 1528
     {
1529
-        $this->active=1;
1529
+        $this->active = 1;
1530 1530
     }
1531 1531
 
1532 1532
     /**
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
      */
1537 1537
     public function disable()
1538 1538
     {
1539
-        $this->active=0;
1539
+        $this->active = 0;
1540 1540
     }
1541 1541
 
1542 1542
     /**
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
                 api_get_user_id()
1665 1665
             );
1666 1666
 
1667
-            if (api_get_setting('search_enabled')=='true') {
1667
+            if (api_get_setting('search_enabled') == 'true') {
1668 1668
                 $this->search_engine_edit();
1669 1669
             }
1670 1670
         } else {
@@ -1812,7 +1812,7 @@  discard block
 block discarded – undo
1812 1812
     public function removeFromList($questionId)
1813 1813
     {
1814 1814
         // searches the position of the question ID in the list
1815
-        $pos = array_search($questionId,$this->questionList);
1815
+        $pos = array_search($questionId, $this->questionList);
1816 1816
 
1817 1817
         // question not found
1818 1818
         if ($pos === false) {
@@ -1847,7 +1847,7 @@  discard block
 block discarded – undo
1847 1847
         api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'QuizDeleted', api_get_user_id());
1848 1848
         api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'delete', api_get_user_id());
1849 1849
 
1850
-        if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian') ) {
1850
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
1851 1851
             $this->search_engine_delete();
1852 1852
         }
1853 1853
     }
@@ -1856,7 +1856,7 @@  discard block
 block discarded – undo
1856 1856
      * Creates the form to create / edit an exercise
1857 1857
      * @param FormValidator $form
1858 1858
      */
1859
-    public function createForm($form, $type='full')
1859
+    public function createForm($form, $type = 'full')
1860 1860
     {
1861 1861
         if (empty($type)) {
1862 1862
             $type = 'full';
@@ -1887,7 +1887,7 @@  discard block
 block discarded – undo
1887 1887
             'Width' => '100%',
1888 1888
             'Height' => '150',
1889 1889
         );
1890
-        if (is_array($type)){
1890
+        if (is_array($type)) {
1891 1891
             $editor_config = array_merge($editor_config, $type);
1892 1892
         }
1893 1893
 
@@ -1941,7 +1941,7 @@  discard block
 block discarded – undo
1941 1941
                     '2',
1942 1942
                     array('id' => 'exerciseType_2')
1943 1943
                 );
1944
-                $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions')), '');
1944
+                $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')), '');
1945 1945
 
1946 1946
                 // Type of results display on the final page
1947 1947
                 $radios_results_disabled = array();
@@ -1985,8 +1985,8 @@  discard block
 block discarded – undo
1985 1985
                 // Type of questions disposition on page
1986 1986
                 $radios = array();
1987 1987
 
1988
-                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
1989
-                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
1988
+                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
1989
+                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
1990 1990
 
1991 1991
                 $form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
1992 1992
 
@@ -1996,33 +1996,33 @@  discard block
 block discarded – undo
1996 1996
 
1997 1997
                     // feedback type
1998 1998
                     $radios_feedback = array();
1999
-                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'),'0',array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()'));
1999
+                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()'));
2000 2000
 
2001 2001
                     if (api_get_setting('enable_quiz_scenario') == 'true') {
2002
-                        $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1' , 'onclick' => 'check_direct_feedback()'));
2002
+                        $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
2003 2003
                     }
2004
-                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2',array('id' =>'exerciseType_2'));
2005
-                    $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions')));
2004
+                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' =>'exerciseType_2'));
2005
+                    $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')));
2006 2006
 
2007 2007
                     //$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
2008 2008
                     $radios_results_disabled = array();
2009 2009
                     $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0'));
2010
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
2011
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()'));
2012
-                    $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),'');
2010
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()'));
2011
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()'));
2012
+                    $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
2013 2013
 
2014 2014
                     // Type of questions disposition on page
2015 2015
                     $radios = array();
2016
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1');
2017
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2');
2016
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1');
2017
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2');
2018 2018
                     $form->addGroup($radios, null, get_lang('ExerciseType'));
2019 2019
 
2020 2020
                 } else {
2021 2021
                     //Show options freeze
2022 2022
                     $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0'));
2023
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
2024
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()'));
2025
-                    $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),'');
2023
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()'));
2024
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()'));
2025
+                    $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
2026 2026
                     $result_disable_group->freeze();
2027 2027
 
2028 2028
                     //we force the options to the DirectFeedback exercisetype
@@ -2030,8 +2030,8 @@  discard block
 block discarded – undo
2030 2030
                     $form->addElement('hidden', 'exerciseType', ONE_PER_PAGE);
2031 2031
 
2032 2032
                     // Type of questions disposition on page
2033
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
2034
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
2033
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
2034
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
2035 2035
 
2036 2036
                     $type_group = $form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
2037 2037
                     $type_group->freeze();
@@ -2163,26 +2163,26 @@  discard block
 block discarded – undo
2163 2163
 
2164 2164
                 // number of random question
2165 2165
 
2166
-                $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10 ;
2166
+                $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10;
2167 2167
                 $option = range(0, $max);
2168 2168
                 $option[0] = get_lang('No');
2169 2169
                 $option[-1] = get_lang('AllQuestionsShort');
2170
-                $form->addElement('select', 'randomQuestions',array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions'));
2170
+                $form->addElement('select', 'randomQuestions', array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions'));
2171 2171
 
2172 2172
                 // Random answers
2173 2173
                 $radios_random_answers = array();
2174
-                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'),'1');
2175
-                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'),'0');
2174
+                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'), '1');
2175
+                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'), '0');
2176 2176
                 $form->addGroup($radios_random_answers, null, get_lang('RandomAnswers'), '');
2177 2177
 
2178 2178
                 // Random by category
2179
-                $form->addElement('html','<div class="clear">&nbsp;</div>');
2179
+                $form->addElement('html', '<div class="clear">&nbsp;</div>');
2180 2180
                 $radiocat = array();
2181
-                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'),'1');
2182
-                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'),'2');
2183
-                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'),'0');
2181
+                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'), '1');
2182
+                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'), '2');
2183
+                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'), '0');
2184 2184
                 $radioCatGroup = $form->addGroup($radiocat, null, get_lang('RandomQuestionByCategory'), '');
2185
-                $form->addElement('html','<div class="clear">&nbsp;</div>');
2185
+                $form->addElement('html', '<div class="clear">&nbsp;</div>');
2186 2186
 
2187 2187
                 // add the radio display the category name for student
2188 2188
                 $radio_display_cat_name = array();
@@ -2203,36 +2203,36 @@  discard block
 block discarded – undo
2203 2203
             );
2204 2204
 
2205 2205
             // Exercise time limit
2206
-            $form->addElement('checkbox', 'activate_start_date_check',null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
2206
+            $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
2207 2207
 
2208 2208
             $var = Exercise::selectTimeLimit();
2209 2209
 
2210 2210
             if (($this->start_time != '0000-00-00 00:00:00'))
2211
-                $form->addElement('html','<div id="start_date_div" style="display:block;">');
2211
+                $form->addElement('html', '<div id="start_date_div" style="display:block;">');
2212 2212
             else
2213
-                $form->addElement('html','<div id="start_date_div" style="display:none;">');
2213
+                $form->addElement('html', '<div id="start_date_div" style="display:none;">');
2214 2214
 
2215 2215
             $form->addElement('date_time_picker', 'start_time');
2216 2216
 
2217
-            $form->addElement('html','</div>');
2217
+            $form->addElement('html', '</div>');
2218 2218
 
2219
-            $form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
2219
+            $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
2220 2220
 
2221 2221
             if (($this->end_time != '0000-00-00 00:00:00'))
2222
-                $form->addElement('html','<div id="end_date_div" style="display:block;">');
2222
+                $form->addElement('html', '<div id="end_date_div" style="display:block;">');
2223 2223
             else
2224
-                $form->addElement('html','<div id="end_date_div" style="display:none;">');
2224
+                $form->addElement('html', '<div id="end_date_div" style="display:none;">');
2225 2225
 
2226 2226
             $form->addElement('date_time_picker', 'end_time');
2227
-            $form->addElement('html','</div>');
2227
+            $form->addElement('html', '</div>');
2228 2228
 
2229 2229
             //$check_option=$this->selectType();
2230 2230
             $diplay = 'block';
2231 2231
             $form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults'));
2232
-            $form->addElement('html','<div class="clear">&nbsp;</div>');
2232
+            $form->addElement('html', '<div class="clear">&nbsp;</div>');
2233 2233
             $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers'));
2234 2234
 
2235
-            $form->addElement('html','<div id="divtimecontrol"  style="display:'.$diplay.';">');
2235
+            $form->addElement('html', '<div id="divtimecontrol"  style="display:'.$diplay.';">');
2236 2236
 
2237 2237
             //Timer control
2238 2238
             //$time_hours_option = range(0,12);
@@ -2248,12 +2248,12 @@  discard block
 block discarded – undo
2248 2248
                     'onload' => 'check_load_time()',
2249 2249
                 )
2250 2250
             );
2251
-            $expired_date = (int)$this->selectExpiredTime();
2251
+            $expired_date = (int) $this->selectExpiredTime();
2252 2252
 
2253
-            if (($expired_date!='0')) {
2254
-                $form->addElement('html','<div id="timercontrol" style="display:block;">');
2253
+            if (($expired_date != '0')) {
2254
+                $form->addElement('html', '<div id="timercontrol" style="display:block;">');
2255 2255
             } else {
2256
-                $form->addElement('html','<div id="timercontrol" style="display:none;">');
2256
+                $form->addElement('html', '<div id="timercontrol" style="display:none;">');
2257 2257
             }
2258 2258
             $form->addText(
2259 2259
                 'enabletimercontroltotalminutes',
@@ -2264,7 +2264,7 @@  discard block
 block discarded – undo
2264 2264
                     'cols-size' => [2, 2, 8]
2265 2265
                 ]
2266 2266
             );
2267
-            $form->addElement('html','</div>');
2267
+            $form->addElement('html', '</div>');
2268 2268
 
2269 2269
             $form->addElement(
2270 2270
                 'text',
@@ -2288,23 +2288,23 @@  discard block
 block discarded – undo
2288 2288
             $defaults = array();
2289 2289
 
2290 2290
             if (api_get_setting('search_enabled') === 'true') {
2291
-                require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
2291
+                require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2292 2292
 
2293
-                $form->addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
2294
-                $form->addElement ('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
2293
+                $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
2294
+                $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
2295 2295
 
2296 2296
                 $specific_fields = get_specific_field_list();
2297 2297
 
2298 2298
                 foreach ($specific_fields as $specific_field) {
2299
-                    $form->addElement ('text', $specific_field['code'], $specific_field['name']);
2299
+                    $form->addElement('text', $specific_field['code'], $specific_field['name']);
2300 2300
                     $filter = array(
2301 2301
                         'c_id' => api_get_course_int_id(),
2302 2302
                         'field_id' => $specific_field['id'],
2303 2303
                         'ref_id' => $this->id,
2304
-                        'tool_id' => "'" . TOOL_QUIZ . "'"
2304
+                        'tool_id' => "'".TOOL_QUIZ."'"
2305 2305
                     );
2306 2306
                     $values = get_specific_field_values_list($filter, array('value'));
2307
-                    if ( !empty($values) ) {
2307
+                    if (!empty($values)) {
2308 2308
                         $arr_str_values = array();
2309 2309
                         foreach ($values as $value) {
2310 2310
                             $arr_str_values[] = $value['value'];
@@ -2315,8 +2315,8 @@  discard block
 block discarded – undo
2315 2315
                 //$form->addElement ('html','</div>');
2316 2316
             }
2317 2317
 
2318
-            $form->addElement('html','</div>');  //End advanced setting
2319
-            $form->addElement('html','</div>');
2318
+            $form->addElement('html', '</div>'); //End advanced setting
2319
+            $form->addElement('html', '</div>');
2320 2320
         }
2321 2321
 
2322 2322
         // submit
@@ -2336,10 +2336,10 @@  discard block
 block discarded – undo
2336 2336
         }
2337 2337
 
2338 2338
         // defaults
2339
-        if ($type=='full') {
2339
+        if ($type == 'full') {
2340 2340
             if ($this->id > 0) {
2341 2341
                 if ($this->random > $this->selectNbrQuestions()) {
2342
-                    $defaults['randomQuestions'] =  $this->selectNbrQuestions();
2342
+                    $defaults['randomQuestions'] = $this->selectNbrQuestions();
2343 2343
                 } else {
2344 2344
                     $defaults['randomQuestions'] = $this->random;
2345 2345
                 }
@@ -2366,8 +2366,8 @@  discard block
 block discarded – undo
2366 2366
                     $defaults['activate_end_date_check'] = 1;
2367 2367
                 }
2368 2368
 
2369
-                $defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00') ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00');
2370
-                $defaults['end_time'] = ($this->end_time!='0000-00-00 00:00:00') ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time()+84600);
2369
+                $defaults['start_time'] = ($this->start_time != '0000-00-00 00:00:00') ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00');
2370
+                $defaults['end_time'] = ($this->end_time != '0000-00-00 00:00:00') ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time() + 84600);
2371 2371
 
2372 2372
                 // Get expired time
2373 2373
                 if ($this->expired_time != '0') {
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
                 $defaults['text_when_finished'] = "";
2389 2389
                 $defaults['start_time'] = date('Y-m-d 12:00:00');
2390 2390
                 $defaults['display_category_name'] = 1;
2391
-                $defaults['end_time']   = date('Y-m-d 12:00:00', time()+84600);
2391
+                $defaults['end_time']   = date('Y-m-d 12:00:00', time() + 84600);
2392 2392
                 $defaults['pass_percentage'] = '';
2393 2393
                 $defaults['end_button'] = $this->selectEndButton();
2394 2394
                 $defaults['question_selection_type'] = 1;
@@ -2474,7 +2474,7 @@  discard block
 block discarded – undo
2474 2474
             $end_time = $form->getSubmitValue('end_time');
2475 2475
             $this->end_time = api_get_utc_datetime($end_time);
2476 2476
         } else {
2477
-            $this->end_time   = '0000-00-00 00:00:00';
2477
+            $this->end_time = '0000-00-00 00:00:00';
2478 2478
         }
2479 2479
 
2480 2480
         if ($form->getSubmitValue('enabletimercontrol') == 1) {
@@ -2487,9 +2487,9 @@  discard block
 block discarded – undo
2487 2487
         }
2488 2488
 
2489 2489
         if ($form->getSubmitValue('randomAnswers') == 1) {
2490
-            $this->random_answers=1;
2490
+            $this->random_answers = 1;
2491 2491
         } else {
2492
-            $this->random_answers=0;
2492
+            $this->random_answers = 0;
2493 2493
         }
2494 2494
         $this->save($type);
2495 2495
     }
@@ -2501,9 +2501,9 @@  discard block
 block discarded – undo
2501 2501
         }
2502 2502
         $course_id = api_get_course_id();
2503 2503
 
2504
-        require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
2505
-        require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
2506
-        require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
2504
+        require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
2505
+        require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php';
2506
+        require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2507 2507
 
2508 2508
         $specific_fields = get_specific_field_list();
2509 2509
         $ic_slide = new IndexableChunk();
@@ -2513,7 +2513,7 @@  discard block
 block discarded – undo
2513 2513
             if (isset($_REQUEST[$specific_field['code']])) {
2514 2514
                 $sterms = trim($_REQUEST[$specific_field['code']]);
2515 2515
                 if (!empty($sterms)) {
2516
-                    $all_specific_terms .= ' '. $sterms;
2516
+                    $all_specific_terms .= ' '.$sterms;
2517 2517
                     $sterms = explode(',', $sterms);
2518 2518
                     foreach ($sterms as $sterm) {
2519 2519
                         $ic_slide->addTerm(trim($sterm), $specific_field['code']);
@@ -2530,15 +2530,15 @@  discard block
 block discarded – undo
2530 2530
         $xapian_data = array(
2531 2531
             SE_COURSE_ID => $course_id,
2532 2532
             SE_TOOL_ID => TOOL_QUIZ,
2533
-            SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id),
2534
-            SE_USER => (int)api_get_user_id(),
2533
+            SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id),
2534
+            SE_USER => (int) api_get_user_id(),
2535 2535
         );
2536 2536
         $ic_slide->xapian_data = serialize($xapian_data);
2537
-        $exercise_description = $all_specific_terms .' '. $this->description;
2537
+        $exercise_description = $all_specific_terms.' '.$this->description;
2538 2538
         $ic_slide->addValue("content", $exercise_description);
2539 2539
 
2540 2540
         $di = new ChamiloIndexer();
2541
-        isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
2541
+        isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english';
2542 2542
         $di->connectDb(NULL, NULL, $lang);
2543 2543
         $di->addChunk($ic_slide);
2544 2544
 
@@ -2557,7 +2557,7 @@  discard block
 block discarded – undo
2557 2557
     function search_engine_edit()
2558 2558
     {
2559 2559
         // update search enchine and its values table if enabled
2560
-        if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {
2560
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
2561 2561
             $course_id = api_get_course_id();
2562 2562
 
2563 2563
             // actually, it consists on delete terms from db,
@@ -2569,9 +2569,9 @@  discard block
 block discarded – undo
2569 2569
             $res = Database::query($sql);
2570 2570
 
2571 2571
             if (Database::num_rows($res) > 0) {
2572
-                require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php');
2573
-                require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php');
2574
-                require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
2572
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
2573
+                require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php');
2574
+                require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php');
2575 2575
 
2576 2576
                 $se_ref = Database::fetch_array($res);
2577 2577
                 $specific_fields = get_specific_field_list();
@@ -2582,7 +2582,7 @@  discard block
 block discarded – undo
2582 2582
                     delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_QUIZ, $this->id);
2583 2583
                     if (isset($_REQUEST[$specific_field['code']])) {
2584 2584
                         $sterms = trim($_REQUEST[$specific_field['code']]);
2585
-                        $all_specific_terms .= ' '. $sterms;
2585
+                        $all_specific_terms .= ' '.$sterms;
2586 2586
                         $sterms = explode(',', $sterms);
2587 2587
                         foreach ($sterms as $sterm) {
2588 2588
                             $ic_slide->addTerm(trim($sterm), $specific_field['code']);
@@ -2598,17 +2598,17 @@  discard block
 block discarded – undo
2598 2598
                 $xapian_data = array(
2599 2599
                     SE_COURSE_ID => $course_id,
2600 2600
                     SE_TOOL_ID => TOOL_QUIZ,
2601
-                    SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id),
2602
-                    SE_USER => (int)api_get_user_id(),
2601
+                    SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id),
2602
+                    SE_USER => (int) api_get_user_id(),
2603 2603
                 );
2604 2604
                 $ic_slide->xapian_data = serialize($xapian_data);
2605
-                $exercise_description = $all_specific_terms .' '. $this->description;
2605
+                $exercise_description = $all_specific_terms.' '.$this->description;
2606 2606
                 $ic_slide->addValue("content", $exercise_description);
2607 2607
 
2608 2608
                 $di = new ChamiloIndexer();
2609
-                isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
2609
+                isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english';
2610 2610
                 $di->connectDb(NULL, NULL, $lang);
2611
-                $di->remove_document((int)$se_ref['search_did']);
2611
+                $di->remove_document((int) $se_ref['search_did']);
2612 2612
                 $di->addChunk($ic_slide);
2613 2613
 
2614 2614
                 //index and return search engine document id
@@ -2633,7 +2633,7 @@  discard block
 block discarded – undo
2633 2633
     function search_engine_delete()
2634 2634
     {
2635 2635
         // remove from search engine if enabled
2636
-        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian') ) {
2636
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
2637 2637
             $course_id = api_get_course_id();
2638 2638
             $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
2639 2639
             $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level IS NULL LIMIT 1';
@@ -2641,19 +2641,19 @@  discard block
 block discarded – undo
2641 2641
             $res = Database::query($sql);
2642 2642
             if (Database::num_rows($res) > 0) {
2643 2643
                 $row = Database::fetch_array($res);
2644
-                require_once(api_get_path(LIBRARY_PATH) .'search/ChamiloIndexer.class.php');
2644
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
2645 2645
                 $di = new ChamiloIndexer();
2646
-                $di->remove_document((int)$row['search_did']);
2646
+                $di->remove_document((int) $row['search_did']);
2647 2647
                 unset($di);
2648 2648
                 $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
2649
-                foreach ( $this->questionList as $question_i) {
2649
+                foreach ($this->questionList as $question_i) {
2650 2650
                     $sql = 'SELECT type FROM %s WHERE id=%s';
2651 2651
                     $sql = sprintf($sql, $tbl_quiz_question, $question_i);
2652 2652
                     $qres = Database::query($sql);
2653 2653
                     if (Database::num_rows($qres) > 0) {
2654 2654
                         $qrow = Database::fetch_array($qres);
2655 2655
                         $objQuestion = Question::getInstance($qrow['type']);
2656
-                        $objQuestion = Question::read((int)$question_i);
2656
+                        $objQuestion = Question::read((int) $question_i);
2657 2657
                         $objQuestion->search_engine_edit($this->id, FALSE, TRUE);
2658 2658
                         unset($objQuestion);
2659 2659
                     }
@@ -2664,7 +2664,7 @@  discard block
 block discarded – undo
2664 2664
             Database::query($sql);
2665 2665
 
2666 2666
             // remove terms from db
2667
-            require_once api_get_path(LIBRARY_PATH) .'specific_fields_manager.lib.php';
2667
+            require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2668 2668
             delete_all_values_for_item($course_id, TOOL_QUIZ, $this->id);
2669 2669
         }
2670 2670
     }
@@ -2759,7 +2759,7 @@  discard block
 block discarded – undo
2759 2759
      */
2760 2760
     public function copy_exercise()
2761 2761
     {
2762
-        $exercise_obj= new Exercise();
2762
+        $exercise_obj = new Exercise();
2763 2763
         $exercise_obj = $this;
2764 2764
 
2765 2765
         // force the creation of a new exercise
@@ -2831,25 +2831,25 @@  discard block
 block discarded – undo
2831 2831
             $lp_id = 0;
2832 2832
         }
2833 2833
         if (empty($lp_item_id)) {
2834
-            $lp_item_id   = 0;
2834
+            $lp_item_id = 0;
2835 2835
         }
2836 2836
         if (empty($lp_item_view_id)) {
2837 2837
             $lp_item_view_id = 0;
2838 2838
         }
2839
-        $condition = ' WHERE exe_exo_id 	= ' . "'" . $this->id . "'" .' AND
2840
-					   exe_user_id 			= ' . "'" . api_get_user_id() . "'" . ' AND
2841
-					   c_id                 = ' . api_get_course_int_id() . ' AND
2842
-					   status 				= ' . "'" . Database::escape_string($status). "'" . ' AND
2843
-					   orig_lp_id 			= ' . "'" . $lp_id . "'" . ' AND
2844
-					   orig_lp_item_id 		= ' . "'" . $lp_item_id . "'" . ' AND
2845
-                       orig_lp_item_view_id = ' . "'" . $lp_item_view_id . "'" . ' AND
2846
-					   session_id 			= ' . "'" . api_get_session_id() . "' LIMIT 1"; //Adding limit 1 just in case
2839
+        $condition = ' WHERE exe_exo_id 	= '."'".$this->id."'".' AND
2840
+					   exe_user_id 			= ' . "'".api_get_user_id()."'".' AND
2841
+					   c_id                 = ' . api_get_course_int_id().' AND
2842
+					   status 				= ' . "'".Database::escape_string($status)."'".' AND
2843
+					   orig_lp_id 			= ' . "'".$lp_id."'".' AND
2844
+					   orig_lp_item_id 		= ' . "'".$lp_item_id."'".' AND
2845
+                       orig_lp_item_view_id = ' . "'".$lp_item_view_id."'".' AND
2846
+					   session_id 			= ' . "'".api_get_session_id()."' LIMIT 1"; //Adding limit 1 just in case
2847 2847
 
2848 2848
         $sql_track = 'SELECT * FROM '.$track_exercises.$condition;
2849 2849
 
2850 2850
         $result = Database::query($sql_track);
2851 2851
         $new_array = array();
2852
-        if (Database::num_rows($result) > 0 ) {
2852
+        if (Database::num_rows($result) > 0) {
2853 2853
             $new_array = Database::fetch_array($result, 'ASSOC');
2854 2854
             $new_array['num_exe'] = Database::num_rows($result);
2855 2855
         }
@@ -2892,12 +2892,12 @@  discard block
 block discarded – undo
2892 2892
         $questionList = array_map('intval', $questionList);
2893 2893
 
2894 2894
         $params = array(
2895
-            'exe_exo_id' => $this->id ,
2895
+            'exe_exo_id' => $this->id,
2896 2896
             'exe_user_id' => api_get_user_id(),
2897 2897
             'c_id' => api_get_course_int_id(),
2898 2898
             'status' =>  'incomplete',
2899 2899
             'session_id'  => api_get_session_id(),
2900
-            'data_tracking'  => implode(',', $questionList) ,
2900
+            'data_tracking'  => implode(',', $questionList),
2901 2901
             'start_date' => api_get_utc_datetime(),
2902 2902
             'orig_lp_id' => $safe_lp_id,
2903 2903
             'orig_lp_item_id'  => $safe_lp_item_id,
@@ -2929,7 +2929,7 @@  discard block
 block discarded – undo
2929 2929
         $nbrQuestions = $this->get_count_question_list();
2930 2930
 
2931 2931
         $all_button = $html = $label = '';
2932
-        $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']):null;
2932
+        $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null;
2933 2933
 
2934 2934
         if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) {
2935 2935
             $urlTitle = get_lang('ContinueTest');
@@ -2940,7 +2940,7 @@  discard block
 block discarded – undo
2940 2940
 
2941 2941
             $html .= Display::url(
2942 2942
                 $urlTitle,
2943
-                'exercise_submit_modal.php?' . http_build_query([
2943
+                'exercise_submit_modal.php?'.http_build_query([
2944 2944
                     'learnpath_id' => $safe_lp_id,
2945 2945
                     'learnpath_item_id' => $safe_lp_item_id,
2946 2946
                     'learnpath_item_view_id' => $safe_lp_item_view_id,
@@ -2957,7 +2957,7 @@  discard block
 block discarded – undo
2957 2957
                     'data-size' => 'md'
2958 2958
                 ]
2959 2959
             );
2960
-            $html .='<br />';
2960
+            $html .= '<br />';
2961 2961
         } else {
2962 2962
             // User
2963 2963
             if (api_is_allowed_to_session_edit()) {
@@ -2982,7 +2982,7 @@  discard block
 block discarded – undo
2982 2982
 
2983 2983
                     //Next question
2984 2984
                     if (!empty($questions_in_media)) {
2985
-                        $questions_in_media = "['".implode("','",$questions_in_media)."']";
2985
+                        $questions_in_media = "['".implode("','", $questions_in_media)."']";
2986 2986
                         $all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_question_list('.$questions_in_media.'); ">'.$label.'</a>';
2987 2987
                     } else {
2988 2988
                         $all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.', \'\', \''.$currentAnswer.'\'); ">'.$label.'</a>';
@@ -3000,7 +3000,7 @@  discard block
 block discarded – undo
3000 3000
                     }
3001 3001
 					$class .= ' question-validate-btn'; // used to select it with jquery
3002 3002
                     $all_button = '&nbsp;<a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>';
3003
-                    $all_button .= '&nbsp;' . Display::span(null, ['id' => 'save_all_reponse']);
3003
+                    $all_button .= '&nbsp;'.Display::span(null, ['id' => 'save_all_reponse']);
3004 3004
                     $html .= $all_button;
3005 3005
                 }
3006 3006
             }
@@ -3243,8 +3243,8 @@  discard block
 block discarded – undo
3243 3243
             $params = array();
3244 3244
             $params['course_id'] = $course_id;
3245 3245
             $params['session_id'] = api_get_session_id();
3246
-            $params['user_id'] = isset($exe_info['exe_user_id'])? $exe_info['exe_user_id'] : api_get_user_id();
3247
-            $params['exercise_id'] = isset($exe_info['exe_exo_id'])? $exe_info['exe_exo_id'] : $this->id;
3246
+            $params['user_id'] = isset($exe_info['exe_user_id']) ? $exe_info['exe_user_id'] : api_get_user_id();
3247
+            $params['exercise_id'] = isset($exe_info['exe_exo_id']) ? $exe_info['exe_exo_id'] : $this->id;
3248 3248
             $params['question_id'] = $questionId;
3249 3249
             $params['exe_id'] = isset($exe_info['exe_id']) ? $exe_info['exe_id'] : $exeId;
3250 3250
 
@@ -3297,7 +3297,7 @@  discard block
 block discarded – undo
3297 3297
             $answer = $objAnswerTmp->selectAnswer($answerId);
3298 3298
             $answerComment = $objAnswerTmp->selectComment($answerId);
3299 3299
             $answerCorrect = $objAnswerTmp->isCorrect($answerId);
3300
-            $answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId);
3300
+            $answerWeighting = (float) $objAnswerTmp->selectWeighting($answerId);
3301 3301
             $answerAutoId = $objAnswerTmp->selectAutoId($answerId);
3302 3302
 
3303 3303
             if ($debug) {
@@ -3307,7 +3307,7 @@  discard block
 block discarded – undo
3307 3307
 
3308 3308
             // Delineation
3309 3309
             $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
3310
-            $answer_delineation_destination=$objAnswerTmp->selectDestination(1);
3310
+            $answer_delineation_destination = $objAnswerTmp->selectDestination(1);
3311 3311
 
3312 3312
             switch ($answerType) {
3313 3313
                 // for unique answer
@@ -3320,7 +3320,7 @@  discard block
 block discarded – undo
3320 3320
                                     exe_id = '".$exeId."' AND
3321 3321
                                     question_id= '".$questionId."'";
3322 3322
                         $result = Database::query($sql);
3323
-                        $choice = Database::result($result,0,"answer");
3323
+                        $choice = Database::result($result, 0, "answer");
3324 3324
 
3325 3325
                         $studentChoice = $choice == $answerAutoId ? 1 : 0;
3326 3326
                         if ($studentChoice) {
@@ -3371,7 +3371,7 @@  discard block
 block discarded – undo
3371 3371
                     } else {
3372 3372
                         // If no result then the user just hit don't know
3373 3373
                         $studentChoice = 3;
3374
-                        $questionScore  +=  $doubt_score;
3374
+                        $questionScore += $doubt_score;
3375 3375
                     }
3376 3376
                     $totalScore = $questionScore;
3377 3377
                     break;
@@ -3387,17 +3387,17 @@  discard block
 block discarded – undo
3387 3387
                         }
3388 3388
 
3389 3389
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3390
-                        $real_answers[$answerId] = (bool)$studentChoice;
3390
+                        $real_answers[$answerId] = (bool) $studentChoice;
3391 3391
 
3392 3392
                         if ($studentChoice) {
3393
-                            $questionScore  +=$answerWeighting;
3393
+                            $questionScore += $answerWeighting;
3394 3394
                         }
3395 3395
                     } else {
3396 3396
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3397
-                        $real_answers[$answerId] = (bool)$studentChoice;
3397
+                        $real_answers[$answerId] = (bool) $studentChoice;
3398 3398
 
3399 3399
                         if (isset($studentChoice)) {
3400
-                            $questionScore  += $answerWeighting;
3400
+                            $questionScore += $answerWeighting;
3401 3401
                         }
3402 3402
                     }
3403 3403
                     $totalScore += $answerWeighting;
@@ -3415,16 +3415,16 @@  discard block
 block discarded – undo
3415 3415
                             $choice[$ind] = 1;
3416 3416
                         }
3417 3417
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3418
-                        $real_answers[$answerId] = (bool)$studentChoice;
3418
+                        $real_answers[$answerId] = (bool) $studentChoice;
3419 3419
                         if ($studentChoice) {
3420
-                            $questionScore +=$answerWeighting;
3420
+                            $questionScore += $answerWeighting;
3421 3421
                         }
3422 3422
                     } else {
3423 3423
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3424 3424
                         if (isset($studentChoice)) {
3425 3425
                             $questionScore += $answerWeighting;
3426 3426
                         }
3427
-                        $real_answers[$answerId] = (bool)$studentChoice;
3427
+                        $real_answers[$answerId] = (bool) $studentChoice;
3428 3428
                     }
3429 3429
                     $totalScore += $answerWeighting;
3430 3430
                     if ($debug) error_log("studentChoice: $studentChoice");
@@ -3436,7 +3436,7 @@  discard block
 block discarded – undo
3436 3436
                         $resultans = Database::query($sql);
3437 3437
                         while ($row = Database::fetch_array($resultans)) {
3438 3438
                             $ind = $row['answer'];
3439
-                            $result = explode(':',$ind);
3439
+                            $result = explode(':', $ind);
3440 3440
                             if (isset($result[0])) {
3441 3441
                                 $my_answer_id = isset($result[0]) ? $result[0] : '';
3442 3442
                                 $option = isset($result[1]) ? $result[1] : '';
@@ -3556,10 +3556,10 @@  discard block
 block discarded – undo
3556 3556
                             }
3557 3557
                             // adds the piece of text that is before the blank
3558 3558
                             //and ends with '[' into a general storage array
3559
-                            $real_text[] = api_substr($temp, 0, $pos +1);
3560
-                            $answer .= api_substr($temp, 0, $pos +1);
3559
+                            $real_text[] = api_substr($temp, 0, $pos + 1);
3560
+                            $answer .= api_substr($temp, 0, $pos + 1);
3561 3561
                             //take the string remaining (after the last "[" we found)
3562
-                            $temp = api_substr($temp, $pos +1);
3562
+                            $temp = api_substr($temp, $pos + 1);
3563 3563
                             // quit the loop if there are no more blanks, and update $pos to the position of next ']'
3564 3564
                             if (($pos = api_strpos($temp, ']')) === false) {
3565 3565
                                 // adds the end of the text
@@ -3595,7 +3595,7 @@  discard block
 block discarded – undo
3595 3595
                             //put the contents of the [] answer tag into correct_tags[]
3596 3596
                             $correct_tags[] = api_substr($temp, 0, $pos);
3597 3597
                             $j++;
3598
-                            $temp = api_substr($temp, $pos +1);
3598
+                            $temp = api_substr($temp, $pos + 1);
3599 3599
                         }
3600 3600
                         $answer = '';
3601 3601
                         $real_correct_tags = $correct_tags;
@@ -3618,7 +3618,7 @@  discard block
 block discarded – undo
3618 3618
                                 } elseif (!empty($user_tags[$i])) {
3619 3619
                                     // else if the word entered by the student IS NOT the same as the one defined by the professor
3620 3620
                                     // adds the word in red at the end of the string, and strikes it
3621
-                                    $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>';
3621
+                                    $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>';
3622 3622
                                 } else {
3623 3623
                                     // adds a tabulation if no word has been typed by the student
3624 3624
                                     $answer .= ''; // remove &nbsp; that causes issue
@@ -3637,17 +3637,17 @@  discard block
 block discarded – undo
3637 3637
                                 } elseif (!empty ($user_tags[$i])) {
3638 3638
                                     // else if the word entered by the student IS NOT the same as the one defined by the professor
3639 3639
                                     // adds the word in red at the end of the string, and strikes it
3640
-                                    $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>';
3640
+                                    $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>';
3641 3641
                                 } else {
3642 3642
                                     // adds a tabulation if no word has been typed by the student
3643
-                                    $answer .= '';  // remove &nbsp; that causes issue
3643
+                                    $answer .= ''; // remove &nbsp; that causes issue
3644 3644
                                 }
3645 3645
                             }
3646 3646
 
3647 3647
                             // adds the correct word, followed by ] to close the blank
3648
-                            $answer .= ' / <font color="green"><b>' . $real_correct_tags[$i] . '</b></font>]';
3649
-                            if (isset($real_text[$i +1])) {
3650
-                                $answer .= $real_text[$i +1];
3648
+                            $answer .= ' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]';
3649
+                            if (isset($real_text[$i + 1])) {
3650
+                                $answer .= $real_text[$i + 1];
3651 3651
                             }
3652 3652
                         }
3653 3653
                     } else {
@@ -3771,10 +3771,10 @@  discard block
 block discarded – undo
3771 3771
                         }
3772 3772
                         // adds the piece of text that is before the blank
3773 3773
                         //and ends with '[' into a general storage array
3774
-                        $realText[] = api_substr($temp, 0, $pos +1);
3775
-                        $answer .= api_substr($temp, 0, $pos +1);
3774
+                        $realText[] = api_substr($temp, 0, $pos + 1);
3775
+                        $answer .= api_substr($temp, 0, $pos + 1);
3776 3776
                         //take the string remaining (after the last "[" we found)
3777
-                        $temp = api_substr($temp, $pos +1);
3777
+                        $temp = api_substr($temp, $pos + 1);
3778 3778
                         // quit the loop if there are no more blanks, and update $pos to the position of next ']'
3779 3779
                         if (($pos = api_strpos($temp, ']')) === false) {
3780 3780
                             // adds the end of the text
@@ -3815,7 +3815,7 @@  discard block
 block discarded – undo
3815 3815
                         //put the contents of the [] answer tag into correct_tags[]
3816 3816
                         $correctTags[] = api_substr($temp, 0, $pos);
3817 3817
                         $j++;
3818
-                        $temp = api_substr($temp, $pos +1);
3818
+                        $temp = api_substr($temp, $pos + 1);
3819 3819
                     }
3820 3820
                     $answer = '';
3821 3821
                     $realCorrectTags = $correctTags;
@@ -3835,7 +3835,7 @@  discard block
 block discarded – undo
3835 3835
                         } elseif (!empty($userTags[$i])) {
3836 3836
                             // else if the word entered by the student IS NOT the same as the one defined by the professor
3837 3837
                             // adds the word in red at the end of the string, and strikes it
3838
-                            $answer .= '<font color="red"><s>' . $userTags[$i] . '</s></font>';
3838
+                            $answer .= '<font color="red"><s>'.$userTags[$i].'</s></font>';
3839 3839
                         } else {
3840 3840
                             // adds a tabulation if no word has been typed by the student
3841 3841
                             $answer .= ''; // remove &nbsp; that causes issue
@@ -3845,19 +3845,19 @@  discard block
 block discarded – undo
3845 3845
                         if (
3846 3846
                             $this->results_disabled != EXERCISE_FEEDBACK_TYPE_EXAM
3847 3847
                         ) {
3848
-                            $answer .= ' / <font color="green"><b>' . $realCorrectTags[$i] . '</b></font>';
3848
+                            $answer .= ' / <font color="green"><b>'.$realCorrectTags[$i].'</b></font>';
3849 3849
                         }
3850 3850
 
3851 3851
                         $answer .= ']';
3852 3852
 
3853
-                        if (isset($realText[$i +1])) {
3854
-                            $answer .= $realText[$i +1];
3853
+                        if (isset($realText[$i + 1])) {
3854
+                            $answer .= $realText[$i + 1];
3855 3855
                         }
3856 3856
                     }
3857 3857
                     break;
3858 3858
                 case FREE_ANSWER:
3859 3859
                     if ($from_database) {
3860
-                        $query  = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3860
+                        $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3861 3861
                                    WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3862 3862
                         $resq = Database::query($query);
3863 3863
                         $data = Database::fetch_array($resq);
@@ -3868,9 +3868,9 @@  discard block
 block discarded – undo
3868 3868
                         $questionScore = $data['marks'];
3869 3869
 
3870 3870
                         if ($questionScore == -1) {
3871
-                            $totalScore+= 0;
3871
+                            $totalScore += 0;
3872 3872
                         } else {
3873
-                            $totalScore+= $questionScore;
3873
+                            $totalScore += $questionScore;
3874 3874
                         }
3875 3875
                         if ($questionScore == '') {
3876 3876
                             $questionScore = 0;
@@ -3891,14 +3891,14 @@  discard block
 block discarded – undo
3891 3891
                         $query  = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3892 3892
                                    WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3893 3893
                         $resq   = Database::query($query);
3894
-                        $choice = Database::result($resq,0,'answer');
3894
+                        $choice = Database::result($resq, 0, 'answer');
3895 3895
                         $choice = str_replace('\r\n', '', $choice);
3896 3896
                         $choice = stripslashes($choice);
3897
-                        $questionScore = Database::result($resq,0,"marks");
3897
+                        $questionScore = Database::result($resq, 0, "marks");
3898 3898
                         if ($questionScore == -1) {
3899
-                            $totalScore+=0;
3899
+                            $totalScore += 0;
3900 3900
                         } else {
3901
-                            $totalScore+=$questionScore;
3901
+                            $totalScore += $questionScore;
3902 3902
                         }
3903 3903
                         $arrques = $questionName;
3904 3904
                         $arrans  = $choice;
@@ -3943,7 +3943,7 @@  discard block
 block discarded – undo
3943 3943
 
3944 3944
                         while ($a_answers = Database::fetch_array($res_answers)) {
3945 3945
                             $i_answer_id = $a_answers['id']; //3
3946
-                            $s_answer_label = $a_answers['answer'];  // your daddy - your mother
3946
+                            $s_answer_label = $a_answers['answer']; // your daddy - your mother
3947 3947
                             $i_answer_correct_answer = $a_answers['correct']; //1 - 2
3948 3948
                             $i_answer_id_auto = $a_answers['id_auto']; // 3 - 4
3949 3949
 
@@ -3998,8 +3998,8 @@  discard block
 block discarded – undo
3998 3998
                                     $user_answer = '';
3999 3999
                                 }
4000 4000
                                 echo '<tr>';
4001
-                                echo '<td>' . $s_answer_label . '</td>';
4002
-                                echo '<td>' . $user_answer;
4001
+                                echo '<td>'.$s_answer_label.'</td>';
4002
+                                echo '<td>'.$user_answer;
4003 4003
 
4004 4004
                                 if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
4005 4005
                                     if (isset($real_list[$i_answer_correct_answer]) && $showTotalScoreAndUserChoices == false) {
@@ -4107,7 +4107,7 @@  discard block
 block discarded – undo
4107 4107
                     if ($from_database) {
4108 4108
                         // getting the user answer
4109 4109
                         $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
4110
-                        $query   = "SELECT hotspot_correct, hotspot_coordinate
4110
+                        $query = "SELECT hotspot_correct, hotspot_coordinate
4111 4111
                                     FROM $TBL_TRACK_HOTSPOT
4112 4112
                                     WHERE
4113 4113
                                         hotspot_exe_id = '".$exeId."' AND
@@ -4115,20 +4115,20 @@  discard block
 block discarded – undo
4115 4115
                                         hotspot_answer_id='1'";
4116 4116
                         //by default we take 1 because it's a delineation
4117 4117
                         $resq = Database::query($query);
4118
-                        $row = Database::fetch_array($resq,'ASSOC');
4118
+                        $row = Database::fetch_array($resq, 'ASSOC');
4119 4119
 
4120 4120
                         $choice = $row['hotspot_correct'];
4121 4121
                         $user_answer = $row['hotspot_coordinate'];
4122 4122
 
4123 4123
                         // THIS is very important otherwise the poly_compile will throw an error!!
4124 4124
                         // round-up the coordinates
4125
-                        $coords = explode('/',$user_answer);
4125
+                        $coords = explode('/', $user_answer);
4126 4126
                         $user_array = '';
4127 4127
                         foreach ($coords as $coord) {
4128
-                            list($x,$y) = explode(';',$coord);
4128
+                            list($x, $y) = explode(';', $coord);
4129 4129
                             $user_array .= round($x).';'.round($y).'/';
4130 4130
                         }
4131
-                        $user_array = substr($user_array,0,-1);
4131
+                        $user_array = substr($user_array, 0, -1);
4132 4132
                     } else {
4133 4133
                         if (!empty($studentChoice)) {
4134 4134
                             $newquestionList[] = $questionId;
@@ -4138,7 +4138,7 @@  discard block
 block discarded – undo
4138 4138
                             $studentChoice = $choice[$answerId];
4139 4139
                             $questionScore += $answerWeighting;
4140 4140
 
4141
-                            if ($hotspot_delineation_result[1]==1) {
4141
+                            if ($hotspot_delineation_result[1] == 1) {
4142 4142
                                 $totalScore += $answerWeighting; //adding the total
4143 4143
                             }
4144 4144
                         }
@@ -4277,13 +4277,13 @@  discard block
 block discarded – undo
4277 4277
                             $user_answer = $_SESSION['exerciseResultCoordinates'][$questionId];
4278 4278
 
4279 4279
                             //round-up the coordinates
4280
-                            $coords = explode('/',$user_answer);
4280
+                            $coords = explode('/', $user_answer);
4281 4281
                             $user_array = '';
4282 4282
                             foreach ($coords as $coord) {
4283
-                                list($x,$y) = explode(';',$coord);
4283
+                                list($x, $y) = explode(';', $coord);
4284 4284
                                 $user_array .= round($x).';'.round($y).'/';
4285 4285
                             }
4286
-                            $user_array = substr($user_array,0,-1);
4286
+                            $user_array = substr($user_array, 0, -1);
4287 4287
 
4288 4288
                             if ($next) {
4289 4289
 
@@ -4310,7 +4310,7 @@  discard block
 block discarded – undo
4310 4310
                                 //$overlap = round(polygons_overlap($poly_answer,$poly_user));
4311 4311
                                 // //this is an area in pixels
4312 4312
                                 if ($debug > 0) {
4313
-                                    error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0);
4313
+                                    error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0);
4314 4314
                                 }
4315 4315
 
4316 4316
                                 if ($overlap < 1) {
@@ -4323,43 +4323,43 @@  discard block
 block discarded – undo
4323 4323
                                     // that is overlapped by the user's polygon
4324 4324
                                     $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
4325 4325
                                     if ($debug > 1) {
4326
-                                        error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
4326
+                                        error_log(__LINE__.' - Final overlap is '.$final_overlap, 0);
4327 4327
                                     }
4328 4328
                                     // the final missing area is the percentage of the initial polygon
4329 4329
                                     // that is not overlapped by the user's polygon
4330 4330
                                     $final_missing = 100 - $final_overlap;
4331 4331
                                     if ($debug > 1) {
4332
-                                        error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
4332
+                                        error_log(__LINE__.' - Final missing is '.$final_missing, 0);
4333 4333
                                     }
4334 4334
                                     // the final excess area is the percentage of the initial polygon's size
4335 4335
                                     // that is covered by the user's polygon outside of the initial polygon
4336 4336
                                     $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
4337 4337
                                     if ($debug > 1) {
4338
-                                        error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0);
4338
+                                        error_log(__LINE__.' - Final excess is '.$final_excess, 0);
4339 4339
                                     }
4340 4340
                                 }
4341 4341
 
4342 4342
                                 //checking the destination parameters parsing the "@@"
4343
-                                $destination_items= explode('@@', $answerDestination);
4343
+                                $destination_items = explode('@@', $answerDestination);
4344 4344
                                 $threadhold_total = $destination_items[0];
4345
-                                $threadhold_items=explode(';',$threadhold_total);
4345
+                                $threadhold_items = explode(';', $threadhold_total);
4346 4346
                                 $threadhold1 = $threadhold_items[0]; // overlap
4347 4347
                                 $threadhold2 = $threadhold_items[1]; // excess
4348
-                                $threadhold3 = $threadhold_items[2];	 //missing
4348
+                                $threadhold3 = $threadhold_items[2]; //missing
4349 4349
 
4350 4350
                                 // if is delineation
4351
-                                if ($answerId===1) {
4351
+                                if ($answerId === 1) {
4352 4352
                                     //setting colors
4353
-                                    if ($final_overlap>=$threadhold1) {
4354
-                                        $overlap_color=true; //echo 'a';
4353
+                                    if ($final_overlap >= $threadhold1) {
4354
+                                        $overlap_color = true; //echo 'a';
4355 4355
                                     }
4356 4356
                                     //echo $excess.'-'.$threadhold2;
4357
-                                    if ($final_excess<=$threadhold2) {
4358
-                                        $excess_color=true; //echo 'b';
4357
+                                    if ($final_excess <= $threadhold2) {
4358
+                                        $excess_color = true; //echo 'b';
4359 4359
                                     }
4360 4360
                                     //echo '--------'.$missing.'-'.$threadhold3;
4361
-                                    if ($final_missing<=$threadhold3) {
4362
-                                        $missing_color=true; //echo 'c';
4361
+                                    if ($final_missing <= $threadhold3) {
4362
+                                        $missing_color = true; //echo 'c';
4363 4363
                                     }
4364 4364
 
4365 4365
                                     // if pass
@@ -4368,67 +4368,67 @@  discard block
 block discarded – undo
4368 4368
                                         $final_missing <= $threadhold3 &&
4369 4369
                                         $final_excess <= $threadhold2
4370 4370
                                     ) {
4371
-                                        $next=1; //go to the oars
4372
-                                        $result_comment=get_lang('Acceptable');
4373
-                                        $final_answer = 1;	// do not update with  update_exercise_attempt
4371
+                                        $next = 1; //go to the oars
4372
+                                        $result_comment = get_lang('Acceptable');
4373
+                                        $final_answer = 1; // do not update with  update_exercise_attempt
4374 4374
                                     } else {
4375
-                                        $next=0;
4376
-                                        $result_comment=get_lang('Unacceptable');
4377
-                                        $comment=$answerDestination=$objAnswerTmp->selectComment(1);
4378
-                                        $answerDestination=$objAnswerTmp->selectDestination(1);
4375
+                                        $next = 0;
4376
+                                        $result_comment = get_lang('Unacceptable');
4377
+                                        $comment = $answerDestination = $objAnswerTmp->selectComment(1);
4378
+                                        $answerDestination = $objAnswerTmp->selectDestination(1);
4379 4379
                                         //checking the destination parameters parsing the "@@"
4380
-                                        $destination_items= explode('@@', $answerDestination);
4380
+                                        $destination_items = explode('@@', $answerDestination);
4381 4381
                                     }
4382
-                                } elseif($answerId>1) {
4382
+                                } elseif ($answerId > 1) {
4383 4383
                                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
4384
-                                        if ($debug>0) {
4385
-                                            error_log(__LINE__.' - answerId is of type noerror',0);
4384
+                                        if ($debug > 0) {
4385
+                                            error_log(__LINE__.' - answerId is of type noerror', 0);
4386 4386
                                         }
4387 4387
                                         //type no error shouldn't be treated
4388 4388
                                         $next = 1;
4389 4389
                                         continue;
4390 4390
                                     }
4391
-                                    if ($debug>0) {
4392
-                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);
4391
+                                    if ($debug > 0) {
4392
+                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
4393 4393
                                     }
4394 4394
                                     //check the intersection between the oar and the user
4395 4395
                                     //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
4396 4396
                                     //echo 'official';print_r($x_list);print_r($y_list);
4397 4397
                                     //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
4398
-                                    $inter= $result['success'];
4398
+                                    $inter = $result['success'];
4399 4399
 
4400 4400
                                     //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
4401
-                                    $delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
4401
+                                    $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId);
4402 4402
 
4403
-                                    $poly_answer = convert_coordinates($delineation_cord,'|');
4404
-                                    $max_coord = poly_get_max($poly_user,$poly_answer);
4405
-                                    $poly_answer_compiled = poly_compile($poly_answer,$max_coord);
4406
-                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
4403
+                                    $poly_answer = convert_coordinates($delineation_cord, '|');
4404
+                                    $max_coord = poly_get_max($poly_user, $poly_answer);
4405
+                                    $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
4406
+                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
4407 4407
 
4408 4408
                                     if ($overlap == false) {
4409 4409
                                         //all good, no overlap
4410 4410
                                         $next = 1;
4411 4411
                                         continue;
4412 4412
                                     } else {
4413
-                                        if ($debug>0) {
4414
-                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);
4413
+                                        if ($debug > 0) {
4414
+                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0);
4415 4415
                                         }
4416 4416
                                         $organs_at_risk_hit++;
4417 4417
                                         //show the feedback
4418
-                                        $next=0;
4419
-                                        $comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
4420
-                                        $answerDestination=$objAnswerTmp->selectDestination($answerId);
4421
-
4422
-                                        $destination_items= explode('@@', $answerDestination);
4423
-                                        $try_hotspot=$destination_items[1];
4424
-                                        $lp_hotspot=$destination_items[2];
4425
-                                        $select_question_hotspot=$destination_items[3];
4426
-                                        $url_hotspot=$destination_items[4];
4418
+                                        $next = 0;
4419
+                                        $comment = $answerDestination = $objAnswerTmp->selectComment($answerId);
4420
+                                        $answerDestination = $objAnswerTmp->selectDestination($answerId);
4421
+
4422
+                                        $destination_items = explode('@@', $answerDestination);
4423
+                                        $try_hotspot = $destination_items[1];
4424
+                                        $lp_hotspot = $destination_items[2];
4425
+                                        $select_question_hotspot = $destination_items[3];
4426
+                                        $url_hotspot = $destination_items[4];
4427 4427
                                     }
4428 4428
                                 }
4429 4429
                             } else {	// the first delineation feedback
4430
-                                if ($debug>0) {
4431
-                                    error_log(__LINE__.' first',0);
4430
+                                if ($debug > 0) {
4431
+                                    error_log(__LINE__.' first', 0);
4432 4432
                                 }
4433 4433
                             }
4434 4434
                         } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
@@ -4436,7 +4436,7 @@  discard block
 block discarded – undo
4436 4436
                             echo Display::tag('td', $answerMatching[$answerId]);
4437 4437
                             echo Display::tag(
4438 4438
                                 'td',
4439
-                                "$user_answer / " . Display::tag(
4439
+                                "$user_answer / ".Display::tag(
4440 4440
                                     'strong',
4441 4441
                                     $answerMatching[$answerCorrect],
4442 4442
                                     ['style' => 'color: #008000; font-weight: bold;']
@@ -4588,7 +4588,7 @@  discard block
 block discarded – undo
4588 4588
                                     $questionId,
4589 4589
                                     $nano,
4590 4590
                                     $results_disabled
4591
-                                ) . '</td>
4591
+                                ).'</td>
4592 4592
                                 </tr>
4593 4593
                                 </table>';
4594 4594
                             break;
@@ -4650,7 +4650,7 @@  discard block
 block discarded – undo
4650 4650
 
4651 4651
                                 //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
4652 4652
                                 if ($debug > 0) {
4653
-                                    error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0);
4653
+                                    error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0);
4654 4654
                                 }
4655 4655
                                 if ($overlap < 1) {
4656 4656
                                     //shortcut to avoid complicated calculations
@@ -4661,17 +4661,17 @@  discard block
 block discarded – undo
4661 4661
                                     // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
4662 4662
                                     $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
4663 4663
                                     if ($debug > 1) {
4664
-                                        error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
4664
+                                        error_log(__LINE__.' - Final overlap is '.$final_overlap, 0);
4665 4665
                                     }
4666 4666
                                     // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
4667 4667
                                     $final_missing = 100 - $final_overlap;
4668 4668
                                     if ($debug > 1) {
4669
-                                        error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
4669
+                                        error_log(__LINE__.' - Final missing is '.$final_missing, 0);
4670 4670
                                     }
4671 4671
                                     // the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
4672 4672
                                     $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
4673 4673
                                     if ($debug > 1) {
4674
-                                        error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0);
4674
+                                        error_log(__LINE__.' - Final excess is '.$final_excess, 0);
4675 4675
                                     }
4676 4676
                                 }
4677 4677
 
@@ -4681,7 +4681,7 @@  discard block
 block discarded – undo
4681 4681
                                 $threadhold_items = explode(';', $threadhold_total);
4682 4682
                                 $threadhold1 = $threadhold_items[0]; // overlap
4683 4683
                                 $threadhold2 = $threadhold_items[1]; // excess
4684
-                                $threadhold3 = $threadhold_items[2];  //missing
4684
+                                $threadhold3 = $threadhold_items[2]; //missing
4685 4685
                                 // if is delineation
4686 4686
                                 if ($answerId === 1) {
4687 4687
                                     //setting colors
@@ -4713,14 +4713,14 @@  discard block
 block discarded – undo
4713 4713
                                 } elseif ($answerId > 1) {
4714 4714
                                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
4715 4715
                                         if ($debug > 0) {
4716
-                                            error_log(__LINE__ . ' - answerId is of type noerror', 0);
4716
+                                            error_log(__LINE__.' - answerId is of type noerror', 0);
4717 4717
                                         }
4718 4718
                                         //type no error shouldn't be treated
4719 4719
                                         $next = 1;
4720 4720
                                         continue;
4721 4721
                                     }
4722 4722
                                     if ($debug > 0) {
4723
-                                        error_log(__LINE__ . ' - answerId is >1 so we\'re probably in OAR', 0);
4723
+                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
4724 4724
                                     }
4725 4725
                                     //check the intersection between the oar and the user
4726 4726
                                     //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
@@ -4734,7 +4734,7 @@  discard block
 block discarded – undo
4734 4734
                                     $poly_answer = convert_coordinates($delineation_cord, '|');
4735 4735
                                     $max_coord = poly_get_max($poly_user, $poly_answer);
4736 4736
                                     $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
4737
-                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
4737
+                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
4738 4738
 
4739 4739
                                     if ($overlap == false) {
4740 4740
                                         //all good, no overlap
@@ -4742,7 +4742,7 @@  discard block
 block discarded – undo
4742 4742
                                         continue;
4743 4743
                                     } else {
4744 4744
                                         if ($debug > 0) {
4745
-                                            error_log(__LINE__ . ' - Overlap is ' . $overlap . ': OAR hit', 0);
4745
+                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0);
4746 4746
                                         }
4747 4747
                                         $organs_at_risk_hit++;
4748 4748
                                         //show the feedback
@@ -4754,12 +4754,12 @@  discard block
 block discarded – undo
4754 4754
                                         $try_hotspot = $destination_items[1];
4755 4755
                                         $lp_hotspot = $destination_items[2];
4756 4756
                                         $select_question_hotspot = $destination_items[3];
4757
-                                        $url_hotspot=$destination_items[4];
4757
+                                        $url_hotspot = $destination_items[4];
4758 4758
                                     }
4759 4759
                                 }
4760 4760
                             } else {	// the first delineation feedback
4761 4761
                                 if ($debug > 0) {
4762
-                                    error_log(__LINE__ . ' first', 0);
4762
+                                    error_log(__LINE__.' first', 0);
4763 4763
                                 }
4764 4764
                             }
4765 4765
                             break;
@@ -4781,7 +4781,7 @@  discard block
 block discarded – undo
4781 4781
                             echo Display::tag('td', $answerMatching[$answerId]);
4782 4782
                             echo Display::tag(
4783 4783
                                 'td',
4784
-                                "$user_answer / " . Display::tag(
4784
+                                "$user_answer / ".Display::tag(
4785 4785
                                     'strong',
4786 4786
                                     $answerMatching[$answerCorrect],
4787 4787
                                     ['style' => 'color: #008000; font-weight: bold;']
@@ -4867,7 +4867,7 @@  discard block
 block discarded – undo
4867 4867
             //  we use the results from the session (from_db=0)
4868 4868
             // TODO Change this, because it is wrong to show the user
4869 4869
             //  some results that haven't been stored in the database yet
4870
-            if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) {
4870
+            if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION) {
4871 4871
 
4872 4872
                 if ($debug) error_log('$from AND this is a hotspot kind of question ');
4873 4873
 
@@ -4876,19 +4876,19 @@  discard block
 block discarded – undo
4876 4876
                 if ($answerType == HOT_SPOT_DELINEATION) {
4877 4877
                     if (0) {
4878 4878
                         if ($overlap_color) {
4879
-                            $overlap_color='green';
4879
+                            $overlap_color = 'green';
4880 4880
                         } else {
4881
-                            $overlap_color='red';
4881
+                            $overlap_color = 'red';
4882 4882
                         }
4883 4883
                         if ($missing_color) {
4884
-                            $missing_color='green';
4884
+                            $missing_color = 'green';
4885 4885
                         } else {
4886
-                            $missing_color='red';
4886
+                            $missing_color = 'red';
4887 4887
                         }
4888 4888
                         if ($excess_color) {
4889
-                            $excess_color='green';
4889
+                            $excess_color = 'green';
4890 4890
                         } else {
4891
-                            $excess_color='red';
4891
+                            $excess_color = 'red';
4892 4892
                         }
4893 4893
                         if (!is_numeric($final_overlap)) {
4894 4894
                             $final_overlap = 0;
@@ -4900,33 +4900,33 @@  discard block
 block discarded – undo
4900 4900
                             $final_excess = 0;
4901 4901
                         }
4902 4902
 
4903
-                        if ($final_overlap>100) {
4903
+                        if ($final_overlap > 100) {
4904 4904
                             $final_overlap = 100;
4905 4905
                         }
4906 4906
 
4907
-                        $table_resume='<table class="data_table">
4907
+                        $table_resume = '<table class="data_table">
4908 4908
                                 <tr class="row_odd" >
4909 4909
                                     <td></td>
4910
-                                    <td ><b>' . get_lang('Requirements') . '</b></td>
4911
-                                    <td><b>' . get_lang('YourAnswer') . '</b></td>
4910
+                                    <td ><b>' . get_lang('Requirements').'</b></td>
4911
+                                    <td><b>' . get_lang('YourAnswer').'</b></td>
4912 4912
                                 </tr>
4913 4913
                                 <tr class="row_even">
4914
-                                    <td><b>' . get_lang('Overlap') . '</b></td>
4915
-                                    <td>' . get_lang('Min') . ' ' . $threadhold1 . '</td>
4916
-                                    <td><div style="color:' . $overlap_color . '">'
4917
-                                        . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '</div></td>
4914
+                                    <td><b>' . get_lang('Overlap').'</b></td>
4915
+                                    <td>' . get_lang('Min').' '.$threadhold1.'</td>
4916
+                                    <td><div style="color:' . $overlap_color.'">'
4917
+                                        . (($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td>
4918 4918
                                 </tr>
4919 4919
                                 <tr>
4920
-                                    <td><b>' . get_lang('Excess') . '</b></td>
4921
-                                    <td>' . get_lang('Max') . ' ' . $threadhold2 . '</td>
4922
-                                    <td><div style="color:' . $excess_color . '">'
4923
-                                        . (($final_excess < 0) ? 0 : intval($final_excess)) . '</div></td>
4920
+                                    <td><b>' . get_lang('Excess').'</b></td>
4921
+                                    <td>' . get_lang('Max').' '.$threadhold2.'</td>
4922
+                                    <td><div style="color:' . $excess_color.'">'
4923
+                                        . (($final_excess < 0) ? 0 : intval($final_excess)).'</div></td>
4924 4924
                                 </tr>
4925 4925
                                 <tr class="row_even">
4926
-                                    <td><b>' . get_lang('Missing') . '</b></td>
4927
-                                    <td>' . get_lang('Max') . ' ' . $threadhold3 . '</td>
4928
-                                    <td><div style="color:' . $missing_color . '">'
4929
-                                        . (($final_missing < 0) ? 0 : intval($final_missing)) . '</div></td>
4926
+                                    <td><b>' . get_lang('Missing').'</b></td>
4927
+                                    <td>' . get_lang('Max').' '.$threadhold3.'</td>
4928
+                                    <td><div style="color:' . $missing_color.'">'
4929
+                                        . (($final_missing < 0) ? 0 : intval($final_missing)).'</div></td>
4930 4930
                                 </tr>
4931 4931
                             </table>';
4932 4932
                         if ($next == 0) {
@@ -4941,20 +4941,20 @@  discard block
 block discarded – undo
4941 4941
                             $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
4942 4942
                         }
4943 4943
 
4944
-                        echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1>
4944
+                        echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>
4945 4945
                             <p style="text-align:center">';
4946 4946
 
4947
-                        $message = '<p>' . get_lang('YourDelineation') . '</p>';
4947
+                        $message = '<p>'.get_lang('YourDelineation').'</p>';
4948 4948
                         $message .= $table_resume;
4949
-                        $message .= '<br />' . get_lang('ResultIs') . ' ' . $result_comment . '<br />';
4949
+                        $message .= '<br />'.get_lang('ResultIs').' '.$result_comment.'<br />';
4950 4950
                         if ($organs_at_risk_hit > 0) {
4951
-                            $message .= '<p><b>' . get_lang('OARHit') . '</b></p>';
4951
+                            $message .= '<p><b>'.get_lang('OARHit').'</b></p>';
4952 4952
                         }
4953
-                        $message .='<p>' . $comment . '</p>';
4953
+                        $message .= '<p>'.$comment.'</p>';
4954 4954
                         echo $message;
4955 4955
                     } else {
4956 4956
                         echo $hotspot_delineation_result[0]; //prints message
4957
-                        $from_database = 1;  // the hotspot_solution.swf needs this variable
4957
+                        $from_database = 1; // the hotspot_solution.swf needs this variable
4958 4958
                     }
4959 4959
 
4960 4960
                     //save the score attempts
@@ -4976,20 +4976,20 @@  discard block
 block discarded – undo
4976 4976
                             $exerciseResultCoordinates[$quesId]
4977 4977
                         );
4978 4978
                     } else {
4979
-                        if ($final_answer==0) {
4979
+                        if ($final_answer == 0) {
4980 4980
                             $questionScore = 0;
4981
-                            $answer=0;
4981
+                            $answer = 0;
4982 4982
                             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
4983 4983
                             if (is_array($exerciseResultCoordinates[$quesId])) {
4984
-                                foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
4985
-                                    Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,0,$val);
4984
+                                foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
4985
+                                    Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, 0, $val);
4986 4986
                                 }
4987 4987
                             }
4988 4988
                         } else {
4989 4989
                             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
4990 4990
                             if (is_array($exerciseResultCoordinates[$quesId])) {
4991
-                                foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
4992
-                                    Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,$choice[$idx],$val);
4991
+                                foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
4992
+                                    Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, $choice[$idx], $val);
4993 4993
                                 }
4994 4994
                             }
4995 4995
                         }
@@ -5008,7 +5008,7 @@  discard block
 block discarded – undo
5008 5008
                     echo "
5009 5009
                         <tr>
5010 5010
                             <td colspan=\"2\">
5011
-                                <p><em>" . get_lang('HotSpot') . "</em></p>
5011
+                                <p><em>" . get_lang('HotSpot')."</em></p>
5012 5012
 
5013 5013
                                 <div id=\"hotspot-solution-$questionId\"></div>
5014 5014
 
@@ -5046,7 +5046,7 @@  discard block
 block discarded – undo
5046 5046
 
5047 5047
         if ($saved_results) {
5048 5048
             if ($debug) error_log("Save question results $saved_results");
5049
-            if ($debug) error_log(print_r($choice ,1 ));
5049
+            if ($debug) error_log(print_r($choice, 1));
5050 5050
 
5051 5051
             if (empty($choice)) {
5052 5052
                 $choice = 0;
@@ -5058,14 +5058,14 @@  discard block
 block discarded – undo
5058 5058
                         $ans = $reply[$i];
5059 5059
                         Event::saveQuestionAttempt(
5060 5060
                             $questionScore,
5061
-                            $ans . ':' . $choice[$ans],
5061
+                            $ans.':'.$choice[$ans],
5062 5062
                             $quesId,
5063 5063
                             $exeId,
5064 5064
                             $i,
5065 5065
                             $this->id
5066 5066
                         );
5067 5067
                         if ($debug) {
5068
-                            error_log('result =>' . $questionScore . ' ' . $ans . ':' . $choice[$ans]);
5068
+                            error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]);
5069 5069
                         }
5070 5070
                     }
5071 5071
                 } else {
@@ -5076,7 +5076,7 @@  discard block
 block discarded – undo
5076 5076
                     $reply = array_keys($choice);
5077 5077
 
5078 5078
                     if ($debug) {
5079
-                        error_log("reply " . print_r($reply, 1) . "");
5079
+                        error_log("reply ".print_r($reply, 1)."");
5080 5080
                     }
5081 5081
                     for ($i = 0; $i < sizeof($reply); $i++) {
5082 5082
                         $ans = $reply[$i];
@@ -5135,7 +5135,7 @@  discard block
 block discarded – undo
5135 5135
 
5136 5136
                 Event::saveQuestionAttempt($questionScore, implode('|', $answer), $quesId, $exeId, 0, $this->id);
5137 5137
             } else {
5138
-                Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0,$this->id);
5138
+                Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
5139 5139
             }
5140 5140
         }
5141 5141
 
@@ -5145,8 +5145,8 @@  discard block
 block discarded – undo
5145 5145
 
5146 5146
         if ($saved_results) {
5147 5147
             $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5148
-            $sql = 'UPDATE ' . $stat_table . ' SET
5149
-                        exe_result = exe_result + ' . floatval($questionScore) . '
5148
+            $sql = 'UPDATE '.$stat_table.' SET
5149
+                        exe_result = exe_result + ' . floatval($questionScore).'
5150 5150
                     WHERE exe_id = ' . $exeId;
5151 5151
             if ($debug) error_log($sql);
5152 5152
             Database::query($sql);
@@ -5170,7 +5170,7 @@  discard block
 block discarded – undo
5170 5170
      */
5171 5171
     public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id)
5172 5172
     {
5173
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5173
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5174 5174
             return null;
5175 5175
         }
5176 5176
         // Email configuration settings
@@ -5221,7 +5221,7 @@  discard block
 block discarded – undo
5221 5221
         $msg = str_replace("#course#", $courseInfo['name'], $msg1);
5222 5222
 
5223 5223
         if ($origin != 'learnpath') {
5224
-            $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5224
+            $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5225 5225
         }
5226 5226
         $msg1 = str_replace("#url#", $url_email, $msg);
5227 5227
         $mail_content = $msg1;
@@ -5250,7 +5250,7 @@  discard block
 block discarded – undo
5250 5250
      */
5251 5251
     function send_notification_for_open_questions($question_list_answers, $origin, $exe_id)
5252 5252
     {
5253
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5253
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5254 5254
             return null;
5255 5255
         }
5256 5256
         // Email configuration settings
@@ -5313,11 +5313,11 @@  discard block
 block discarded – undo
5313 5313
             $msg .= '</table><br />';
5314 5314
 
5315 5315
 
5316
-            $msg1   = str_replace("#exercise#",    $this->exercise, $msg);
5317
-            $msg    = str_replace("#firstName#",   $user_info['firstname'],$msg1);
5318
-            $msg1   = str_replace("#lastName#",    $user_info['lastname'],$msg);
5319
-            $msg    = str_replace("#mail#",        $user_info['email'],$msg1);
5320
-            $msg    = str_replace("#course#",      $course_info['name'],$msg1);
5316
+            $msg1   = str_replace("#exercise#", $this->exercise, $msg);
5317
+            $msg    = str_replace("#firstName#", $user_info['firstname'], $msg1);
5318
+            $msg1   = str_replace("#lastName#", $user_info['lastname'], $msg);
5319
+            $msg    = str_replace("#mail#", $user_info['email'], $msg1);
5320
+            $msg    = str_replace("#course#", $course_info['name'], $msg1);
5321 5321
 
5322 5322
             if ($origin != 'learnpath') {
5323 5323
                 $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
@@ -5346,7 +5346,7 @@  discard block
 block discarded – undo
5346 5346
 
5347 5347
     function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id)
5348 5348
     {
5349
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5349
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5350 5350
             return null;
5351 5351
         }
5352 5352
         // Email configuration settings
@@ -5370,7 +5370,7 @@  discard block
 block discarded – undo
5370 5370
             $answer_type = $item['answer_type'];
5371 5371
 
5372 5372
             if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) {
5373
-                $oral_question_list.='<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">'
5373
+                $oral_question_list .= '<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">'
5374 5374
                     .'<tr>'
5375 5375
                         .'<td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Question').'</td>'
5376 5376
                         .'<td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>'
@@ -5403,7 +5403,7 @@  discard block
 block discarded – undo
5403 5403
                             .'<td>&nbsp;#mail#</td>'
5404 5404
                         .'</tr>'
5405 5405
                     .'</table>';
5406
-            $msg .=  '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'),$oral_question_list).'<br />';
5406
+            $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'), $oral_question_list).'<br />';
5407 5407
             $msg1 = str_replace("#exercise#", $this->exercise, $msg);
5408 5408
             $msg = str_replace("#firstName#", $user_info['firstname'], $msg1);
5409 5409
             $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg);
@@ -5411,7 +5411,7 @@  discard block
 block discarded – undo
5411 5411
             $msg = str_replace("#course#", $course_info['name'], $msg1);
5412 5412
 
5413 5413
             if ($origin != 'learnpath') {
5414
-                $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5414
+                $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5415 5415
             }
5416 5416
             $msg1 = str_replace("#url#", $url_email, $msg);
5417 5417
             $mail_content = $msg1;
@@ -5477,10 +5477,10 @@  discard block
 block discarded – undo
5477 5477
         }
5478 5478
         $html  = '<div class="question-result">';
5479 5479
         $html .= Display::page_header(
5480
-            Display::return_icon('test-quiz.png', get_lang('Result'),null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result')
5480
+            Display::return_icon('test-quiz.png', get_lang('Result'), null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result')
5481 5481
         );
5482 5482
         $html .= Display::description($array);
5483
-        $html .="</div>";
5483
+        $html .= "</div>";
5484 5484
         return $html;
5485 5485
     }
5486 5486
 
@@ -5597,7 +5597,7 @@  discard block
 block discarded – undo
5597 5597
                     false,
5598 5598
                     $objExercise->selectPropagateNeg()
5599 5599
                 );
5600
-                $totalScore      += $question_result['score'];
5600
+                $totalScore += $question_result['score'];
5601 5601
             }
5602 5602
 
5603 5603
             if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) {
@@ -5803,7 +5803,7 @@  discard block
 block discarded – undo
5803 5803
         }
5804 5804
 
5805 5805
         $rawMessage = "";
5806
-        if (!empty($message)){
5806
+        if (!empty($message)) {
5807 5807
             $rawMessage = $message;
5808 5808
             $message = Display::return_message($message, 'warning', false);
5809 5809
         }
@@ -5819,7 +5819,7 @@  discard block
 block discarded – undo
5819 5819
     {
5820 5820
         $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
5821 5821
         $sql = "SELECT max_score FROM $TBL_LP_ITEM
5822
-            WHERE c_id = {$this->course_id} AND item_type = '" . TOOL_QUIZ . "' AND path = '{$this->id}'";
5822
+            WHERE c_id = {$this->course_id} AND item_type = '".TOOL_QUIZ."' AND path = '{$this->id}'";
5823 5823
         $result = Database::query($sql);
5824 5824
         if (Database::num_rows($result) > 0) {
5825 5825
             return true;
@@ -6149,7 +6149,7 @@  discard block
 block discarded – undo
6149 6149
         $sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id ";
6150 6150
         $result = Database::query($sql_track);
6151 6151
         $new_array = array();
6152
-        if (Database::num_rows($result) > 0 ) {
6152
+        if (Database::num_rows($result) > 0) {
6153 6153
             $new_array = Database::fetch_array($result, 'ASSOC');
6154 6154
 
6155 6155
             $new_array['duration'] = null;
@@ -6161,11 +6161,11 @@  discard block
 block discarded – undo
6161 6161
                 $start_date = api_strtotime($start_date, 'UTC');
6162 6162
                 $end_date = api_strtotime($end_date, 'UTC');
6163 6163
                 if ($start_date && $end_date) {
6164
-                    $mytime = $end_date- $start_date;
6164
+                    $mytime = $end_date - $start_date;
6165 6165
                     $new_learnpath_item = new learnpathItem(null);
6166 6166
                     $time_attemp = $new_learnpath_item->get_scorm_time('js', $mytime);
6167 6167
                     $h = get_lang('h');
6168
-                    $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
6168
+                    $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp);
6169 6169
                     $new_array['duration'] = $time_attemp;
6170 6170
                 }
6171 6171
             }
@@ -6187,7 +6187,7 @@  discard block
 block discarded – undo
6187 6187
                     $result = Database::query($sql);
6188 6188
                 }
6189 6189
             } else {
6190
-                $remind_list = explode(',',$exercise_info['questions_to_check']);
6190
+                $remind_list = explode(',', $exercise_info['questions_to_check']);
6191 6191
 
6192 6192
                 $remind_list_string = '';
6193 6193
                 if ($action == 'add') {
@@ -6199,7 +6199,7 @@  discard block
 block discarded – undo
6199 6199
                         }
6200 6200
                         $remind_list_string = implode(',', $remind_list);
6201 6201
                     }
6202
-                } elseif ($action == 'delete')  {
6202
+                } elseif ($action == 'delete') {
6203 6203
                     if (!empty($remind_list)) {
6204 6204
                         if (in_array($question_id, $remind_list)) {
6205 6205
                             $remind_list = array_flip($remind_list);
@@ -6441,7 +6441,7 @@  discard block
 block discarded – undo
6441 6441
                     true
6442 6442
                 );
6443 6443
 
6444
-                $counter += count($mediaQuestions[$questionId]) - 1 ;
6444
+                $counter += count($mediaQuestions[$questionId]) - 1;
6445 6445
                 $before = count($questionList);
6446 6446
                 $wasMedia = true;
6447 6447
                 $nextValue += count($questionList);
@@ -6520,7 +6520,7 @@  discard block
 block discarded – undo
6520 6520
                         // If it was already seen, then merge the previous with
6521 6521
                         // the current category
6522 6522
                         $oldQuestionList = $newCategoryList[$rootElement]['question_list'];
6523
-                        $category['question_list'] = array_merge($oldQuestionList , $category['question_list']);
6523
+                        $category['question_list'] = array_merge($oldQuestionList, $category['question_list']);
6524 6524
                         $newCategoryList[$rootElement] = $category;
6525 6525
                     }
6526 6526
                 }
@@ -6546,7 +6546,7 @@  discard block
 block discarded – undo
6546 6546
 
6547 6547
                 if ($useRootAsCategoryTitle) {
6548 6548
                     if (isset($category['parent_info'])) {
6549
-                        $categoryName  = $category['parent_info']['title'];
6549
+                        $categoryName = $category['parent_info']['title'];
6550 6550
                     }
6551 6551
                 }
6552 6552
                 $html .= '<div class="row">';
@@ -6688,7 +6688,7 @@  discard block
 block discarded – undo
6688 6688
         // end foreach()
6689 6689
 
6690 6690
         if ($this->type == ALL_ON_ONE_PAGE) {
6691
-            $exercise_actions =  $this->show_button($questionId, $currentQuestion);
6691
+            $exercise_actions = $this->show_button($questionId, $currentQuestion);
6692 6692
             echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
6693 6693
         }
6694 6694
     }
@@ -6774,7 +6774,7 @@  discard block
 block discarded – undo
6774 6774
 
6775 6775
             // Showing the question
6776 6776
 
6777
-            $exercise_actions  = null;
6777
+            $exercise_actions = null;
6778 6778
 
6779 6779
             echo '<a id="questionanchor'.$questionId.'"></a><br />';
6780 6780
             echo '<div id="question_div_'.$questionId.'" class="main_question '.$remind_highlight.'" >';
@@ -7042,7 +7042,7 @@  discard block
 block discarded – undo
7042 7042
                         $header .= Display::tag('th', get_lang('Feedback'));
7043 7043
                     }
7044 7044
                     $s .= '<table class="data_table">';
7045
-                    $s.= Display::tag('tr', $header, array('style' => 'text-align:left;'));
7045
+                    $s .= Display::tag('tr', $header, array('style' => 'text-align:left;'));
7046 7046
                 }
7047 7047
             }
7048 7048
 
@@ -7142,7 +7142,7 @@  discard block
 block discarded – undo
7142 7142
                             $s .= '<td>';
7143 7143
                             $s .= $comment;
7144 7144
                             $s .= '</td>';
7145
-                            $s .='</tr>';
7145
+                            $s .= '</tr>';
7146 7146
                         } else {
7147 7147
                             $s .= $answer_input;
7148 7148
                         }
@@ -7156,7 +7156,7 @@  discard block
 block discarded – undo
7156 7156
                             }
7157 7157
                         }
7158 7158
 
7159
-                        $s .='<tr>';
7159
+                        $s .= '<tr>';
7160 7160
                         $s .= Display::tag('td', $answer);
7161 7161
 
7162 7162
                         if (!empty($quiz_question_options)) {
@@ -7183,7 +7183,7 @@  discard block
 block discarded – undo
7183 7183
                             $s .= $comment;
7184 7184
                             $s .= '</td>';
7185 7185
                         }
7186
-                        $s.='</tr>';
7186
+                        $s .= '</tr>';
7187 7187
                     }
7188 7188
 
7189 7189
                 } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
@@ -7212,16 +7212,16 @@  discard block
 block discarded – undo
7212 7212
                     $answer_input .= '</label>';
7213 7213
 
7214 7214
                     if ($show_comment) {
7215
-                        $s.= '<tr>';
7215
+                        $s .= '<tr>';
7216 7216
                         $s .= '<td>';
7217
-                        $s.= $answer_input;
7217
+                        $s .= $answer_input;
7218 7218
                         $s .= '</td>';
7219 7219
                         $s .= '<td>';
7220 7220
                         $s .= $comment;
7221 7221
                         $s .= '</td>';
7222
-                        $s.= '</tr>';
7222
+                        $s .= '</tr>';
7223 7223
                     } else {
7224
-                        $s.= $answer_input;
7224
+                        $s .= $answer_input;
7225 7225
                     }
7226 7226
                 } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
7227 7227
                     $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
@@ -7234,7 +7234,7 @@  discard block
 block discarded – undo
7234 7234
                         }
7235 7235
                     }
7236 7236
                     $answer = Security::remove_XSS($answer);
7237
-                    $s .='<tr>';
7237
+                    $s .= '<tr>';
7238 7238
                     $s .= Display::tag('td', $answer);
7239 7239
 
7240 7240
                     foreach ($objQuestionTmp->options as $key => $item) {
@@ -7258,7 +7258,7 @@  discard block
 block discarded – undo
7258 7258
                         $s .= $comment;
7259 7259
                         $s .= '</td>';
7260 7260
                     }
7261
-                    $s.='</tr>';
7261
+                    $s .= '</tr>';
7262 7262
                 } elseif ($answerType == FILL_IN_BLANKS) {
7263 7263
                     list($answer) = explode('::', $answer);
7264 7264
 
@@ -7292,7 +7292,7 @@  discard block
 block discarded – undo
7292 7292
                                     $value = str_replace('&nbsp;', '', trim($value[0]));
7293 7293
                                 }
7294 7294
                                 $correct_item = preg_quote($correct_item);
7295
-                                $correct_item = api_preg_replace('|/|', '\/', $correct_item);   // to prevent error if there is a / in the text to find
7295
+                                $correct_item = api_preg_replace('|/|', '\/', $correct_item); // to prevent error if there is a / in the text to find
7296 7296
                                 $answer = api_preg_replace('/'.$correct_item.'/', Display::input('text', "choice[$questionId][]", $value), $answer, 1);
7297 7297
                             }
7298 7298
                             $i++;
@@ -7349,7 +7349,7 @@  discard block
 block discarded – undo
7349 7349
                         }
7350 7350
 
7351 7351
                         if (!empty($answerCorrect) && !empty($selectedValue)) {
7352
-                            $s.= '<script>
7352
+                            $s .= '<script>
7353 7353
                                 jsPlumb.ready(function() {
7354 7354
                                     jsPlumb.connect({
7355 7355
                                         source: "window_'.$windowId.'",
@@ -7364,14 +7364,14 @@  discard block
 block discarded – undo
7364 7364
                         }
7365 7365
                         $s .= '</select></div></td>';
7366 7366
 
7367
-                        $s.='<td width="45%" valign="top" >';
7367
+                        $s .= '<td width="45%" valign="top" >';
7368 7368
 
7369 7369
                         if (isset($select_items[$lines_count])) {
7370
-                            $s.= '<div id="window_'.$windowId.'_answer" class="window window_right_question">
7370
+                            $s .= '<div id="window_'.$windowId.'_answer" class="window window_right_question">
7371 7371
                                     <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].'
7372 7372
                                   </div>';
7373 7373
                         } else {
7374
-                            $s.='&nbsp;';
7374
+                            $s .= '&nbsp;';
7375 7375
                         }
7376 7376
 
7377 7377
                         $s .= '</td>';
@@ -7385,16 +7385,16 @@  discard block
 block discarded – undo
7385 7385
                                 $s .= '<tr>
7386 7386
                                       <td colspan="2"></td>
7387 7387
                                       <td valign="top">';
7388
-                                $s.='<b>'.$select_items[$lines_count]['letter'].'.</b>';
7388
+                                $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b>';
7389 7389
                                 $s .= $select_items[$lines_count]['answer'];
7390
-                                $s.="</td>
7390
+                                $s .= "</td>
7391 7391
                                 </tr>";
7392 7392
                                 $lines_count++;
7393 7393
                             } // end while()
7394 7394
                         }  // end if()
7395 7395
                         $matching_correct_answer++;
7396 7396
                     }
7397
-                } elseif ($answerType ==  DRAGGABLE) {
7397
+                } elseif ($answerType == DRAGGABLE) {
7398 7398
                     // matching type, showing suggestions and answers
7399 7399
                     // TODO: replace $answerId by $numAnswer
7400 7400
 
@@ -7436,7 +7436,7 @@  discard block
 block discarded – undo
7436 7436
                         $s .= '</select>';
7437 7437
 
7438 7438
                         if (!empty($answerCorrect) && !empty($selectedValue)) {
7439
-                            $s.= '<script>
7439
+                            $s .= '<script>
7440 7440
                                 $(function() {
7441 7441
                                     deleteItem($("#'.$questionId.'_'.$selectedValue.'"), $("#drop_'.$windowId.'"));
7442 7442
                                 });
@@ -7444,11 +7444,11 @@  discard block
 block discarded – undo
7444 7444
                         }
7445 7445
 
7446 7446
                         if (isset($select_items[$lines_count])) {
7447
-                            $s.= '<div id="window_'.$windowId.'_answer" class="">
7447
+                            $s .= '<div id="window_'.$windowId.'_answer" class="">
7448 7448
                                     <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].'
7449 7449
                                   </div>';
7450 7450
                         } else {
7451
-                            $s.='&nbsp;';
7451
+                            $s .= '&nbsp;';
7452 7452
                         }
7453 7453
                         $lines_count++;
7454 7454
                         //if the left side of the "matching" has been completely
@@ -7457,7 +7457,7 @@  discard block
 block discarded – undo
7457 7457
                         if (($lines_count - 1) == $num_suggestions) {
7458 7458
                             // if it remains answers to shown at the right side
7459 7459
                             while (isset($select_items[$lines_count])) {
7460
-                                $s.='<b>'.$select_items[$lines_count]['letter'].'.</b>';
7460
+                                $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b>';
7461 7461
                                 $s .= $select_items[$lines_count]['answer'];
7462 7462
                                 $lines_count++;
7463 7463
                             }
@@ -7560,9 +7560,9 @@  discard block
 block discarded – undo
7560 7560
 
7561 7561
             if (!$only_questions) {
7562 7562
                 if ($show_title) {
7563
-                    $html .=  TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id);
7564
-                    $html .=  '<div class="question_title">'.$current_item.'. '.$questionName.'</div>';
7565
-                    $html .=  $questionDescription;
7563
+                    $html .= TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id);
7564
+                    $html .= '<div class="question_title">'.$current_item.'. '.$questionName.'</div>';
7565
+                    $html .= $questionDescription;
7566 7566
                 } else {
7567 7567
                     $html .= '<div class="media">';
7568 7568
                     $html .= '<div class="pull-left">';
@@ -7578,11 +7578,11 @@  discard block
 block discarded – undo
7578 7578
                     $html .= '</div>';
7579 7579
                 }
7580 7580
                 //@todo I need to the get the feedback type
7581
-                $html .=  '<input type="hidden" name="hidden_hotspot_id" value="'.$questionId.'" />';
7582
-                $html .=  '<table class="exercise_questions">
7581
+                $html .= '<input type="hidden" name="hidden_hotspot_id" value="'.$questionId.'" />';
7582
+                $html .= '<table class="exercise_questions">
7583 7583
                            <tr>
7584 7584
                             <td valign="top" colspan="2">';
7585
-                $html .=  '</td></tr>';
7585
+                $html .= '</td></tr>';
7586 7586
             }
7587 7587
 
7588 7588
             $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
Please login to merge, or discard this patch.