Completed
Push — 1.10.x ( 4c5f4c...61bcd5 )
by Yannick
419:40 queued 371:43
created
main/exercice/exercise_report.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -400,8 +400,9 @@
 block discarded – undo
400 400
 $extra .= $form->return_form();
401 401
 $extra .= '</div>';
402 402
 
403
-if ($is_allowedToEdit)
403
+if ($is_allowedToEdit) {
404 404
     echo $extra;
405
+}
405 406
 
406 407
 echo $actions;
407 408
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
             Display::addFlash(
249 249
                 Display::return_message(get_lang('MessageSent'))
250 250
             );
251
-            header('Location: ' . api_get_self().'?'.api_get_cidreq().'&exerciseId='.$exerciseId);
251
+            header('Location: '.api_get_self().'?'.api_get_cidreq().'&exerciseId='.$exerciseId);
252 252
             exit;
253 253
         }
254 254
     }
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
         api_is_course_tutor() || api_is_course_coach()
279 279
     ) {
280 280
         $actions .= '<a href="admin.php?exerciseId='.intval($_GET['exerciseId']).'">'.Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
281
-        $actions .='<a href="live_stats.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'">'.Display :: return_icon('activity_monitor.png', get_lang('LiveResults'), '', ICON_SIZE_MEDIUM).'</a>';
282
-        $actions .='<a href="stats.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'">'.Display :: return_icon('statistics.png', get_lang('ReportByQuestion'), '', ICON_SIZE_MEDIUM).'</a>';
281
+        $actions .= '<a href="live_stats.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'">'.Display :: return_icon('activity_monitor.png', get_lang('LiveResults'), '', ICON_SIZE_MEDIUM).'</a>';
282
+        $actions .= '<a href="stats.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'">'.Display :: return_icon('statistics.png', get_lang('ReportByQuestion'), '', ICON_SIZE_MEDIUM).'</a>';
283 283
 
284 284
         $actions .= '<a id="export_opener" href="'.api_get_self().'?export_report=1&exerciseId='.intval($_GET['exerciseId']).'" >'.
285 285
         Display::return_icon('save.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
Please login to merge, or discard this patch.
main/exercice/exercise.class.php 4 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
                     $label = get_lang('NextQuestion');
1967 1967
                     $class = 'btn btn-primary';
1968 1968
                 }
1969
-				$class .= ' question-validate-btn'; // used to select it with jquery
1969
+                $class .= ' question-validate-btn'; // used to select it with jquery
1970 1970
                 if ($this->type == ONE_PER_PAGE) {
1971 1971
                     if ($questionNum != 1) {
1972 1972
                         $prev_question = $questionNum - 2;
@@ -1991,7 +1991,7 @@  discard block
 block discarded – undo
1991 1991
                         $all_label = get_lang('EndTest');
1992 1992
                         $class = 'btn btn-warning';
1993 1993
                     }
1994
-					$class .= ' question-validate-btn'; // used to select it with jquery
1994
+                    $class .= ' question-validate-btn'; // used to select it with jquery
1995 1995
                     $all_button = '&nbsp;<a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>';
1996 1996
                     $all_button .= '&nbsp;' . Display::span(null, ['id' => 'save_all_reponse']);
1997 1997
                     $html .= $all_button;
@@ -3774,7 +3774,7 @@  discard block
 block discarded – undo
3774 3774
 
3775 3775
         //Fixes multiple answer question in order to be exact
3776 3776
         //if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
3777
-       /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) {
3777
+        /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) {
3778 3778
             $diff = @array_diff($answer_correct_array, $real_answers);
3779 3779
 
3780 3780
             // All good answers or nothing works like exact
@@ -5073,8 +5073,8 @@  discard block
 block discarded – undo
5073 5073
     }
5074 5074
 
5075 5075
     /**
5076
-    * @return string
5077
-    */
5076
+     * @return string
5077
+     */
5078 5078
     public function get_formated_title()
5079 5079
     {
5080 5080
         return api_html_entity_decode($this->selectTitle());
Please login to merge, or discard this patch.
Braces   +51 added lines, -24 removed lines patch added patch discarded remove patch
@@ -538,10 +538,11 @@  discard block
 block discarded – undo
538 538
      */
539 539
     public function isInList($questionId)
540 540
     {
541
-        if (is_array($this->questionList))
542
-            return in_array($questionId,$this->questionList);
543
-        else
544
-            return false;
541
+        if (is_array($this->questionList)) {
542
+                    return in_array($questionId,$this->questionList);
543
+        } else {
544
+                    return false;
545
+        }
545 546
     }
546 547
 
547 548
     /**
@@ -1227,10 +1228,11 @@  discard block
 block discarded – undo
1227 1228
 
1228 1229
             $var = Exercise::selectTimeLimit();
1229 1230
 
1230
-            if (($this->start_time != '0000-00-00 00:00:00'))
1231
-                $form->addElement('html','<div id="start_date_div" style="display:block;">');
1232
-            else
1233
-                $form->addElement('html','<div id="start_date_div" style="display:none;">');
1231
+            if (($this->start_time != '0000-00-00 00:00:00')) {
1232
+                            $form->addElement('html','<div id="start_date_div" style="display:block;">');
1233
+            } else {
1234
+                            $form->addElement('html','<div id="start_date_div" style="display:none;">');
1235
+            }
1234 1236
 
1235 1237
             $form->addElement('date_time_picker', 'start_time');
1236 1238
 
@@ -1238,10 +1240,11 @@  discard block
 block discarded – undo
1238 1240
 
1239 1241
             $form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
1240 1242
 
1241
-            if (($this->end_time != '0000-00-00 00:00:00'))
1242
-                $form->addElement('html','<div id="end_date_div" style="display:block;">');
1243
-            else
1244
-                $form->addElement('html','<div id="end_date_div" style="display:none;">');
1243
+            if (($this->end_time != '0000-00-00 00:00:00')) {
1244
+                            $form->addElement('html','<div id="end_date_div" style="display:block;">');
1245
+            } else {
1246
+                            $form->addElement('html','<div id="end_date_div" style="display:none;">');
1247
+            }
1245 1248
 
1246 1249
             $form->addElement('date_time_picker', 'end_time');
1247 1250
             $form->addElement('html','</div>');
@@ -2268,7 +2271,9 @@  discard block
 block discarded – undo
2268 2271
         $organs_at_risk_hit = 0;
2269 2272
         $questionScore = 0;
2270 2273
 
2271
-        if ($debug) error_log('Start answer loop ');
2274
+        if ($debug) {
2275
+            error_log('Start answer loop ');
2276
+        }
2272 2277
 
2273 2278
         $answer_correct_array = array();
2274 2279
 
@@ -2383,7 +2388,9 @@  discard block
 block discarded – undo
2383 2388
                     }
2384 2389
                     $totalScore += $answerWeighting;
2385 2390
 
2386
-                    if ($debug) error_log("studentChoice: $studentChoice");
2391
+                    if ($debug) {
2392
+                        error_log("studentChoice: $studentChoice");
2393
+                    }
2387 2394
                     break;
2388 2395
                 case GLOBAL_MULTIPLE_ANSWER:
2389 2396
                     if ($from_database) {
@@ -2408,7 +2415,9 @@  discard block
 block discarded – undo
2408 2415
                         $real_answers[$answerId] = (bool)$studentChoice;
2409 2416
                     }
2410 2417
                     $totalScore += $answerWeighting;
2411
-                    if ($debug) error_log("studentChoice: $studentChoice");
2418
+                    if ($debug) {
2419
+                        error_log("studentChoice: $studentChoice");
2420
+                    }
2412 2421
                     break;
2413 2422
                 case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
2414 2423
                     if ($from_database) {
@@ -3125,9 +3134,13 @@  discard block
 block discarded – undo
3125 3134
             } // end switch Answertype
3126 3135
 
3127 3136
             if ($show_result) {
3128
-                if ($debug) error_log('show result '.$show_result);
3137
+                if ($debug) {
3138
+                    error_log('show result '.$show_result);
3139
+                }
3129 3140
                 if ($from == 'exercise_result') {
3130
-                    if ($debug) error_log('Showing questions $from '.$from);
3141
+                    if ($debug) {
3142
+                        error_log('Showing questions $from '.$from);
3143
+                    }
3131 3144
                     //display answers (if not matching type, or if the answer is correct)
3132 3145
                     if (
3133 3146
                         !in_array(
@@ -3415,7 +3428,9 @@  discard block
 block discarded – undo
3415 3428
                         }
3416 3429
                     }
3417 3430
                 } else {
3418
-                    if ($debug) error_log('Showing questions $from '.$from);
3431
+                    if ($debug) {
3432
+                        error_log('Showing questions $from '.$from);
3433
+                    }
3419 3434
 
3420 3435
                     switch ($answerType) {
3421 3436
                         case UNIQUE_ANSWER:
@@ -3747,10 +3762,14 @@  discard block
 block discarded – undo
3747 3762
                     }
3748 3763
                 }
3749 3764
             }
3750
-            if ($debug) error_log(' ------ ');
3765
+            if ($debug) {
3766
+                error_log(' ------ ');
3767
+            }
3751 3768
         } // end for that loops over all answers of the current question
3752 3769
 
3753
-        if ($debug) error_log('-- end answer loop --');
3770
+        if ($debug) {
3771
+            error_log('-- end answer loop --');
3772
+        }
3754 3773
 
3755 3774
         $final_answer = true;
3756 3775
 
@@ -3823,7 +3842,9 @@  discard block
 block discarded – undo
3823 3842
             //  some results that haven't been stored in the database yet
3824 3843
             if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) {
3825 3844
 
3826
-                if ($debug) error_log('$from AND this is a hotspot kind of question ');
3845
+                if ($debug) {
3846
+                    error_log('$from AND this is a hotspot kind of question ');
3847
+                }
3827 3848
 
3828 3849
                 $my_exe_id = 0;
3829 3850
                 $from_database = 0;
@@ -3999,8 +4020,12 @@  discard block
 block discarded – undo
3999 4020
         // stored by exercise_results.php (using the session)
4000 4021
 
4001 4022
         if ($saved_results) {
4002
-            if ($debug) error_log("Save question results $saved_results");
4003
-            if ($debug) error_log(print_r($choice ,1 ));
4023
+            if ($debug) {
4024
+                error_log("Save question results $saved_results");
4025
+            }
4026
+            if ($debug) {
4027
+                error_log(print_r($choice ,1 ));
4028
+            }
4004 4029
 
4005 4030
             if (empty($choice)) {
4006 4031
                 $choice = 0;
@@ -4102,7 +4127,9 @@  discard block
 block discarded – undo
4102 4127
             $sql = 'UPDATE ' . $stat_table . ' SET
4103 4128
                         exe_result = exe_result + ' . floatval($questionScore) . '
4104 4129
                     WHERE exe_id = ' . $exeId;
4105
-            if ($debug) error_log($sql);
4130
+            if ($debug) {
4131
+                error_log($sql);
4132
+            }
4106 4133
             Database::query($sql);
4107 4134
         }
4108 4135
 
Please login to merge, or discard this patch.
Doc Comments   +13 added lines, -8 removed lines patch added patch discarded remove patch
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
     }
355 355
 
356 356
     /**
357
-     * @return int
357
+     * @return string
358 358
      */
359 359
     public function selectPassPercentage()
360 360
     {
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
      * tells if questions are selected randomly, and if so returns the draws
474 474
      *
475 475
      * @author Olivier Brouckaert
476
-     * @return integer - 0 if not random, otherwise the draws
476
+     * @return boolean - 0 if not random, otherwise the draws
477 477
      */
478 478
     public function isRandom()
479 479
     {
@@ -2830,7 +2830,7 @@  discard block
 block discarded – undo
2830 2830
      * @param int  int lp id
2831 2831
      * @param int  int lp item id
2832 2832
      * @param int  int lp item_view id
2833
-     * @param float $weight
2833
+     * @param integer $weight
2834 2834
      * @param array question list
2835 2835
      */
2836 2836
     public function save_stat_track_exercise_info(
@@ -5118,6 +5118,7 @@  discard block
 block discarded – undo
5118 5118
     /**
5119 5119
      * Sends a notification when a user ends an examn
5120 5120
      *
5121
+     * @param integer $exe_id
5121 5122
      */
5122 5123
     public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id)
5123 5124
     {
@@ -5198,6 +5199,7 @@  discard block
 block discarded – undo
5198 5199
     /**
5199 5200
      * Sends a notification when a user ends an examn
5200 5201
      *
5202
+     * @param integer $exe_id
5201 5203
      */
5202 5204
     function send_notification_for_open_questions($question_list_answers, $origin, $exe_id)
5203 5205
     {
@@ -5295,6 +5297,9 @@  discard block
 block discarded – undo
5295 5297
         }
5296 5298
     }
5297 5299
 
5300
+    /**
5301
+     * @param integer $exe_id
5302
+     */
5298 5303
     function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id)
5299 5304
     {
5300 5305
         if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
@@ -5388,7 +5393,7 @@  discard block
 block discarded – undo
5388 5393
 
5389 5394
     /**
5390 5395
      * @param array $user_data result of api_get_user_info()
5391
-     * @param null $start_date
5396
+     * @param string $start_date
5392 5397
      * @param null $duration
5393 5398
      * @param string $ip Optional. The user IP
5394 5399
      * @return string
@@ -5446,7 +5451,7 @@  discard block
 block discarded – undo
5446 5451
      * @param int     Maximum number of attempts (0 if no limit)
5447 5452
      * @param int     Feedback type
5448 5453
      * @todo this was function was added due the import exercise via CSV
5449
-     * @return    int New exercise ID
5454
+     * @return    string New exercise ID
5450 5455
      */
5451 5456
     public function createExercise(
5452 5457
         $title,
@@ -6795,7 +6800,7 @@  discard block
 block discarded – undo
6795 6800
      * @param bool $show_comment
6796 6801
      * @param null $exercise_feedback
6797 6802
      * @param bool $show_answers
6798
-     * @param null $modelType
6803
+     * @param integer $modelType
6799 6804
      * @param bool $categoryMinusOne
6800 6805
      * @return bool|null|string
6801 6806
      */
@@ -7956,8 +7961,8 @@  discard block
 block discarded – undo
7956 7961
     /**
7957 7962
      * Returns an HTML ribbon to show on top of the exercise result, with
7958 7963
      * colouring depending on the success or failure of the student
7959
-     * @param $score
7960
-     * @param $weight
7964
+     * @param integer $score
7965
+     * @param integer $weight
7961 7966
      * @param bool $check_pass_percentage
7962 7967
      * @return string
7963 7968
      */
Please login to merge, or discard this patch.
Spacing   +348 added lines, -348 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,13 +1941,13 @@  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();
1948 1948
                 $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0'));
1949
-                $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
1950
-                $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2', array('id'=>'result_disabled_2'));
1949
+                $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()'));
1950
+                $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2'));
1951 1951
                 //$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ExamModeWithFinalScoreShowOnlyFinalScoreWithCategoriesIfAvailable'),  '3', array('id'=>'result_disabled_3','onclick' => 'check_results_disabled()'));
1952 1952
 
1953 1953
                 $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
@@ -1955,8 +1955,8 @@  discard block
 block discarded – undo
1955 1955
                 // Type of questions disposition on page
1956 1956
                 $radios = array();
1957 1957
 
1958
-                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
1959
-                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
1958
+                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
1959
+                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
1960 1960
 
1961 1961
                 $form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
1962 1962
 
@@ -1966,33 +1966,33 @@  discard block
 block discarded – undo
1966 1966
 
1967 1967
                     // feedback type
1968 1968
                     $radios_feedback = array();
1969
-                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'),'0',array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()'));
1969
+                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()'));
1970 1970
 
1971 1971
                     if (api_get_setting('enable_quiz_scenario') == 'true') {
1972
-                        $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1' , 'onclick' => 'check_direct_feedback()'));
1972
+                        $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
1973 1973
                     }
1974
-                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2',array('id' =>'exerciseType_2'));
1975
-                    $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions')));
1974
+                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' =>'exerciseType_2'));
1975
+                    $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')));
1976 1976
 
1977 1977
                     //$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
1978 1978
                     $radios_results_disabled = array();
1979 1979
                     $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0'));
1980
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
1981
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()'));
1982
-                    $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),'');
1980
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()'));
1981
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()'));
1982
+                    $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
1983 1983
 
1984 1984
                     // Type of questions disposition on page
1985 1985
                     $radios = array();
1986
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1');
1987
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2');
1986
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1');
1987
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2');
1988 1988
                     $form->addGroup($radios, null, get_lang('ExerciseType'));
1989 1989
 
1990 1990
                 } else {
1991 1991
                     //Show options freeze
1992 1992
                     $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0'));
1993
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
1994
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()'));
1995
-                    $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),'');
1993
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()'));
1994
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()'));
1995
+                    $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
1996 1996
                     $result_disable_group->freeze();
1997 1997
 
1998 1998
                     //we force the options to the DirectFeedback exercisetype
@@ -2000,8 +2000,8 @@  discard block
 block discarded – undo
2000 2000
                     $form->addElement('hidden', 'exerciseType', ONE_PER_PAGE);
2001 2001
 
2002 2002
                     // Type of questions disposition on page
2003
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
2004
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
2003
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
2004
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
2005 2005
 
2006 2006
                     $type_group = $form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
2007 2007
                     $type_group->freeze();
@@ -2133,26 +2133,26 @@  discard block
 block discarded – undo
2133 2133
 
2134 2134
                 // number of random question
2135 2135
 
2136
-                $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10 ;
2136
+                $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10;
2137 2137
                 $option = range(0, $max);
2138 2138
                 $option[0] = get_lang('No');
2139 2139
                 $option[-1] = get_lang('AllQuestionsShort');
2140
-                $form->addElement('select', 'randomQuestions',array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions'));
2140
+                $form->addElement('select', 'randomQuestions', array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions'));
2141 2141
 
2142 2142
                 // Random answers
2143 2143
                 $radios_random_answers = array();
2144
-                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'),'1');
2145
-                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'),'0');
2144
+                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'), '1');
2145
+                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'), '0');
2146 2146
                 $form->addGroup($radios_random_answers, null, get_lang('RandomAnswers'), '');
2147 2147
 
2148 2148
                 // Random by category
2149
-                $form->addElement('html','<div class="clear">&nbsp;</div>');
2149
+                $form->addElement('html', '<div class="clear">&nbsp;</div>');
2150 2150
                 $radiocat = array();
2151
-                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'),'1');
2152
-                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'),'2');
2153
-                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'),'0');
2151
+                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'), '1');
2152
+                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'), '2');
2153
+                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'), '0');
2154 2154
                 $radioCatGroup = $form->addGroup($radiocat, null, get_lang('RandomQuestionByCategory'), '');
2155
-                $form->addElement('html','<div class="clear">&nbsp;</div>');
2155
+                $form->addElement('html', '<div class="clear">&nbsp;</div>');
2156 2156
 
2157 2157
                 // add the radio display the category name for student
2158 2158
                 $radio_display_cat_name = array();
@@ -2173,36 +2173,36 @@  discard block
 block discarded – undo
2173 2173
             );
2174 2174
 
2175 2175
             // Exercise time limit
2176
-            $form->addElement('checkbox', 'activate_start_date_check',null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
2176
+            $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
2177 2177
 
2178 2178
             $var = Exercise::selectTimeLimit();
2179 2179
 
2180 2180
             if (($this->start_time != '0000-00-00 00:00:00'))
2181
-                $form->addElement('html','<div id="start_date_div" style="display:block;">');
2181
+                $form->addElement('html', '<div id="start_date_div" style="display:block;">');
2182 2182
             else
2183
-                $form->addElement('html','<div id="start_date_div" style="display:none;">');
2183
+                $form->addElement('html', '<div id="start_date_div" style="display:none;">');
2184 2184
 
2185 2185
             $form->addElement('date_time_picker', 'start_time');
2186 2186
 
2187
-            $form->addElement('html','</div>');
2187
+            $form->addElement('html', '</div>');
2188 2188
 
2189
-            $form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
2189
+            $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
2190 2190
 
2191 2191
             if (($this->end_time != '0000-00-00 00:00:00'))
2192
-                $form->addElement('html','<div id="end_date_div" style="display:block;">');
2192
+                $form->addElement('html', '<div id="end_date_div" style="display:block;">');
2193 2193
             else
2194
-                $form->addElement('html','<div id="end_date_div" style="display:none;">');
2194
+                $form->addElement('html', '<div id="end_date_div" style="display:none;">');
2195 2195
 
2196 2196
             $form->addElement('date_time_picker', 'end_time');
2197
-            $form->addElement('html','</div>');
2197
+            $form->addElement('html', '</div>');
2198 2198
 
2199 2199
             //$check_option=$this->selectType();
2200 2200
             $diplay = 'block';
2201 2201
             $form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults'));
2202
-            $form->addElement('html','<div class="clear">&nbsp;</div>');
2202
+            $form->addElement('html', '<div class="clear">&nbsp;</div>');
2203 2203
             $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers'));
2204 2204
 
2205
-            $form->addElement('html','<div id="divtimecontrol"  style="display:'.$diplay.';">');
2205
+            $form->addElement('html', '<div id="divtimecontrol"  style="display:'.$diplay.';">');
2206 2206
 
2207 2207
             //Timer control
2208 2208
             //$time_hours_option = range(0,12);
@@ -2218,12 +2218,12 @@  discard block
 block discarded – undo
2218 2218
                     'onload' => 'check_load_time()',
2219 2219
                 )
2220 2220
             );
2221
-            $expired_date = (int)$this->selectExpiredTime();
2221
+            $expired_date = (int) $this->selectExpiredTime();
2222 2222
 
2223
-            if (($expired_date!='0')) {
2224
-                $form->addElement('html','<div id="timercontrol" style="display:block;">');
2223
+            if (($expired_date != '0')) {
2224
+                $form->addElement('html', '<div id="timercontrol" style="display:block;">');
2225 2225
             } else {
2226
-                $form->addElement('html','<div id="timercontrol" style="display:none;">');
2226
+                $form->addElement('html', '<div id="timercontrol" style="display:none;">');
2227 2227
             }
2228 2228
             $form->addText(
2229 2229
                 'enabletimercontroltotalminutes',
@@ -2234,7 +2234,7 @@  discard block
 block discarded – undo
2234 2234
                     'cols-size' => [2, 2, 8]
2235 2235
                 ]
2236 2236
             );
2237
-            $form->addElement('html','</div>');
2237
+            $form->addElement('html', '</div>');
2238 2238
 
2239 2239
             $form->addElement(
2240 2240
                 'text',
@@ -2256,23 +2256,23 @@  discard block
 block discarded – undo
2256 2256
             $defaults = array();
2257 2257
 
2258 2258
             if (api_get_setting('search_enabled') === 'true') {
2259
-                require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
2259
+                require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2260 2260
 
2261
-                $form->addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
2262
-                $form->addElement ('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
2261
+                $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
2262
+                $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
2263 2263
 
2264 2264
                 $specific_fields = get_specific_field_list();
2265 2265
 
2266 2266
                 foreach ($specific_fields as $specific_field) {
2267
-                    $form->addElement ('text', $specific_field['code'], $specific_field['name']);
2267
+                    $form->addElement('text', $specific_field['code'], $specific_field['name']);
2268 2268
                     $filter = array(
2269 2269
                         'c_id' => api_get_course_int_id(),
2270 2270
                         'field_id' => $specific_field['id'],
2271 2271
                         'ref_id' => $this->id,
2272
-                        'tool_id' => "'" . TOOL_QUIZ . "'"
2272
+                        'tool_id' => "'".TOOL_QUIZ."'"
2273 2273
                     );
2274 2274
                     $values = get_specific_field_values_list($filter, array('value'));
2275
-                    if ( !empty($values) ) {
2275
+                    if (!empty($values)) {
2276 2276
                         $arr_str_values = array();
2277 2277
                         foreach ($values as $value) {
2278 2278
                             $arr_str_values[] = $value['value'];
@@ -2283,8 +2283,8 @@  discard block
 block discarded – undo
2283 2283
                 //$form->addElement ('html','</div>');
2284 2284
             }
2285 2285
 
2286
-            $form->addElement('html','</div>');  //End advanced setting
2287
-            $form->addElement('html','</div>');
2286
+            $form->addElement('html', '</div>'); //End advanced setting
2287
+            $form->addElement('html', '</div>');
2288 2288
         }
2289 2289
 
2290 2290
         // submit
@@ -2304,10 +2304,10 @@  discard block
 block discarded – undo
2304 2304
         }
2305 2305
 
2306 2306
         // defaults
2307
-        if ($type=='full') {
2307
+        if ($type == 'full') {
2308 2308
             if ($this->id > 0) {
2309 2309
                 if ($this->random > $this->selectNbrQuestions()) {
2310
-                    $defaults['randomQuestions'] =  $this->selectNbrQuestions();
2310
+                    $defaults['randomQuestions'] = $this->selectNbrQuestions();
2311 2311
                 } else {
2312 2312
                     $defaults['randomQuestions'] = $this->random;
2313 2313
                 }
@@ -2334,8 +2334,8 @@  discard block
 block discarded – undo
2334 2334
                     $defaults['activate_end_date_check'] = 1;
2335 2335
                 }
2336 2336
 
2337
-                $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');
2338
-                $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);
2337
+                $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');
2338
+                $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);
2339 2339
 
2340 2340
                 // Get expired time
2341 2341
                 if ($this->expired_time != '0') {
@@ -2356,7 +2356,7 @@  discard block
 block discarded – undo
2356 2356
                 $defaults['text_when_finished'] = "";
2357 2357
                 $defaults['start_time'] = date('Y-m-d 12:00:00');
2358 2358
                 $defaults['display_category_name'] = 1;
2359
-                $defaults['end_time']   = date('Y-m-d 12:00:00', time()+84600);
2359
+                $defaults['end_time']   = date('Y-m-d 12:00:00', time() + 84600);
2360 2360
                 $defaults['pass_percentage'] = '';
2361 2361
                 $defaults['end_button'] = $this->selectEndButton();
2362 2362
                 $defaults['question_selection_type'] = 1;
@@ -2442,7 +2442,7 @@  discard block
 block discarded – undo
2442 2442
             $end_time = $form->getSubmitValue('end_time');
2443 2443
             $this->end_time = api_get_utc_datetime($end_time);
2444 2444
         } else {
2445
-            $this->end_time   = '0000-00-00 00:00:00';
2445
+            $this->end_time = '0000-00-00 00:00:00';
2446 2446
         }
2447 2447
 
2448 2448
         if ($form->getSubmitValue('enabletimercontrol') == 1) {
@@ -2455,9 +2455,9 @@  discard block
 block discarded – undo
2455 2455
         }
2456 2456
 
2457 2457
         if ($form->getSubmitValue('randomAnswers') == 1) {
2458
-            $this->random_answers=1;
2458
+            $this->random_answers = 1;
2459 2459
         } else {
2460
-            $this->random_answers=0;
2460
+            $this->random_answers = 0;
2461 2461
         }
2462 2462
         $this->save($type);
2463 2463
     }
@@ -2469,9 +2469,9 @@  discard block
 block discarded – undo
2469 2469
         }
2470 2470
         $course_id = api_get_course_id();
2471 2471
 
2472
-        require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
2473
-        require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
2474
-        require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
2472
+        require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
2473
+        require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php';
2474
+        require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2475 2475
 
2476 2476
         $specific_fields = get_specific_field_list();
2477 2477
         $ic_slide = new IndexableChunk();
@@ -2481,7 +2481,7 @@  discard block
 block discarded – undo
2481 2481
             if (isset($_REQUEST[$specific_field['code']])) {
2482 2482
                 $sterms = trim($_REQUEST[$specific_field['code']]);
2483 2483
                 if (!empty($sterms)) {
2484
-                    $all_specific_terms .= ' '. $sterms;
2484
+                    $all_specific_terms .= ' '.$sterms;
2485 2485
                     $sterms = explode(',', $sterms);
2486 2486
                     foreach ($sterms as $sterm) {
2487 2487
                         $ic_slide->addTerm(trim($sterm), $specific_field['code']);
@@ -2498,15 +2498,15 @@  discard block
 block discarded – undo
2498 2498
         $xapian_data = array(
2499 2499
             SE_COURSE_ID => $course_id,
2500 2500
             SE_TOOL_ID => TOOL_QUIZ,
2501
-            SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id),
2502
-            SE_USER => (int)api_get_user_id(),
2501
+            SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id),
2502
+            SE_USER => (int) api_get_user_id(),
2503 2503
         );
2504 2504
         $ic_slide->xapian_data = serialize($xapian_data);
2505
-        $exercise_description = $all_specific_terms .' '. $this->description;
2505
+        $exercise_description = $all_specific_terms.' '.$this->description;
2506 2506
         $ic_slide->addValue("content", $exercise_description);
2507 2507
 
2508 2508
         $di = new ChamiloIndexer();
2509
-        isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
2509
+        isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english';
2510 2510
         $di->connectDb(NULL, NULL, $lang);
2511 2511
         $di->addChunk($ic_slide);
2512 2512
 
@@ -2525,7 +2525,7 @@  discard block
 block discarded – undo
2525 2525
     function search_engine_edit()
2526 2526
     {
2527 2527
         // update search enchine and its values table if enabled
2528
-        if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {
2528
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
2529 2529
             $course_id = api_get_course_id();
2530 2530
 
2531 2531
             // actually, it consists on delete terms from db,
@@ -2537,9 +2537,9 @@  discard block
 block discarded – undo
2537 2537
             $res = Database::query($sql);
2538 2538
 
2539 2539
             if (Database::num_rows($res) > 0) {
2540
-                require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php');
2541
-                require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php');
2542
-                require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
2540
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
2541
+                require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php');
2542
+                require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php');
2543 2543
 
2544 2544
                 $se_ref = Database::fetch_array($res);
2545 2545
                 $specific_fields = get_specific_field_list();
@@ -2550,7 +2550,7 @@  discard block
 block discarded – undo
2550 2550
                     delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_QUIZ, $this->id);
2551 2551
                     if (isset($_REQUEST[$specific_field['code']])) {
2552 2552
                         $sterms = trim($_REQUEST[$specific_field['code']]);
2553
-                        $all_specific_terms .= ' '. $sterms;
2553
+                        $all_specific_terms .= ' '.$sterms;
2554 2554
                         $sterms = explode(',', $sterms);
2555 2555
                         foreach ($sterms as $sterm) {
2556 2556
                             $ic_slide->addTerm(trim($sterm), $specific_field['code']);
@@ -2566,17 +2566,17 @@  discard block
 block discarded – undo
2566 2566
                 $xapian_data = array(
2567 2567
                     SE_COURSE_ID => $course_id,
2568 2568
                     SE_TOOL_ID => TOOL_QUIZ,
2569
-                    SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id),
2570
-                    SE_USER => (int)api_get_user_id(),
2569
+                    SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id),
2570
+                    SE_USER => (int) api_get_user_id(),
2571 2571
                 );
2572 2572
                 $ic_slide->xapian_data = serialize($xapian_data);
2573
-                $exercise_description = $all_specific_terms .' '. $this->description;
2573
+                $exercise_description = $all_specific_terms.' '.$this->description;
2574 2574
                 $ic_slide->addValue("content", $exercise_description);
2575 2575
 
2576 2576
                 $di = new ChamiloIndexer();
2577
-                isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
2577
+                isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english';
2578 2578
                 $di->connectDb(NULL, NULL, $lang);
2579
-                $di->remove_document((int)$se_ref['search_did']);
2579
+                $di->remove_document((int) $se_ref['search_did']);
2580 2580
                 $di->addChunk($ic_slide);
2581 2581
 
2582 2582
                 //index and return search engine document id
@@ -2601,7 +2601,7 @@  discard block
 block discarded – undo
2601 2601
     function search_engine_delete()
2602 2602
     {
2603 2603
         // remove from search engine if enabled
2604
-        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian') ) {
2604
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
2605 2605
             $course_id = api_get_course_id();
2606 2606
             $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
2607 2607
             $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';
@@ -2609,19 +2609,19 @@  discard block
 block discarded – undo
2609 2609
             $res = Database::query($sql);
2610 2610
             if (Database::num_rows($res) > 0) {
2611 2611
                 $row = Database::fetch_array($res);
2612
-                require_once(api_get_path(LIBRARY_PATH) .'search/ChamiloIndexer.class.php');
2612
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
2613 2613
                 $di = new ChamiloIndexer();
2614
-                $di->remove_document((int)$row['search_did']);
2614
+                $di->remove_document((int) $row['search_did']);
2615 2615
                 unset($di);
2616 2616
                 $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
2617
-                foreach ( $this->questionList as $question_i) {
2617
+                foreach ($this->questionList as $question_i) {
2618 2618
                     $sql = 'SELECT type FROM %s WHERE id=%s';
2619 2619
                     $sql = sprintf($sql, $tbl_quiz_question, $question_i);
2620 2620
                     $qres = Database::query($sql);
2621 2621
                     if (Database::num_rows($qres) > 0) {
2622 2622
                         $qrow = Database::fetch_array($qres);
2623 2623
                         $objQuestion = Question::getInstance($qrow['type']);
2624
-                        $objQuestion = Question::read((int)$question_i);
2624
+                        $objQuestion = Question::read((int) $question_i);
2625 2625
                         $objQuestion->search_engine_edit($this->id, FALSE, TRUE);
2626 2626
                         unset($objQuestion);
2627 2627
                     }
@@ -2632,7 +2632,7 @@  discard block
 block discarded – undo
2632 2632
             Database::query($sql);
2633 2633
 
2634 2634
             // remove terms from db
2635
-            require_once api_get_path(LIBRARY_PATH) .'specific_fields_manager.lib.php';
2635
+            require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2636 2636
             delete_all_values_for_item($course_id, TOOL_QUIZ, $this->id);
2637 2637
         }
2638 2638
     }
@@ -2727,7 +2727,7 @@  discard block
 block discarded – undo
2727 2727
      */
2728 2728
     public function copy_exercise()
2729 2729
     {
2730
-        $exercise_obj= new Exercise();
2730
+        $exercise_obj = new Exercise();
2731 2731
         $exercise_obj = $this;
2732 2732
 
2733 2733
         // force the creation of a new exercise
@@ -2799,25 +2799,25 @@  discard block
 block discarded – undo
2799 2799
             $lp_id = 0;
2800 2800
         }
2801 2801
         if (empty($lp_item_id)) {
2802
-            $lp_item_id   = 0;
2802
+            $lp_item_id = 0;
2803 2803
         }
2804 2804
         if (empty($lp_item_view_id)) {
2805 2805
             $lp_item_view_id = 0;
2806 2806
         }
2807
-        $condition = ' WHERE exe_exo_id 	= ' . "'" . $this->id . "'" .' AND
2808
-					   exe_user_id 			= ' . "'" . api_get_user_id() . "'" . ' AND
2809
-					   c_id                 = ' . api_get_course_int_id() . ' AND
2810
-					   status 				= ' . "'" . Database::escape_string($status). "'" . ' AND
2811
-					   orig_lp_id 			= ' . "'" . $lp_id . "'" . ' AND
2812
-					   orig_lp_item_id 		= ' . "'" . $lp_item_id . "'" . ' AND
2813
-                       orig_lp_item_view_id = ' . "'" . $lp_item_view_id . "'" . ' AND
2814
-					   session_id 			= ' . "'" . api_get_session_id() . "' LIMIT 1"; //Adding limit 1 just in case
2807
+        $condition = ' WHERE exe_exo_id 	= '."'".$this->id."'".' AND
2808
+					   exe_user_id 			= ' . "'".api_get_user_id()."'".' AND
2809
+					   c_id                 = ' . api_get_course_int_id().' AND
2810
+					   status 				= ' . "'".Database::escape_string($status)."'".' AND
2811
+					   orig_lp_id 			= ' . "'".$lp_id."'".' AND
2812
+					   orig_lp_item_id 		= ' . "'".$lp_item_id."'".' AND
2813
+                       orig_lp_item_view_id = ' . "'".$lp_item_view_id."'".' AND
2814
+					   session_id 			= ' . "'".api_get_session_id()."' LIMIT 1"; //Adding limit 1 just in case
2815 2815
 
2816 2816
         $sql_track = 'SELECT * FROM '.$track_exercises.$condition;
2817 2817
 
2818 2818
         $result = Database::query($sql_track);
2819 2819
         $new_array = array();
2820
-        if (Database::num_rows($result) > 0 ) {
2820
+        if (Database::num_rows($result) > 0) {
2821 2821
             $new_array = Database::fetch_array($result, 'ASSOC');
2822 2822
             $new_array['num_exe'] = Database::num_rows($result);
2823 2823
         }
@@ -2860,12 +2860,12 @@  discard block
 block discarded – undo
2860 2860
         $questionList = array_map('intval', $questionList);
2861 2861
 
2862 2862
         $params = array(
2863
-            'exe_exo_id' => $this->id ,
2863
+            'exe_exo_id' => $this->id,
2864 2864
             'exe_user_id' => api_get_user_id(),
2865 2865
             'c_id' => api_get_course_int_id(),
2866 2866
             'status' =>  'incomplete',
2867 2867
             'session_id'  => api_get_session_id(),
2868
-            'data_tracking'  => implode(',', $questionList) ,
2868
+            'data_tracking'  => implode(',', $questionList),
2869 2869
             'start_date' => api_get_utc_datetime(),
2870 2870
             'orig_lp_id' => $safe_lp_id,
2871 2871
             'orig_lp_item_id'  => $safe_lp_item_id,
@@ -2897,7 +2897,7 @@  discard block
 block discarded – undo
2897 2897
         $nbrQuestions = $this->get_count_question_list();
2898 2898
 
2899 2899
         $all_button = $html = $label = '';
2900
-        $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']):null;
2900
+        $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null;
2901 2901
 
2902 2902
         if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) {
2903 2903
             $urlTitle = get_lang('ContinueTest');
@@ -2908,7 +2908,7 @@  discard block
 block discarded – undo
2908 2908
 
2909 2909
             $html .= Display::url(
2910 2910
                 $urlTitle,
2911
-                'exercise_submit_modal.php?' . http_build_query([
2911
+                'exercise_submit_modal.php?'.http_build_query([
2912 2912
                     'learnpath_id' => $safe_lp_id,
2913 2913
                     'learnpath_item_id' => $safe_lp_item_id,
2914 2914
                     'learnpath_item_view_id' => $safe_lp_item_view_id,
@@ -2925,7 +2925,7 @@  discard block
 block discarded – undo
2925 2925
                     'data-size' => 'md'
2926 2926
                 ]
2927 2927
             );
2928
-            $html .='<br />';
2928
+            $html .= '<br />';
2929 2929
         } else {
2930 2930
             // User
2931 2931
             if (api_is_allowed_to_session_edit()) {
@@ -2950,7 +2950,7 @@  discard block
 block discarded – undo
2950 2950
 
2951 2951
                     //Next question
2952 2952
                     if (!empty($questions_in_media)) {
2953
-                        $questions_in_media = "['".implode("','",$questions_in_media)."']";
2953
+                        $questions_in_media = "['".implode("','", $questions_in_media)."']";
2954 2954
                         $all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_question_list('.$questions_in_media.'); ">'.$label.'</a>';
2955 2955
                     } else {
2956 2956
                         $all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.', \'\', \''.$currentAnswer.'\'); ">'.$label.'</a>';
@@ -2968,7 +2968,7 @@  discard block
 block discarded – undo
2968 2968
                     }
2969 2969
 					$class .= ' question-validate-btn'; // used to select it with jquery
2970 2970
                     $all_button = '&nbsp;<a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>';
2971
-                    $all_button .= '&nbsp;' . Display::span(null, ['id' => 'save_all_reponse']);
2971
+                    $all_button .= '&nbsp;'.Display::span(null, ['id' => 'save_all_reponse']);
2972 2972
                     $html .= $all_button;
2973 2973
                 }
2974 2974
             }
@@ -3210,8 +3210,8 @@  discard block
 block discarded – undo
3210 3210
             $params = array();
3211 3211
             $params['course_id'] = $course_id;
3212 3212
             $params['session_id'] = api_get_session_id();
3213
-            $params['user_id'] = isset($exe_info['exe_user_id'])? $exe_info['exe_user_id'] : api_get_user_id();
3214
-            $params['exercise_id'] = isset($exe_info['exe_exo_id'])? $exe_info['exe_exo_id'] : $this->id;
3213
+            $params['user_id'] = isset($exe_info['exe_user_id']) ? $exe_info['exe_user_id'] : api_get_user_id();
3214
+            $params['exercise_id'] = isset($exe_info['exe_exo_id']) ? $exe_info['exe_exo_id'] : $this->id;
3215 3215
             $params['question_id'] = $questionId;
3216 3216
             $params['exe_id'] = isset($exe_info['exe_id']) ? $exe_info['exe_id'] : $exeId;
3217 3217
 
@@ -3267,10 +3267,10 @@  discard block
 block discarded – undo
3267 3267
             $answer = $objAnswerTmp->selectAnswer($answerId);
3268 3268
             $answerComment = $objAnswerTmp->selectComment($answerId);
3269 3269
             $answerCorrect = $objAnswerTmp->isCorrect($answerId);
3270
-            $answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId);
3270
+            $answerWeighting = (float) $objAnswerTmp->selectWeighting($answerId);
3271 3271
             $answerAutoId = $objAnswerTmp->selectAutoId($answerId);
3272 3272
 
3273
-            $answer_correct_array[$answerId] = (bool)$answerCorrect;
3273
+            $answer_correct_array[$answerId] = (bool) $answerCorrect;
3274 3274
 
3275 3275
             if ($debug) {
3276 3276
                 error_log("answer auto id: $answerAutoId ");
@@ -3279,7 +3279,7 @@  discard block
 block discarded – undo
3279 3279
 
3280 3280
             // Delineation
3281 3281
             $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
3282
-            $answer_delineation_destination=$objAnswerTmp->selectDestination(1);
3282
+            $answer_delineation_destination = $objAnswerTmp->selectDestination(1);
3283 3283
 
3284 3284
             switch ($answerType) {
3285 3285
                 // for unique answer
@@ -3292,7 +3292,7 @@  discard block
 block discarded – undo
3292 3292
                                     exe_id = '".$exeId."' AND
3293 3293
                                     question_id= '".$questionId."'";
3294 3294
                         $result = Database::query($sql);
3295
-                        $choice = Database::result($result,0,"answer");
3295
+                        $choice = Database::result($result, 0, "answer");
3296 3296
 
3297 3297
                         $studentChoice = $choice == $answerAutoId ? 1 : 0;
3298 3298
                         if ($studentChoice) {
@@ -3343,7 +3343,7 @@  discard block
 block discarded – undo
3343 3343
                     } else {
3344 3344
                         // If no result then the user just hit don't know
3345 3345
                         $studentChoice = 3;
3346
-                        $questionScore  +=  $doubt_score;
3346
+                        $questionScore += $doubt_score;
3347 3347
                     }
3348 3348
                     $totalScore = $questionScore;
3349 3349
                     break;
@@ -3359,17 +3359,17 @@  discard block
 block discarded – undo
3359 3359
                         }
3360 3360
 
3361 3361
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3362
-                        $real_answers[$answerId] = (bool)$studentChoice;
3362
+                        $real_answers[$answerId] = (bool) $studentChoice;
3363 3363
 
3364 3364
                         if ($studentChoice) {
3365
-                            $questionScore  +=$answerWeighting;
3365
+                            $questionScore += $answerWeighting;
3366 3366
                         }
3367 3367
                     } else {
3368 3368
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3369
-                        $real_answers[$answerId] = (bool)$studentChoice;
3369
+                        $real_answers[$answerId] = (bool) $studentChoice;
3370 3370
 
3371 3371
                         if (isset($studentChoice)) {
3372
-                            $questionScore  += $answerWeighting;
3372
+                            $questionScore += $answerWeighting;
3373 3373
                         }
3374 3374
                     }
3375 3375
                     $totalScore += $answerWeighting;
@@ -3387,16 +3387,16 @@  discard block
 block discarded – undo
3387 3387
                             $choice[$ind] = 1;
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
                         if ($studentChoice) {
3392
-                            $questionScore +=$answerWeighting;
3392
+                            $questionScore += $answerWeighting;
3393 3393
                         }
3394 3394
                     } else {
3395 3395
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3396 3396
                         if (isset($studentChoice)) {
3397 3397
                             $questionScore += $answerWeighting;
3398 3398
                         }
3399
-                        $real_answers[$answerId] = (bool)$studentChoice;
3399
+                        $real_answers[$answerId] = (bool) $studentChoice;
3400 3400
                     }
3401 3401
                     $totalScore += $answerWeighting;
3402 3402
                     if ($debug) error_log("studentChoice: $studentChoice");
@@ -3408,7 +3408,7 @@  discard block
 block discarded – undo
3408 3408
                         $resultans = Database::query($sql);
3409 3409
                         while ($row = Database::fetch_array($resultans)) {
3410 3410
                             $ind = $row['answer'];
3411
-                            $result = explode(':',$ind);
3411
+                            $result = explode(':', $ind);
3412 3412
                             if (isset($result[0])) {
3413 3413
                                 $my_answer_id = isset($result[0]) ? $result[0] : '';
3414 3414
                                 $option = isset($result[1]) ? $result[1] : '';
@@ -3529,10 +3529,10 @@  discard block
 block discarded – undo
3529 3529
                             }
3530 3530
                             // adds the piece of text that is before the blank
3531 3531
                             //and ends with '[' into a general storage array
3532
-                            $real_text[] = api_substr($temp, 0, $pos +1);
3533
-                            $answer .= api_substr($temp, 0, $pos +1);
3532
+                            $real_text[] = api_substr($temp, 0, $pos + 1);
3533
+                            $answer .= api_substr($temp, 0, $pos + 1);
3534 3534
                             //take the string remaining (after the last "[" we found)
3535
-                            $temp = api_substr($temp, $pos +1);
3535
+                            $temp = api_substr($temp, $pos + 1);
3536 3536
                             // quit the loop if there are no more blanks, and update $pos to the position of next ']'
3537 3537
                             if (($pos = api_strpos($temp, ']')) === false) {
3538 3538
                                 // adds the end of the text
@@ -3568,7 +3568,7 @@  discard block
 block discarded – undo
3568 3568
                             //put the contents of the [] answer tag into correct_tags[]
3569 3569
                             $correct_tags[] = api_substr($temp, 0, $pos);
3570 3570
                             $j++;
3571
-                            $temp = api_substr($temp, $pos +1);
3571
+                            $temp = api_substr($temp, $pos + 1);
3572 3572
                         }
3573 3573
                         $answer = '';
3574 3574
                         $real_correct_tags = $correct_tags;
@@ -3591,7 +3591,7 @@  discard block
 block discarded – undo
3591 3591
                                 } elseif (!empty($user_tags[$i])) {
3592 3592
                                     // else if the word entered by the student IS NOT the same as the one defined by the professor
3593 3593
                                     // adds the word in red at the end of the string, and strikes it
3594
-                                    $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>';
3594
+                                    $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>';
3595 3595
                                 } else {
3596 3596
                                     // adds a tabulation if no word has been typed by the student
3597 3597
                                     $answer .= ''; // remove &nbsp; that causes issue
@@ -3610,17 +3610,17 @@  discard block
 block discarded – undo
3610 3610
                                 } elseif (!empty ($user_tags[$i])) {
3611 3611
                                     // else if the word entered by the student IS NOT the same as the one defined by the professor
3612 3612
                                     // adds the word in red at the end of the string, and strikes it
3613
-                                    $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>';
3613
+                                    $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>';
3614 3614
                                 } else {
3615 3615
                                     // adds a tabulation if no word has been typed by the student
3616
-                                    $answer .= '';  // remove &nbsp; that causes issue
3616
+                                    $answer .= ''; // remove &nbsp; that causes issue
3617 3617
                                 }
3618 3618
                             }
3619 3619
 
3620 3620
                             // adds the correct word, followed by ] to close the blank
3621
-                            $answer .= ' / <font color="green"><b>' . $real_correct_tags[$i] . '</b></font>]';
3622
-                            if (isset($real_text[$i +1])) {
3623
-                                $answer .= $real_text[$i +1];
3621
+                            $answer .= ' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]';
3622
+                            if (isset($real_text[$i + 1])) {
3623
+                                $answer .= $real_text[$i + 1];
3624 3624
                             }
3625 3625
                         }
3626 3626
                     } else {
@@ -3754,10 +3754,10 @@  discard block
 block discarded – undo
3754 3754
                         }
3755 3755
                         // adds the piece of text that is before the blank
3756 3756
                         //and ends with '[' into a general storage array
3757
-                        $realText[] = api_substr($temp, 0, $pos +1);
3758
-                        $answer .= api_substr($temp, 0, $pos +1);
3757
+                        $realText[] = api_substr($temp, 0, $pos + 1);
3758
+                        $answer .= api_substr($temp, 0, $pos + 1);
3759 3759
                         //take the string remaining (after the last "[" we found)
3760
-                        $temp = api_substr($temp, $pos +1);
3760
+                        $temp = api_substr($temp, $pos + 1);
3761 3761
                         // quit the loop if there are no more blanks, and update $pos to the position of next ']'
3762 3762
                         if (($pos = api_strpos($temp, ']')) === false) {
3763 3763
                             // adds the end of the text
@@ -3791,7 +3791,7 @@  discard block
 block discarded – undo
3791 3791
                         //put the contents of the [] answer tag into correct_tags[]
3792 3792
                         $correctTags[] = api_substr($temp, 0, $pos);
3793 3793
                         $j++;
3794
-                        $temp = api_substr($temp, $pos +1);
3794
+                        $temp = api_substr($temp, $pos + 1);
3795 3795
                     }
3796 3796
                     $answer = '';
3797 3797
                     $realCorrectTags = $correctTags;
@@ -3811,22 +3811,22 @@  discard block
 block discarded – undo
3811 3811
                         } elseif (!empty($userTags[$i])) {
3812 3812
                             // else if the word entered by the student IS NOT the same as the one defined by the professor
3813 3813
                             // adds the word in red at the end of the string, and strikes it
3814
-                            $answer .= '<font color="red"><s>' . $userTags[$i] . '</s></font>';
3814
+                            $answer .= '<font color="red"><s>'.$userTags[$i].'</s></font>';
3815 3815
                         } else {
3816 3816
                             // adds a tabulation if no word has been typed by the student
3817 3817
                             $answer .= ''; // remove &nbsp; that causes issue
3818 3818
                         }
3819 3819
                         // adds the correct word, followed by ] to close the blank
3820
-                        $answer .= ' / <font color="green"><b>' . $realCorrectTags[$i] . '</b></font>]';
3821
-                        if (isset($realText[$i +1])) {
3822
-                            $answer .= $realText[$i +1];
3820
+                        $answer .= ' / <font color="green"><b>'.$realCorrectTags[$i].'</b></font>]';
3821
+                        if (isset($realText[$i + 1])) {
3822
+                            $answer .= $realText[$i + 1];
3823 3823
                         }
3824 3824
                     }
3825 3825
                     break;
3826 3826
                 // for free answer
3827 3827
                 case FREE_ANSWER:
3828 3828
                     if ($from_database) {
3829
-                        $query  = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3829
+                        $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3830 3830
                                    WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3831 3831
                         $resq = Database::query($query);
3832 3832
                         $data = Database::fetch_array($resq);
@@ -3837,9 +3837,9 @@  discard block
 block discarded – undo
3837 3837
                         $questionScore = $data['marks'];
3838 3838
 
3839 3839
                         if ($questionScore == -1) {
3840
-                            $totalScore+= 0;
3840
+                            $totalScore += 0;
3841 3841
                         } else {
3842
-                            $totalScore+= $questionScore;
3842
+                            $totalScore += $questionScore;
3843 3843
                         }
3844 3844
                         if ($questionScore == '') {
3845 3845
                             $questionScore = 0;
@@ -3860,14 +3860,14 @@  discard block
 block discarded – undo
3860 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
-                        $choice = Database::result($resq,0,'answer');
3863
+                        $choice = Database::result($resq, 0, 'answer');
3864 3864
                         $choice = str_replace('\r\n', '', $choice);
3865 3865
                         $choice = stripslashes($choice);
3866
-                        $questionScore = Database::result($resq,0,"marks");
3867
-                        if ($questionScore==-1) {
3868
-                            $totalScore+=0;
3866
+                        $questionScore = Database::result($resq, 0, "marks");
3867
+                        if ($questionScore == -1) {
3868
+                            $totalScore += 0;
3869 3869
                         } else {
3870
-                            $totalScore+=$questionScore;
3870
+                            $totalScore += $questionScore;
3871 3871
                         }
3872 3872
                         $arrques = $questionName;
3873 3873
                         $arrans  = $choice;
@@ -3912,7 +3912,7 @@  discard block
 block discarded – undo
3912 3912
 
3913 3913
                         while ($a_answers = Database::fetch_array($res_answers)) {
3914 3914
                             $i_answer_id = $a_answers['id']; //3
3915
-                            $s_answer_label = $a_answers['answer'];  // your daddy - your mother
3915
+                            $s_answer_label = $a_answers['answer']; // your daddy - your mother
3916 3916
                             $i_answer_correct_answer = $a_answers['correct']; //1 - 2
3917 3917
                             $i_answer_id_auto = $a_answers['id_auto']; // 3 - 4
3918 3918
 
@@ -3964,8 +3964,8 @@  discard block
 block discarded – undo
3964 3964
 
3965 3965
                             if ($show_result) {
3966 3966
                                 echo '<tr>';
3967
-                                echo '<td>' . $s_answer_label . '</td>';
3968
-                                echo '<td>' . $user_answer;
3967
+                                echo '<td>'.$s_answer_label.'</td>';
3968
+                                echo '<td>'.$user_answer;
3969 3969
 
3970 3970
                                 if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
3971 3971
                                     if (isset($real_list[$i_answer_correct_answer])) {
@@ -4074,7 +4074,7 @@  discard block
 block discarded – undo
4074 4074
                     if ($from_database) {
4075 4075
                         // getting the user answer
4076 4076
                         $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
4077
-                        $query   = "SELECT hotspot_correct, hotspot_coordinate
4077
+                        $query = "SELECT hotspot_correct, hotspot_coordinate
4078 4078
                                     FROM $TBL_TRACK_HOTSPOT
4079 4079
                                     WHERE
4080 4080
                                         hotspot_exe_id = '".$exeId."' AND
@@ -4082,20 +4082,20 @@  discard block
 block discarded – undo
4082 4082
                                         hotspot_answer_id='1'";
4083 4083
                         //by default we take 1 because it's a delineation
4084 4084
                         $resq = Database::query($query);
4085
-                        $row = Database::fetch_array($resq,'ASSOC');
4085
+                        $row = Database::fetch_array($resq, 'ASSOC');
4086 4086
 
4087 4087
                         $choice = $row['hotspot_correct'];
4088 4088
                         $user_answer = $row['hotspot_coordinate'];
4089 4089
 
4090 4090
                         // THIS is very important otherwise the poly_compile will throw an error!!
4091 4091
                         // round-up the coordinates
4092
-                        $coords = explode('/',$user_answer);
4092
+                        $coords = explode('/', $user_answer);
4093 4093
                         $user_array = '';
4094 4094
                         foreach ($coords as $coord) {
4095
-                            list($x,$y) = explode(';',$coord);
4095
+                            list($x, $y) = explode(';', $coord);
4096 4096
                             $user_array .= round($x).';'.round($y).'/';
4097 4097
                         }
4098
-                        $user_array = substr($user_array,0,-1);
4098
+                        $user_array = substr($user_array, 0, -1);
4099 4099
                     } else {
4100 4100
                         if (!empty($studentChoice)) {
4101 4101
                             $newquestionList[] = $questionId;
@@ -4105,13 +4105,13 @@  discard block
 block discarded – undo
4105 4105
                             $studentChoice = $choice[$answerId];
4106 4106
                             $questionScore += $answerWeighting;
4107 4107
 
4108
-                            if ($hotspot_delineation_result[1]==1) {
4108
+                            if ($hotspot_delineation_result[1] == 1) {
4109 4109
                                 $totalScore += $answerWeighting; //adding the total
4110 4110
                             }
4111 4111
                         }
4112 4112
                     }
4113
-                    $_SESSION['hotspot_coord'][1]	= $delineation_cord;
4114
-                    $_SESSION['hotspot_dest'][1]	= $answer_delineation_destination;
4113
+                    $_SESSION['hotspot_coord'][1] = $delineation_cord;
4114
+                    $_SESSION['hotspot_dest'][1] = $answer_delineation_destination;
4115 4115
                     break;
4116 4116
             } // end switch Answertype
4117 4117
 
@@ -4169,7 +4169,7 @@  discard block
 block discarded – undo
4169 4169
                                 $results_disabled
4170 4170
                             );
4171 4171
                             //}
4172
-                        } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
4172
+                        } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
4173 4173
                             //	if ($origin!='learnpath') {
4174 4174
                             ExerciseShowFunctions::display_multiple_answer_combination_true_false(
4175 4175
                                 $feedback_type,
@@ -4186,11 +4186,11 @@  discard block
 block discarded – undo
4186 4186
                             //}
4187 4187
                         } elseif ($answerType == FILL_IN_BLANKS) {
4188 4188
                             //if ($origin!='learnpath') {
4189
-                            ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer,0,0, $results_disabled);
4189
+                            ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer, 0, 0, $results_disabled);
4190 4190
                             //	}
4191 4191
                         } elseif ($answerType == CALCULATED_ANSWER) {
4192 4192
                             //if ($origin!='learnpath') {
4193
-                            ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer,0,0);
4193
+                            ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer, 0, 0);
4194 4194
                             //  }
4195 4195
                         } elseif ($answerType == FREE_ANSWER) {
4196 4196
                             //if($origin != 'learnpath') {
@@ -4244,13 +4244,13 @@  discard block
 block discarded – undo
4244 4244
                             $user_answer = $_SESSION['exerciseResultCoordinates'][$questionId];
4245 4245
 
4246 4246
                             //round-up the coordinates
4247
-                            $coords = explode('/',$user_answer);
4247
+                            $coords = explode('/', $user_answer);
4248 4248
                             $user_array = '';
4249 4249
                             foreach ($coords as $coord) {
4250
-                                list($x,$y) = explode(';',$coord);
4250
+                                list($x, $y) = explode(';', $coord);
4251 4251
                                 $user_array .= round($x).';'.round($y).'/';
4252 4252
                             }
4253
-                            $user_array = substr($user_array,0,-1);
4253
+                            $user_array = substr($user_array, 0, -1);
4254 4254
 
4255 4255
                             if ($next) {
4256 4256
 
@@ -4277,7 +4277,7 @@  discard block
 block discarded – undo
4277 4277
                                 //$overlap = round(polygons_overlap($poly_answer,$poly_user));
4278 4278
                                 // //this is an area in pixels
4279 4279
                                 if ($debug > 0) {
4280
-                                    error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0);
4280
+                                    error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0);
4281 4281
                                 }
4282 4282
 
4283 4283
                                 if ($overlap < 1) {
@@ -4290,43 +4290,43 @@  discard block
 block discarded – undo
4290 4290
                                     // that is overlapped by the user's polygon
4291 4291
                                     $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
4292 4292
                                     if ($debug > 1) {
4293
-                                        error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
4293
+                                        error_log(__LINE__.' - Final overlap is '.$final_overlap, 0);
4294 4294
                                     }
4295 4295
                                     // the final missing area is the percentage of the initial polygon
4296 4296
                                     // that is not overlapped by the user's polygon
4297 4297
                                     $final_missing = 100 - $final_overlap;
4298 4298
                                     if ($debug > 1) {
4299
-                                        error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
4299
+                                        error_log(__LINE__.' - Final missing is '.$final_missing, 0);
4300 4300
                                     }
4301 4301
                                     // the final excess area is the percentage of the initial polygon's size
4302 4302
                                     // that is covered by the user's polygon outside of the initial polygon
4303 4303
                                     $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
4304 4304
                                     if ($debug > 1) {
4305
-                                        error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0);
4305
+                                        error_log(__LINE__.' - Final excess is '.$final_excess, 0);
4306 4306
                                     }
4307 4307
                                 }
4308 4308
 
4309 4309
                                 //checking the destination parameters parsing the "@@"
4310
-                                $destination_items= explode('@@', $answerDestination);
4310
+                                $destination_items = explode('@@', $answerDestination);
4311 4311
                                 $threadhold_total = $destination_items[0];
4312
-                                $threadhold_items=explode(';',$threadhold_total);
4312
+                                $threadhold_items = explode(';', $threadhold_total);
4313 4313
                                 $threadhold1 = $threadhold_items[0]; // overlap
4314 4314
                                 $threadhold2 = $threadhold_items[1]; // excess
4315
-                                $threadhold3 = $threadhold_items[2];	 //missing
4315
+                                $threadhold3 = $threadhold_items[2]; //missing
4316 4316
 
4317 4317
                                 // if is delineation
4318
-                                if ($answerId===1) {
4318
+                                if ($answerId === 1) {
4319 4319
                                     //setting colors
4320
-                                    if ($final_overlap>=$threadhold1) {
4321
-                                        $overlap_color=true; //echo 'a';
4320
+                                    if ($final_overlap >= $threadhold1) {
4321
+                                        $overlap_color = true; //echo 'a';
4322 4322
                                     }
4323 4323
                                     //echo $excess.'-'.$threadhold2;
4324
-                                    if ($final_excess<=$threadhold2) {
4325
-                                        $excess_color=true; //echo 'b';
4324
+                                    if ($final_excess <= $threadhold2) {
4325
+                                        $excess_color = true; //echo 'b';
4326 4326
                                     }
4327 4327
                                     //echo '--------'.$missing.'-'.$threadhold3;
4328
-                                    if ($final_missing<=$threadhold3) {
4329
-                                        $missing_color=true; //echo 'c';
4328
+                                    if ($final_missing <= $threadhold3) {
4329
+                                        $missing_color = true; //echo 'c';
4330 4330
                                     }
4331 4331
 
4332 4332
                                     // if pass
@@ -4335,67 +4335,67 @@  discard block
 block discarded – undo
4335 4335
                                         $final_missing <= $threadhold3 &&
4336 4336
                                         $final_excess <= $threadhold2
4337 4337
                                     ) {
4338
-                                        $next=1; //go to the oars
4339
-                                        $result_comment=get_lang('Acceptable');
4340
-                                        $final_answer = 1;	// do not update with  update_exercise_attempt
4338
+                                        $next = 1; //go to the oars
4339
+                                        $result_comment = get_lang('Acceptable');
4340
+                                        $final_answer = 1; // do not update with  update_exercise_attempt
4341 4341
                                     } else {
4342
-                                        $next=0;
4343
-                                        $result_comment=get_lang('Unacceptable');
4344
-                                        $comment=$answerDestination=$objAnswerTmp->selectComment(1);
4345
-                                        $answerDestination=$objAnswerTmp->selectDestination(1);
4342
+                                        $next = 0;
4343
+                                        $result_comment = get_lang('Unacceptable');
4344
+                                        $comment = $answerDestination = $objAnswerTmp->selectComment(1);
4345
+                                        $answerDestination = $objAnswerTmp->selectDestination(1);
4346 4346
                                         //checking the destination parameters parsing the "@@"
4347
-                                        $destination_items= explode('@@', $answerDestination);
4347
+                                        $destination_items = explode('@@', $answerDestination);
4348 4348
                                     }
4349
-                                } elseif($answerId>1) {
4349
+                                } elseif ($answerId > 1) {
4350 4350
                                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
4351
-                                        if ($debug>0) {
4352
-                                            error_log(__LINE__.' - answerId is of type noerror',0);
4351
+                                        if ($debug > 0) {
4352
+                                            error_log(__LINE__.' - answerId is of type noerror', 0);
4353 4353
                                         }
4354 4354
                                         //type no error shouldn't be treated
4355 4355
                                         $next = 1;
4356 4356
                                         continue;
4357 4357
                                     }
4358
-                                    if ($debug>0) {
4359
-                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);
4358
+                                    if ($debug > 0) {
4359
+                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
4360 4360
                                     }
4361 4361
                                     //check the intersection between the oar and the user
4362 4362
                                     //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
4363 4363
                                     //echo 'official';print_r($x_list);print_r($y_list);
4364 4364
                                     //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
4365
-                                    $inter= $result['success'];
4365
+                                    $inter = $result['success'];
4366 4366
 
4367 4367
                                     //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
4368
-                                    $delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
4368
+                                    $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId);
4369 4369
 
4370
-                                    $poly_answer = convert_coordinates($delineation_cord,'|');
4371
-                                    $max_coord = poly_get_max($poly_user,$poly_answer);
4372
-                                    $poly_answer_compiled = poly_compile($poly_answer,$max_coord);
4373
-                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
4370
+                                    $poly_answer = convert_coordinates($delineation_cord, '|');
4371
+                                    $max_coord = poly_get_max($poly_user, $poly_answer);
4372
+                                    $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
4373
+                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
4374 4374
 
4375 4375
                                     if ($overlap == false) {
4376 4376
                                         //all good, no overlap
4377 4377
                                         $next = 1;
4378 4378
                                         continue;
4379 4379
                                     } else {
4380
-                                        if ($debug>0) {
4381
-                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);
4380
+                                        if ($debug > 0) {
4381
+                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0);
4382 4382
                                         }
4383 4383
                                         $organs_at_risk_hit++;
4384 4384
                                         //show the feedback
4385
-                                        $next=0;
4386
-                                        $comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
4387
-                                        $answerDestination=$objAnswerTmp->selectDestination($answerId);
4388
-
4389
-                                        $destination_items= explode('@@', $answerDestination);
4390
-                                        $try_hotspot=$destination_items[1];
4391
-                                        $lp_hotspot=$destination_items[2];
4392
-                                        $select_question_hotspot=$destination_items[3];
4393
-                                        $url_hotspot=$destination_items[4];
4385
+                                        $next = 0;
4386
+                                        $comment = $answerDestination = $objAnswerTmp->selectComment($answerId);
4387
+                                        $answerDestination = $objAnswerTmp->selectDestination($answerId);
4388
+
4389
+                                        $destination_items = explode('@@', $answerDestination);
4390
+                                        $try_hotspot = $destination_items[1];
4391
+                                        $lp_hotspot = $destination_items[2];
4392
+                                        $select_question_hotspot = $destination_items[3];
4393
+                                        $url_hotspot = $destination_items[4];
4394 4394
                                     }
4395 4395
                                 }
4396 4396
                             } else {	// the first delineation feedback
4397
-                                if ($debug>0) {
4398
-                                    error_log(__LINE__.' first',0);
4397
+                                if ($debug > 0) {
4398
+                                    error_log(__LINE__.' first', 0);
4399 4399
                                 }
4400 4400
                             }
4401 4401
                         } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
@@ -4403,7 +4403,7 @@  discard block
 block discarded – undo
4403 4403
                             echo Display::tag('td', $answerMatching[$answerId]);
4404 4404
                             echo Display::tag(
4405 4405
                                 'td',
4406
-                                "$user_answer / " . Display::tag(
4406
+                                "$user_answer / ".Display::tag(
4407 4407
                                     'strong',
4408 4408
                                     $answerMatching[$answerCorrect],
4409 4409
                                     ['style' => 'color: #008000; font-weight: bold;']
@@ -4543,7 +4543,7 @@  discard block
 block discarded – undo
4543 4543
                                     $exeId,
4544 4544
                                     $questionId,
4545 4545
                                     $nano
4546
-                                ) . '</td>
4546
+                                ).'</td>
4547 4547
                                 </tr>
4548 4548
                                 </table>';
4549 4549
                             break;
@@ -4602,7 +4602,7 @@  discard block
 block discarded – undo
4602 4602
 
4603 4603
                                 //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
4604 4604
                                 if ($debug > 0) {
4605
-                                    error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0);
4605
+                                    error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0);
4606 4606
                                 }
4607 4607
                                 if ($overlap < 1) {
4608 4608
                                     //shortcut to avoid complicated calculations
@@ -4613,17 +4613,17 @@  discard block
 block discarded – undo
4613 4613
                                     // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
4614 4614
                                     $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
4615 4615
                                     if ($debug > 1) {
4616
-                                        error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
4616
+                                        error_log(__LINE__.' - Final overlap is '.$final_overlap, 0);
4617 4617
                                     }
4618 4618
                                     // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
4619 4619
                                     $final_missing = 100 - $final_overlap;
4620 4620
                                     if ($debug > 1) {
4621
-                                        error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
4621
+                                        error_log(__LINE__.' - Final missing is '.$final_missing, 0);
4622 4622
                                     }
4623 4623
                                     // 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
4624 4624
                                     $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
4625 4625
                                     if ($debug > 1) {
4626
-                                        error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0);
4626
+                                        error_log(__LINE__.' - Final excess is '.$final_excess, 0);
4627 4627
                                     }
4628 4628
                                 }
4629 4629
 
@@ -4633,7 +4633,7 @@  discard block
 block discarded – undo
4633 4633
                                 $threadhold_items = explode(';', $threadhold_total);
4634 4634
                                 $threadhold1 = $threadhold_items[0]; // overlap
4635 4635
                                 $threadhold2 = $threadhold_items[1]; // excess
4636
-                                $threadhold3 = $threadhold_items[2];  //missing
4636
+                                $threadhold3 = $threadhold_items[2]; //missing
4637 4637
                                 // if is delineation
4638 4638
                                 if ($answerId === 1) {
4639 4639
                                     //setting colors
@@ -4665,14 +4665,14 @@  discard block
 block discarded – undo
4665 4665
                                 } elseif ($answerId > 1) {
4666 4666
                                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
4667 4667
                                         if ($debug > 0) {
4668
-                                            error_log(__LINE__ . ' - answerId is of type noerror', 0);
4668
+                                            error_log(__LINE__.' - answerId is of type noerror', 0);
4669 4669
                                         }
4670 4670
                                         //type no error shouldn't be treated
4671 4671
                                         $next = 1;
4672 4672
                                         continue;
4673 4673
                                     }
4674 4674
                                     if ($debug > 0) {
4675
-                                        error_log(__LINE__ . ' - answerId is >1 so we\'re probably in OAR', 0);
4675
+                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
4676 4676
                                     }
4677 4677
                                     //check the intersection between the oar and the user
4678 4678
                                     //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
@@ -4686,7 +4686,7 @@  discard block
 block discarded – undo
4686 4686
                                     $poly_answer = convert_coordinates($delineation_cord, '|');
4687 4687
                                     $max_coord = poly_get_max($poly_user, $poly_answer);
4688 4688
                                     $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
4689
-                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
4689
+                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
4690 4690
 
4691 4691
                                     if ($overlap == false) {
4692 4692
                                         //all good, no overlap
@@ -4694,7 +4694,7 @@  discard block
 block discarded – undo
4694 4694
                                         continue;
4695 4695
                                     } else {
4696 4696
                                         if ($debug > 0) {
4697
-                                            error_log(__LINE__ . ' - Overlap is ' . $overlap . ': OAR hit', 0);
4697
+                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0);
4698 4698
                                         }
4699 4699
                                         $organs_at_risk_hit++;
4700 4700
                                         //show the feedback
@@ -4706,12 +4706,12 @@  discard block
 block discarded – undo
4706 4706
                                         $try_hotspot = $destination_items[1];
4707 4707
                                         $lp_hotspot = $destination_items[2];
4708 4708
                                         $select_question_hotspot = $destination_items[3];
4709
-                                        $url_hotspot=$destination_items[4];
4709
+                                        $url_hotspot = $destination_items[4];
4710 4710
                                     }
4711 4711
                                 }
4712 4712
                             } else {	// the first delineation feedback
4713 4713
                                 if ($debug > 0) {
4714
-                                    error_log(__LINE__ . ' first', 0);
4714
+                                    error_log(__LINE__.' first', 0);
4715 4715
                                 }
4716 4716
                             }
4717 4717
                             break;
@@ -4733,7 +4733,7 @@  discard block
 block discarded – undo
4733 4733
                             echo Display::tag('td', $answerMatching[$answerId]);
4734 4734
                             echo Display::tag(
4735 4735
                                 'td',
4736
-                                "$user_answer / " . Display::tag(
4736
+                                "$user_answer / ".Display::tag(
4737 4737
                                     'strong',
4738 4738
                                     $answerMatching[$answerCorrect],
4739 4739
                                     ['style' => 'color: #008000; font-weight: bold;']
@@ -4819,7 +4819,7 @@  discard block
 block discarded – undo
4819 4819
             //  we use the results from the session (from_db=0)
4820 4820
             // TODO Change this, because it is wrong to show the user
4821 4821
             //  some results that haven't been stored in the database yet
4822
-            if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) {
4822
+            if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION) {
4823 4823
 
4824 4824
                 if ($debug) error_log('$from AND this is a hotspot kind of question ');
4825 4825
 
@@ -4828,19 +4828,19 @@  discard block
 block discarded – undo
4828 4828
                 if ($answerType == HOT_SPOT_DELINEATION) {
4829 4829
                     if (0) {
4830 4830
                         if ($overlap_color) {
4831
-                            $overlap_color='green';
4831
+                            $overlap_color = 'green';
4832 4832
                         } else {
4833
-                            $overlap_color='red';
4833
+                            $overlap_color = 'red';
4834 4834
                         }
4835 4835
                         if ($missing_color) {
4836
-                            $missing_color='green';
4836
+                            $missing_color = 'green';
4837 4837
                         } else {
4838
-                            $missing_color='red';
4838
+                            $missing_color = 'red';
4839 4839
                         }
4840 4840
                         if ($excess_color) {
4841
-                            $excess_color='green';
4841
+                            $excess_color = 'green';
4842 4842
                         } else {
4843
-                            $excess_color='red';
4843
+                            $excess_color = 'red';
4844 4844
                         }
4845 4845
                         if (!is_numeric($final_overlap)) {
4846 4846
                             $final_overlap = 0;
@@ -4852,33 +4852,33 @@  discard block
 block discarded – undo
4852 4852
                             $final_excess = 0;
4853 4853
                         }
4854 4854
 
4855
-                        if ($final_overlap>100) {
4855
+                        if ($final_overlap > 100) {
4856 4856
                             $final_overlap = 100;
4857 4857
                         }
4858 4858
 
4859
-                        $table_resume='<table class="data_table">
4859
+                        $table_resume = '<table class="data_table">
4860 4860
                                 <tr class="row_odd" >
4861 4861
                                     <td></td>
4862
-                                    <td ><b>' . get_lang('Requirements') . '</b></td>
4863
-                                    <td><b>' . get_lang('YourAnswer') . '</b></td>
4862
+                                    <td ><b>' . get_lang('Requirements').'</b></td>
4863
+                                    <td><b>' . get_lang('YourAnswer').'</b></td>
4864 4864
                                 </tr>
4865 4865
                                 <tr class="row_even">
4866
-                                    <td><b>' . get_lang('Overlap') . '</b></td>
4867
-                                    <td>' . get_lang('Min') . ' ' . $threadhold1 . '</td>
4868
-                                    <td><div style="color:' . $overlap_color . '">'
4869
-                                        . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '</div></td>
4866
+                                    <td><b>' . get_lang('Overlap').'</b></td>
4867
+                                    <td>' . get_lang('Min').' '.$threadhold1.'</td>
4868
+                                    <td><div style="color:' . $overlap_color.'">'
4869
+                                        . (($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td>
4870 4870
                                 </tr>
4871 4871
                                 <tr>
4872
-                                    <td><b>' . get_lang('Excess') . '</b></td>
4873
-                                    <td>' . get_lang('Max') . ' ' . $threadhold2 . '</td>
4874
-                                    <td><div style="color:' . $excess_color . '">'
4875
-                                        . (($final_excess < 0) ? 0 : intval($final_excess)) . '</div></td>
4872
+                                    <td><b>' . get_lang('Excess').'</b></td>
4873
+                                    <td>' . get_lang('Max').' '.$threadhold2.'</td>
4874
+                                    <td><div style="color:' . $excess_color.'">'
4875
+                                        . (($final_excess < 0) ? 0 : intval($final_excess)).'</div></td>
4876 4876
                                 </tr>
4877 4877
                                 <tr class="row_even">
4878
-                                    <td><b>' . get_lang('Missing') . '</b></td>
4879
-                                    <td>' . get_lang('Max') . ' ' . $threadhold3 . '</td>
4880
-                                    <td><div style="color:' . $missing_color . '">'
4881
-                                        . (($final_missing < 0) ? 0 : intval($final_missing)) . '</div></td>
4878
+                                    <td><b>' . get_lang('Missing').'</b></td>
4879
+                                    <td>' . get_lang('Max').' '.$threadhold3.'</td>
4880
+                                    <td><div style="color:' . $missing_color.'">'
4881
+                                        . (($final_missing < 0) ? 0 : intval($final_missing)).'</div></td>
4882 4882
                                 </tr>
4883 4883
                             </table>';
4884 4884
                         if ($next == 0) {
@@ -4893,20 +4893,20 @@  discard block
 block discarded – undo
4893 4893
                             $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
4894 4894
                         }
4895 4895
 
4896
-                        echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1>
4896
+                        echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>
4897 4897
                             <p style="text-align:center">';
4898 4898
 
4899
-                        $message = '<p>' . get_lang('YourDelineation') . '</p>';
4899
+                        $message = '<p>'.get_lang('YourDelineation').'</p>';
4900 4900
                         $message .= $table_resume;
4901
-                        $message .= '<br />' . get_lang('ResultIs') . ' ' . $result_comment . '<br />';
4901
+                        $message .= '<br />'.get_lang('ResultIs').' '.$result_comment.'<br />';
4902 4902
                         if ($organs_at_risk_hit > 0) {
4903
-                            $message .= '<p><b>' . get_lang('OARHit') . '</b></p>';
4903
+                            $message .= '<p><b>'.get_lang('OARHit').'</b></p>';
4904 4904
                         }
4905
-                        $message .='<p>' . $comment . '</p>';
4905
+                        $message .= '<p>'.$comment.'</p>';
4906 4906
                         echo $message;
4907 4907
                     } else {
4908 4908
                         echo $hotspot_delineation_result[0]; //prints message
4909
-                        $from_database = 1;  // the hotspot_solution.swf needs this variable
4909
+                        $from_database = 1; // the hotspot_solution.swf needs this variable
4910 4910
                     }
4911 4911
 
4912 4912
                     //save the score attempts
@@ -4928,20 +4928,20 @@  discard block
 block discarded – undo
4928 4928
                             $exerciseResultCoordinates[$quesId]
4929 4929
                         );
4930 4930
                     } else {
4931
-                        if ($final_answer==0) {
4931
+                        if ($final_answer == 0) {
4932 4932
                             $questionScore = 0;
4933
-                            $answer=0;
4933
+                            $answer = 0;
4934 4934
                             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
4935 4935
                             if (is_array($exerciseResultCoordinates[$quesId])) {
4936
-                                foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
4937
-                                    Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,0,$val);
4936
+                                foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
4937
+                                    Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, 0, $val);
4938 4938
                                 }
4939 4939
                             }
4940 4940
                         } else {
4941 4941
                             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
4942 4942
                             if (is_array($exerciseResultCoordinates[$quesId])) {
4943
-                                foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
4944
-                                    Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,$choice[$idx],$val);
4943
+                                foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
4944
+                                    Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, $choice[$idx], $val);
4945 4945
                                 }
4946 4946
                             }
4947 4947
                         }
@@ -4960,7 +4960,7 @@  discard block
 block discarded – undo
4960 4960
                     echo "
4961 4961
                         <tr>
4962 4962
                             <td colspan=\"2\">
4963
-                                <p><em>" . get_lang('HotSpot') . "</em></p>
4963
+                                <p><em>" . get_lang('HotSpot')."</em></p>
4964 4964
 
4965 4965
                                 <div id=\"hotspot-solution-$questionId\"></div>
4966 4966
 
@@ -4998,7 +4998,7 @@  discard block
 block discarded – undo
4998 4998
 
4999 4999
         if ($saved_results) {
5000 5000
             if ($debug) error_log("Save question results $saved_results");
5001
-            if ($debug) error_log(print_r($choice ,1 ));
5001
+            if ($debug) error_log(print_r($choice, 1));
5002 5002
 
5003 5003
             if (empty($choice)) {
5004 5004
                 $choice = 0;
@@ -5010,14 +5010,14 @@  discard block
 block discarded – undo
5010 5010
                         $ans = $reply[$i];
5011 5011
                         Event::saveQuestionAttempt(
5012 5012
                             $questionScore,
5013
-                            $ans . ':' . $choice[$ans],
5013
+                            $ans.':'.$choice[$ans],
5014 5014
                             $quesId,
5015 5015
                             $exeId,
5016 5016
                             $i,
5017 5017
                             $this->id
5018 5018
                         );
5019 5019
                         if ($debug) {
5020
-                            error_log('result =>' . $questionScore . ' ' . $ans . ':' . $choice[$ans]);
5020
+                            error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]);
5021 5021
                         }
5022 5022
                     }
5023 5023
                 } else {
@@ -5028,7 +5028,7 @@  discard block
 block discarded – undo
5028 5028
                     $reply = array_keys($choice);
5029 5029
 
5030 5030
                     if ($debug) {
5031
-                        error_log("reply " . print_r($reply, 1) . "");
5031
+                        error_log("reply ".print_r($reply, 1)."");
5032 5032
                     }
5033 5033
                     for ($i = 0; $i < sizeof($reply); $i++) {
5034 5034
                         $ans = $reply[$i];
@@ -5087,7 +5087,7 @@  discard block
 block discarded – undo
5087 5087
 
5088 5088
                 Event::saveQuestionAttempt($questionScore, implode('|', $answer), $quesId, $exeId, 0, $this->id);
5089 5089
             } else {
5090
-                Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0,$this->id);
5090
+                Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
5091 5091
             }
5092 5092
         }
5093 5093
 
@@ -5097,8 +5097,8 @@  discard block
 block discarded – undo
5097 5097
 
5098 5098
         if ($saved_results) {
5099 5099
             $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5100
-            $sql = 'UPDATE ' . $stat_table . ' SET
5101
-                        exe_result = exe_result + ' . floatval($questionScore) . '
5100
+            $sql = 'UPDATE '.$stat_table.' SET
5101
+                        exe_result = exe_result + ' . floatval($questionScore).'
5102 5102
                     WHERE exe_id = ' . $exeId;
5103 5103
             if ($debug) error_log($sql);
5104 5104
             Database::query($sql);
@@ -5122,7 +5122,7 @@  discard block
 block discarded – undo
5122 5122
      */
5123 5123
     public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id)
5124 5124
     {
5125
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5125
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5126 5126
             return null;
5127 5127
         }
5128 5128
         // Email configuration settings
@@ -5173,7 +5173,7 @@  discard block
 block discarded – undo
5173 5173
         $msg = str_replace("#course#", $courseInfo['name'], $msg1);
5174 5174
 
5175 5175
         if ($origin != 'learnpath') {
5176
-            $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5176
+            $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5177 5177
         }
5178 5178
         $msg1 = str_replace("#url#", $url_email, $msg);
5179 5179
         $mail_content = $msg1;
@@ -5202,7 +5202,7 @@  discard block
 block discarded – undo
5202 5202
      */
5203 5203
     function send_notification_for_open_questions($question_list_answers, $origin, $exe_id)
5204 5204
     {
5205
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5205
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5206 5206
             return null;
5207 5207
         }
5208 5208
         // Email configuration settings
@@ -5265,11 +5265,11 @@  discard block
 block discarded – undo
5265 5265
             $msg .= '</table><br />';
5266 5266
 
5267 5267
 
5268
-            $msg1   = str_replace("#exercise#",    $this->exercise, $msg);
5269
-            $msg    = str_replace("#firstName#",   $user_info['firstname'],$msg1);
5270
-            $msg1   = str_replace("#lastName#",    $user_info['lastname'],$msg);
5271
-            $msg    = str_replace("#mail#",        $user_info['email'],$msg1);
5272
-            $msg    = str_replace("#course#",      $course_info['name'],$msg1);
5268
+            $msg1   = str_replace("#exercise#", $this->exercise, $msg);
5269
+            $msg    = str_replace("#firstName#", $user_info['firstname'], $msg1);
5270
+            $msg1   = str_replace("#lastName#", $user_info['lastname'], $msg);
5271
+            $msg    = str_replace("#mail#", $user_info['email'], $msg1);
5272
+            $msg    = str_replace("#course#", $course_info['name'], $msg1);
5273 5273
 
5274 5274
             if ($origin != 'learnpath') {
5275 5275
                 $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
@@ -5298,7 +5298,7 @@  discard block
 block discarded – undo
5298 5298
 
5299 5299
     function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id)
5300 5300
     {
5301
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5301
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5302 5302
             return null;
5303 5303
         }
5304 5304
         // Email configuration settings
@@ -5322,7 +5322,7 @@  discard block
 block discarded – undo
5322 5322
             $answer_type = $item['answer_type'];
5323 5323
 
5324 5324
             if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) {
5325
-                $oral_question_list.='<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">'
5325
+                $oral_question_list .= '<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">'
5326 5326
                     .'<tr>'
5327 5327
                         .'<td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Question').'</td>'
5328 5328
                         .'<td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>'
@@ -5355,7 +5355,7 @@  discard block
 block discarded – undo
5355 5355
                             .'<td>&nbsp;#mail#</td>'
5356 5356
                         .'</tr>'
5357 5357
                     .'</table>';
5358
-            $msg .=  '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'),$oral_question_list).'<br />';
5358
+            $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'), $oral_question_list).'<br />';
5359 5359
             $msg1 = str_replace("#exercise#", $this->exercise, $msg);
5360 5360
             $msg = str_replace("#firstName#", $user_info['firstname'], $msg1);
5361 5361
             $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg);
@@ -5363,7 +5363,7 @@  discard block
 block discarded – undo
5363 5363
             $msg = str_replace("#course#", $course_info['name'], $msg1);
5364 5364
 
5365 5365
             if ($origin != 'learnpath') {
5366
-                $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5366
+                $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5367 5367
             }
5368 5368
             $msg1 = str_replace("#url#", $url_email, $msg);
5369 5369
             $mail_content = $msg1;
@@ -5429,10 +5429,10 @@  discard block
 block discarded – undo
5429 5429
         }
5430 5430
         $html  = '<div class="question-result">';
5431 5431
         $html .= Display::page_header(
5432
-            Display::return_icon('test-quiz.png', get_lang('Result'),null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result')
5432
+            Display::return_icon('test-quiz.png', get_lang('Result'), null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result')
5433 5433
         );
5434 5434
         $html .= Display::description($array);
5435
-        $html .="</div>";
5435
+        $html .= "</div>";
5436 5436
         return $html;
5437 5437
     }
5438 5438
 
@@ -5549,7 +5549,7 @@  discard block
 block discarded – undo
5549 5549
                     false,
5550 5550
                     $objExercise->selectPropagateNeg()
5551 5551
                 );
5552
-                $totalScore      += $question_result['score'];
5552
+                $totalScore += $question_result['score'];
5553 5553
             }
5554 5554
 
5555 5555
             if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) {
@@ -5755,7 +5755,7 @@  discard block
 block discarded – undo
5755 5755
         }
5756 5756
 
5757 5757
         $rawMessage = "";
5758
-        if (!empty($message)){
5758
+        if (!empty($message)) {
5759 5759
             $rawMessage = $message;
5760 5760
             $message = Display::return_message($message, 'warning', false);
5761 5761
         }
@@ -5771,7 +5771,7 @@  discard block
 block discarded – undo
5771 5771
     {
5772 5772
         $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
5773 5773
         $sql = "SELECT max_score FROM $TBL_LP_ITEM
5774
-            WHERE c_id = {$this->course_id} AND item_type = '" . TOOL_QUIZ . "' AND path = '{$this->id}'";
5774
+            WHERE c_id = {$this->course_id} AND item_type = '".TOOL_QUIZ."' AND path = '{$this->id}'";
5775 5775
         $result = Database::query($sql);
5776 5776
         if (Database::num_rows($result) > 0) {
5777 5777
             return true;
@@ -6099,7 +6099,7 @@  discard block
 block discarded – undo
6099 6099
         $sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id ";
6100 6100
         $result = Database::query($sql_track);
6101 6101
         $new_array = array();
6102
-        if (Database::num_rows($result) > 0 ) {
6102
+        if (Database::num_rows($result) > 0) {
6103 6103
             $new_array = Database::fetch_array($result, 'ASSOC');
6104 6104
 
6105 6105
             $new_array['duration'] = null;
@@ -6111,11 +6111,11 @@  discard block
 block discarded – undo
6111 6111
                 $start_date = api_strtotime($start_date, 'UTC');
6112 6112
                 $end_date = api_strtotime($end_date, 'UTC');
6113 6113
                 if ($start_date && $end_date) {
6114
-                    $mytime = $end_date- $start_date;
6114
+                    $mytime = $end_date - $start_date;
6115 6115
                     $new_learnpath_item = new learnpathItem(null);
6116 6116
                     $time_attemp = $new_learnpath_item->get_scorm_time('js', $mytime);
6117 6117
                     $h = get_lang('h');
6118
-                    $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
6118
+                    $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp);
6119 6119
                     $new_array['duration'] = $time_attemp;
6120 6120
                 }
6121 6121
             }
@@ -6137,7 +6137,7 @@  discard block
 block discarded – undo
6137 6137
                     $result = Database::query($sql);
6138 6138
                 }
6139 6139
             } else {
6140
-                $remind_list = explode(',',$exercise_info['questions_to_check']);
6140
+                $remind_list = explode(',', $exercise_info['questions_to_check']);
6141 6141
 
6142 6142
                 $remind_list_string = '';
6143 6143
                 if ($action == 'add') {
@@ -6149,7 +6149,7 @@  discard block
 block discarded – undo
6149 6149
                         }
6150 6150
                         $remind_list_string = implode(',', $remind_list);
6151 6151
                     }
6152
-                } elseif ($action == 'delete')  {
6152
+                } elseif ($action == 'delete') {
6153 6153
                     if (!empty($remind_list)) {
6154 6154
                         if (in_array($question_id, $remind_list)) {
6155 6155
                             $remind_list = array_flip($remind_list);
@@ -6391,7 +6391,7 @@  discard block
 block discarded – undo
6391 6391
                     true
6392 6392
                 );
6393 6393
 
6394
-                $counter += count($mediaQuestions[$questionId]) - 1 ;
6394
+                $counter += count($mediaQuestions[$questionId]) - 1;
6395 6395
                 $before = count($questionList);
6396 6396
                 $wasMedia = true;
6397 6397
                 $nextValue += count($questionList);
@@ -6470,7 +6470,7 @@  discard block
 block discarded – undo
6470 6470
                         // If it was already seen, then merge the previous with
6471 6471
                         // the current category
6472 6472
                         $oldQuestionList = $newCategoryList[$rootElement]['question_list'];
6473
-                        $category['question_list'] = array_merge($oldQuestionList , $category['question_list']);
6473
+                        $category['question_list'] = array_merge($oldQuestionList, $category['question_list']);
6474 6474
                         $newCategoryList[$rootElement] = $category;
6475 6475
                     }
6476 6476
                 }
@@ -6496,7 +6496,7 @@  discard block
 block discarded – undo
6496 6496
 
6497 6497
                 if ($useRootAsCategoryTitle) {
6498 6498
                     if (isset($category['parent_info'])) {
6499
-                        $categoryName  = $category['parent_info']['title'];
6499
+                        $categoryName = $category['parent_info']['title'];
6500 6500
                     }
6501 6501
                 }
6502 6502
                 $html .= '<div class="row">';
@@ -6639,7 +6639,7 @@  discard block
 block discarded – undo
6639 6639
         // end foreach()
6640 6640
 
6641 6641
         if ($this->type == ALL_ON_ONE_PAGE) {
6642
-            $exercise_actions =  $this->show_button($questionId, $currentQuestion);
6642
+            $exercise_actions = $this->show_button($questionId, $currentQuestion);
6643 6643
             echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
6644 6644
         }
6645 6645
     }
@@ -6725,7 +6725,7 @@  discard block
 block discarded – undo
6725 6725
 
6726 6726
             // Showing the question
6727 6727
 
6728
-            $exercise_actions  = null;
6728
+            $exercise_actions = null;
6729 6729
 
6730 6730
             echo '<a id="questionanchor'.$questionId.'"></a><br />';
6731 6731
             echo '<div id="question_div_'.$questionId.'" class="main_question '.$remind_highlight.'" >';
@@ -6993,7 +6993,7 @@  discard block
 block discarded – undo
6993 6993
                         $header .= Display::tag('th', get_lang('Feedback'));
6994 6994
                     }
6995 6995
                     $s .= '<table class="data_table">';
6996
-                    $s.= Display::tag('tr', $header, array('style' => 'text-align:left;'));
6996
+                    $s .= Display::tag('tr', $header, array('style' => 'text-align:left;'));
6997 6997
                 }
6998 6998
             }
6999 6999
 
@@ -7093,7 +7093,7 @@  discard block
 block discarded – undo
7093 7093
                             $s .= '<td>';
7094 7094
                             $s .= $comment;
7095 7095
                             $s .= '</td>';
7096
-                            $s .='</tr>';
7096
+                            $s .= '</tr>';
7097 7097
                         } else {
7098 7098
                             $s .= $answer_input;
7099 7099
                         }
@@ -7107,7 +7107,7 @@  discard block
 block discarded – undo
7107 7107
                             }
7108 7108
                         }
7109 7109
 
7110
-                        $s .='<tr>';
7110
+                        $s .= '<tr>';
7111 7111
                         $s .= Display::tag('td', $answer);
7112 7112
 
7113 7113
                         if (!empty($quiz_question_options)) {
@@ -7134,7 +7134,7 @@  discard block
 block discarded – undo
7134 7134
                             $s .= $comment;
7135 7135
                             $s .= '</td>';
7136 7136
                         }
7137
-                        $s.='</tr>';
7137
+                        $s .= '</tr>';
7138 7138
                     }
7139 7139
 
7140 7140
                 } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
@@ -7163,16 +7163,16 @@  discard block
 block discarded – undo
7163 7163
                     $answer_input .= '</label>';
7164 7164
 
7165 7165
                     if ($show_comment) {
7166
-                        $s.= '<tr>';
7166
+                        $s .= '<tr>';
7167 7167
                         $s .= '<td>';
7168
-                        $s.= $answer_input;
7168
+                        $s .= $answer_input;
7169 7169
                         $s .= '</td>';
7170 7170
                         $s .= '<td>';
7171 7171
                         $s .= $comment;
7172 7172
                         $s .= '</td>';
7173
-                        $s.= '</tr>';
7173
+                        $s .= '</tr>';
7174 7174
                     } else {
7175
-                        $s.= $answer_input;
7175
+                        $s .= $answer_input;
7176 7176
                     }
7177 7177
                 } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
7178 7178
                     $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
@@ -7185,7 +7185,7 @@  discard block
 block discarded – undo
7185 7185
                         }
7186 7186
                     }
7187 7187
                     $answer = Security::remove_XSS($answer);
7188
-                    $s .='<tr>';
7188
+                    $s .= '<tr>';
7189 7189
                     $s .= Display::tag('td', $answer);
7190 7190
 
7191 7191
                     foreach ($objQuestionTmp->options as $key => $item) {
@@ -7209,7 +7209,7 @@  discard block
 block discarded – undo
7209 7209
                         $s .= $comment;
7210 7210
                         $s .= '</td>';
7211 7211
                     }
7212
-                    $s.='</tr>';
7212
+                    $s .= '</tr>';
7213 7213
                 } elseif ($answerType == FILL_IN_BLANKS) {
7214 7214
                     list($answer) = explode('::', $answer);
7215 7215
 
@@ -7243,7 +7243,7 @@  discard block
 block discarded – undo
7243 7243
                                     $value = str_replace('&nbsp;', '', trim($value[0]));
7244 7244
                                 }
7245 7245
                                 $correct_item = preg_quote($correct_item);
7246
-                                $correct_item = api_preg_replace('|/|', '\/', $correct_item);   // to prevent error if there is a / in the text to find
7246
+                                $correct_item = api_preg_replace('|/|', '\/', $correct_item); // to prevent error if there is a / in the text to find
7247 7247
                                 $answer = api_preg_replace('/'.$correct_item.'/', Display::input('text', "choice[$questionId][]", $value), $answer, 1);
7248 7248
                             }
7249 7249
                             $i++;
@@ -7300,7 +7300,7 @@  discard block
 block discarded – undo
7300 7300
                         }
7301 7301
 
7302 7302
                         if (!empty($answerCorrect) && !empty($selectedValue)) {
7303
-                            $s.= '<script>
7303
+                            $s .= '<script>
7304 7304
                                 jsPlumb.ready(function() {
7305 7305
                                     jsPlumb.connect({
7306 7306
                                         source: "window_'.$windowId.'",
@@ -7315,14 +7315,14 @@  discard block
 block discarded – undo
7315 7315
                         }
7316 7316
                         $s .= '</select></div></td>';
7317 7317
 
7318
-                        $s.='<td width="45%" valign="top" >';
7318
+                        $s .= '<td width="45%" valign="top" >';
7319 7319
 
7320 7320
                         if (isset($select_items[$lines_count])) {
7321
-                            $s.= '<div id="window_'.$windowId.'_answer" class="window window_right_question">
7321
+                            $s .= '<div id="window_'.$windowId.'_answer" class="window window_right_question">
7322 7322
                                     <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].'
7323 7323
                                   </div>';
7324 7324
                         } else {
7325
-                            $s.='&nbsp;';
7325
+                            $s .= '&nbsp;';
7326 7326
                         }
7327 7327
 
7328 7328
                         $s .= '</td>';
@@ -7336,16 +7336,16 @@  discard block
 block discarded – undo
7336 7336
                                 $s .= '<tr>
7337 7337
                                       <td colspan="2"></td>
7338 7338
                                       <td valign="top">';
7339
-                                $s.='<b>'.$select_items[$lines_count]['letter'].'.</b>';
7339
+                                $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b>';
7340 7340
                                 $s .= $select_items[$lines_count]['answer'];
7341
-                                $s.="</td>
7341
+                                $s .= "</td>
7342 7342
                                 </tr>";
7343 7343
                                 $lines_count++;
7344 7344
                             } // end while()
7345 7345
                         }  // end if()
7346 7346
                         $matching_correct_answer++;
7347 7347
                     }
7348
-                } elseif ($answerType ==  DRAGGABLE) {
7348
+                } elseif ($answerType == DRAGGABLE) {
7349 7349
                     // matching type, showing suggestions and answers
7350 7350
                     // TODO: replace $answerId by $numAnswer
7351 7351
 
@@ -7388,7 +7388,7 @@  discard block
 block discarded – undo
7388 7388
                         $s .= '</select>';
7389 7389
 
7390 7390
                         if (!empty($answerCorrect) && !empty($selectedValue)) {
7391
-                            $s.= '<script>
7391
+                            $s .= '<script>
7392 7392
                                 $(function() {
7393 7393
                                     deleteItem($("#'.$questionId.'_'.$selectedValue.'"), $("#drop_'.$windowId.'"));
7394 7394
                                 });
@@ -7397,11 +7397,11 @@  discard block
 block discarded – undo
7397 7397
 
7398 7398
 
7399 7399
                         if (isset($select_items[$lines_count])) {
7400
-                            $s.= '<div id="window_'.$windowId.'_answer" class="">
7400
+                            $s .= '<div id="window_'.$windowId.'_answer" class="">
7401 7401
                                     <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].'
7402 7402
                                   </div>';
7403 7403
                         } else {
7404
-                            $s.='&nbsp;';
7404
+                            $s .= '&nbsp;';
7405 7405
                         }
7406 7406
                         $lines_count++;
7407 7407
                         //if the left side of the "matching" has been completely
@@ -7410,7 +7410,7 @@  discard block
 block discarded – undo
7410 7410
                         if (($lines_count - 1) == $num_suggestions) {
7411 7411
                             // if it remains answers to shown at the right side
7412 7412
                             while (isset($select_items[$lines_count])) {
7413
-                                $s.='<b>'.$select_items[$lines_count]['letter'].'.</b>';
7413
+                                $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b>';
7414 7414
                                 $s .= $select_items[$lines_count]['answer'];
7415 7415
                                 $lines_count++;
7416 7416
                             }
@@ -7513,9 +7513,9 @@  discard block
 block discarded – undo
7513 7513
 
7514 7514
             if (!$only_questions) {
7515 7515
                 if ($show_title) {
7516
-                    $html .=  TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id);
7517
-                    $html .=  '<div class="question_title">'.$current_item.'. '.$questionName.'</div>';
7518
-                    $html .=  $questionDescription;
7516
+                    $html .= TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id);
7517
+                    $html .= '<div class="question_title">'.$current_item.'. '.$questionName.'</div>';
7518
+                    $html .= $questionDescription;
7519 7519
                 } else {
7520 7520
                     $html .= '<div class="media">';
7521 7521
                     $html .= '<div class="pull-left">';
@@ -7531,11 +7531,11 @@  discard block
 block discarded – undo
7531 7531
                     $html .= '</div>';
7532 7532
                 }
7533 7533
                 //@todo I need to the get the feedback type
7534
-                $html .=  '<input type="hidden" name="hidden_hotspot_id" value="'.$questionId.'" />';
7535
-                $html .=  '<table class="exercise_questions">
7534
+                $html .= '<input type="hidden" name="hidden_hotspot_id" value="'.$questionId.'" />';
7535
+                $html .= '<table class="exercise_questions">
7536 7536
                            <tr>
7537 7537
                             <td valign="top" colspan="2">';
7538
-                $html .=  '</td></tr>';
7538
+                $html .= '</td></tr>';
7539 7539
             }
7540 7540
 
7541 7541
             $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
Please login to merge, or discard this patch.
main/exercice/hotpotatoes_exercise_report.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 if ($is_allowedToEdit && $origin != 'learnpath') {
74 74
     // the form
75 75
     if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
76
-        $actions .= '<a id="export_opener" href="'.api_get_self().'?export_report=1&path='.Security::remove_XSS($hotpotatoes_path).' ">'.Display::return_icon('save.png',   get_lang('Export'),'',ICON_SIZE_MEDIUM).'</a>';
76
+        $actions .= '<a id="export_opener" href="'.api_get_self().'?export_report=1&path='.Security::remove_XSS($hotpotatoes_path).' ">'.Display::return_icon('save.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
77 77
     }
78 78
 } else {
79
-    $actions .= '<a href="exercise.php">' . Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
79
+    $actions .= '<a href="exercise.php">'.Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
80 80
 }
81 81
 
82 82
 if ($is_allowedToEdit) {
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
 
99 99
 if ($is_allowedToEdit || $is_tutor) {
100 100
     $nameTools = get_lang('StudentScore');
101
-    $interbreadcrumb[] = array("url" => "exercise.php","name" => get_lang('Exercises'));
101
+    $interbreadcrumb[] = array("url" => "exercise.php", "name" => get_lang('Exercises'));
102 102
     $objExerciseTmp = new Exercise();
103 103
     /*if ($objExerciseTmp->read($exercise_id)) {
104 104
         $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$exercise_id, "name" => $objExerciseTmp->name);
105 105
     }*/
106 106
 } else {
107
-    $interbreadcrumb[] = array("url" => "exercise.php","name" => get_lang('Exercises'));
107
+    $interbreadcrumb[] = array("url" => "exercise.php", "name" => get_lang('Exercises'));
108 108
     $objExerciseTmp = new Exercise();
109 109
     /*if ($objExerciseTmp->read($exercise_id)) {
110 110
         $nameTools = get_lang('Results').': '.$objExerciseTmp->name;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
 $actions = Display::div($actions, array('class'=> 'actions'));
117 117
 
118
-$extra =  '<script type="text/javascript">
118
+$extra = '<script type="text/javascript">
119 119
     $(document).ready(function() {
120 120
 
121 121
         $( "#dialog:ui-dialog" ).dialog( "destroy" );
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 // Generating group list
170 170
 
171 171
 $group_list = GroupManager::get_group_list();
172
-$group_parameters = array('group_all:'.get_lang('All'),'group_none:'.get_lang('None'));
172
+$group_parameters = array('group_all:'.get_lang('All'), 'group_none:'.get_lang('None'));
173 173
 
174 174
 foreach ($group_list as $group) {
175 175
     $group_parameters[] = $group['id'].':'.$group['name'];
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
 
193 193
   // Column config
194 194
   // @todo fix search firstname/lastname that doesn't work. rmove search for the moment
195
-	$column_model   = array(
196
-        array('name'=>'firstname',      'index'=>'firstname',		'width'=>'50',   'align'=>'left', 'search' => 'false'),
197
-        array('name'=>'lastname',		    'index'=>'lastname',		'width'=>'50',   'align'=>'left', 'formatter'=>'action_formatter', 'search' => 'false'),
198
-        array('name'=>'login',          'hidden'=>'true',       'index'=>'username',        'width'=>'40',   'align'=>'left', 'search' => 'false'),
199
-        array('name'=>'group_name',		  'index'=>'group_id',    'width'=>'40',   'align'=>'left', 'search' => 'false'),
200
-        array('name'=>'exe_date',		    'index'=>'exe_date',		'width'=>'60',   'align'=>'left', 'search' => 'false'),
201
-        array('name'=>'score',			    'index'=>'exe_result',	'width'=>'50',   'align'=>'left', 'search' => 'false'),
202
-        array('name'=>'actions',        'index'=>'actions',     'width'=>'60',  'align'=>'left', 'search' => 'false')
195
+	$column_model = array(
196
+        array('name'=>'firstname', 'index'=>'firstname', 'width'=>'50', 'align'=>'left', 'search' => 'false'),
197
+        array('name'=>'lastname', 'index'=>'lastname', 'width'=>'50', 'align'=>'left', 'formatter'=>'action_formatter', 'search' => 'false'),
198
+        array('name'=>'login', 'hidden'=>'true', 'index'=>'username', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
199
+        array('name'=>'group_name', 'index'=>'group_id', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
200
+        array('name'=>'exe_date', 'index'=>'exe_date', 'width'=>'60', 'align'=>'left', 'search' => 'false'),
201
+        array('name'=>'score', 'index'=>'exe_result', 'width'=>'50', 'align'=>'left', 'search' => 'false'),
202
+        array('name'=>'actions', 'index'=>'actions', 'width'=>'60', 'align'=>'left', 'search' => 'false')
203 203
     );
204 204
 
205 205
     $action_links = '
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
 
223 223
     //Column config
224 224
     // @todo fix search firstname/lastname that doesn't work. rmove search for the moment
225
-    $column_model  = array(
226
-        array('name'=>'exe_date',		    'index'=>'exe_date',		'width'=>'60',   'align'=>'left', 'search' => 'false'),
227
-        array('name'=>'score',			    'index'=>'exe_result',	'width'=>'50',   'align'=>'left', 'search' => 'false'),
228
-        array('name'=>'actions',        'index'=>'actions',     'width'=>'60',  'align'=>'left', 'search' => 'false')
225
+    $column_model = array(
226
+        array('name'=>'exe_date', 'index'=>'exe_date', 'width'=>'60', 'align'=>'left', 'search' => 'false'),
227
+        array('name'=>'score', 'index'=>'exe_result', 'width'=>'50', 'align'=>'left', 'search' => 'false'),
228
+        array('name'=>'actions', 'index'=>'actions', 'width'=>'60', 'align'=>'left', 'search' => 'false')
229 229
     );
230 230
 }
231 231
 
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 }
46 46
 
47 47
 if (!$is_allowedToEdit) {
48
-   // api_not_allowed();
48
+    // api_not_allowed();
49 49
 }
50 50
 
51 51
 if (!empty($_REQUEST['path'])) {
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
         get_lang('Actions')
191 191
     );
192 192
 
193
-  // Column config
194
-  // @todo fix search firstname/lastname that doesn't work. rmove search for the moment
195
-	$column_model   = array(
193
+    // Column config
194
+    // @todo fix search firstname/lastname that doesn't work. rmove search for the moment
195
+    $column_model   = array(
196 196
         array('name'=>'firstname',      'index'=>'firstname',		'width'=>'50',   'align'=>'left', 'search' => 'false'),
197 197
         array('name'=>'lastname',		    'index'=>'lastname',		'width'=>'50',   'align'=>'left', 'formatter'=>'action_formatter', 'search' => 'false'),
198 198
         array('name'=>'login',          'hidden'=>'true',       'index'=>'username',        'width'=>'40',   'align'=>'left', 'search' => 'false'),
Please login to merge, or discard this patch.
main/exercice/hotspot.inc.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@
 block discarded – undo
18 18
 $file = file(api_get_path(SYS_LANG_PATH).'english/hotspot.inc.php');
19 19
 
20 20
 foreach ($file as &$value) {
21
-	$variable = explode('=', $value , 2);
22
-	if (count($variable) > 1) {
23
-		$variable = substr(trim($variable[0]), 1);
24
-		$variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' ';
25
-		echo $variable;
26
-	}
21
+    $variable = explode('=', $value , 2);
22
+    if (count($variable) > 1) {
23
+        $variable = substr(trim($variable[0]), 1);
24
+        $variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' ';
25
+        echo $variable;
26
+    }
27 27
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 $file = file(api_get_path(SYS_LANG_PATH).'english/hotspot.inc.php');
19 19
 
20 20
 foreach ($file as &$value) {
21
-	$variable = explode('=', $value , 2);
21
+	$variable = explode('=', $value, 2);
22 22
 	if (count($variable) > 1) {
23 23
 		$variable = substr(trim($variable[0]), 1);
24 24
 		$variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' ';
Please login to merge, or discard this patch.
main/exercice/tests_category.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 function add_category_form($action) {
148 148
     $action = Security::remove_XSS($action);
149 149
     // initiate the object
150
-    $form = new FormValidator('note', 'post', api_get_self() . '?action=' . $action);
150
+    $form = new FormValidator('note', 'post', api_get_self().'?action='.$action);
151 151
     // Setting the form elements
152 152
     $form->addElement('header', get_lang('AddACategory'));
153 153
     $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95'));
@@ -189,19 +189,19 @@  discard block
 block discarded – undo
189 189
 
190 190
 function display_add_category() {
191 191
     echo '<div class="actions">';
192
-    echo '<a href="exercise.php?' . api_get_cidreq() . '">' .
193
-            Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
194
-    echo '<a href="' . api_get_self() . '?action=addcategory">' .
195
-        Display::return_icon('question_category.gif', get_lang('AddACategory')) . '</a>';
192
+    echo '<a href="exercise.php?'.api_get_cidreq().'">'.
193
+            Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
194
+    echo '<a href="'.api_get_self().'?action=addcategory">'.
195
+        Display::return_icon('question_category.gif', get_lang('AddACategory')).'</a>';
196 196
     echo '</div>';
197 197
     echo "<br/>";
198
-    echo "<fieldset><legend>" . get_lang('QuestionCategory') . "</legend></fieldset>";
198
+    echo "<fieldset><legend>".get_lang('QuestionCategory')."</legend></fieldset>";
199 199
 }
200 200
 
201 201
 // display goback to category list page link
202 202
 function display_goback() {
203 203
     echo '<div class="actions">';
204
-    echo '<a href="' . api_get_self() . '">' .
205
-        Display::return_icon('back.png', get_lang('BackToCategoryList'), array(), 32) . '</a>';
204
+    echo '<a href="'.api_get_self().'">'.
205
+        Display::return_icon('back.png', get_lang('BackToCategoryList'), array(), 32).'</a>';
206 206
     echo '</div>';
207 207
 }
Please login to merge, or discard this patch.
main/exercice/overview.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -249,7 +249,7 @@
 block discarded – undo
249 249
             break;
250 250
         case RESULT_DISABLE_SHOW_SCORE_ONLY:
251 251
             if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) {
252
-               $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'));
252
+                $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'));
253 253
             }
254 254
             else {
255 255
                 $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'), get_lang('Details'));
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 require_once '../inc/global.inc.php';
14 14
 
15
-$current_course_tool  = TOOL_QUIZ;
15
+$current_course_tool = TOOL_QUIZ;
16 16
 
17 17
 // Clear the exercise session just in case
18 18
 if (isset($_SESSION['objExercise'])) {
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 if ($time_control) {
51 51
     // Get time left for expiring time
52
-    $time_left = api_strtotime($clock_expired_time,'UTC') - time();
52
+    $time_left = api_strtotime($clock_expired_time, 'UTC') - time();
53 53
 
54 54
     $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/stylesheet/jquery.epiclock.css');
55 55
     $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css');
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 $html = '';
74 74
 $message = '';
75
-$html.= '<div class="exercise">';
75
+$html .= '<div class="exercise">';
76 76
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
77 77
 $edit_link = '';
78 78
 if ($is_allowed_to_edit && $objExercise->sessionId == $sessionId) {
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
             $attempt_result['exe_result'],
178 178
             $attempt_result['exe_weighting']
179 179
         );
180
-        $attempt_url = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?';
181
-        $attempt_url .= api_get_cidreq() . '&show_headers=1&';
180
+        $attempt_url = api_get_path(WEB_CODE_PATH).'exercice/result.php?';
181
+        $attempt_url .= api_get_cidreq().'&show_headers=1&';
182 182
         $attempt_url .= http_build_query([
183 183
             'id' => $attempt_result['exe_id']
184 184
         ]);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
             get_lang('Show'),
189 189
             $attempt_url,
190 190
             [
191
-                'class' => $btn_class . 'btn btn-default',
191
+                'class' => $btn_class.'btn btn-default',
192 192
                 'data-title' => get_lang('Show'),
193 193
                 'data-size' => 'lg'
194 194
             ]
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             ),
207 207
             'userIp' => $attempt_result['user_ip']
208 208
         );
209
-        $attempt_link .= "&nbsp;&nbsp;&nbsp;" . $teacher_revised;
209
+        $attempt_link .= "&nbsp;&nbsp;&nbsp;".$teacher_revised;
210 210
 
211 211
         if (in_array(
212 212
             $objExercise->results_disabled,
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
         $attempt_message = Display::return_message($attempt_message, 'info');
284 284
     }
285 285
     if ($visible_return['value'] == true) {
286
-        $message .=   $attempt_message;
286
+        $message .= $attempt_message;
287 287
     }
288 288
 }
289 289
 
290 290
 if ($time_control) {
291
-    $html.= $objExercise->return_time_left_div();
291
+    $html .= $objExercise->return_time_left_div();
292 292
 }
293 293
 
294 294
 $html .= $message;
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
     $table_content,
309 309
     ['class' => 'table-responsive']
310 310
 );
311
-$html.= '</div>';
311
+$html .= '</div>';
312 312
 echo $html;
313 313
 
314 314
 Display::display_footer();
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -250,8 +250,7 @@
 block discarded – undo
250 250
         case RESULT_DISABLE_SHOW_SCORE_ONLY:
251 251
             if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) {
252 252
                $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'));
253
-            }
254
-            else {
253
+            } else {
255 254
                 $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'), get_lang('Details'));
256 255
             }
257 256
             break;
Please login to merge, or discard this patch.
main/exercice/TestCategory.php 4 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -401,8 +401,7 @@
 block discarded – undo
401 401
 				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
402 402
 				if ($nbQuestionInThisCat > $in_nbrandom) {
403 403
 					$nbquestionresult += $in_nbrandom;
404
-				}
405
-				else {
404
+				} else {
406 405
 					$nbquestionresult += $nbQuestionInThisCat;
407 406
 				}
408 407
 			}
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	 * Return the list of differents categories NAME for a test
368 368
 	 * @param int exercise id
369 369
 	 * @param bool
370
-	 * @return array of string
370
+	 * @return integer of string
371 371
 	 *
372 372
      * @author function rewrote by jmontoya
373 373
 	 */
@@ -983,7 +983,6 @@  discard block
 block discarded – undo
983 983
     /**
984 984
      * Return the id of the test category with title = $in_title
985 985
      * @param $in_title
986
-     * @param int $in_c_id
987 986
      *
988 987
      * @return int is id of test category
989 988
      */
@@ -1011,7 +1010,7 @@  discard block
 block discarded – undo
1011 1010
      * @param int $questionId
1012 1011
      * @param int $courseId
1013 1012
 	 *
1014
-	 * @return int
1013
+	 * @return string|false
1015 1014
      */
1016 1015
     public static function add_category_for_question_id($categoryId, $questionId, $courseId)
1017 1016
     {
Please login to merge, or discard this patch.
Indentation   +504 added lines, -504 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
     public $name;
14 14
     public $description;
15 15
 
16
-	/**
17
-	 * Constructor of the class Category
18
-	 * If you give an in_id and no in_name, you get info concerning the category of id=in_id
19
-	 * otherwise, you've got an category objet avec your in_id, in_name, in_descr
20
-	 *
16
+    /**
17
+     * Constructor of the class Category
18
+     * If you give an in_id and no in_name, you get info concerning the category of id=in_id
19
+     * otherwise, you've got an category objet avec your in_id, in_name, in_descr
20
+     *
21 21
      * @param int    $id
22 22
      * @param string $name
23 23
      * @param string $description
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
         }
62 62
     }
63 63
 
64
-	/**
64
+    /**
65 65
      * add TestCategory in the database if name doesn't already exists
66
-	 */
66
+     */
67 67
     public function addCategoryInBDD()
68 68
     {
69 69
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 
109 109
             return false;
110 110
         }
111
-	}
111
+    }
112 112
 
113
-	/**
113
+    /**
114 114
      * Removes the category from the database
115 115
      * if there were question in this category, the link between question and category is removed
116
-	 */
116
+     */
117 117
     public function removeCategory()
118 118
     {
119 119
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 
144 144
             return true;
145 145
         }
146
-	}
146
+    }
147 147
 
148
-	/**
148
+    /**
149 149
      * Modify category name or description of category with id=in_id
150
-	 */
150
+     */
151 151
     public function modifyCategory()
152 152
     {
153 153
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -175,40 +175,40 @@  discard block
 block discarded – undo
175 175
 
176 176
             return true;
177 177
         }
178
-	}
178
+    }
179 179
 
180
-	/**
180
+    /**
181 181
      * Gets the number of question of category id=in_id
182
-	 */
182
+     */
183 183
     public function getCategoryQuestionsNumber()
184 184
     {
185
-		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
186
-		$in_id = intval($this->id);
187
-		$sql = "SELECT count(*) AS nb
185
+        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
186
+        $in_id = intval($this->id);
187
+        $sql = "SELECT count(*) AS nb
188 188
 		        FROM $table
189 189
 		        WHERE category_id=$in_id AND c_id=".api_get_course_int_id();
190
-		$res = Database::query($sql);
191
-		$row = Database::fetch_array($res);
190
+        $res = Database::query($sql);
191
+        $row = Database::fetch_array($res);
192 192
 
193
-		return $row['nb'];
194
-	}
193
+        return $row['nb'];
194
+    }
195 195
 
196 196
     /**
197 197
      * @param string $in_color
198 198
      */
199 199
     public function display($in_color="#E0EBF5")
200 200
     {
201
-		echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
202
-		print_r($this);
203
-		echo "</textarea>";
204
-	}
201
+        echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
202
+        print_r($this);
203
+        echo "</textarea>";
204
+    }
205 205
 
206
-	/**
206
+    /**
207 207
      * Return an array of all Category objects in the database
208
-	 * If in_field=="" Return an array of all category objects in the database
209
-	 * Otherwise, return an array of all in_field value
210
-	 * in the database (in_field = id or name or description)
211
-	 */
208
+     * If in_field=="" Return an array of all category objects in the database
209
+     * Otherwise, return an array of all in_field value
210
+     * in the database (in_field = id or name or description)
211
+     */
212 212
     public static function getCategoryListInfo($in_field = "", $courseId = "")
213 213
     {
214 214
         if (empty($courseId) || $courseId=="") {
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
             }
240 240
         }
241 241
 
242
-		return $tabres;
243
-	}
242
+        return $tabres;
243
+    }
244 244
 
245 245
     /**
246 246
      * Return the TestCategory id for question with question_id = $questionId
@@ -251,246 +251,246 @@  discard block
 block discarded – undo
251 251
      *
252 252
      * @return int
253 253
      */
254
-	public static function getCategoryForQuestion($questionId, $courseId ="")
254
+    public static function getCategoryForQuestion($questionId, $courseId ="")
255 255
     {
256
-		$result = 0;
256
+        $result = 0;
257 257
         if (empty($courseId) || $courseId == "") {
258 258
             $courseId = api_get_course_int_id();
259 259
         }
260
-		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
260
+        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
261 261
         $questionId = intval($questionId);
262
-		$sql = "SELECT category_id
262
+        $sql = "SELECT category_id
263 263
 		        FROM $table
264 264
 		        WHERE question_id = $questionId AND c_id = $courseId";
265
-		$res = Database::query($sql);
266
-		if (Database::num_rows($res) > 0) {
265
+        $res = Database::query($sql);
266
+        if (Database::num_rows($res) > 0) {
267 267
             $data = Database::fetch_array($res);
268
-			$result = $data['category_id'];
269
-		}
268
+            $result = $data['category_id'];
269
+        }
270 270
 
271
-		return $result;
272
-	}
271
+        return $result;
272
+    }
273 273
 
274
-	/**
275
-	 * true if question id has a category
276
-	 */
277
-	public static function isQuestionHasCategory($questionId)
274
+    /**
275
+     * true if question id has a category
276
+     */
277
+    public static function isQuestionHasCategory($questionId)
278 278
     {
279
-		if (TestCategory::getCategoryForQuestion($questionId) > 0) {
280
-			return true;
281
-		}
282
-		return false;
283
-	}
279
+        if (TestCategory::getCategoryForQuestion($questionId) > 0) {
280
+            return true;
281
+        }
282
+        return false;
283
+    }
284 284
 
285
-	/**
285
+    /**
286 286
 	 Return the category name for question with question_id = $questionId
287 287
 	 In this version, a question has only 1 category.
288 288
 	 Return the category id, "" if none
289
-	 */
289
+     */
290 290
     public static function getCategoryNameForQuestion(
291 291
         $questionId,
292 292
         $courseId = ""
293 293
     ) {
294
-		if (empty($courseId) || $courseId=="") {
295
-			$courseId = api_get_course_int_id();
296
-		}
297
-		$catid = TestCategory::getCategoryForQuestion($questionId, $courseId);
298
-		$result = "";	// result
299
-		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
300
-		$catid = intval($catid);
301
-		$sql = "SELECT title FROM $table
294
+        if (empty($courseId) || $courseId=="") {
295
+            $courseId = api_get_course_int_id();
296
+        }
297
+        $catid = TestCategory::getCategoryForQuestion($questionId, $courseId);
298
+        $result = "";	// result
299
+        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
300
+        $catid = intval($catid);
301
+        $sql = "SELECT title FROM $table
302 302
 		        WHERE id = $catid  AND c_id = $courseId";
303
-		$res = Database::query($sql);
304
-		$data = Database::fetch_array($res);
305
-		if (Database::num_rows($res) > 0) {
306
-			$result = $data['title'];
307
-		}
308
-
309
-		return $result;
310
-	}
311
-
312
-	/**
313
-	 * Return the list of differents categories ID for a test in the current course
314
-	 * input : test_id
315
-	 * return : array of category id (integer)
316
-	 * hubert.borderiou 07-04-2011
317
-	 * @param int $exerciseId
318
-	 */
319
-	public static function getListOfCategoriesIDForTest($exerciseId)
303
+        $res = Database::query($sql);
304
+        $data = Database::fetch_array($res);
305
+        if (Database::num_rows($res) > 0) {
306
+            $result = $data['title'];
307
+        }
308
+
309
+        return $result;
310
+    }
311
+
312
+    /**
313
+     * Return the list of differents categories ID for a test in the current course
314
+     * input : test_id
315
+     * return : array of category id (integer)
316
+     * hubert.borderiou 07-04-2011
317
+     * @param int $exerciseId
318
+     */
319
+    public static function getListOfCategoriesIDForTest($exerciseId)
320 320
     {
321
-		// parcourir les questions d'un test, recup les categories uniques dans un tableau
322
-		$exercise = new Exercise();
323
-		$exercise->read($exerciseId, false);
324
-		$categoriesInExercise = $exercise->getQuestionWithCategories();
325
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
326
-		$categories = array();
321
+        // parcourir les questions d'un test, recup les categories uniques dans un tableau
322
+        $exercise = new Exercise();
323
+        $exercise->read($exerciseId, false);
324
+        $categoriesInExercise = $exercise->getQuestionWithCategories();
325
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
326
+        $categories = array();
327 327
         if (!empty($categoriesInExercise)) {
328
-			foreach ($categoriesInExercise as $category) {
329
-				//$category['id'] = $category['iid'];
330
-				$categories[$category['id']] = $category;
331
-			}
332
-		}
333
-
334
-		return $categories;
335
-	}
336
-
337
-	/**
338
-	 * @param Exercise $exercise_obj
339
-	 * @return array
340
-	 */
341
-	public static function getListOfCategoriesIDForTestObject(Exercise $exercise_obj)
342
-	{
343
-		// parcourir les questions d'un test, recup les categories uniques dans un tableau
344
-		$categories_in_exercise = array();
345
-		// $question_list = $exercise_obj->getQuestionList();
346
-		$question_list = $exercise_obj->getQuestionOrderedListByName();
347
-
348
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
349
-		foreach ($question_list as $questionInfo) {
350
-			$question_id = $questionInfo['question_id'];
351
-			$category_list = self::getCategoryForQuestion($question_id);
352
-			if (is_numeric($category_list)) {
353
-				$category_list = array($category_list);
354
-			}
355
-
356
-			if (!empty($category_list)) {
357
-				$categories_in_exercise = array_merge($categories_in_exercise, $category_list);
358
-			}
359
-		}
360
-		if (!empty($categories_in_exercise)) {
361
-			$categories_in_exercise = array_unique(array_filter($categories_in_exercise));
362
-		}
363
-		return $categories_in_exercise;
364
-	}
365
-
366
-	/**
367
-	 * Return the list of differents categories NAME for a test
368
-	 * @param int exercise id
369
-	 * @param bool
370
-	 * @return array of string
371
-	 *
328
+            foreach ($categoriesInExercise as $category) {
329
+                //$category['id'] = $category['iid'];
330
+                $categories[$category['id']] = $category;
331
+            }
332
+        }
333
+
334
+        return $categories;
335
+    }
336
+
337
+    /**
338
+     * @param Exercise $exercise_obj
339
+     * @return array
340
+     */
341
+    public static function getListOfCategoriesIDForTestObject(Exercise $exercise_obj)
342
+    {
343
+        // parcourir les questions d'un test, recup les categories uniques dans un tableau
344
+        $categories_in_exercise = array();
345
+        // $question_list = $exercise_obj->getQuestionList();
346
+        $question_list = $exercise_obj->getQuestionOrderedListByName();
347
+
348
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
349
+        foreach ($question_list as $questionInfo) {
350
+            $question_id = $questionInfo['question_id'];
351
+            $category_list = self::getCategoryForQuestion($question_id);
352
+            if (is_numeric($category_list)) {
353
+                $category_list = array($category_list);
354
+            }
355
+
356
+            if (!empty($category_list)) {
357
+                $categories_in_exercise = array_merge($categories_in_exercise, $category_list);
358
+            }
359
+        }
360
+        if (!empty($categories_in_exercise)) {
361
+            $categories_in_exercise = array_unique(array_filter($categories_in_exercise));
362
+        }
363
+        return $categories_in_exercise;
364
+    }
365
+
366
+    /**
367
+     * Return the list of differents categories NAME for a test
368
+     * @param int exercise id
369
+     * @param bool
370
+     * @return array of string
371
+     *
372 372
      * @author function rewrote by jmontoya
373
-	 */
374
-	public static function getListOfCategoriesNameForTest($exercise_id, $grouped_by_category = true)
373
+     */
374
+    public static function getListOfCategoriesNameForTest($exercise_id, $grouped_by_category = true)
375 375
     {
376
-		$result = array();
377
-		$categories = self::getListOfCategoriesIDForTest($exercise_id, $grouped_by_category);
376
+        $result = array();
377
+        $categories = self::getListOfCategoriesIDForTest($exercise_id, $grouped_by_category);
378 378
 
379
-		foreach ($categories as $catInfo) {
380
-			$categoryId = $catInfo['id'];
381
-			if (!empty($categoryId)) {
382
-				$result[$categoryId] = array(
379
+        foreach ($categories as $catInfo) {
380
+            $categoryId = $catInfo['id'];
381
+            if (!empty($categoryId)) {
382
+                $result[$categoryId] = array(
383 383
                     'title' => $catInfo['title'],
384 384
                     //'parent_id' =>  $catInfo['parent_id'],
385
-					'parent_id' => '',
385
+                    'parent_id' => '',
386 386
                     'c_id' => $catInfo['c_id']
387 387
                 );
388
-		}
389
-		}
390
-
391
-		return $result;
392
-	}
393
-
394
-	/**
395
-	 * @param Exercise $exercise_obj
396
-	 * @return array
397
-	 */
398
-	public static function getListOfCategoriesForTest(Exercise $exercise_obj)
399
-	{
400
-		$result = array();
401
-		$categories = self::getListOfCategoriesIDForTestObject($exercise_obj);
402
-		foreach ($categories as $cat_id) {
403
-			$cat = new TestCategory($cat_id);
404
-			$cat = (array)$cat;
405
-			$cat['iid'] = $cat['id'];
406
-			$cat['title'] = $cat['name'];
407
-			$result[$cat['id']] = $cat;
408
-		}
409
-		return $result;
410
-	}
411
-
412
-	/**
413
-	 * return the number of differents categories for a test
414
-	 * input : test_id
415
-	 * return : integer
416
-	 * hubert.borderiou 07-04-2011
417
-	 */
418
-	public static function getNumberOfCategoriesForTest($id)
388
+        }
389
+        }
390
+
391
+        return $result;
392
+    }
393
+
394
+    /**
395
+     * @param Exercise $exercise_obj
396
+     * @return array
397
+     */
398
+    public static function getListOfCategoriesForTest(Exercise $exercise_obj)
399
+    {
400
+        $result = array();
401
+        $categories = self::getListOfCategoriesIDForTestObject($exercise_obj);
402
+        foreach ($categories as $cat_id) {
403
+            $cat = new TestCategory($cat_id);
404
+            $cat = (array)$cat;
405
+            $cat['iid'] = $cat['id'];
406
+            $cat['title'] = $cat['name'];
407
+            $result[$cat['id']] = $cat;
408
+        }
409
+        return $result;
410
+    }
411
+
412
+    /**
413
+     * return the number of differents categories for a test
414
+     * input : test_id
415
+     * return : integer
416
+     * hubert.borderiou 07-04-2011
417
+     */
418
+    public static function getNumberOfCategoriesForTest($id)
419 419
     {
420
-		return count(TestCategory::getListOfCategoriesIDForTest($id));
421
-	}
420
+        return count(TestCategory::getListOfCategoriesIDForTest($id));
421
+    }
422 422
 
423
-	/**
424
-	 * return the number of question of a category id in a test
425
-	 * @param int $exerciseId
423
+    /**
424
+     * return the number of question of a category id in a test
425
+     * @param int $exerciseId
426 426
      * @param int $categoryId
427 427
      *
428
-	 * @return integer
428
+     * @return integer
429 429
      *
430
-	 * @author hubert.borderiou 07-04-2011
431
-	 */
432
-	public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId)
430
+     * @author hubert.borderiou 07-04-2011
431
+     */
432
+    public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId)
433 433
     {
434
-		$nbCatResult = 0;
435
-		$quiz = new Exercise();
436
-		$quiz->read($exerciseId);
437
-		$tabQuestionList = $quiz->selectQuestionList();
438
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
439
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
440
-			if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
441
-				$nbCatResult++;
442
-			}
443
-		}
444
-
445
-		return $nbCatResult;
446
-	}
447
-
448
-	/**
449
-	 * return the number of question for a test using random by category
450
-	 * input  : test_id, number of random question (min 1)
451
-	 * hubert.borderiou 07-04-2011
452
-	 * question without categories are not counted
453
-	 */
454
-	public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom)
434
+        $nbCatResult = 0;
435
+        $quiz = new Exercise();
436
+        $quiz->read($exerciseId);
437
+        $tabQuestionList = $quiz->selectQuestionList();
438
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
439
+        for ($i=1; $i <= count($tabQuestionList); $i++) {
440
+            if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
441
+                $nbCatResult++;
442
+            }
443
+        }
444
+
445
+        return $nbCatResult;
446
+    }
447
+
448
+    /**
449
+     * return the number of question for a test using random by category
450
+     * input  : test_id, number of random question (min 1)
451
+     * hubert.borderiou 07-04-2011
452
+     * question without categories are not counted
453
+     */
454
+    public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom)
455 455
     {
456
-		$nbquestionresult = 0;
457
-		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
458
-		for ($i=0; $i < count($tabcatid); $i++) {
459
-			if ($tabcatid[$i] > 0 && $tabcatid[$i] > 0) {	// 0 = no category for this questio
460
-				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
461
-				if ($nbQuestionInThisCat > $in_nbrandom) {
462
-					$nbquestionresult += $in_nbrandom;
463
-				}
464
-				else {
465
-					$nbquestionresult += $nbQuestionInThisCat;
466
-				}
467
-			}
468
-		}
469
-
470
-		return $nbquestionresult;
471
-	}
472
-
473
-	/**
474
-	 * Return an array (id=>name)
475
-	 * tabresult[0] = get_lang('NoCategory');
456
+        $nbquestionresult = 0;
457
+        $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
458
+        for ($i=0; $i < count($tabcatid); $i++) {
459
+            if ($tabcatid[$i] > 0 && $tabcatid[$i] > 0) {	// 0 = no category for this questio
460
+                $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
461
+                if ($nbQuestionInThisCat > $in_nbrandom) {
462
+                    $nbquestionresult += $in_nbrandom;
463
+                }
464
+                else {
465
+                    $nbquestionresult += $nbQuestionInThisCat;
466
+                }
467
+            }
468
+        }
469
+
470
+        return $nbquestionresult;
471
+    }
472
+
473
+    /**
474
+     * Return an array (id=>name)
475
+     * tabresult[0] = get_lang('NoCategory');
476 476
      *
477 477
      * @param int $courseId
478 478
      *
479 479
      * @return array
480
-	 *
481
-	 */
480
+     *
481
+     */
482 482
     public static function getCategoriesIdAndName($courseId = "")
483 483
     {
484
-		if (empty($courseId)) {
485
-			$courseId = api_get_course_int_id();
486
-		}
487
-	 	$tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
488
-	 	$tabresult = array("0"=>get_lang('NoCategorySelected'));
489
-	 	for ($i=0; $i < count($tabcatobject); $i++) {
490
-	 		$tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
491
-	 	}
492
-	 	return $tabresult;
493
-	}
484
+        if (empty($courseId)) {
485
+            $courseId = api_get_course_int_id();
486
+        }
487
+            $tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
488
+            $tabresult = array("0"=>get_lang('NoCategorySelected'));
489
+            for ($i=0; $i < count($tabcatobject); $i++) {
490
+                $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
491
+            }
492
+            return $tabresult;
493
+    }
494 494
 
495 495
     /**
496 496
      * Returns an array of question ids for each category
@@ -499,10 +499,10 @@  discard block
 block discarded – undo
499 499
      * @param int exercise
500 500
      * @param array $check_in_question_list
501 501
      * @param array $categoriesAddedInExercise
502
-    *
503
-    * @param int $exerciseId
504
-    * @return array
505
-    */
502
+     *
503
+     * @param int $exerciseId
504
+     * @return array
505
+     */
506 506
     static function getQuestionsByCat(
507 507
         $exerciseId,
508 508
         $check_in_question_list = array(),
@@ -580,28 +580,28 @@  discard block
 block discarded – undo
580 580
         }
581 581
 
582 582
         return $categories;
583
-	}
583
+    }
584 584
 
585
-	/**
586
-	 * return a tab of $in_number random elements of $in_tab
587
-	 */
585
+    /**
586
+     * return a tab of $in_number random elements of $in_tab
587
+     */
588 588
     public static function getNElementsFromArray($in_tab, $in_number)
589 589
     {
590
-		$tabres = $in_tab;
591
-		shuffle($tabres);
592
-		if ($in_number < count($tabres)) {
593
-			$tabres = array_slice($tabres, 0, $in_number);
594
-		}
595
-		return $tabres;
596
-	}
597
-
598
-	/**
599
-	 * display the category
600
-	 */
601
-	public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1)
590
+        $tabres = $in_tab;
591
+        shuffle($tabres);
592
+        if ($in_number < count($tabres)) {
593
+            $tabres = array_slice($tabres, 0, $in_number);
594
+        }
595
+        return $tabres;
596
+    }
597
+
598
+    /**
599
+     * display the category
600
+     */
601
+    public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1)
602 602
     {
603 603
         echo self::returnCategoryAndTitle($questionId, $in_display_category_name);
604
-	}
604
+    }
605 605
 
606 606
     /**
607 607
      * @param int $questionId
@@ -617,98 +617,98 @@  discard block
 block discarded – undo
617 617
             $in_display_category_name = $objExercise->display_category_name;
618 618
         }
619 619
         $content = null;
620
-		if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) {
620
+        if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) {
621 621
             $content .= '<div class="page-header">';
622 622
             $content .= '<h4>'.get_lang('Category').": ".TestCategory::getCategoryNameForQuestion($questionId).'</h4>';
623 623
             $content .= "</div>";
624
-		}
624
+        }
625 625
         return $content;
626
-	}
626
+    }
627 627
 
628 628
     /**
629
-    * Display signs [+] and/or (>0) after question title if question has options
630
-    * scoreAlwaysPositive and/or uncheckedMayScore
631
-    */
629
+     * Display signs [+] and/or (>0) after question title if question has options
630
+     * scoreAlwaysPositive and/or uncheckedMayScore
631
+     */
632 632
     public function displayQuestionOption($in_objQuestion)
633 633
     {
634
-		if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) {
635
-			echo "<span style='font-size:75%'> (>0)</span>";
636
-		}
637
-		if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) {
638
-			echo "<span style='font-size:75%'> [+]</span>";
639
-		}
640
-	}
641
-
642
-	/**
643
-	 * sortTabByBracketLabel ($tabCategoryQuestions)
644
-	 * key of $tabCategoryQuestions are the category id (0 for not in a category)
645
-	 * value is the array of question id of this category
646
-	 * Sort question by Category
647
-	*/
634
+        if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) {
635
+            echo "<span style='font-size:75%'> (>0)</span>";
636
+        }
637
+        if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) {
638
+            echo "<span style='font-size:75%'> [+]</span>";
639
+        }
640
+    }
641
+
642
+    /**
643
+     * sortTabByBracketLabel ($tabCategoryQuestions)
644
+     * key of $tabCategoryQuestions are the category id (0 for not in a category)
645
+     * value is the array of question id of this category
646
+     * Sort question by Category
647
+     */
648 648
     public static function sortTabByBracketLabel($in_tab)
649 649
     {
650
-		$tabResult = array();
651
-		$tabCatName = array();	// tab of category name
652
-		while (list($cat_id, $tabquestion) = each($in_tab)) {
653
-			$catTitle = new TestCategory($cat_id);
654
-			$tabCatName[$cat_id] = $catTitle->name;
655
-		}
656
-		reset($in_tab);
657
-		// sort table by value, keeping keys as they are
658
-		asort($tabCatName);
659
-		// keys of $tabCatName are keys order for $in_tab
660
-		while (list($key, $val) = each($tabCatName)) {
661
-			$tabResult[$key] = $in_tab[$key];
662
-		}
663
-		return $tabResult;
664
-	}
650
+        $tabResult = array();
651
+        $tabCatName = array();	// tab of category name
652
+        while (list($cat_id, $tabquestion) = each($in_tab)) {
653
+            $catTitle = new TestCategory($cat_id);
654
+            $tabCatName[$cat_id] = $catTitle->name;
655
+        }
656
+        reset($in_tab);
657
+        // sort table by value, keeping keys as they are
658
+        asort($tabCatName);
659
+        // keys of $tabCatName are keys order for $in_tab
660
+        while (list($key, $val) = each($tabCatName)) {
661
+            $tabResult[$key] = $in_tab[$key];
662
+        }
663
+        return $tabResult;
664
+    }
665 665
 
666 666
     /**
667
-	 * return total score for test exe_id for all question in the category $in_cat_id for user
668
-	 * If no question for this category, return ""
669
-	 */
670
-	public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id)
671
-	{
672
-		$tbl_track_attempt		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
673
-		$tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
674
-		$in_cat_id = intval($in_cat_id);
675
-		$in_exe_id = intval($in_exe_id);
676
-		$in_user_id = intval($in_user_id);
677
-
678
-		$query = "SELECT DISTINCT
667
+     * return total score for test exe_id for all question in the category $in_cat_id for user
668
+     * If no question for this category, return ""
669
+     */
670
+    public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id)
671
+    {
672
+        $tbl_track_attempt		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
673
+        $tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
674
+        $in_cat_id = intval($in_cat_id);
675
+        $in_exe_id = intval($in_exe_id);
676
+        $in_user_id = intval($in_user_id);
677
+
678
+        $query = "SELECT DISTINCT
679 679
 		            marks, exe_id, user_id, ta.question_id, category_id
680 680
                   FROM $tbl_track_attempt ta , $tbl_question_rel_category qrc
681 681
                   WHERE
682 682
                     ta.question_id=qrc.question_id AND
683 683
                     qrc.category_id=$in_cat_id AND
684 684
                     exe_id=$in_exe_id AND user_id=$in_user_id";
685
-		$res = Database::query($query);
686
-		$totalcatscore = "";
687
-		while ($data = Database::fetch_array($res)) {
688
-			$totalcatscore += $data['marks'];
689
-		}
690
-		return $totalcatscore;
691
-	}
692
-
693
-	/**
685
+        $res = Database::query($query);
686
+        $totalcatscore = "";
687
+        while ($data = Database::fetch_array($res)) {
688
+            $totalcatscore += $data['marks'];
689
+        }
690
+        return $totalcatscore;
691
+    }
692
+
693
+    /**
694 694
      * return the number max of question in a category
695 695
      * count the number of questions in all categories, and return the max
696 696
      * @param int $exerciseId
697 697
      * @author - hubert borderiou
698
-    */
698
+     */
699 699
     public static function getNumberMaxQuestionByCat($exerciseId)
700 700
     {
701 701
         $res_num_max = 0;
702 702
         // foreach question
703
-		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
704
-		for ($i=0; $i < count($tabcatid); $i++) {
705
-			if ($tabcatid[$i] > 0) {	// 0 = no category for this question
706
-				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
703
+        $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
704
+        for ($i=0; $i < count($tabcatid); $i++) {
705
+            if ($tabcatid[$i] > 0) {	// 0 = no category for this question
706
+                $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
707 707
                 if ($nbQuestionInThisCat > $res_num_max) {
708 708
                     $res_num_max = $nbQuestionInThisCat;
709 709
                 }
710
-			}
711
-		}
710
+            }
711
+        }
712 712
         return $res_num_max;
713 713
     }
714 714
 
@@ -768,34 +768,34 @@  discard block
 block discarded – undo
768 768
     }
769 769
 
770 770
     /**
771
-	 * @return array
772
-	 */
773
-	function get_all_categories()
774
-	{
775
-		$table = Database::get_course_table(TABLE_QUIZ_CATEGORY);
776
-		$sql = "SELECT * FROM $table ORDER BY title ASC";
777
-		$res = Database::query($sql);
778
-		while ($row = Database::fetch_array($res,'ASSOC')) {
779
-			$array[] = $row;
780
-		}
781
-		return $array;
782
-	}
783
-
784
-	/**
785
-	 * @param Exercise $exercise
786
-	 * @param int $course_id
787
-	 * @param string $order
788
-	 * @param bool $shuffle
789
-	 * @param bool $excludeCategoryWithNoQuestions
790
-	 * @return array|bool
791
-	 */
792
-	public function getCategoryExerciseTree(
793
-		$exercise,
794
-		$course_id,
795
-		$order = null,
796
-		$shuffle = false,
797
-		$excludeCategoryWithNoQuestions = true
798
-	) {
771
+     * @return array
772
+     */
773
+    function get_all_categories()
774
+    {
775
+        $table = Database::get_course_table(TABLE_QUIZ_CATEGORY);
776
+        $sql = "SELECT * FROM $table ORDER BY title ASC";
777
+        $res = Database::query($sql);
778
+        while ($row = Database::fetch_array($res,'ASSOC')) {
779
+            $array[] = $row;
780
+        }
781
+        return $array;
782
+    }
783
+
784
+    /**
785
+     * @param Exercise $exercise
786
+     * @param int $course_id
787
+     * @param string $order
788
+     * @param bool $shuffle
789
+     * @param bool $excludeCategoryWithNoQuestions
790
+     * @return array|bool
791
+     */
792
+    public function getCategoryExerciseTree(
793
+        $exercise,
794
+        $course_id,
795
+        $order = null,
796
+        $shuffle = false,
797
+        $excludeCategoryWithNoQuestions = true
798
+    ) {
799 799
         if (empty($exercise)) {
800 800
             return array();
801 801
         }
@@ -805,165 +805,165 @@  discard block
 block discarded – undo
805 805
         }
806 806
 
807 807
         $course_id = intval($course_id);
808
-		$table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY);
808
+        $table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY);
809 809
         $categoryTable = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
810
-		$sql = "SELECT * FROM $table qc
810
+        $sql = "SELECT * FROM $table qc
811 811
               	LEFT JOIN $categoryTable c
812 812
                 ON (qc.c_id = c.c_id AND c.id = qc.category_id)
813 813
                 WHERE qc.c_id = $course_id AND exercise_id = {$exercise->id} ";
814 814
 
815
-		if (!empty($order)) {
816
-			$sql .= "ORDER BY $order";
817
-		}
818
-
819
-		$categories = array();
820
-
821
-		$result = Database::query($sql);
822
-		if (Database::num_rows($result)) {
823
-			while ($row = Database::fetch_array($result, 'ASSOC')) {
824
-				if ($excludeCategoryWithNoQuestions) {
825
-					if ($row['count_questions'] == 0) {
826
-						continue;
827
-					}
828
-				}
829
-				if (empty($row['title']) && empty($row['category_id'])) {
830
-					$row['title'] = get_lang('NoCategory');
831
-				}
815
+        if (!empty($order)) {
816
+            $sql .= "ORDER BY $order";
817
+        }
818
+
819
+        $categories = array();
820
+
821
+        $result = Database::query($sql);
822
+        if (Database::num_rows($result)) {
823
+            while ($row = Database::fetch_array($result, 'ASSOC')) {
824
+                if ($excludeCategoryWithNoQuestions) {
825
+                    if ($row['count_questions'] == 0) {
826
+                        continue;
827
+                    }
828
+                }
829
+                if (empty($row['title']) && empty($row['category_id'])) {
830
+                    $row['title'] = get_lang('NoCategory');
831
+                }
832 832
                 $categories[$row['category_id']] = $row;
833
-			}
834
-		}
835
-
836
-		if ($shuffle) {
837
-			shuffle_assoc($categories);
838
-		}
839
-
840
-		return $categories;
841
-	}
842
-
843
-	public function getForm(& $form, $action = 'new')
844
-	{
845
-		switch($action) {
846
-			case 'new':
847
-				$header = get_lang('AddACategory');
848
-				$submit = get_lang('AddTestCategory');
849
-				break;
850
-			case 'edit':
851
-				$header = get_lang('EditCategory');
852
-				$submit = get_lang('ModifyCategory');
853
-				break;
854
-		}
855
-
856
-		// settting the form elements
857
-		$form->addElement('header', $header);
858
-		$form->addElement('hidden', 'category_id');
859
-		$form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6'));
860
-		$form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
861
-		$category_parent_list = array();
862
-
863
-		$options = array(
864
-				'1' => get_lang('Visible'),
865
-				'0' => get_lang('Hidden')
866
-		);
867
-		$form->addElement('select', 'visibility', get_lang('Visibility'), $options);
868
-		$script = null;
869
-		if (!empty($this->parent_id)) {
870
-			$parent_cat = new TestCategory($this->parent_id);
871
-			$category_parent_list = array($parent_cat->id => $parent_cat->name);
872
-			$script .= '<script>$(function() { $("#parent_id").trigger("addItem",[{"title": "'.$parent_cat->name.'", "value": "'.$parent_cat->id.'"}]); });</script>';
873
-		}
874
-		$form->addElement('html', $script);
875
-
876
-		$form->addElement('select', 'parent_id', get_lang('Parent'), $category_parent_list, array('id' => 'parent_id'));
877
-		$form->addElement('style_submit_button', 'SubmitNote', $submit, 'class="add"');
878
-
879
-		// setting the defaults
880
-		$defaults = array();
881
-		$defaults["category_id"] = $this->id;
882
-		$defaults["category_name"] = $this->name;
883
-		$defaults["category_description"] = $this->description;
884
-		$defaults["parent_id"] = $this->parent_id;
885
-		$defaults["visibility"] = $this->visibility;
886
-		$form->setDefaults($defaults);
887
-
888
-		// setting the rules
889
-		$form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
890
-	}
891
-
892
-	/**
893
-	 * Returns the category form.
894
-	 * @param Exercise $exercise_obj
895
-	 * @return string
896
-	 */
897
-	public function returnCategoryForm(Exercise $exercise_obj)
898
-	{
899
-		$categories = $this->getListOfCategoriesForTest($exercise_obj);
900
-
901
-		$saved_categories = $exercise_obj->get_categories_in_exercise();
902
-		$return = null;
903
-
904
-		if (!empty($categories)) {
905
-			$nbQuestionsTotal = $exercise_obj->getNumberQuestionExerciseCategory();
906
-			$exercise_obj->setCategoriesGrouping(true);
907
-			$real_question_count = count($exercise_obj->getQuestionList());
908
-
909
-			$warning = null;
910
-			if ($nbQuestionsTotal != $real_question_count) {
911
-				$warning = Display::return_message(get_lang('CheckThatYouHaveEnoughQuestionsInYourCategories'), 'warning');
912
-			}
913
-
914
-			$return .= $warning;
915
-			$return .= '<table class="data_table">';
916
-			$return .= '<tr>';
917
-			$return .= '<th height="24">' . get_lang('Categories') . '</th>';
918
-			$return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>';
919
-
920
-			$emptyCategory = array(
921
-				'id' => '0',
922
-				'name' => get_lang('NoCategory'),
923
-				'description' => '',
924
-				'iid' => '0',
925
-				'title' => get_lang('NoCategory')
926
-			);
927
-
928
-			$categories[] = $emptyCategory;
929
-
930
-			foreach ($categories as $category) {
931
-				$cat_id = $category['iid'];
932
-				$return .= '<tr>';
933
-				$return .= '<td>';
934
-				//$return .= Display::div(isset($category['parent_path']) ? $category['parent_path'] : '');
935
-				$return .= Display::div($category['name']);
936
-				$return .= '</td>';
937
-				$return .= '<td>';
938
-				$value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1;
939
-				$return .= '<input name="category['.$cat_id.']" value="' .$value.'" />';
940
-				$return .= '</td>';
941
-				$return .= '</tr>';
942
-			}
943
-
944
-			$return .= '</table>';
945
-			$return .= get_lang('ZeroMeansNoQuestionWillBeSelectedMinusOneMeansThatAllQuestionsWillBeSelected');
946
-			return $return;
947
-		}
948
-	}
949
-
950
-	/**
951
-	 * Sorts an array
952
-	 * @param $array
953
-	 * @return mixed
954
-	 */
955
-	public function sort_tree_array($array)
956
-	{
957
-		foreach ($array as $key => $row) {
958
-			$parent[$key] = $row['parent_id'];
959
-		}
960
-		if (count($array) > 0) {
961
-			array_multisort($parent, SORT_ASC, $array);
962
-		}
963
-		return $array;
964
-	}
965
-
966
-	/**
833
+            }
834
+        }
835
+
836
+        if ($shuffle) {
837
+            shuffle_assoc($categories);
838
+        }
839
+
840
+        return $categories;
841
+    }
842
+
843
+    public function getForm(& $form, $action = 'new')
844
+    {
845
+        switch($action) {
846
+            case 'new':
847
+                $header = get_lang('AddACategory');
848
+                $submit = get_lang('AddTestCategory');
849
+                break;
850
+            case 'edit':
851
+                $header = get_lang('EditCategory');
852
+                $submit = get_lang('ModifyCategory');
853
+                break;
854
+        }
855
+
856
+        // settting the form elements
857
+        $form->addElement('header', $header);
858
+        $form->addElement('hidden', 'category_id');
859
+        $form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6'));
860
+        $form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
861
+        $category_parent_list = array();
862
+
863
+        $options = array(
864
+                '1' => get_lang('Visible'),
865
+                '0' => get_lang('Hidden')
866
+        );
867
+        $form->addElement('select', 'visibility', get_lang('Visibility'), $options);
868
+        $script = null;
869
+        if (!empty($this->parent_id)) {
870
+            $parent_cat = new TestCategory($this->parent_id);
871
+            $category_parent_list = array($parent_cat->id => $parent_cat->name);
872
+            $script .= '<script>$(function() { $("#parent_id").trigger("addItem",[{"title": "'.$parent_cat->name.'", "value": "'.$parent_cat->id.'"}]); });</script>';
873
+        }
874
+        $form->addElement('html', $script);
875
+
876
+        $form->addElement('select', 'parent_id', get_lang('Parent'), $category_parent_list, array('id' => 'parent_id'));
877
+        $form->addElement('style_submit_button', 'SubmitNote', $submit, 'class="add"');
878
+
879
+        // setting the defaults
880
+        $defaults = array();
881
+        $defaults["category_id"] = $this->id;
882
+        $defaults["category_name"] = $this->name;
883
+        $defaults["category_description"] = $this->description;
884
+        $defaults["parent_id"] = $this->parent_id;
885
+        $defaults["visibility"] = $this->visibility;
886
+        $form->setDefaults($defaults);
887
+
888
+        // setting the rules
889
+        $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
890
+    }
891
+
892
+    /**
893
+     * Returns the category form.
894
+     * @param Exercise $exercise_obj
895
+     * @return string
896
+     */
897
+    public function returnCategoryForm(Exercise $exercise_obj)
898
+    {
899
+        $categories = $this->getListOfCategoriesForTest($exercise_obj);
900
+
901
+        $saved_categories = $exercise_obj->get_categories_in_exercise();
902
+        $return = null;
903
+
904
+        if (!empty($categories)) {
905
+            $nbQuestionsTotal = $exercise_obj->getNumberQuestionExerciseCategory();
906
+            $exercise_obj->setCategoriesGrouping(true);
907
+            $real_question_count = count($exercise_obj->getQuestionList());
908
+
909
+            $warning = null;
910
+            if ($nbQuestionsTotal != $real_question_count) {
911
+                $warning = Display::return_message(get_lang('CheckThatYouHaveEnoughQuestionsInYourCategories'), 'warning');
912
+            }
913
+
914
+            $return .= $warning;
915
+            $return .= '<table class="data_table">';
916
+            $return .= '<tr>';
917
+            $return .= '<th height="24">' . get_lang('Categories') . '</th>';
918
+            $return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>';
919
+
920
+            $emptyCategory = array(
921
+                'id' => '0',
922
+                'name' => get_lang('NoCategory'),
923
+                'description' => '',
924
+                'iid' => '0',
925
+                'title' => get_lang('NoCategory')
926
+            );
927
+
928
+            $categories[] = $emptyCategory;
929
+
930
+            foreach ($categories as $category) {
931
+                $cat_id = $category['iid'];
932
+                $return .= '<tr>';
933
+                $return .= '<td>';
934
+                //$return .= Display::div(isset($category['parent_path']) ? $category['parent_path'] : '');
935
+                $return .= Display::div($category['name']);
936
+                $return .= '</td>';
937
+                $return .= '<td>';
938
+                $value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1;
939
+                $return .= '<input name="category['.$cat_id.']" value="' .$value.'" />';
940
+                $return .= '</td>';
941
+                $return .= '</tr>';
942
+            }
943
+
944
+            $return .= '</table>';
945
+            $return .= get_lang('ZeroMeansNoQuestionWillBeSelectedMinusOneMeansThatAllQuestionsWillBeSelected');
946
+            return $return;
947
+        }
948
+    }
949
+
950
+    /**
951
+     * Sorts an array
952
+     * @param $array
953
+     * @return mixed
954
+     */
955
+    public function sort_tree_array($array)
956
+    {
957
+        foreach ($array as $key => $row) {
958
+            $parent[$key] = $row['parent_id'];
959
+        }
960
+        if (count($array) > 0) {
961
+            array_multisort($parent, SORT_ASC, $array);
962
+        }
963
+        return $array;
964
+    }
965
+
966
+    /**
967 967
      * Return true if a category already exists with the same name
968 968
      * @param string $in_name
969 969
      *
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
      * @param int $categoryId
1011 1011
      * @param int $questionId
1012 1012
      * @param int $courseId
1013
-	 *
1014
-	 * @return int
1013
+     *
1014
+     * @return int
1015 1015
      */
1016 1016
     public static function add_category_for_question_id($categoryId, $questionId, $courseId)
1017 1017
     {
@@ -1019,18 +1019,18 @@  discard block
 block discarded – undo
1019 1019
         // if question doesn't have a category
1020 1020
         // @todo change for 1.10 when a question can have several categories
1021 1021
         if (TestCategory::getCategoryForQuestion($questionId, $courseId) == 0 &&
1022
-			$questionId > 0 &&
1023
-			$courseId > 0
1022
+            $questionId > 0 &&
1023
+            $courseId > 0
1024 1024
         ) {
1025 1025
             $sql = "INSERT INTO $table (c_id, question_id, category_id)
1026 1026
                     VALUES (".intval($courseId).", ".intval($questionId).", ".intval($categoryId).")";
1027 1027
             Database::query($sql);
1028
-			$id = Database::insert_id();
1028
+            $id = Database::insert_id();
1029 1029
 
1030
-			return $id;
1030
+            return $id;
1031 1031
         }
1032 1032
 
1033
-		return false;
1033
+        return false;
1034 1034
     }
1035 1035
 
1036 1036
     /**
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             $row = Database::fetch_array($res);
58 58
             $this->id = $row['id'];
59 59
             $this->name = $row['title'];
60
-            $this->description  = $row['description'];
60
+            $this->description = $row['description'];
61 61
         }
62 62
     }
63 63
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     /**
197 197
      * @param string $in_color
198 198
      */
199
-    public function display($in_color="#E0EBF5")
199
+    public function display($in_color = "#E0EBF5")
200 200
     {
201 201
 		echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
202 202
 		print_r($this);
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 */
212 212
     public static function getCategoryListInfo($in_field = "", $courseId = "")
213 213
     {
214
-        if (empty($courseId) || $courseId=="") {
214
+        if (empty($courseId) || $courseId == "") {
215 215
             $courseId = api_get_course_int_id();
216 216
         }
217 217
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      *
252 252
      * @return int
253 253
      */
254
-	public static function getCategoryForQuestion($questionId, $courseId ="")
254
+	public static function getCategoryForQuestion($questionId, $courseId = "")
255 255
     {
256 256
 		$result = 0;
257 257
         if (empty($courseId) || $courseId == "") {
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
         $questionId,
292 292
         $courseId = ""
293 293
     ) {
294
-		if (empty($courseId) || $courseId=="") {
294
+		if (empty($courseId) || $courseId == "") {
295 295
 			$courseId = api_get_course_int_id();
296 296
 		}
297 297
 		$catid = TestCategory::getCategoryForQuestion($questionId, $courseId);
298
-		$result = "";	// result
298
+		$result = ""; // result
299 299
 		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
300 300
 		$catid = intval($catid);
301 301
 		$sql = "SELECT title FROM $table
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 		$categories = self::getListOfCategoriesIDForTestObject($exercise_obj);
402 402
 		foreach ($categories as $cat_id) {
403 403
 			$cat = new TestCategory($cat_id);
404
-			$cat = (array)$cat;
404
+			$cat = (array) $cat;
405 405
 			$cat['iid'] = $cat['id'];
406 406
 			$cat['title'] = $cat['name'];
407 407
 			$result[$cat['id']] = $cat;
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		$quiz->read($exerciseId);
437 437
 		$tabQuestionList = $quiz->selectQuestionList();
438 438
 		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
439
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
439
+		for ($i = 1; $i <= count($tabQuestionList); $i++) {
440 440
 			if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
441 441
 				$nbCatResult++;
442 442
 			}
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
     {
456 456
 		$nbquestionresult = 0;
457 457
 		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
458
-		for ($i=0; $i < count($tabcatid); $i++) {
458
+		for ($i = 0; $i < count($tabcatid); $i++) {
459 459
 			if ($tabcatid[$i] > 0 && $tabcatid[$i] > 0) {	// 0 = no category for this questio
460 460
 				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
461 461
 				if ($nbQuestionInThisCat > $in_nbrandom) {
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 		}
487 487
 	 	$tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
488 488
 	 	$tabresult = array("0"=>get_lang('NoCategorySelected'));
489
-	 	for ($i=0; $i < count($tabcatobject); $i++) {
489
+	 	for ($i = 0; $i < count($tabcatobject); $i++) {
490 490
 	 		$tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
491 491
 	 	}
492 492
 	 	return $tabresult;
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
      */
611 611
     public static function returnCategoryAndTitle($questionId, $in_display_category_name = 1)
612 612
     {
613
-        $is_student = !(api_is_allowed_to_edit(null,true) || api_is_session_admin());
613
+        $is_student = !(api_is_allowed_to_edit(null, true) || api_is_session_admin());
614 614
         // @todo fix $_SESSION['objExercise']
615 615
         $objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null;
616 616
         if (!empty($objExercise)) {
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
     public static function sortTabByBracketLabel($in_tab)
649 649
     {
650 650
 		$tabResult = array();
651
-		$tabCatName = array();	// tab of category name
651
+		$tabCatName = array(); // tab of category name
652 652
 		while (list($cat_id, $tabquestion) = each($in_tab)) {
653 653
 			$catTitle = new TestCategory($cat_id);
654 654
 			$tabCatName[$cat_id] = $catTitle->name;
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 	 */
670 670
 	public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id)
671 671
 	{
672
-		$tbl_track_attempt		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
672
+		$tbl_track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
673 673
 		$tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
674 674
 		$in_cat_id = intval($in_cat_id);
675 675
 		$in_exe_id = intval($in_exe_id);
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
         $res_num_max = 0;
702 702
         // foreach question
703 703
 		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
704
-		for ($i=0; $i < count($tabcatid); $i++) {
704
+		for ($i = 0; $i < count($tabcatid); $i++) {
705 705
 			if ($tabcatid[$i] > 0) {	// 0 = no category for this question
706 706
 				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
707 707
                 if ($nbQuestionInThisCat > $res_num_max) {
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 		$table = Database::get_course_table(TABLE_QUIZ_CATEGORY);
776 776
 		$sql = "SELECT * FROM $table ORDER BY title ASC";
777 777
 		$res = Database::query($sql);
778
-		while ($row = Database::fetch_array($res,'ASSOC')) {
778
+		while ($row = Database::fetch_array($res, 'ASSOC')) {
779 779
 			$array[] = $row;
780 780
 		}
781 781
 		return $array;
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 
843 843
 	public function getForm(& $form, $action = 'new')
844 844
 	{
845
-		switch($action) {
845
+		switch ($action) {
846 846
 			case 'new':
847 847
 				$header = get_lang('AddACategory');
848 848
 				$submit = get_lang('AddTestCategory');
@@ -914,8 +914,8 @@  discard block
 block discarded – undo
914 914
 			$return .= $warning;
915 915
 			$return .= '<table class="data_table">';
916 916
 			$return .= '<tr>';
917
-			$return .= '<th height="24">' . get_lang('Categories') . '</th>';
918
-			$return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>';
917
+			$return .= '<th height="24">'.get_lang('Categories').'</th>';
918
+			$return .= '<th width="70" height="24">'.get_lang('Number').'</th></tr>';
919 919
 
920 920
 			$emptyCategory = array(
921 921
 				'id' => '0',
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 				$return .= '</td>';
937 937
 				$return .= '<td>';
938 938
 				$value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1;
939
-				$return .= '<input name="category['.$cat_id.']" value="' .$value.'" />';
939
+				$return .= '<input name="category['.$cat_id.']" value="'.$value.'" />';
940 940
 				$return .= '</td>';
941 941
 				$return .= '</tr>';
942 942
 			}
@@ -1083,20 +1083,20 @@  discard block
 block discarded – undo
1083 1083
             $tmpobj = new TestCategory($category['id']);
1084 1084
             $nb_question = $tmpobj->getCategoryQuestionsNumber();
1085 1085
             $rowname = self::protectJSDialogQuote($category['title']);
1086
-            $nb_question_label = $nb_question == 1 ? $nb_question . ' ' . get_lang('Question') : $nb_question . ' ' . get_lang('Questions');
1086
+            $nb_question_label = $nb_question == 1 ? $nb_question.' '.get_lang('Question') : $nb_question.' '.get_lang('Questions');
1087 1087
 
1088 1088
             //$html .= '<div class="sectiontitle" id="id_cat' . $category['id'] . '">';
1089
-            $content = "<span style='float:right'>" . $nb_question_label . "</span>";
1089
+            $content = "<span style='float:right'>".$nb_question_label."</span>";
1090 1090
 
1091 1091
             $content .= '<div class="sectioncomment">';
1092 1092
             $content .= $category['description'];
1093 1093
             $content .= '</div>';
1094 1094
 
1095
-            $links = '<a href="' . api_get_self() . '?action=editcategory&category_id=' . $category['id'] . '">' .
1096
-                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
1097
-            $links .= ' <a href="' . api_get_self() . '?action=deletecategory&category_id=' . $category['id'] . '" ';
1098
-            $links .= 'onclick="return confirmDelete(\'' . self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure') . '[' . $rowname) . '] ?\', \'id_cat' . $category['id'] . '\');">';
1099
-            $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
1095
+            $links = '<a href="'.api_get_self().'?action=editcategory&category_id='.$category['id'].'">'.
1096
+                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
1097
+            $links .= ' <a href="'.api_get_self().'?action=deletecategory&category_id='.$category['id'].'" ';
1098
+            $links .= 'onclick="return confirmDelete(\''.self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure').'['.$rowname).'] ?\', \'id_cat'.$category['id'].'\');">';
1099
+            $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
1100 1100
             $html .= Display::panel($content, $category['title'].$links);
1101 1101
         }
1102 1102
 
Please login to merge, or discard this patch.
main/exercice/multiple_answer_combination.class.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     }
179 179
 
180 180
     /**
181
-	 * abstract function which creates the form to create/edit the answers of the question
182
-	 * @param FormValidator $form
183
-	 */
181
+     * abstract function which creates the form to create/edit the answers of the question
182
+     * @param FormValidator $form
183
+     */
184 184
     public function processAnswersCreation($form)
185 185
     {
186 186
         $questionWeighting = $nbrGoodAnswers = 0;
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
         // sets the total weighting of the question
222 222
         $this->updateWeighting($questionWeighting);
223 223
         $this->save();
224
-	}
224
+    }
225 225
 
226 226
     function return_header($feedback_type = null, $counter = null, $score = null)
227 227
     {
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
         $html = '<table class="table table-striped table-hover">';
40 40
         $html .= '<thead>';
41 41
         $html .= '<tr>';
42
-        $html .= '<th width="10">' . get_lang('Number') . '</th>';
43
-        $html .= '<th width="10">' . get_lang('True') . '</th>';
44
-        $html .= '<th width="50%">' . get_lang('Comment') . '</th>';
45
-        $html .= '<th width="50%">' . get_lang('Answer') . '</th>';
42
+        $html .= '<th width="10">'.get_lang('Number').'</th>';
43
+        $html .= '<th width="10">'.get_lang('True').'</th>';
44
+        $html .= '<th width="50%">'.get_lang('Comment').'</th>';
45
+        $html .= '<th width="50%">'.get_lang('Answer').'</th>';
46 46
         $html .= '</tr>';
47 47
         $html .= '</thead>';
48 48
         $html .= '<tbody>';
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
             $form->addHtml('<tr>');
75 75
 
76 76
             if (is_object($answer)) {
77
-                $defaults['answer[' . $i . ']'] = $answer->answer[$i];
78
-                $defaults['comment[' . $i . ']'] = $answer->comment[$i];
79
-                $defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1);
80
-                $defaults['correct[' . $i . ']'] = $answer->correct[$i];
77
+                $defaults['answer['.$i.']'] = $answer->answer[$i];
78
+                $defaults['comment['.$i.']'] = $answer->comment[$i];
79
+                $defaults['weighting['.$i.']'] = float_format($answer->weighting[$i], 1);
80
+                $defaults['correct['.$i.']'] = $answer->correct[$i];
81 81
             } else {
82 82
                 $defaults['answer[1]'] = get_lang('DefaultMultipleAnswer2');
83 83
                 $defaults['comment[1]'] = get_lang('DefaultMultipleComment2');
@@ -93,44 +93,44 @@  discard block
 block discarded – undo
93 93
 
94 94
             $renderer->setElementTemplate(
95 95
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
96
-                'correct[' . $i . ']'
96
+                'correct['.$i.']'
97 97
             );
98 98
             $renderer->setElementTemplate(
99 99
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
100
-                'counter[' . $i . ']'
100
+                'counter['.$i.']'
101 101
             );
102 102
             $renderer->setElementTemplate(
103 103
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
104
-                'answer[' . $i . ']'
104
+                'answer['.$i.']'
105 105
             );
106 106
             $renderer->setElementTemplate(
107 107
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
108
-                'comment[' . $i . ']'
108
+                'comment['.$i.']'
109 109
             );
110 110
 
111
-            $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
111
+            $answer_number = $form->addElement('text', 'counter['.$i.']', null, 'value="'.$i.'"');
112 112
             $answer_number->freeze();
113 113
 
114 114
             $form->addElement('checkbox',
115
-                'correct[' . $i . ']',
115
+                'correct['.$i.']',
116 116
                 null,
117 117
                 null,
118 118
                 'class="checkbox" style="margin-left: 0em;"'
119 119
             );
120
-            $boxes_names[] = 'correct[' . $i . ']';
120
+            $boxes_names[] = 'correct['.$i.']';
121 121
 
122 122
             $form->addElement(
123 123
                 'html_editor',
124
-                'answer[' . $i . ']',
124
+                'answer['.$i.']',
125 125
                 null,
126 126
                 array(),
127 127
                 array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')
128 128
             );
129
-            $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
129
+            $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
130 130
 
131 131
             $form->addElement(
132 132
                 'html_editor',
133
-                'comment[' . $i . ']',
133
+                'comment['.$i.']',
134 134
                 null,
135 135
                 array(),
136 136
                 array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     function return_header($feedback_type = null, $counter = null, $score = null)
227 227
     {
228 228
         $header = parent::return_header($feedback_type, $counter, $score);
229
-        $header .= '<table class="'.$this->question_table_class .'">
229
+        $header .= '<table class="'.$this->question_table_class.'">
230 230
             <tr>
231 231
                 <th>'.get_lang("Choice").'</th>
232 232
                 <th>'. get_lang("ExpectedChoice").'</th>
Please login to merge, or discard this patch.
main/exercice/live_stats.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 $result = $objExercise->read($exercise_id);
18 18
 
19 19
 if (!$result) {
20
-	api_not_allowed(true);
20
+    api_not_allowed(true);
21 21
 }
22 22
 
23 23
 $interbreadcrumb[] = array(
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 $url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=get_live_stats&exercise_id='.$objExercise->id.'&minutes='.$minutes;
42 42
 
43 43
 //The order is important you need to check the the $column variable in the model.ajax.php file
44
-$columns        = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score'));
44
+$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score'));
45 45
 
46 46
 //Column config
47 47
 $column_model = array(
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 
94 94
 $(function() {
95 95
     <?php
96
-        echo Display::grid_js('live_stats',  $url, $columns, $column_model, $extra_params, array(), null, true);
96
+        echo Display::grid_js('live_stats', $url, $columns, $column_model, $extra_params, array(), null, true);
97 97
     ?>
98 98
     refreshGrid();
99 99
 });
100 100
 </script>
101 101
 <?php
102 102
 
103
-$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">' .
104
-    Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
103
+$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">'.
104
+    Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
105 105
 echo $actions = Display::div($actions, array('class'=> 'actions'));
106 106
 
107 107
 echo Display::grid_html('live_stats');
Please login to merge, or discard this patch.