Completed
Pull Request — 1.11.x (#1458)
by José
138:44 queued 104:05
created
main/exercise/exercise.class.php 4 patches
Doc Comments   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
     }
354 354
 
355 355
     /**
356
-     * @return int
356
+     * @return string
357 357
      */
358 358
     public function selectPassPercentage()
359 359
     {
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
      * tells if questions are selected randomly, and if so returns the draws
463 463
      *
464 464
      * @author Olivier Brouckaert
465
-     * @return integer - 0 if not random, otherwise the draws
465
+     * @return boolean - 0 if not random, otherwise the draws
466 466
      */
467 467
     public function isRandom()
468 468
     {
@@ -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(
@@ -5327,6 +5327,9 @@  discard block
 block discarded – undo
5327 5327
         }
5328 5328
     }
5329 5329
 
5330
+    /**
5331
+     * @param integer $exe_id
5332
+     */
5330 5333
     function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id)
5331 5334
     {
5332 5335
         if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
@@ -5478,7 +5481,7 @@  discard block
 block discarded – undo
5478 5481
      * @param int     Maximum number of attempts (0 if no limit)
5479 5482
      * @param int     Feedback type
5480 5483
      * @todo this was function was added due the import exercise via CSV
5481
-     * @return    int New exercise ID
5484
+     * @return    string New exercise ID
5482 5485
      */
5483 5486
     public function createExercise(
5484 5487
         $title,
@@ -6813,7 +6816,7 @@  discard block
 block discarded – undo
6813 6816
      * @param bool $show_comment
6814 6817
      * @param null $exercise_feedback
6815 6818
      * @param bool $show_answers
6816
-     * @param null $modelType
6819
+     * @param integer $modelType
6817 6820
      * @param bool $categoryMinusOne
6818 6821
      * @return bool|null|string
6819 6822
      */
Please login to merge, or discard this patch.
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   +30 added lines, -10 removed lines patch added patch discarded remove patch
@@ -3243,7 +3243,9 @@  discard block
 block discarded – undo
3243 3243
         $organs_at_risk_hit = 0;
3244 3244
         $questionScore = 0;
3245 3245
 
3246
-        if ($debug) error_log('Start answer loop ');
3246
+        if ($debug) {
3247
+            error_log('Start answer loop ');
3248
+        }
3247 3249
 
3248 3250
         $answer_correct_array = array();
3249 3251
 
@@ -3372,7 +3374,9 @@  discard block
 block discarded – undo
3372 3374
                     }
3373 3375
                     $totalScore += $answerWeighting;
3374 3376
 
3375
-                    if ($debug) error_log("studentChoice: $studentChoice");
3377
+                    if ($debug) {
3378
+                        error_log("studentChoice: $studentChoice");
3379
+                    }
3376 3380
                     break;
3377 3381
                 case GLOBAL_MULTIPLE_ANSWER:
3378 3382
                     if ($from_database) {
@@ -3397,7 +3401,9 @@  discard block
 block discarded – undo
3397 3401
                         $real_answers[$answerId] = (bool)$studentChoice;
3398 3402
                     }
3399 3403
                     $totalScore += $answerWeighting;
3400
-                    if ($debug) error_log("studentChoice: $studentChoice");
3404
+                    if ($debug) {
3405
+                        error_log("studentChoice: $studentChoice");
3406
+                    }
3401 3407
                     break;
3402 3408
                 case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
3403 3409
                     if ($from_database) {
@@ -4143,7 +4149,9 @@  discard block
 block discarded – undo
4143 4149
             } // end switch Answertype
4144 4150
 
4145 4151
             if ($show_result) {
4146
-                if ($debug) error_log('Showing questions $from '.$from);
4152
+                if ($debug) {
4153
+                    error_log('Showing questions $from '.$from);
4154
+                }
4147 4155
                 if ($from == 'exercise_result') {
4148 4156
                     //display answers (if not matching type, or if the answer is correct)
4149 4157
                     if (
@@ -4440,7 +4448,9 @@  discard block
 block discarded – undo
4440 4448
                         }
4441 4449
                     }
4442 4450
                 } else {
4443
-                    if ($debug) error_log('Showing questions $from '.$from);
4451
+                    if ($debug) {
4452
+                        error_log('Showing questions $from '.$from);
4453
+                    }
4444 4454
 
4445 4455
                     switch ($answerType) {
4446 4456
                         case UNIQUE_ANSWER:
@@ -4786,10 +4796,14 @@  discard block
 block discarded – undo
4786 4796
                     }
4787 4797
                 }
4788 4798
             }
4789
-            if ($debug) error_log(' ------ ');
4799
+            if ($debug) {
4800
+                error_log(' ------ ');
4801
+            }
4790 4802
         } // end for that loops over all answers of the current question
4791 4803
 
4792
-        if ($debug) error_log('-- end answer loop --');
4804
+        if ($debug) {
4805
+            error_log('-- end answer loop --');
4806
+        }
4793 4807
 
4794 4808
         $final_answer = true;
4795 4809
 
@@ -4862,7 +4876,9 @@  discard block
 block discarded – undo
4862 4876
             //  some results that haven't been stored in the database yet
4863 4877
             if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) {
4864 4878
 
4865
-                if ($debug) error_log('$from AND this is a hotspot kind of question ');
4879
+                if ($debug) {
4880
+                    error_log('$from AND this is a hotspot kind of question ');
4881
+                }
4866 4882
 
4867 4883
                 $my_exe_id = 0;
4868 4884
                 $from_database = 0;
@@ -5038,8 +5054,12 @@  discard block
 block discarded – undo
5038 5054
         // stored by exercise_results.php (using the session)
5039 5055
 
5040 5056
         if ($saved_results) {
5041
-            if ($debug) error_log("Save question results $saved_results");
5042
-            if ($debug) error_log(print_r($choice ,1 ));
5057
+            if ($debug) {
5058
+                error_log("Save question results $saved_results");
5059
+            }
5060
+            if ($debug) {
5061
+                error_log(print_r($choice ,1 ));
5062
+            }
5043 5063
 
5044 5064
             if (empty($choice)) {
5045 5065
                 $choice = 0;
Please login to merge, or discard this patch.
Spacing   +309 added lines, -309 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     public $feedback_type;
30 30
     public $end_time;
31 31
     public $start_time;
32
-    public $questionList;  // array with the list of this exercise's questions
32
+    public $questionList; // array with the list of this exercise's questions
33 33
     /* including question list of the media */
34 34
     public $questionListUncompressed;
35 35
     public $results_disabled;
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
130 130
         $table_lp_item = Database::get_course_table(TABLE_LP_ITEM);
131 131
 
132
-        $id  = intval($id);
132
+        $id = intval($id);
133 133
         if (empty($this->course_id)) {
134 134
 
135 135
             return false;
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
      */
467 467
     public function isRandom()
468 468
     {
469
-        if($this->random > 0 || $this->random == -1) {
469
+        if ($this->random > 0 || $this->random == -1) {
470 470
             return true;
471 471
         } else {
472 472
             return false;
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
                     $question_media = null;
628 628
                     if (!empty($objQuestionTmp->parent_id)) {
629 629
                         $objQuestionMedia = Question::read($objQuestionTmp->parent_id);
630
-                        $question_media  = Question::getMediaLabel($objQuestionMedia->question);
630
+                        $question_media = Question::getMediaLabel($objQuestionMedia->question);
631 631
                     }
632 632
 
633 633
                     $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), ICON_SIZE_MEDIUM).$question_media);
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
                 $cat = new TestCategory();
1023 1023
                 $cat = $cat->getCategory($categoryId);
1024 1024
 
1025
-                $cat = (array)$cat;
1025
+                $cat = (array) $cat;
1026 1026
                 $cat['iid'] = $cat['id'];
1027 1027
                 //*$cat['name'] = $cat['name'];
1028 1028
 
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
      */
1235 1235
     public function updateTitle($title)
1236 1236
     {
1237
-        $this->exercise=$title;
1237
+        $this->exercise = $title;
1238 1238
     }
1239 1239
 
1240 1240
     /**
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
      */
1245 1245
     public function updateAttempts($attempts)
1246 1246
     {
1247
-        $this->attempts=$attempts;
1247
+        $this->attempts = $attempts;
1248 1248
     }
1249 1249
 
1250 1250
     /**
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
      */
1255 1255
     public function updateFeedbackType($feedback_type)
1256 1256
     {
1257
-        $this->feedback_type=$feedback_type;
1257
+        $this->feedback_type = $feedback_type;
1258 1258
     }
1259 1259
 
1260 1260
     /**
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
      */
1266 1266
     public function updateDescription($description)
1267 1267
     {
1268
-        $this->description=$description;
1268
+        $this->description = $description;
1269 1269
     }
1270 1270
 
1271 1271
     /**
@@ -1401,23 +1401,23 @@  discard block
 block discarded – undo
1401 1401
      * @param string $sound - exercise sound file
1402 1402
      * @param string $delete - ask to delete the file
1403 1403
      */
1404
-    public function updateSound($sound,$delete)
1404
+    public function updateSound($sound, $delete)
1405 1405
     {
1406 1406
         global $audioPath, $documentPath;
1407 1407
         $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
1408 1408
 
1409
-        if ($sound['size'] && (strstr($sound['type'],'audio') || strstr($sound['type'],'video'))) {
1410
-            $this->sound=$sound['name'];
1409
+        if ($sound['size'] && (strstr($sound['type'], 'audio') || strstr($sound['type'], 'video'))) {
1410
+            $this->sound = $sound['name'];
1411 1411
 
1412
-            if (@move_uploaded_file($sound['tmp_name'],$audioPath.'/'.$this->sound)) {
1412
+            if (@move_uploaded_file($sound['tmp_name'], $audioPath.'/'.$this->sound)) {
1413 1413
                 $sql = "SELECT 1 FROM $TBL_DOCUMENT
1414
-                        WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath,'',$audioPath).'/'.$this->sound."'";
1414
+                        WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath, '', $audioPath).'/'.$this->sound."'";
1415 1415
                 $result = Database::query($sql);
1416 1416
 
1417 1417
                 if (!Database::num_rows($result)) {
1418 1418
                     $id = add_document(
1419 1419
                         $this->course,
1420
-                        str_replace($documentPath,'',$audioPath).'/'.$this->sound,
1420
+                        str_replace($documentPath, '', $audioPath).'/'.$this->sound,
1421 1421
                         'file',
1422 1422
                         $sound['size'],
1423 1423
                         $sound['name']
@@ -1436,8 +1436,8 @@  discard block
 block discarded – undo
1436 1436
                     );
1437 1437
                 }
1438 1438
             }
1439
-        } elseif($delete && is_file($audioPath.'/'.$this->sound)) {
1440
-            $this->sound='';
1439
+        } elseif ($delete && is_file($audioPath.'/'.$this->sound)) {
1440
+            $this->sound = '';
1441 1441
         }
1442 1442
     }
1443 1443
 
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
      */
1486 1486
     public function enable()
1487 1487
     {
1488
-        $this->active=1;
1488
+        $this->active = 1;
1489 1489
     }
1490 1490
 
1491 1491
     /**
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
      */
1496 1496
     public function disable()
1497 1497
     {
1498
-        $this->active=0;
1498
+        $this->active = 0;
1499 1499
     }
1500 1500
 
1501 1501
     /**
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
                 api_get_user_id()
1623 1623
             );
1624 1624
 
1625
-            if (api_get_setting('search_enabled')=='true') {
1625
+            if (api_get_setting('search_enabled') == 'true') {
1626 1626
                 $this->search_engine_edit();
1627 1627
             }
1628 1628
         } else {
@@ -1770,7 +1770,7 @@  discard block
 block discarded – undo
1770 1770
     public function removeFromList($questionId)
1771 1771
     {
1772 1772
         // searches the position of the question ID in the list
1773
-        $pos = array_search($questionId,$this->questionList);
1773
+        $pos = array_search($questionId, $this->questionList);
1774 1774
 
1775 1775
         // question not found
1776 1776
         if ($pos === false) {
@@ -1806,7 +1806,7 @@  discard block
 block discarded – undo
1806 1806
         api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'QuizDeleted', api_get_user_id());
1807 1807
         api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'delete', api_get_user_id());
1808 1808
 
1809
-        if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian') ) {
1809
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
1810 1810
             $this->search_engine_delete();
1811 1811
         }
1812 1812
     }
@@ -1815,7 +1815,7 @@  discard block
 block discarded – undo
1815 1815
      * Creates the form to create / edit an exercise
1816 1816
      * @param FormValidator $form
1817 1817
      */
1818
-    public function createForm($form, $type='full')
1818
+    public function createForm($form, $type = 'full')
1819 1819
     {
1820 1820
         if (empty($type)) {
1821 1821
             $type = 'full';
@@ -1846,7 +1846,7 @@  discard block
 block discarded – undo
1846 1846
             'Width' => '100%',
1847 1847
             'Height' => '150',
1848 1848
         );
1849
-        if (is_array($type)){
1849
+        if (is_array($type)) {
1850 1850
             $editor_config = array_merge($editor_config, $type);
1851 1851
         }
1852 1852
 
@@ -1900,7 +1900,7 @@  discard block
 block discarded – undo
1900 1900
                     '2',
1901 1901
                     array('id' => 'exerciseType_2')
1902 1902
                 );
1903
-                $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions')));
1903
+                $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')));
1904 1904
 
1905 1905
                 // Type of results display on the final page
1906 1906
                 $radios_results_disabled = array();
@@ -1944,8 +1944,8 @@  discard block
 block discarded – undo
1944 1944
                 // Type of questions disposition on page
1945 1945
                 $radios = array();
1946 1946
 
1947
-                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
1948
-                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
1947
+                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
1948
+                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
1949 1949
 
1950 1950
                 $form->addGroup($radios, null, get_lang('QuestionsPerPage'));
1951 1951
 
@@ -1955,32 +1955,32 @@  discard block
 block discarded – undo
1955 1955
 
1956 1956
                     // feedback type
1957 1957
                     $radios_feedback = array();
1958
-                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'),'0',array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()'));
1958
+                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()'));
1959 1959
 
1960 1960
                     if (api_get_setting('enable_quiz_scenario') == 'true') {
1961
-                        $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1' , 'onclick' => 'check_direct_feedback()'));
1961
+                        $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
1962 1962
                     }
1963
-                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2',array('id' =>'exerciseType_2'));
1964
-                    $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions')));
1963
+                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' =>'exerciseType_2'));
1964
+                    $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')));
1965 1965
 
1966 1966
                     //$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
1967 1967
                     $radios_results_disabled = array();
1968 1968
                     $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0'));
1969
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
1970
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()'));
1971
-                    $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),'');
1969
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()'));
1970
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()'));
1971
+                    $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
1972 1972
 
1973 1973
                     // Type of questions disposition on page
1974 1974
                     $radios = array();
1975
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1');
1976
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2');
1975
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1');
1976
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2');
1977 1977
                     $form->addGroup($radios, null, get_lang('ExerciseType'));
1978 1978
 
1979 1979
                 } else {
1980 1980
                     //Show options freeze
1981 1981
                     $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0'));
1982
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
1983
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()'));
1982
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()'));
1983
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()'));
1984 1984
                     $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'));
1985 1985
                     $result_disable_group->freeze();
1986 1986
 
@@ -1989,8 +1989,8 @@  discard block
 block discarded – undo
1989 1989
                     $form->addElement('hidden', 'exerciseType', ONE_PER_PAGE);
1990 1990
 
1991 1991
                     // Type of questions disposition on page
1992
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
1993
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
1992
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
1993
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
1994 1994
 
1995 1995
                     $type_group = $form->addGroup($radios, null, get_lang('QuestionsPerPage'));
1996 1996
                     $type_group->freeze();
@@ -2162,7 +2162,7 @@  discard block
 block discarded – undo
2162 2162
             );
2163 2163
 
2164 2164
             // Exercise time limit
2165
-            $form->addElement('checkbox', 'activate_start_date_check',null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
2165
+            $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
2166 2166
 
2167 2167
             $var = Exercise::selectTimeLimit();
2168 2168
 
@@ -2174,9 +2174,9 @@  discard block
 block discarded – undo
2174 2174
 
2175 2175
             $form->addElement('date_time_picker', 'start_time');
2176 2176
 
2177
-            $form->addElement('html','</div>');
2177
+            $form->addElement('html', '</div>');
2178 2178
 
2179
-            $form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
2179
+            $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
2180 2180
 
2181 2181
             if (!empty($this->end_time)) {
2182 2182
                 $form->addElement('html', '<div id="end_date_div" style="display:block;">');
@@ -2185,7 +2185,7 @@  discard block
 block discarded – undo
2185 2185
             }
2186 2186
 
2187 2187
             $form->addElement('date_time_picker', 'end_time');
2188
-            $form->addElement('html','</div>');
2188
+            $form->addElement('html', '</div>');
2189 2189
 
2190 2190
             //$check_option=$this->selectType();
2191 2191
             $diplay = 'block';
@@ -2195,10 +2195,10 @@  discard block
 block discarded – undo
2195 2195
                 null,
2196 2196
                 get_lang('SaveTheCorrectAnswersForTheNextAttempt')
2197 2197
             );
2198
-            $form->addElement('html','<div class="clear">&nbsp;</div>');
2198
+            $form->addElement('html', '<div class="clear">&nbsp;</div>');
2199 2199
             $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers'));
2200 2200
 
2201
-            $form->addElement('html','<div id="divtimecontrol"  style="display:'.$diplay.';">');
2201
+            $form->addElement('html', '<div id="divtimecontrol"  style="display:'.$diplay.';">');
2202 2202
 
2203 2203
             //Timer control
2204 2204
             //$time_hours_option = range(0,12);
@@ -2215,12 +2215,12 @@  discard block
 block discarded – undo
2215 2215
                 )
2216 2216
             );
2217 2217
 
2218
-            $expired_date = (int)$this->selectExpiredTime();
2218
+            $expired_date = (int) $this->selectExpiredTime();
2219 2219
 
2220
-            if (($expired_date!='0')) {
2221
-                $form->addElement('html','<div id="timercontrol" style="display:block;">');
2220
+            if (($expired_date != '0')) {
2221
+                $form->addElement('html', '<div id="timercontrol" style="display:block;">');
2222 2222
             } else {
2223
-                $form->addElement('html','<div id="timercontrol" style="display:none;">');
2223
+                $form->addElement('html', '<div id="timercontrol" style="display:none;">');
2224 2224
             }
2225 2225
             $form->addText(
2226 2226
                 'enabletimercontroltotalminutes',
@@ -2231,7 +2231,7 @@  discard block
 block discarded – undo
2231 2231
                     'cols-size' => [2, 2, 8]
2232 2232
                 ]
2233 2233
             );
2234
-            $form->addElement('html','</div>');
2234
+            $form->addElement('html', '</div>');
2235 2235
 
2236 2236
             $form->addElement(
2237 2237
                 'text',
@@ -2256,7 +2256,7 @@  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 2261
                 $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
2262 2262
                 $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
@@ -2264,15 +2264,15 @@  discard block
 block discarded – undo
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'];
@@ -2282,8 +2282,8 @@  discard block
 block discarded – undo
2282 2282
                 }
2283 2283
             }
2284 2284
 
2285
-            $form->addElement('html','</div>');  //End advanced setting
2286
-            $form->addElement('html','</div>');
2285
+            $form->addElement('html', '</div>'); //End advanced setting
2286
+            $form->addElement('html', '</div>');
2287 2287
         }
2288 2288
 
2289 2289
         // submit
@@ -2303,10 +2303,10 @@  discard block
 block discarded – undo
2303 2303
         }
2304 2304
 
2305 2305
         // defaults
2306
-        if ($type=='full') {
2306
+        if ($type == 'full') {
2307 2307
             if ($this->id > 0) {
2308 2308
                 if ($this->random > $this->selectNbrQuestions()) {
2309
-                    $defaults['randomQuestions'] =  $this->selectNbrQuestions();
2309
+                    $defaults['randomQuestions'] = $this->selectNbrQuestions();
2310 2310
                 } else {
2311 2311
                     $defaults['randomQuestions'] = $this->random;
2312 2312
                 }
@@ -2335,7 +2335,7 @@  discard block
 block discarded – undo
2335 2335
                 }
2336 2336
 
2337 2337
                 $defaults['start_time'] = !empty($this->start_time) ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00');
2338
-                $defaults['end_time'] = empty($this->end_time) ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time()+84600);
2338
+                $defaults['end_time'] = empty($this->end_time) ? 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;
@@ -2456,9 +2456,9 @@  discard block
 block discarded – undo
2456 2456
         }
2457 2457
 
2458 2458
         if ($form->getSubmitValue('randomAnswers') == 1) {
2459
-            $this->random_answers=1;
2459
+            $this->random_answers = 1;
2460 2460
         } else {
2461
-            $this->random_answers=0;
2461
+            $this->random_answers = 0;
2462 2462
         }
2463 2463
         $this->save($type);
2464 2464
     }
@@ -2470,9 +2470,9 @@  discard block
 block discarded – undo
2470 2470
         }
2471 2471
         $course_id = api_get_course_id();
2472 2472
 
2473
-        require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
2474
-        require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
2475
-        require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
2473
+        require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
2474
+        require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php';
2475
+        require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2476 2476
 
2477 2477
         $specific_fields = get_specific_field_list();
2478 2478
         $ic_slide = new IndexableChunk();
@@ -2482,7 +2482,7 @@  discard block
 block discarded – undo
2482 2482
             if (isset($_REQUEST[$specific_field['code']])) {
2483 2483
                 $sterms = trim($_REQUEST[$specific_field['code']]);
2484 2484
                 if (!empty($sterms)) {
2485
-                    $all_specific_terms .= ' '. $sterms;
2485
+                    $all_specific_terms .= ' '.$sterms;
2486 2486
                     $sterms = explode(',', $sterms);
2487 2487
                     foreach ($sterms as $sterm) {
2488 2488
                         $ic_slide->addTerm(trim($sterm), $specific_field['code']);
@@ -2499,15 +2499,15 @@  discard block
 block discarded – undo
2499 2499
         $xapian_data = array(
2500 2500
             SE_COURSE_ID => $course_id,
2501 2501
             SE_TOOL_ID => TOOL_QUIZ,
2502
-            SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id),
2503
-            SE_USER => (int)api_get_user_id(),
2502
+            SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id),
2503
+            SE_USER => (int) api_get_user_id(),
2504 2504
         );
2505 2505
         $ic_slide->xapian_data = serialize($xapian_data);
2506
-        $exercise_description = $all_specific_terms .' '. $this->description;
2506
+        $exercise_description = $all_specific_terms.' '.$this->description;
2507 2507
         $ic_slide->addValue("content", $exercise_description);
2508 2508
 
2509 2509
         $di = new ChamiloIndexer();
2510
-        isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
2510
+        isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english';
2511 2511
         $di->connectDb(NULL, NULL, $lang);
2512 2512
         $di->addChunk($ic_slide);
2513 2513
 
@@ -2526,7 +2526,7 @@  discard block
 block discarded – undo
2526 2526
     function search_engine_edit()
2527 2527
     {
2528 2528
         // update search enchine and its values table if enabled
2529
-        if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {
2529
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
2530 2530
             $course_id = api_get_course_id();
2531 2531
 
2532 2532
             // actually, it consists on delete terms from db,
@@ -2538,9 +2538,9 @@  discard block
 block discarded – undo
2538 2538
             $res = Database::query($sql);
2539 2539
 
2540 2540
             if (Database::num_rows($res) > 0) {
2541
-                require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php');
2542
-                require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php');
2543
-                require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
2541
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
2542
+                require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php');
2543
+                require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php');
2544 2544
 
2545 2545
                 $se_ref = Database::fetch_array($res);
2546 2546
                 $specific_fields = get_specific_field_list();
@@ -2551,7 +2551,7 @@  discard block
 block discarded – undo
2551 2551
                     delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_QUIZ, $this->id);
2552 2552
                     if (isset($_REQUEST[$specific_field['code']])) {
2553 2553
                         $sterms = trim($_REQUEST[$specific_field['code']]);
2554
-                        $all_specific_terms .= ' '. $sterms;
2554
+                        $all_specific_terms .= ' '.$sterms;
2555 2555
                         $sterms = explode(',', $sterms);
2556 2556
                         foreach ($sterms as $sterm) {
2557 2557
                             $ic_slide->addTerm(trim($sterm), $specific_field['code']);
@@ -2567,17 +2567,17 @@  discard block
 block discarded – undo
2567 2567
                 $xapian_data = array(
2568 2568
                     SE_COURSE_ID => $course_id,
2569 2569
                     SE_TOOL_ID => TOOL_QUIZ,
2570
-                    SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id),
2571
-                    SE_USER => (int)api_get_user_id(),
2570
+                    SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id),
2571
+                    SE_USER => (int) api_get_user_id(),
2572 2572
                 );
2573 2573
                 $ic_slide->xapian_data = serialize($xapian_data);
2574
-                $exercise_description = $all_specific_terms .' '. $this->description;
2574
+                $exercise_description = $all_specific_terms.' '.$this->description;
2575 2575
                 $ic_slide->addValue("content", $exercise_description);
2576 2576
 
2577 2577
                 $di = new ChamiloIndexer();
2578
-                isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
2578
+                isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english';
2579 2579
                 $di->connectDb(NULL, NULL, $lang);
2580
-                $di->remove_document((int)$se_ref['search_did']);
2580
+                $di->remove_document((int) $se_ref['search_did']);
2581 2581
                 $di->addChunk($ic_slide);
2582 2582
 
2583 2583
                 //index and return search engine document id
@@ -2602,7 +2602,7 @@  discard block
 block discarded – undo
2602 2602
     function search_engine_delete()
2603 2603
     {
2604 2604
         // remove from search engine if enabled
2605
-        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian') ) {
2605
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
2606 2606
             $course_id = api_get_course_id();
2607 2607
             $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
2608 2608
             $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';
@@ -2610,19 +2610,19 @@  discard block
 block discarded – undo
2610 2610
             $res = Database::query($sql);
2611 2611
             if (Database::num_rows($res) > 0) {
2612 2612
                 $row = Database::fetch_array($res);
2613
-                require_once(api_get_path(LIBRARY_PATH) .'search/ChamiloIndexer.class.php');
2613
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
2614 2614
                 $di = new ChamiloIndexer();
2615
-                $di->remove_document((int)$row['search_did']);
2615
+                $di->remove_document((int) $row['search_did']);
2616 2616
                 unset($di);
2617 2617
                 $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
2618
-                foreach ( $this->questionList as $question_i) {
2618
+                foreach ($this->questionList as $question_i) {
2619 2619
                     $sql = 'SELECT type FROM %s WHERE id=%s';
2620 2620
                     $sql = sprintf($sql, $tbl_quiz_question, $question_i);
2621 2621
                     $qres = Database::query($sql);
2622 2622
                     if (Database::num_rows($qres) > 0) {
2623 2623
                         $qrow = Database::fetch_array($qres);
2624 2624
                         $objQuestion = Question::getInstance($qrow['type']);
2625
-                        $objQuestion = Question::read((int)$question_i);
2625
+                        $objQuestion = Question::read((int) $question_i);
2626 2626
                         $objQuestion->search_engine_edit($this->id, FALSE, TRUE);
2627 2627
                         unset($objQuestion);
2628 2628
                     }
@@ -2633,7 +2633,7 @@  discard block
 block discarded – undo
2633 2633
             Database::query($sql);
2634 2634
 
2635 2635
             // remove terms from db
2636
-            require_once api_get_path(LIBRARY_PATH) .'specific_fields_manager.lib.php';
2636
+            require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2637 2637
             delete_all_values_for_item($course_id, TOOL_QUIZ, $this->id);
2638 2638
         }
2639 2639
     }
@@ -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
         }
@@ -2861,12 +2861,12 @@  discard block
 block discarded – undo
2861 2861
         $questionList = array_map('intval', $questionList);
2862 2862
 
2863 2863
         $params = array(
2864
-            'exe_exo_id' => $this->id ,
2864
+            'exe_exo_id' => $this->id,
2865 2865
             'exe_user_id' => api_get_user_id(),
2866 2866
             'c_id' => api_get_course_int_id(),
2867 2867
             'status' =>  'incomplete',
2868 2868
             'session_id'  => api_get_session_id(),
2869
-            'data_tracking'  => implode(',', $questionList) ,
2869
+            'data_tracking'  => implode(',', $questionList),
2870 2870
             'start_date' => api_get_utc_datetime(),
2871 2871
             'orig_lp_id' => $safe_lp_id,
2872 2872
             'orig_lp_item_id'  => $safe_lp_item_id,
@@ -2900,7 +2900,7 @@  discard block
 block discarded – undo
2900 2900
         $nbrQuestions = $this->get_count_question_list();
2901 2901
 
2902 2902
         $all_button = $html = $label = '';
2903
-        $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']):null;
2903
+        $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null;
2904 2904
 
2905 2905
         if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) {
2906 2906
             $urlTitle = get_lang('ContinueTest');
@@ -2911,7 +2911,7 @@  discard block
 block discarded – undo
2911 2911
 
2912 2912
             $html .= Display::url(
2913 2913
                 $urlTitle,
2914
-                'exercise_submit_modal.php?' . http_build_query([
2914
+                'exercise_submit_modal.php?'.http_build_query([
2915 2915
                     'learnpath_id' => $safe_lp_id,
2916 2916
                     'learnpath_item_id' => $safe_lp_item_id,
2917 2917
                     'learnpath_item_view_id' => $safe_lp_item_view_id,
@@ -2928,7 +2928,7 @@  discard block
 block discarded – undo
2928 2928
                     'data-size' => 'md'
2929 2929
                 ]
2930 2930
             );
2931
-            $html .='<br />';
2931
+            $html .= '<br />';
2932 2932
         } else {
2933 2933
             // User
2934 2934
             if (api_is_allowed_to_session_edit()) {
@@ -2953,7 +2953,7 @@  discard block
 block discarded – undo
2953 2953
 
2954 2954
                     //Next question
2955 2955
                     if (!empty($questions_in_media)) {
2956
-                        $questions_in_media = "['".implode("','",$questions_in_media)."']";
2956
+                        $questions_in_media = "['".implode("','", $questions_in_media)."']";
2957 2957
                         $all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_question_list('.$questions_in_media.'); ">'.$label.'</a>';
2958 2958
                     } else {
2959 2959
                         $all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.', \'\', \''.$currentAnswer.'\'); ">'.$label.'</a>';
@@ -2971,7 +2971,7 @@  discard block
 block discarded – undo
2971 2971
                     }
2972 2972
 					$class .= ' question-validate-btn'; // used to select it with jquery
2973 2973
                     $all_button = '&nbsp;<a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>';
2974
-                    $all_button .= '&nbsp;' . Display::span(null, ['id' => 'save_all_reponse']);
2974
+                    $all_button .= '&nbsp;'.Display::span(null, ['id' => 'save_all_reponse']);
2975 2975
                     $html .= $all_button;
2976 2976
                 }
2977 2977
             }
@@ -3265,11 +3265,11 @@  discard block
 block discarded – undo
3265 3265
             $answer = $objAnswerTmp->selectAnswer($answerId);
3266 3266
             $answerComment = $objAnswerTmp->selectComment($answerId);
3267 3267
             $answerCorrect = $objAnswerTmp->isCorrect($answerId);
3268
-            $answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId);
3268
+            $answerWeighting = (float) $objAnswerTmp->selectWeighting($answerId);
3269 3269
             $answerAutoId = $objAnswerTmp->selectAutoId($answerId);
3270 3270
             $answerIid = isset($objAnswerTmp->iid[$answerId]) ? $objAnswerTmp->iid[$answerId] : '';
3271 3271
 
3272
-            $answer_correct_array[$answerId] = (bool)$answerCorrect;
3272
+            $answer_correct_array[$answerId] = (bool) $answerCorrect;
3273 3273
 
3274 3274
             if ($debug) {
3275 3275
                 error_log("answer auto id: $answerAutoId ");
@@ -3278,7 +3278,7 @@  discard block
 block discarded – undo
3278 3278
 
3279 3279
             // Delineation
3280 3280
             $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
3281
-            $answer_delineation_destination=$objAnswerTmp->selectDestination(1);
3281
+            $answer_delineation_destination = $objAnswerTmp->selectDestination(1);
3282 3282
 
3283 3283
             switch ($answerType) {
3284 3284
                 // for unique answer
@@ -3291,7 +3291,7 @@  discard block
 block discarded – undo
3291 3291
                                     exe_id = '".$exeId."' AND
3292 3292
                                     question_id= '".$questionId."'";
3293 3293
                         $result = Database::query($sql);
3294
-                        $choice = Database::result($result,0,"answer");
3294
+                        $choice = Database::result($result, 0, "answer");
3295 3295
 
3296 3296
                         $studentChoice = $choice == $answerAutoId ? 1 : 0;
3297 3297
                         if ($studentChoice) {
@@ -3342,7 +3342,7 @@  discard block
 block discarded – undo
3342 3342
                     } else {
3343 3343
                         // If no result then the user just hit don't know
3344 3344
                         $studentChoice = 3;
3345
-                        $questionScore  +=  $doubt_score;
3345
+                        $questionScore += $doubt_score;
3346 3346
                     }
3347 3347
                     $totalScore = $questionScore;
3348 3348
                     break;
@@ -3358,17 +3358,17 @@  discard block
 block discarded – undo
3358 3358
                         }
3359 3359
 
3360 3360
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3361
-                        $real_answers[$answerId] = (bool)$studentChoice;
3361
+                        $real_answers[$answerId] = (bool) $studentChoice;
3362 3362
 
3363 3363
                         if ($studentChoice) {
3364
-                            $questionScore  +=$answerWeighting;
3364
+                            $questionScore += $answerWeighting;
3365 3365
                         }
3366 3366
                     } else {
3367 3367
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3368
-                        $real_answers[$answerId] = (bool)$studentChoice;
3368
+                        $real_answers[$answerId] = (bool) $studentChoice;
3369 3369
 
3370 3370
                         if (isset($studentChoice)) {
3371
-                            $questionScore  += $answerWeighting;
3371
+                            $questionScore += $answerWeighting;
3372 3372
                         }
3373 3373
                     }
3374 3374
                     $totalScore += $answerWeighting;
@@ -3386,16 +3386,16 @@  discard block
 block discarded – undo
3386 3386
                             $choice[$ind] = 1;
3387 3387
                         }
3388 3388
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3389
-                        $real_answers[$answerId] = (bool)$studentChoice;
3389
+                        $real_answers[$answerId] = (bool) $studentChoice;
3390 3390
                         if ($studentChoice) {
3391
-                            $questionScore +=$answerWeighting;
3391
+                            $questionScore += $answerWeighting;
3392 3392
                         }
3393 3393
                     } else {
3394 3394
                         $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3395 3395
                         if (isset($studentChoice)) {
3396 3396
                             $questionScore += $answerWeighting;
3397 3397
                         }
3398
-                        $real_answers[$answerId] = (bool)$studentChoice;
3398
+                        $real_answers[$answerId] = (bool) $studentChoice;
3399 3399
                     }
3400 3400
                     $totalScore += $answerWeighting;
3401 3401
                     if ($debug) error_log("studentChoice: $studentChoice");
@@ -3407,7 +3407,7 @@  discard block
 block discarded – undo
3407 3407
                         $resultans = Database::query($sql);
3408 3408
                         while ($row = Database::fetch_array($resultans)) {
3409 3409
                             $ind = $row['answer'];
3410
-                            $result = explode(':',$ind);
3410
+                            $result = explode(':', $ind);
3411 3411
                             if (isset($result[0])) {
3412 3412
                                 $my_answer_id = isset($result[0]) ? $result[0] : '';
3413 3413
                                 $option = isset($result[1]) ? $result[1] : '';
@@ -3528,10 +3528,10 @@  discard block
 block discarded – undo
3528 3528
                             }
3529 3529
                             // adds the piece of text that is before the blank
3530 3530
                             //and ends with '[' into a general storage array
3531
-                            $real_text[] = api_substr($temp, 0, $pos +1);
3532
-                            $answer .= api_substr($temp, 0, $pos +1);
3531
+                            $real_text[] = api_substr($temp, 0, $pos + 1);
3532
+                            $answer .= api_substr($temp, 0, $pos + 1);
3533 3533
                             //take the string remaining (after the last "[" we found)
3534
-                            $temp = api_substr($temp, $pos +1);
3534
+                            $temp = api_substr($temp, $pos + 1);
3535 3535
                             // quit the loop if there are no more blanks, and update $pos to the position of next ']'
3536 3536
                             if (($pos = api_strpos($temp, ']')) === false) {
3537 3537
                                 // adds the end of the text
@@ -3567,7 +3567,7 @@  discard block
 block discarded – undo
3567 3567
                             //put the contents of the [] answer tag into correct_tags[]
3568 3568
                             $correct_tags[] = api_substr($temp, 0, $pos);
3569 3569
                             $j++;
3570
-                            $temp = api_substr($temp, $pos +1);
3570
+                            $temp = api_substr($temp, $pos + 1);
3571 3571
                         }
3572 3572
                         $answer = '';
3573 3573
                         $real_correct_tags = $correct_tags;
@@ -3590,7 +3590,7 @@  discard block
 block discarded – undo
3590 3590
                                 } elseif (!empty($user_tags[$i])) {
3591 3591
                                     // else if the word entered by the student IS NOT the same as the one defined by the professor
3592 3592
                                     // adds the word in red at the end of the string, and strikes it
3593
-                                    $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>';
3593
+                                    $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>';
3594 3594
                                 } else {
3595 3595
                                     // adds a tabulation if no word has been typed by the student
3596 3596
                                     $answer .= ''; // remove &nbsp; that causes issue
@@ -3609,17 +3609,17 @@  discard block
 block discarded – undo
3609 3609
                                 } elseif (!empty ($user_tags[$i])) {
3610 3610
                                     // else if the word entered by the student IS NOT the same as the one defined by the professor
3611 3611
                                     // adds the word in red at the end of the string, and strikes it
3612
-                                    $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>';
3612
+                                    $answer .= '<font color="red"><s>'.$user_tags[$i].'</s></font>';
3613 3613
                                 } else {
3614 3614
                                     // adds a tabulation if no word has been typed by the student
3615
-                                    $answer .= '';  // remove &nbsp; that causes issue
3615
+                                    $answer .= ''; // remove &nbsp; that causes issue
3616 3616
                                 }
3617 3617
                             }
3618 3618
 
3619 3619
                             // adds the correct word, followed by ] to close the blank
3620
-                            $answer .= ' / <font color="green"><b>' . $real_correct_tags[$i] . '</b></font>]';
3621
-                            if (isset($real_text[$i +1])) {
3622
-                                $answer .= $real_text[$i +1];
3620
+                            $answer .= ' / <font color="green"><b>'.$real_correct_tags[$i].'</b></font>]';
3621
+                            if (isset($real_text[$i + 1])) {
3622
+                                $answer .= $real_text[$i + 1];
3623 3623
                             }
3624 3624
                         }
3625 3625
                     } else {
@@ -3743,10 +3743,10 @@  discard block
 block discarded – undo
3743 3743
                         }
3744 3744
                         // adds the piece of text that is before the blank
3745 3745
                         //and ends with '[' into a general storage array
3746
-                        $realText[] = api_substr($temp, 0, $pos +1);
3747
-                        $answer .= api_substr($temp, 0, $pos +1);
3746
+                        $realText[] = api_substr($temp, 0, $pos + 1);
3747
+                        $answer .= api_substr($temp, 0, $pos + 1);
3748 3748
                         //take the string remaining (after the last "[" we found)
3749
-                        $temp = api_substr($temp, $pos +1);
3749
+                        $temp = api_substr($temp, $pos + 1);
3750 3750
                         // quit the loop if there are no more blanks, and update $pos to the position of next ']'
3751 3751
                         if (($pos = api_strpos($temp, ']')) === false) {
3752 3752
                             // adds the end of the text
@@ -3787,7 +3787,7 @@  discard block
 block discarded – undo
3787 3787
                         //put the contents of the [] answer tag into correct_tags[]
3788 3788
                         $correctTags[] = api_substr($temp, 0, $pos);
3789 3789
                         $j++;
3790
-                        $temp = api_substr($temp, $pos +1);
3790
+                        $temp = api_substr($temp, $pos + 1);
3791 3791
                     }
3792 3792
                     $answer = '';
3793 3793
                     $realCorrectTags = $correctTags;
@@ -3807,7 +3807,7 @@  discard block
 block discarded – undo
3807 3807
                         } elseif (!empty($userTags[$i])) {
3808 3808
                             // else if the word entered by the student IS NOT the same as the one defined by the professor
3809 3809
                             // adds the word in red at the end of the string, and strikes it
3810
-                            $answer .= '<font color="red"><s>' . $userTags[$i] . '</s></font>';
3810
+                            $answer .= '<font color="red"><s>'.$userTags[$i].'</s></font>';
3811 3811
                         } else {
3812 3812
                             // adds a tabulation if no word has been typed by the student
3813 3813
                             $answer .= ''; // remove &nbsp; that causes issue
@@ -3817,19 +3817,19 @@  discard block
 block discarded – undo
3817 3817
                         if (
3818 3818
                             $this->results_disabled != EXERCISE_FEEDBACK_TYPE_EXAM
3819 3819
                         ) {
3820
-                            $answer .= ' / <font color="green"><b>' . $realCorrectTags[$i] . '</b></font>';
3820
+                            $answer .= ' / <font color="green"><b>'.$realCorrectTags[$i].'</b></font>';
3821 3821
                         }
3822 3822
 
3823 3823
                         $answer .= ']';
3824 3824
 
3825
-                        if (isset($realText[$i +1])) {
3826
-                            $answer .= $realText[$i +1];
3825
+                        if (isset($realText[$i + 1])) {
3826
+                            $answer .= $realText[$i + 1];
3827 3827
                         }
3828 3828
                     }
3829 3829
                     break;
3830 3830
                 case FREE_ANSWER:
3831 3831
                     if ($from_database) {
3832
-                        $query  = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3832
+                        $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3833 3833
                                    WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3834 3834
                         $resq = Database::query($query);
3835 3835
                         $data = Database::fetch_array($resq);
@@ -3840,9 +3840,9 @@  discard block
 block discarded – undo
3840 3840
                         $questionScore = $data['marks'];
3841 3841
 
3842 3842
                         if ($questionScore == -1) {
3843
-                            $totalScore+= 0;
3843
+                            $totalScore += 0;
3844 3844
                         } else {
3845
-                            $totalScore+= $questionScore;
3845
+                            $totalScore += $questionScore;
3846 3846
                         }
3847 3847
                         if ($questionScore == '') {
3848 3848
                             $questionScore = 0;
@@ -3920,7 +3920,7 @@  discard block
 block discarded – undo
3920 3920
 
3921 3921
                         while ($a_answers = Database::fetch_array($res_answers)) {
3922 3922
                             $i_answer_id = $a_answers['id']; //3
3923
-                            $s_answer_label = $a_answers['answer'];  // your daddy - your mother
3923
+                            $s_answer_label = $a_answers['answer']; // your daddy - your mother
3924 3924
                             $i_answer_correct_answer = $a_answers['correct']; //1 - 2
3925 3925
                             $i_answer_id_auto = $a_answers['id_auto']; // 3 - 4
3926 3926
 
@@ -3975,8 +3975,8 @@  discard block
 block discarded – undo
3975 3975
                                     $user_answer = '';
3976 3976
                                 }
3977 3977
                                 echo '<tr>';
3978
-                                echo '<td>' . $s_answer_label . '</td>';
3979
-                                echo '<td>' . $user_answer;
3978
+                                echo '<td>'.$s_answer_label.'</td>';
3979
+                                echo '<td>'.$user_answer;
3980 3980
 
3981 3981
                                 if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
3982 3982
                                     if (isset($real_list[$i_answer_correct_answer]) && $showTotalScoreAndUserChoices == false) {
@@ -4136,7 +4136,7 @@  discard block
 block discarded – undo
4136 4136
                     if ($from_database) {
4137 4137
                         // getting the user answer
4138 4138
                         $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
4139
-                        $query   = "SELECT hotspot_correct, hotspot_coordinate
4139
+                        $query = "SELECT hotspot_correct, hotspot_coordinate
4140 4140
                                     FROM $TBL_TRACK_HOTSPOT
4141 4141
                                     WHERE
4142 4142
                                         hotspot_exe_id = '".$exeId."' AND
@@ -4144,20 +4144,20 @@  discard block
 block discarded – undo
4144 4144
                                         hotspot_answer_id='1'";
4145 4145
                         //by default we take 1 because it's a delineation
4146 4146
                         $resq = Database::query($query);
4147
-                        $row = Database::fetch_array($resq,'ASSOC');
4147
+                        $row = Database::fetch_array($resq, 'ASSOC');
4148 4148
 
4149 4149
                         $choice = $row['hotspot_correct'];
4150 4150
                         $user_answer = $row['hotspot_coordinate'];
4151 4151
 
4152 4152
                         // THIS is very important otherwise the poly_compile will throw an error!!
4153 4153
                         // round-up the coordinates
4154
-                        $coords = explode('/',$user_answer);
4154
+                        $coords = explode('/', $user_answer);
4155 4155
                         $user_array = '';
4156 4156
                         foreach ($coords as $coord) {
4157
-                            list($x,$y) = explode(';',$coord);
4157
+                            list($x, $y) = explode(';', $coord);
4158 4158
                             $user_array .= round($x).';'.round($y).'/';
4159 4159
                         }
4160
-                        $user_array = substr($user_array,0,-1);
4160
+                        $user_array = substr($user_array, 0, -1);
4161 4161
                     } else {
4162 4162
                         if (!empty($studentChoice)) {
4163 4163
                             $newquestionList[] = $questionId;
@@ -4167,13 +4167,13 @@  discard block
 block discarded – undo
4167 4167
                             $studentChoice = $choice[$answerId];
4168 4168
                             $questionScore += $answerWeighting;
4169 4169
 
4170
-                            if ($hotspot_delineation_result[1]==1) {
4170
+                            if ($hotspot_delineation_result[1] == 1) {
4171 4171
                                 $totalScore += $answerWeighting; //adding the total
4172 4172
                             }
4173 4173
                         }
4174 4174
                     }
4175
-                    $_SESSION['hotspot_coord'][1]	= $delineation_cord;
4176
-                    $_SESSION['hotspot_dest'][1]	= $answer_delineation_destination;
4175
+                    $_SESSION['hotspot_coord'][1] = $delineation_cord;
4176
+                    $_SESSION['hotspot_dest'][1] = $answer_delineation_destination;
4177 4177
                     break;
4178 4178
             } // end switch Answertype
4179 4179
 
@@ -4225,7 +4225,7 @@  discard block
 block discarded – undo
4225 4225
                                 $results_disabled,
4226 4226
                                 $showTotalScoreAndUserChoices
4227 4227
                             );
4228
-                        } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
4228
+                        } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
4229 4229
                             ExerciseShowFunctions::display_multiple_answer_combination_true_false(
4230 4230
                                 $feedback_type,
4231 4231
                                 $answerType,
@@ -4307,13 +4307,13 @@  discard block
 block discarded – undo
4307 4307
                             $user_answer = $_SESSION['exerciseResultCoordinates'][$questionId];
4308 4308
 
4309 4309
                             //round-up the coordinates
4310
-                            $coords = explode('/',$user_answer);
4310
+                            $coords = explode('/', $user_answer);
4311 4311
                             $user_array = '';
4312 4312
                             foreach ($coords as $coord) {
4313
-                                list($x,$y) = explode(';',$coord);
4313
+                                list($x, $y) = explode(';', $coord);
4314 4314
                                 $user_array .= round($x).';'.round($y).'/';
4315 4315
                             }
4316
-                            $user_array = substr($user_array,0,-1);
4316
+                            $user_array = substr($user_array, 0, -1);
4317 4317
 
4318 4318
                             if ($next) {
4319 4319
 
@@ -4340,7 +4340,7 @@  discard block
 block discarded – undo
4340 4340
                                 //$overlap = round(polygons_overlap($poly_answer,$poly_user));
4341 4341
                                 // //this is an area in pixels
4342 4342
                                 if ($debug > 0) {
4343
-                                    error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0);
4343
+                                    error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0);
4344 4344
                                 }
4345 4345
 
4346 4346
                                 if ($overlap < 1) {
@@ -4353,43 +4353,43 @@  discard block
 block discarded – undo
4353 4353
                                     // that is overlapped by the user's polygon
4354 4354
                                     $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
4355 4355
                                     if ($debug > 1) {
4356
-                                        error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
4356
+                                        error_log(__LINE__.' - Final overlap is '.$final_overlap, 0);
4357 4357
                                     }
4358 4358
                                     // the final missing area is the percentage of the initial polygon
4359 4359
                                     // that is not overlapped by the user's polygon
4360 4360
                                     $final_missing = 100 - $final_overlap;
4361 4361
                                     if ($debug > 1) {
4362
-                                        error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
4362
+                                        error_log(__LINE__.' - Final missing is '.$final_missing, 0);
4363 4363
                                     }
4364 4364
                                     // the final excess area is the percentage of the initial polygon's size
4365 4365
                                     // that is covered by the user's polygon outside of the initial polygon
4366 4366
                                     $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
4367 4367
                                     if ($debug > 1) {
4368
-                                        error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0);
4368
+                                        error_log(__LINE__.' - Final excess is '.$final_excess, 0);
4369 4369
                                     }
4370 4370
                                 }
4371 4371
 
4372 4372
                                 //checking the destination parameters parsing the "@@"
4373
-                                $destination_items= explode('@@', $answerDestination);
4373
+                                $destination_items = explode('@@', $answerDestination);
4374 4374
                                 $threadhold_total = $destination_items[0];
4375
-                                $threadhold_items=explode(';',$threadhold_total);
4375
+                                $threadhold_items = explode(';', $threadhold_total);
4376 4376
                                 $threadhold1 = $threadhold_items[0]; // overlap
4377 4377
                                 $threadhold2 = $threadhold_items[1]; // excess
4378
-                                $threadhold3 = $threadhold_items[2];	 //missing
4378
+                                $threadhold3 = $threadhold_items[2]; //missing
4379 4379
 
4380 4380
                                 // if is delineation
4381
-                                if ($answerId===1) {
4381
+                                if ($answerId === 1) {
4382 4382
                                     //setting colors
4383
-                                    if ($final_overlap>=$threadhold1) {
4384
-                                        $overlap_color=true; //echo 'a';
4383
+                                    if ($final_overlap >= $threadhold1) {
4384
+                                        $overlap_color = true; //echo 'a';
4385 4385
                                     }
4386 4386
                                     //echo $excess.'-'.$threadhold2;
4387
-                                    if ($final_excess<=$threadhold2) {
4388
-                                        $excess_color=true; //echo 'b';
4387
+                                    if ($final_excess <= $threadhold2) {
4388
+                                        $excess_color = true; //echo 'b';
4389 4389
                                     }
4390 4390
                                     //echo '--------'.$missing.'-'.$threadhold3;
4391
-                                    if ($final_missing<=$threadhold3) {
4392
-                                        $missing_color=true; //echo 'c';
4391
+                                    if ($final_missing <= $threadhold3) {
4392
+                                        $missing_color = true; //echo 'c';
4393 4393
                                     }
4394 4394
 
4395 4395
                                     // if pass
@@ -4398,67 +4398,67 @@  discard block
 block discarded – undo
4398 4398
                                         $final_missing <= $threadhold3 &&
4399 4399
                                         $final_excess <= $threadhold2
4400 4400
                                     ) {
4401
-                                        $next=1; //go to the oars
4402
-                                        $result_comment=get_lang('Acceptable');
4403
-                                        $final_answer = 1;	// do not update with  update_exercise_attempt
4401
+                                        $next = 1; //go to the oars
4402
+                                        $result_comment = get_lang('Acceptable');
4403
+                                        $final_answer = 1; // do not update with  update_exercise_attempt
4404 4404
                                     } else {
4405
-                                        $next=0;
4406
-                                        $result_comment=get_lang('Unacceptable');
4407
-                                        $comment=$answerDestination=$objAnswerTmp->selectComment(1);
4408
-                                        $answerDestination=$objAnswerTmp->selectDestination(1);
4405
+                                        $next = 0;
4406
+                                        $result_comment = get_lang('Unacceptable');
4407
+                                        $comment = $answerDestination = $objAnswerTmp->selectComment(1);
4408
+                                        $answerDestination = $objAnswerTmp->selectDestination(1);
4409 4409
                                         //checking the destination parameters parsing the "@@"
4410
-                                        $destination_items= explode('@@', $answerDestination);
4410
+                                        $destination_items = explode('@@', $answerDestination);
4411 4411
                                     }
4412
-                                } elseif($answerId>1) {
4412
+                                } elseif ($answerId > 1) {
4413 4413
                                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
4414
-                                        if ($debug>0) {
4415
-                                            error_log(__LINE__.' - answerId is of type noerror',0);
4414
+                                        if ($debug > 0) {
4415
+                                            error_log(__LINE__.' - answerId is of type noerror', 0);
4416 4416
                                         }
4417 4417
                                         //type no error shouldn't be treated
4418 4418
                                         $next = 1;
4419 4419
                                         continue;
4420 4420
                                     }
4421
-                                    if ($debug>0) {
4422
-                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);
4421
+                                    if ($debug > 0) {
4422
+                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
4423 4423
                                     }
4424 4424
                                     //check the intersection between the oar and the user
4425 4425
                                     //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
4426 4426
                                     //echo 'official';print_r($x_list);print_r($y_list);
4427 4427
                                     //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
4428
-                                    $inter= $result['success'];
4428
+                                    $inter = $result['success'];
4429 4429
 
4430 4430
                                     //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
4431
-                                    $delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
4431
+                                    $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId);
4432 4432
 
4433
-                                    $poly_answer = convert_coordinates($delineation_cord,'|');
4434
-                                    $max_coord = poly_get_max($poly_user,$poly_answer);
4435
-                                    $poly_answer_compiled = poly_compile($poly_answer,$max_coord);
4436
-                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
4433
+                                    $poly_answer = convert_coordinates($delineation_cord, '|');
4434
+                                    $max_coord = poly_get_max($poly_user, $poly_answer);
4435
+                                    $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
4436
+                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
4437 4437
 
4438 4438
                                     if ($overlap == false) {
4439 4439
                                         //all good, no overlap
4440 4440
                                         $next = 1;
4441 4441
                                         continue;
4442 4442
                                     } else {
4443
-                                        if ($debug>0) {
4444
-                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);
4443
+                                        if ($debug > 0) {
4444
+                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0);
4445 4445
                                         }
4446 4446
                                         $organs_at_risk_hit++;
4447 4447
                                         //show the feedback
4448
-                                        $next=0;
4449
-                                        $comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
4450
-                                        $answerDestination=$objAnswerTmp->selectDestination($answerId);
4451
-
4452
-                                        $destination_items= explode('@@', $answerDestination);
4453
-                                        $try_hotspot=$destination_items[1];
4454
-                                        $lp_hotspot=$destination_items[2];
4455
-                                        $select_question_hotspot=$destination_items[3];
4456
-                                        $url_hotspot=$destination_items[4];
4448
+                                        $next = 0;
4449
+                                        $comment = $answerDestination = $objAnswerTmp->selectComment($answerId);
4450
+                                        $answerDestination = $objAnswerTmp->selectDestination($answerId);
4451
+
4452
+                                        $destination_items = explode('@@', $answerDestination);
4453
+                                        $try_hotspot = $destination_items[1];
4454
+                                        $lp_hotspot = $destination_items[2];
4455
+                                        $select_question_hotspot = $destination_items[3];
4456
+                                        $url_hotspot = $destination_items[4];
4457 4457
                                     }
4458 4458
                                 }
4459 4459
                             } else {	// the first delineation feedback
4460
-                                if ($debug>0) {
4461
-                                    error_log(__LINE__.' first',0);
4460
+                                if ($debug > 0) {
4461
+                                    error_log(__LINE__.' first', 0);
4462 4462
                                 }
4463 4463
                             }
4464 4464
                         } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
@@ -4466,7 +4466,7 @@  discard block
 block discarded – undo
4466 4466
                             echo Display::tag('td', $answerMatching[$answerId]);
4467 4467
                             echo Display::tag(
4468 4468
                                 'td',
4469
-                                "$user_answer / " . Display::tag(
4469
+                                "$user_answer / ".Display::tag(
4470 4470
                                     'strong',
4471 4471
                                     $answerMatching[$answerCorrect],
4472 4472
                                     ['style' => 'color: #008000; font-weight: bold;']
@@ -4618,7 +4618,7 @@  discard block
 block discarded – undo
4618 4618
                                     $questionId,
4619 4619
                                     $objQuestionTmp->getFileUrl(),
4620 4620
                                     $results_disabled
4621
-                                ) . '</td>
4621
+                                ).'</td>
4622 4622
                                 </tr>
4623 4623
                                 </table>';
4624 4624
                             break;
@@ -4680,7 +4680,7 @@  discard block
 block discarded – undo
4680 4680
 
4681 4681
                                 //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
4682 4682
                                 if ($debug > 0) {
4683
-                                    error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0);
4683
+                                    error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0);
4684 4684
                                 }
4685 4685
                                 if ($overlap < 1) {
4686 4686
                                     //shortcut to avoid complicated calculations
@@ -4691,17 +4691,17 @@  discard block
 block discarded – undo
4691 4691
                                     // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
4692 4692
                                     $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
4693 4693
                                     if ($debug > 1) {
4694
-                                        error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
4694
+                                        error_log(__LINE__.' - Final overlap is '.$final_overlap, 0);
4695 4695
                                     }
4696 4696
                                     // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
4697 4697
                                     $final_missing = 100 - $final_overlap;
4698 4698
                                     if ($debug > 1) {
4699
-                                        error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
4699
+                                        error_log(__LINE__.' - Final missing is '.$final_missing, 0);
4700 4700
                                     }
4701 4701
                                     // 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
4702 4702
                                     $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
4703 4703
                                     if ($debug > 1) {
4704
-                                        error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0);
4704
+                                        error_log(__LINE__.' - Final excess is '.$final_excess, 0);
4705 4705
                                     }
4706 4706
                                 }
4707 4707
 
@@ -4711,7 +4711,7 @@  discard block
 block discarded – undo
4711 4711
                                 $threadhold_items = explode(';', $threadhold_total);
4712 4712
                                 $threadhold1 = $threadhold_items[0]; // overlap
4713 4713
                                 $threadhold2 = $threadhold_items[1]; // excess
4714
-                                $threadhold3 = $threadhold_items[2];  //missing
4714
+                                $threadhold3 = $threadhold_items[2]; //missing
4715 4715
                                 // if is delineation
4716 4716
                                 if ($answerId === 1) {
4717 4717
                                     //setting colors
@@ -4743,14 +4743,14 @@  discard block
 block discarded – undo
4743 4743
                                 } elseif ($answerId > 1) {
4744 4744
                                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
4745 4745
                                         if ($debug > 0) {
4746
-                                            error_log(__LINE__ . ' - answerId is of type noerror', 0);
4746
+                                            error_log(__LINE__.' - answerId is of type noerror', 0);
4747 4747
                                         }
4748 4748
                                         //type no error shouldn't be treated
4749 4749
                                         $next = 1;
4750 4750
                                         continue;
4751 4751
                                     }
4752 4752
                                     if ($debug > 0) {
4753
-                                        error_log(__LINE__ . ' - answerId is >1 so we\'re probably in OAR', 0);
4753
+                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
4754 4754
                                     }
4755 4755
                                     //check the intersection between the oar and the user
4756 4756
                                     //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
@@ -4764,7 +4764,7 @@  discard block
 block discarded – undo
4764 4764
                                     $poly_answer = convert_coordinates($delineation_cord, '|');
4765 4765
                                     $max_coord = poly_get_max($poly_user, $poly_answer);
4766 4766
                                     $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
4767
-                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
4767
+                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
4768 4768
 
4769 4769
                                     if ($overlap == false) {
4770 4770
                                         //all good, no overlap
@@ -4772,7 +4772,7 @@  discard block
 block discarded – undo
4772 4772
                                         continue;
4773 4773
                                     } else {
4774 4774
                                         if ($debug > 0) {
4775
-                                            error_log(__LINE__ . ' - Overlap is ' . $overlap . ': OAR hit', 0);
4775
+                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0);
4776 4776
                                         }
4777 4777
                                         $organs_at_risk_hit++;
4778 4778
                                         //show the feedback
@@ -4784,12 +4784,12 @@  discard block
 block discarded – undo
4784 4784
                                         $try_hotspot = $destination_items[1];
4785 4785
                                         $lp_hotspot = $destination_items[2];
4786 4786
                                         $select_question_hotspot = $destination_items[3];
4787
-                                        $url_hotspot=$destination_items[4];
4787
+                                        $url_hotspot = $destination_items[4];
4788 4788
                                     }
4789 4789
                                 }
4790 4790
                             } else {	// the first delineation feedback
4791 4791
                                 if ($debug > 0) {
4792
-                                    error_log(__LINE__ . ' first', 0);
4792
+                                    error_log(__LINE__.' first', 0);
4793 4793
                                 }
4794 4794
                             }
4795 4795
                             break;
@@ -4811,7 +4811,7 @@  discard block
 block discarded – undo
4811 4811
                             echo Display::tag('td', $answerMatching[$answerId]);
4812 4812
                             echo Display::tag(
4813 4813
                                 'td',
4814
-                                "$user_answer / " . Display::tag(
4814
+                                "$user_answer / ".Display::tag(
4815 4815
                                     'strong',
4816 4816
                                     $answerMatching[$answerCorrect],
4817 4817
                                     ['style' => 'color: #008000; font-weight: bold;']
@@ -4897,7 +4897,7 @@  discard block
 block discarded – undo
4897 4897
             //  we use the results from the session (from_db=0)
4898 4898
             // TODO Change this, because it is wrong to show the user
4899 4899
             //  some results that haven't been stored in the database yet
4900
-            if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) {
4900
+            if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION) {
4901 4901
 
4902 4902
                 if ($debug) error_log('$from AND this is a hotspot kind of question ');
4903 4903
 
@@ -4906,19 +4906,19 @@  discard block
 block discarded – undo
4906 4906
                 if ($answerType == HOT_SPOT_DELINEATION) {
4907 4907
                     if (0) {
4908 4908
                         if ($overlap_color) {
4909
-                            $overlap_color='green';
4909
+                            $overlap_color = 'green';
4910 4910
                         } else {
4911
-                            $overlap_color='red';
4911
+                            $overlap_color = 'red';
4912 4912
                         }
4913 4913
                         if ($missing_color) {
4914
-                            $missing_color='green';
4914
+                            $missing_color = 'green';
4915 4915
                         } else {
4916
-                            $missing_color='red';
4916
+                            $missing_color = 'red';
4917 4917
                         }
4918 4918
                         if ($excess_color) {
4919
-                            $excess_color='green';
4919
+                            $excess_color = 'green';
4920 4920
                         } else {
4921
-                            $excess_color='red';
4921
+                            $excess_color = 'red';
4922 4922
                         }
4923 4923
                         if (!is_numeric($final_overlap)) {
4924 4924
                             $final_overlap = 0;
@@ -4930,33 +4930,33 @@  discard block
 block discarded – undo
4930 4930
                             $final_excess = 0;
4931 4931
                         }
4932 4932
 
4933
-                        if ($final_overlap>100) {
4933
+                        if ($final_overlap > 100) {
4934 4934
                             $final_overlap = 100;
4935 4935
                         }
4936 4936
 
4937
-                        $table_resume='<table class="data_table">
4937
+                        $table_resume = '<table class="data_table">
4938 4938
                                 <tr class="row_odd" >
4939 4939
                                     <td></td>
4940
-                                    <td ><b>' . get_lang('Requirements') . '</b></td>
4941
-                                    <td><b>' . get_lang('YourAnswer') . '</b></td>
4940
+                                    <td ><b>' . get_lang('Requirements').'</b></td>
4941
+                                    <td><b>' . get_lang('YourAnswer').'</b></td>
4942 4942
                                 </tr>
4943 4943
                                 <tr class="row_even">
4944
-                                    <td><b>' . get_lang('Overlap') . '</b></td>
4945
-                                    <td>' . get_lang('Min') . ' ' . $threadhold1 . '</td>
4946
-                                    <td><div style="color:' . $overlap_color . '">'
4947
-                                        . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '</div></td>
4944
+                                    <td><b>' . get_lang('Overlap').'</b></td>
4945
+                                    <td>' . get_lang('Min').' '.$threadhold1.'</td>
4946
+                                    <td><div style="color:' . $overlap_color.'">'
4947
+                                        . (($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td>
4948 4948
                                 </tr>
4949 4949
                                 <tr>
4950
-                                    <td><b>' . get_lang('Excess') . '</b></td>
4951
-                                    <td>' . get_lang('Max') . ' ' . $threadhold2 . '</td>
4952
-                                    <td><div style="color:' . $excess_color . '">'
4953
-                                        . (($final_excess < 0) ? 0 : intval($final_excess)) . '</div></td>
4950
+                                    <td><b>' . get_lang('Excess').'</b></td>
4951
+                                    <td>' . get_lang('Max').' '.$threadhold2.'</td>
4952
+                                    <td><div style="color:' . $excess_color.'">'
4953
+                                        . (($final_excess < 0) ? 0 : intval($final_excess)).'</div></td>
4954 4954
                                 </tr>
4955 4955
                                 <tr class="row_even">
4956
-                                    <td><b>' . get_lang('Missing') . '</b></td>
4957
-                                    <td>' . get_lang('Max') . ' ' . $threadhold3 . '</td>
4958
-                                    <td><div style="color:' . $missing_color . '">'
4959
-                                        . (($final_missing < 0) ? 0 : intval($final_missing)) . '</div></td>
4956
+                                    <td><b>' . get_lang('Missing').'</b></td>
4957
+                                    <td>' . get_lang('Max').' '.$threadhold3.'</td>
4958
+                                    <td><div style="color:' . $missing_color.'">'
4959
+                                        . (($final_missing < 0) ? 0 : intval($final_missing)).'</div></td>
4960 4960
                                 </tr>
4961 4961
                             </table>';
4962 4962
                         if ($next == 0) {
@@ -4971,20 +4971,20 @@  discard block
 block discarded – undo
4971 4971
                             $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
4972 4972
                         }
4973 4973
 
4974
-                        echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1>
4974
+                        echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>
4975 4975
                             <p style="text-align:center">';
4976 4976
 
4977
-                        $message = '<p>' . get_lang('YourDelineation') . '</p>';
4977
+                        $message = '<p>'.get_lang('YourDelineation').'</p>';
4978 4978
                         $message .= $table_resume;
4979
-                        $message .= '<br />' . get_lang('ResultIs') . ' ' . $result_comment . '<br />';
4979
+                        $message .= '<br />'.get_lang('ResultIs').' '.$result_comment.'<br />';
4980 4980
                         if ($organs_at_risk_hit > 0) {
4981
-                            $message .= '<p><b>' . get_lang('OARHit') . '</b></p>';
4981
+                            $message .= '<p><b>'.get_lang('OARHit').'</b></p>';
4982 4982
                         }
4983
-                        $message .='<p>' . $comment . '</p>';
4983
+                        $message .= '<p>'.$comment.'</p>';
4984 4984
                         echo $message;
4985 4985
                     } else {
4986 4986
                         echo $hotspot_delineation_result[0]; //prints message
4987
-                        $from_database = 1;  // the hotspot_solution.swf needs this variable
4987
+                        $from_database = 1; // the hotspot_solution.swf needs this variable
4988 4988
                     }
4989 4989
 
4990 4990
                     //save the score attempts
@@ -5007,12 +5007,12 @@  discard block
 block discarded – undo
5007 5007
                             $exerciseResultCoordinates[$quesId]
5008 5008
                         );
5009 5009
                     } else {
5010
-                        if ($final_answer==0) {
5010
+                        if ($final_answer == 0) {
5011 5011
                             $questionScore = 0;
5012
-                            $answer=0;
5012
+                            $answer = 0;
5013 5013
                             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
5014 5014
                             if (is_array($exerciseResultCoordinates[$quesId])) {
5015
-                                foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
5015
+                                foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
5016 5016
                                     Event::saveExerciseAttemptHotspot(
5017 5017
                                         $exeId,
5018 5018
                                         $quesId,
@@ -5025,7 +5025,7 @@  discard block
 block discarded – undo
5025 5025
                         } else {
5026 5026
                             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
5027 5027
                             if (is_array($exerciseResultCoordinates[$quesId])) {
5028
-                                foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
5028
+                                foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
5029 5029
                                     $hotspotValue = (int) $choice[$idx] === 1 ? 1 : 0;
5030 5030
                                     Event::saveExerciseAttemptHotspot(
5031 5031
                                         $exeId,
@@ -5052,7 +5052,7 @@  discard block
 block discarded – undo
5052 5052
                     echo "
5053 5053
                         <tr>
5054 5054
                             <td colspan=\"2\">
5055
-                                <p><em>" . get_lang('HotSpot') . "</em></p>
5055
+                                <p><em>" . get_lang('HotSpot')."</em></p>
5056 5056
                                 <div id=\"hotspot-solution-$questionId\"></div>
5057 5057
                                 <script>
5058 5058
                                     $(document).on('ready', function () {
@@ -5087,7 +5087,7 @@  discard block
 block discarded – undo
5087 5087
 
5088 5088
         if ($saved_results) {
5089 5089
             if ($debug) error_log("Save question results $saved_results");
5090
-            if ($debug) error_log(print_r($choice ,1 ));
5090
+            if ($debug) error_log(print_r($choice, 1));
5091 5091
 
5092 5092
             if (empty($choice)) {
5093 5093
                 $choice = 0;
@@ -5099,14 +5099,14 @@  discard block
 block discarded – undo
5099 5099
                         $ans = $reply[$i];
5100 5100
                         Event::saveQuestionAttempt(
5101 5101
                             $questionScore,
5102
-                            $ans . ':' . $choice[$ans],
5102
+                            $ans.':'.$choice[$ans],
5103 5103
                             $quesId,
5104 5104
                             $exeId,
5105 5105
                             $i,
5106 5106
                             $this->id
5107 5107
                         );
5108 5108
                         if ($debug) {
5109
-                            error_log('result =>' . $questionScore . ' ' . $ans . ':' . $choice[$ans]);
5109
+                            error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]);
5110 5110
                         }
5111 5111
                     }
5112 5112
                 } else {
@@ -5117,7 +5117,7 @@  discard block
 block discarded – undo
5117 5117
                     $reply = array_keys($choice);
5118 5118
 
5119 5119
                     if ($debug) {
5120
-                        error_log("reply " . print_r($reply, 1) . "");
5120
+                        error_log("reply ".print_r($reply, 1)."");
5121 5121
                     }
5122 5122
                     for ($i = 0; $i < sizeof($reply); $i++) {
5123 5123
                         $ans = $reply[$i];
@@ -5192,7 +5192,7 @@  discard block
 block discarded – undo
5192 5192
 
5193 5193
                 Event::saveQuestionAttempt($questionScore, implode('|', $answer), $quesId, $exeId, 0, $this->id);
5194 5194
             } else {
5195
-                Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0,$this->id);
5195
+                Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
5196 5196
             }
5197 5197
         }
5198 5198
 
@@ -5202,8 +5202,8 @@  discard block
 block discarded – undo
5202 5202
 
5203 5203
         if ($saved_results) {
5204 5204
             $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5205
-            $sql = 'UPDATE ' . $stat_table . ' SET
5206
-                        exe_result = exe_result + ' . floatval($questionScore) . '
5205
+            $sql = 'UPDATE '.$stat_table.' SET
5206
+                        exe_result = exe_result + ' . floatval($questionScore).'
5207 5207
                     WHERE exe_id = ' . $exeId;
5208 5208
             Database::query($sql);
5209 5209
         }
@@ -5227,7 +5227,7 @@  discard block
 block discarded – undo
5227 5227
      */
5228 5228
     public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id)
5229 5229
     {
5230
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5230
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5231 5231
             return null;
5232 5232
         }
5233 5233
         // Email configuration settings
@@ -5278,7 +5278,7 @@  discard block
 block discarded – undo
5278 5278
         $msg = str_replace("#course#", $courseInfo['name'], $msg1);
5279 5279
 
5280 5280
         if ($origin != 'learnpath') {
5281
-            $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5281
+            $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5282 5282
         }
5283 5283
         $msg1 = str_replace("#url#", $url_email, $msg);
5284 5284
         $mail_content = $msg1;
@@ -5308,7 +5308,7 @@  discard block
 block discarded – undo
5308 5308
      */
5309 5309
     function send_notification_for_open_questions($question_list_answers, $origin, $exe_id)
5310 5310
     {
5311
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5311
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5312 5312
             return null;
5313 5313
         }
5314 5314
         // Email configuration settings
@@ -5371,11 +5371,11 @@  discard block
 block discarded – undo
5371 5371
             $msg .= '</table><br />';
5372 5372
 
5373 5373
 
5374
-            $msg1   = str_replace("#exercise#",    $this->exercise, $msg);
5375
-            $msg    = str_replace("#firstName#",   $user_info['firstname'],$msg1);
5376
-            $msg1   = str_replace("#lastName#",    $user_info['lastname'],$msg);
5377
-            $msg    = str_replace("#mail#",        $user_info['email'],$msg1);
5378
-            $msg    = str_replace("#course#",      $course_info['name'],$msg1);
5374
+            $msg1   = str_replace("#exercise#", $this->exercise, $msg);
5375
+            $msg    = str_replace("#firstName#", $user_info['firstname'], $msg1);
5376
+            $msg1   = str_replace("#lastName#", $user_info['lastname'], $msg);
5377
+            $msg    = str_replace("#mail#", $user_info['email'], $msg1);
5378
+            $msg    = str_replace("#course#", $course_info['name'], $msg1);
5379 5379
 
5380 5380
             if ($origin != 'learnpath') {
5381 5381
                 $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
@@ -5404,7 +5404,7 @@  discard block
 block discarded – undo
5404 5404
 
5405 5405
     function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id)
5406 5406
     {
5407
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5407
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5408 5408
             return null;
5409 5409
         }
5410 5410
         // Email configuration settings
@@ -5428,7 +5428,7 @@  discard block
 block discarded – undo
5428 5428
             $answer_type = $item['answer_type'];
5429 5429
 
5430 5430
             if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) {
5431
-                $oral_question_list.='<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">'
5431
+                $oral_question_list .= '<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">'
5432 5432
                     .'<tr>'
5433 5433
                         .'<td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Question').'</td>'
5434 5434
                         .'<td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>'
@@ -5461,7 +5461,7 @@  discard block
 block discarded – undo
5461 5461
                             .'<td>&nbsp;#mail#</td>'
5462 5462
                         .'</tr>'
5463 5463
                     .'</table>';
5464
-            $msg .=  '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'),$oral_question_list).'<br />';
5464
+            $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'), $oral_question_list).'<br />';
5465 5465
             $msg1 = str_replace("#exercise#", $this->exercise, $msg);
5466 5466
             $msg = str_replace("#firstName#", $user_info['firstname'], $msg1);
5467 5467
             $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg);
@@ -5469,7 +5469,7 @@  discard block
 block discarded – undo
5469 5469
             $msg = str_replace("#course#", $course_info['name'], $msg1);
5470 5470
 
5471 5471
             if ($origin != 'learnpath') {
5472
-                $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5472
+                $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5473 5473
             }
5474 5474
             $msg1 = str_replace("#url#", $url_email, $msg);
5475 5475
             $mail_content = $msg1;
@@ -5535,10 +5535,10 @@  discard block
 block discarded – undo
5535 5535
         }
5536 5536
         $html  = '<div class="question-result">';
5537 5537
         $html .= Display::page_header(
5538
-            Display::return_icon('test-quiz.png', get_lang('Result'),null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result')
5538
+            Display::return_icon('test-quiz.png', get_lang('Result'), null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result')
5539 5539
         );
5540 5540
         $html .= Display::description($array);
5541
-        $html .="</div>";
5541
+        $html .= "</div>";
5542 5542
         return $html;
5543 5543
     }
5544 5544
 
@@ -5655,7 +5655,7 @@  discard block
 block discarded – undo
5655 5655
                     false,
5656 5656
                     $objExercise->selectPropagateNeg()
5657 5657
                 );
5658
-                $totalScore      += $question_result['score'];
5658
+                $totalScore += $question_result['score'];
5659 5659
             }
5660 5660
 
5661 5661
             if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) {
@@ -5859,7 +5859,7 @@  discard block
 block discarded – undo
5859 5859
         }
5860 5860
 
5861 5861
         $rawMessage = "";
5862
-        if (!empty($message)){
5862
+        if (!empty($message)) {
5863 5863
             $rawMessage = $message;
5864 5864
             $message = Display::return_message($message, 'warning', false);
5865 5865
         }
@@ -5875,7 +5875,7 @@  discard block
 block discarded – undo
5875 5875
     {
5876 5876
         $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
5877 5877
         $sql = "SELECT max_score FROM $TBL_LP_ITEM
5878
-            WHERE c_id = {$this->course_id} AND item_type = '" . TOOL_QUIZ . "' AND path = '{$this->id}'";
5878
+            WHERE c_id = {$this->course_id} AND item_type = '".TOOL_QUIZ."' AND path = '{$this->id}'";
5879 5879
         $result = Database::query($sql);
5880 5880
         if (Database::num_rows($result) > 0) {
5881 5881
             return true;
@@ -6204,7 +6204,7 @@  discard block
 block discarded – undo
6204 6204
         $sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id ";
6205 6205
         $result = Database::query($sql_track);
6206 6206
         $new_array = array();
6207
-        if (Database::num_rows($result) > 0 ) {
6207
+        if (Database::num_rows($result) > 0) {
6208 6208
             $new_array = Database::fetch_array($result, 'ASSOC');
6209 6209
 
6210 6210
             $new_array['duration'] = null;
@@ -6216,11 +6216,11 @@  discard block
 block discarded – undo
6216 6216
                 $start_date = api_strtotime($start_date, 'UTC');
6217 6217
                 $end_date = api_strtotime($end_date, 'UTC');
6218 6218
                 if ($start_date && $end_date) {
6219
-                    $mytime = $end_date- $start_date;
6219
+                    $mytime = $end_date - $start_date;
6220 6220
                     $new_learnpath_item = new learnpathItem(null);
6221 6221
                     $time_attemp = $new_learnpath_item->get_scorm_time('js', $mytime);
6222 6222
                     $h = get_lang('h');
6223
-                    $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
6223
+                    $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp);
6224 6224
                     $new_array['duration'] = $time_attemp;
6225 6225
                 }
6226 6226
             }
@@ -6242,7 +6242,7 @@  discard block
 block discarded – undo
6242 6242
                     Database::query($sql);
6243 6243
                 }
6244 6244
             } else {
6245
-                $remind_list = explode(',',$exercise_info['questions_to_check']);
6245
+                $remind_list = explode(',', $exercise_info['questions_to_check']);
6246 6246
 
6247 6247
                 $remind_list_string = '';
6248 6248
                 if ($action == 'add') {
@@ -6254,7 +6254,7 @@  discard block
 block discarded – undo
6254 6254
                         }
6255 6255
                         $remind_list_string = implode(',', $remind_list);
6256 6256
                     }
6257
-                } elseif ($action == 'delete')  {
6257
+                } elseif ($action == 'delete') {
6258 6258
                     if (!empty($remind_list)) {
6259 6259
                         if (in_array($question_id, $remind_list)) {
6260 6260
                             $remind_list = array_flip($remind_list);
@@ -6483,7 +6483,7 @@  discard block
 block discarded – undo
6483 6483
                     true
6484 6484
                 );
6485 6485
 
6486
-                $counter += count($mediaQuestions[$questionId]) - 1 ;
6486
+                $counter += count($mediaQuestions[$questionId]) - 1;
6487 6487
                 $before = count($questionList);
6488 6488
                 $wasMedia = true;
6489 6489
                 $nextValue += count($questionList);
@@ -6562,7 +6562,7 @@  discard block
 block discarded – undo
6562 6562
                         // If it was already seen, then merge the previous with
6563 6563
                         // the current category
6564 6564
                         $oldQuestionList = $newCategoryList[$rootElement]['question_list'];
6565
-                        $category['question_list'] = array_merge($oldQuestionList , $category['question_list']);
6565
+                        $category['question_list'] = array_merge($oldQuestionList, $category['question_list']);
6566 6566
                         $newCategoryList[$rootElement] = $category;
6567 6567
                     }
6568 6568
                 }
@@ -6588,7 +6588,7 @@  discard block
 block discarded – undo
6588 6588
 
6589 6589
                 if ($useRootAsCategoryTitle) {
6590 6590
                     if (isset($category['parent_info'])) {
6591
-                        $categoryName  = $category['parent_info']['title'];
6591
+                        $categoryName = $category['parent_info']['title'];
6592 6592
                     }
6593 6593
                 }
6594 6594
                 $html .= '<div class="row">';
@@ -6731,7 +6731,7 @@  discard block
 block discarded – undo
6731 6731
         // end foreach()
6732 6732
 
6733 6733
         if ($this->type == ALL_ON_ONE_PAGE) {
6734
-            $exercise_actions =  $this->show_button($questionId, $currentQuestion);
6734
+            $exercise_actions = $this->show_button($questionId, $currentQuestion);
6735 6735
             echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
6736 6736
         }
6737 6737
     }
@@ -6817,7 +6817,7 @@  discard block
 block discarded – undo
6817 6817
 
6818 6818
             // Showing the question
6819 6819
 
6820
-            $exercise_actions  = null;
6820
+            $exercise_actions = null;
6821 6821
 
6822 6822
             echo '<a id="questionanchor'.$questionId.'"></a><br />';
6823 6823
             echo '<div id="question_div_'.$questionId.'" class="main_question '.$remind_highlight.'" >';
@@ -7093,7 +7093,7 @@  discard block
 block discarded – undo
7093 7093
                         $header .= Display::tag('th', get_lang('Feedback'));
7094 7094
                     }
7095 7095
                     $s .= '<table class="data_table">';
7096
-                    $s.= Display::tag('tr', $header, array('style' => 'text-align:left;'));
7096
+                    $s .= Display::tag('tr', $header, array('style' => 'text-align:left;'));
7097 7097
                 }
7098 7098
             }
7099 7099
 
@@ -7193,7 +7193,7 @@  discard block
 block discarded – undo
7193 7193
                             $s .= '<td>';
7194 7194
                             $s .= $comment;
7195 7195
                             $s .= '</td>';
7196
-                            $s .='</tr>';
7196
+                            $s .= '</tr>';
7197 7197
                         } else {
7198 7198
                             $s .= $answer_input;
7199 7199
                         }
@@ -7207,7 +7207,7 @@  discard block
 block discarded – undo
7207 7207
                             }
7208 7208
                         }
7209 7209
 
7210
-                        $s .='<tr>';
7210
+                        $s .= '<tr>';
7211 7211
                         $s .= Display::tag('td', $answer);
7212 7212
 
7213 7213
                         if (!empty($quiz_question_options)) {
@@ -7234,7 +7234,7 @@  discard block
 block discarded – undo
7234 7234
                             $s .= $comment;
7235 7235
                             $s .= '</td>';
7236 7236
                         }
7237
-                        $s.='</tr>';
7237
+                        $s .= '</tr>';
7238 7238
                     }
7239 7239
 
7240 7240
                 } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
@@ -7263,16 +7263,16 @@  discard block
 block discarded – undo
7263 7263
                     $answer_input .= '</label>';
7264 7264
 
7265 7265
                     if ($show_comment) {
7266
-                        $s.= '<tr>';
7266
+                        $s .= '<tr>';
7267 7267
                         $s .= '<td>';
7268
-                        $s.= $answer_input;
7268
+                        $s .= $answer_input;
7269 7269
                         $s .= '</td>';
7270 7270
                         $s .= '<td>';
7271 7271
                         $s .= $comment;
7272 7272
                         $s .= '</td>';
7273
-                        $s.= '</tr>';
7273
+                        $s .= '</tr>';
7274 7274
                     } else {
7275
-                        $s.= $answer_input;
7275
+                        $s .= $answer_input;
7276 7276
                     }
7277 7277
                 } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
7278 7278
                     $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
@@ -7285,7 +7285,7 @@  discard block
 block discarded – undo
7285 7285
                         }
7286 7286
                     }
7287 7287
                     $answer = Security::remove_XSS($answer);
7288
-                    $s .='<tr>';
7288
+                    $s .= '<tr>';
7289 7289
                     $s .= Display::tag('td', $answer);
7290 7290
 
7291 7291
                     foreach ($objQuestionTmp->options as $key => $item) {
@@ -7309,7 +7309,7 @@  discard block
 block discarded – undo
7309 7309
                         $s .= $comment;
7310 7310
                         $s .= '</td>';
7311 7311
                     }
7312
-                    $s.='</tr>';
7312
+                    $s .= '</tr>';
7313 7313
                 } elseif ($answerType == FILL_IN_BLANKS) {
7314 7314
                     list($answer) = explode('::', $answer);
7315 7315
 
@@ -7343,7 +7343,7 @@  discard block
 block discarded – undo
7343 7343
                                     $value = str_replace('&nbsp;', '', trim($value[0]));
7344 7344
                                 }
7345 7345
                                 $correct_item = preg_quote($correct_item);
7346
-                                $correct_item = api_preg_replace('|/|', '\/', $correct_item);   // to prevent error if there is a / in the text to find
7346
+                                $correct_item = api_preg_replace('|/|', '\/', $correct_item); // to prevent error if there is a / in the text to find
7347 7347
                                 $answer = api_preg_replace('/'.$correct_item.'/', Display::input('text', "choice[$questionId][]", $value), $answer, 1);
7348 7348
                             }
7349 7349
                             $i++;
@@ -7400,7 +7400,7 @@  discard block
 block discarded – undo
7400 7400
                         }
7401 7401
 
7402 7402
                         if (!empty($answerCorrect) && !empty($selectedValue)) {
7403
-                            $s.= '<script>
7403
+                            $s .= '<script>
7404 7404
                                 jsPlumb.ready(function() {
7405 7405
                                     jsPlumb.connect({
7406 7406
                                         source: "window_'.$windowId.'",
@@ -7415,14 +7415,14 @@  discard block
 block discarded – undo
7415 7415
                         }
7416 7416
                         $s .= '</select></div></td>';
7417 7417
 
7418
-                        $s.='<td width="45%" valign="top" >';
7418
+                        $s .= '<td width="45%" valign="top" >';
7419 7419
 
7420 7420
                         if (isset($select_items[$lines_count])) {
7421
-                            $s.= '<div id="window_'.$windowId.'_answer" class="window window_right_question">
7421
+                            $s .= '<div id="window_'.$windowId.'_answer" class="window window_right_question">
7422 7422
                                     <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].'
7423 7423
                                   </div>';
7424 7424
                         } else {
7425
-                            $s.='&nbsp;';
7425
+                            $s .= '&nbsp;';
7426 7426
                         }
7427 7427
 
7428 7428
                         $s .= '</td>';
@@ -7436,16 +7436,16 @@  discard block
 block discarded – undo
7436 7436
                                 $s .= '<tr>
7437 7437
                                       <td colspan="2"></td>
7438 7438
                                       <td valign="top">';
7439
-                                $s.='<b>'.$select_items[$lines_count]['letter'].'.</b>';
7439
+                                $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b>';
7440 7440
                                 $s .= $select_items[$lines_count]['answer'];
7441
-                                $s.="</td>
7441
+                                $s .= "</td>
7442 7442
                                 </tr>";
7443 7443
                                 $lines_count++;
7444 7444
                             } // end while()
7445 7445
                         }  // end if()
7446 7446
                         $matching_correct_answer++;
7447 7447
                     }
7448
-                } elseif ($answerType ==  DRAGGABLE) {
7448
+                } elseif ($answerType == DRAGGABLE) {
7449 7449
                     // matching type, showing suggestions and answers
7450 7450
                     // TODO: replace $answerId by $numAnswer
7451 7451
 
@@ -7487,7 +7487,7 @@  discard block
 block discarded – undo
7487 7487
                         $s .= '</select>';
7488 7488
 
7489 7489
                         if (!empty($answerCorrect) && !empty($selectedValue)) {
7490
-                            $s.= '<script>
7490
+                            $s .= '<script>
7491 7491
                                 $(function() {
7492 7492
                                     deleteItem($("#'.$questionId.'_'.$selectedValue.'"), $("#drop_'.$windowId.'"));
7493 7493
                                 });
@@ -7495,11 +7495,11 @@  discard block
 block discarded – undo
7495 7495
                         }
7496 7496
 
7497 7497
                         if (isset($select_items[$lines_count])) {
7498
-                            $s.= '<div id="window_'.$windowId.'_answer" class="">
7498
+                            $s .= '<div id="window_'.$windowId.'_answer" class="">
7499 7499
                                     <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].'
7500 7500
                                   </div>';
7501 7501
                         } else {
7502
-                            $s.='&nbsp;';
7502
+                            $s .= '&nbsp;';
7503 7503
                         }
7504 7504
                         $lines_count++;
7505 7505
                         //if the left side of the "matching" has been completely
@@ -7508,7 +7508,7 @@  discard block
 block discarded – undo
7508 7508
                         if (($lines_count - 1) == $num_suggestions) {
7509 7509
                             // if it remains answers to shown at the right side
7510 7510
                             while (isset($select_items[$lines_count])) {
7511
-                                $s.='<b>'.$select_items[$lines_count]['letter'].'.</b>';
7511
+                                $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b>';
7512 7512
                                 $s .= $select_items[$lines_count]['answer'];
7513 7513
                                 $lines_count++;
7514 7514
                             }
@@ -7611,9 +7611,9 @@  discard block
 block discarded – undo
7611 7611
 
7612 7612
             if (!$only_questions) {
7613 7613
                 if ($show_title) {
7614
-                    $html .=  TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id);
7615
-                    $html .=  '<div class="question_title">'.$current_item.'. '.$questionName.'</div>';
7616
-                    $html .=  $questionDescription;
7614
+                    $html .= TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id);
7615
+                    $html .= '<div class="question_title">'.$current_item.'. '.$questionName.'</div>';
7616
+                    $html .= $questionDescription;
7617 7617
                 } else {
7618 7618
                     $html .= '<div class="media">';
7619 7619
                     $html .= '<div class="pull-left">';
@@ -7629,11 +7629,11 @@  discard block
 block discarded – undo
7629 7629
                     $html .= '</div>';
7630 7630
                 }
7631 7631
                 //@todo I need to the get the feedback type
7632
-                $html .=  '<input type="hidden" name="hidden_hotspot_id" value="'.$questionId.'" />';
7633
-                $html .=  '<table class="exercise_questions">
7632
+                $html .= '<input type="hidden" name="hidden_hotspot_id" value="'.$questionId.'" />';
7633
+                $html .= '<table class="exercise_questions">
7634 7634
                            <tr>
7635 7635
                             <td valign="top" colspan="2">';
7636
-                $html .=  '</td></tr>';
7636
+                $html .= '</td></tr>';
7637 7637
             }
7638 7638
 
7639 7639
             $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
Please login to merge, or discard this patch.
main/exercise/export/qti2/qti2_classes.php 4 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -72,6 +72,7 @@  discard block
 block discarded – undo
72 72
     /**
73 73
      * Return the XML flow for the possible answers.
74 74
      *
75
+     * @param string $questionStatment
75 76
      */
76 77
     public function imsExportResponses($questionIdent, $questionStatment)
77 78
     {
@@ -147,6 +148,7 @@  discard block
 block discarded – undo
147 148
      * Export the text with missing words.
148 149
      *
149 150
      *
151
+     * @param string $questionStatment
150 152
      */
151 153
     public function imsExportResponses($questionIdent, $questionStatment)
152 154
     {
@@ -204,6 +206,7 @@  discard block
 block discarded – undo
204 206
 {
205 207
     /**
206 208
      * Export the question part as a matrix-choice, with only one possible answer per line.
209
+     * @param string $questionStatment
207 210
      */
208 211
     public function imsExportResponses($questionIdent, $questionStatment)
209 212
     {
@@ -295,6 +298,7 @@  discard block
 block discarded – undo
295 298
     /**
296 299
      * TODO update this to match hot spots instead of copying matching
297 300
      * Export the question part as a matrix-choice, with only one possible answer per line.
301
+     * @param string $questionStatment
298 302
      */
299 303
     public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
300 304
     {
@@ -382,6 +386,7 @@  discard block
 block discarded – undo
382 386
     /**
383 387
      * TODO implement
384 388
      * Export the question part as a matrix-choice, with only one possible answer per line.
389
+     * @param string $questionStatment
385 390
      */
386 391
     public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
387 392
 	{
Please login to merge, or discard this patch.
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 
56 56
     function createAnswersForm($form)
57 57
     {
58
-    	return true;
58
+        return true;
59 59
     }
60 60
 
61 61
     function processAnswersCreation($form)
62 62
     {
63
-    	return true;
63
+        return true;
64 64
     }
65 65
 }
66 66
 /**
@@ -76,21 +76,21 @@  discard block
 block discarded – undo
76 76
     public function imsExportResponses($questionIdent, $questionStatment)
77 77
     {
78 78
         // @todo getAnswersList() converts the answers using api_html_entity_decode()
79
-		$this->answerList = $this->getAnswersList(true);
79
+        $this->answerList = $this->getAnswersList(true);
80 80
         $out  = '    <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n";
81 81
         $out .= '      <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n";
82
-		if (is_array($this->answerList)) {
83
-	        foreach ($this->answerList as $current_answer) {
84
-	            $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false">
82
+        if (is_array($this->answerList)) {
83
+            foreach ($this->answerList as $current_answer) {
84
+                $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false">
85 85
                          <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>';
86
-	            if (isset($current_answer['comment']) && $current_answer['comment'] != '') {
87
-	                $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '">
86
+                if (isset($current_answer['comment']) && $current_answer['comment'] != '') {
87
+                    $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '">
88 88
 	                         <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]>
89 89
 	                         </feedbackInline>';
90
-	            }
91
-	            $out .= '</simpleChoice>'. "\n";
92
-	        }
93
-		}
90
+                }
91
+                $out .= '</simpleChoice>'. "\n";
92
+            }
93
+        }
94 94
         $out .= '    </choiceInteraction>'. "\n";
95 95
 
96 96
         return $out;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function imsExportResponsesDeclaration($questionIdent)
104 104
     {
105
-		$this->answerList = $this->getAnswersList(true);
106
-		$type = $this->getQuestionType();
105
+        $this->answerList = $this->getAnswersList(true);
106
+        $type = $this->getQuestionType();
107 107
         if ($type == MCMA)  $cardinality = 'multiple'; else $cardinality = 'single';
108 108
 
109 109
         $out = '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n";
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
         // Match the correct answers.
112 112
 
113 113
         $out .= '    <correctResponse>'. "\n";
114
-		if (is_array($this->answerList)) {
115
-	        foreach($this->answerList as $current_answer) {
116
-	            if ($current_answer['correct']) {
117
-	                $out .= '      <value>answer_'. $current_answer['id'] .'</value>'. "\n";
118
-	            }
119
-	        }
120
-		}
114
+        if (is_array($this->answerList)) {
115
+            foreach($this->answerList as $current_answer) {
116
+                if ($current_answer['correct']) {
117
+                    $out .= '      <value>answer_'. $current_answer['id'] .'</value>'. "\n";
118
+                }
119
+            }
120
+        }
121 121
         $out .= '    </correctResponse>'. "\n";
122 122
 
123 123
         //Add the grading
124 124
 
125 125
         $out .= '    <mapping>'. "\n";
126
-		if (is_array($this->answerList)) {
127
-	        foreach($this->answerList as $current_answer) {
128
-	            if (isset($current_answer['grade'])) {
129
-	                $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n";
130
-	            }
131
-	        }
132
-		}
126
+        if (is_array($this->answerList)) {
127
+            foreach($this->answerList as $current_answer) {
128
+                if (isset($current_answer['grade'])) {
129
+                    $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n";
130
+                }
131
+            }
132
+        }
133 133
         $out .= '    </mapping>'. "\n";
134 134
         $out .= '  </responseDeclaration>'. "\n";
135 135
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function imsExportResponses($questionIdent, $questionStatment)
152 152
     {
153
-		$this->answerList = $this->getAnswersList(true);
153
+        $this->answerList = $this->getAnswersList(true);
154 154
         $text = '';
155 155
         $text .= $this->answerText;
156 156
         if (is_array($this->answerList)) {
@@ -171,28 +171,28 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public function imsExportResponsesDeclaration($questionIdent)
173 173
     {
174
-		$this->answerList = $this->getAnswersList(true);
175
-		$this->gradeList = $this->getGradesList();
174
+        $this->answerList = $this->getAnswersList(true);
175
+        $this->gradeList = $this->getGradesList();
176 176
         $out = '';
177
-		if (is_array($this->answerList)) {
178
-	        foreach ($this->answerList as $answer) {
179
-	        	$answerKey = $answer['id'];
180
-	        	$answer = $answer['answer'];
181
-	            $out .= '  <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n";
182
-	            $out .= '    <correctResponse>'. "\n";
177
+        if (is_array($this->answerList)) {
178
+            foreach ($this->answerList as $answer) {
179
+                $answerKey = $answer['id'];
180
+                $answer = $answer['answer'];
181
+                $out .= '  <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n";
182
+                $out .= '    <correctResponse>'. "\n";
183 183
                 $out .= '      <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n";
184
-	            $out .= '    </correctResponse>'. "\n";
185
-	            if (isset($this->gradeList[$answerKey])) {
186
-	                $out .= '    <mapping>'. "\n";
187
-	                $out .= '      <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n";
188
-	                $out .= '    </mapping>'. "\n";
189
-	            }
190
-
191
-	            $out .= '  </responseDeclaration>'. "\n";
192
-	        }
193
-		}
194
-
195
-       return $out;
184
+                $out .= '    </correctResponse>'. "\n";
185
+                if (isset($this->gradeList[$answerKey])) {
186
+                    $out .= '    <mapping>'. "\n";
187
+                    $out .= '      <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n";
188
+                    $out .= '    </mapping>'. "\n";
189
+                }
190
+
191
+                $out .= '  </responseDeclaration>'. "\n";
192
+            }
193
+        }
194
+
195
+        return $out;
196 196
     }
197 197
 }
198 198
 
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public function imsExportResponses($questionIdent, $questionStatment)
209 209
     {
210
-		$this->answerList = $this->getAnswersList(true);
211
-		$maxAssociation = max(count($this->leftList), count($this->rightList));
210
+        $this->answerList = $this->getAnswersList(true);
211
+        $maxAssociation = max(count($this->leftList), count($this->rightList));
212 212
 
213 213
         $out = "";
214 214
 
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
         //add left column
219 219
 
220 220
         $out .= '  <simpleMatchSet>'. "\n";
221
-		if (is_array($this->leftList)) {
222
-	        foreach ($this->leftList as $leftKey=>$leftElement) {
223
-	            $out .= '
221
+        if (is_array($this->leftList)) {
222
+            foreach ($this->leftList as $leftKey=>$leftElement) {
223
+                $out .= '
224 224
 	            <simpleAssociableChoice identifier="left_'.$leftKey.'" >
225 225
 	                <![CDATA['.formatExerciseQtiTitle($leftElement['answer']).']]>
226 226
 	            </simpleAssociableChoice>'. "\n";
227
-	        }
228
-    	}
227
+            }
228
+        }
229 229
 
230 230
         $out .= '  </simpleMatchSet>'. "\n";
231 231
 
@@ -235,14 +235,14 @@  discard block
 block discarded – undo
235 235
 
236 236
         $i = 0;
237 237
 
238
-		if (is_array($this->rightList)) {
239
-	        foreach($this->rightList as $rightKey=>$rightElement) {
240
-	            $out .= '<simpleAssociableChoice identifier="right_'.$i.'" >
238
+        if (is_array($this->rightList)) {
239
+            foreach($this->rightList as $rightKey=>$rightElement) {
240
+                $out .= '<simpleAssociableChoice identifier="right_'.$i.'" >
241 241
 	                    <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]>
242 242
 	                    </simpleAssociableChoice>'. "\n";
243
-	            $i++;
244
-	        }
245
-		}
243
+                $i++;
244
+            }
245
+        }
246 246
         $out .= '  </simpleMatchSet>'. "\n";
247 247
         $out .= '</matchInteraction>'. "\n";
248 248
 
@@ -254,30 +254,30 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function imsExportResponsesDeclaration($questionIdent)
256 256
     {
257
-		$this->answerList = $this->getAnswersList(true);
257
+        $this->answerList = $this->getAnswersList(true);
258 258
         $out =  '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n";
259 259
         $out .= '    <correctResponse>' . "\n";
260 260
 
261 261
         $gradeArray = array();
262
-		if (is_array($this->leftList)) {
263
-	        foreach ($this->leftList as $leftKey=>$leftElement) {
264
-	            $i=0;
265
-	            foreach ($this->rightList as $rightKey=>$rightElement) {
266
-	                if (($leftElement['match'] == $rightElement['code'])) {
267
-	                    $out .= '      <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n";
268
-
269
-	                    $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade'];
270
-	                }
271
-	                $i++;
272
-	            }
273
-	        }
274
-		}
262
+        if (is_array($this->leftList)) {
263
+            foreach ($this->leftList as $leftKey=>$leftElement) {
264
+                $i=0;
265
+                foreach ($this->rightList as $rightKey=>$rightElement) {
266
+                    if (($leftElement['match'] == $rightElement['code'])) {
267
+                        $out .= '      <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n";
268
+
269
+                        $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade'];
270
+                    }
271
+                    $i++;
272
+                }
273
+            }
274
+        }
275 275
         $out .= '    </correctResponse>'. "\n";
276 276
         $out .= '    <mapping>' . "\n";
277 277
         if (is_array($gradeArray)) {
278
-	        foreach ($gradeArray as $gradeKey=>$grade) {
279
-	            $out .= '          <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n";
280
-	        }
278
+            foreach ($gradeArray as $gradeKey=>$grade) {
279
+                $out .= '          <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n";
280
+            }
281 281
         }
282 282
         $out .= '    </mapping>' . "\n";
283 283
         $out .= '  </responseDeclaration>'. "\n";
@@ -298,49 +298,49 @@  discard block
 block discarded – undo
298 298
      */
299 299
     public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
300 300
     {
301
-		$this->answerList = $this->getAnswersList(true);
302
-		$questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia;
303
-		$mimetype = mime_content_type($questionMedia);
304
-		if(empty($mimetype)){
305
-			$mimetype = 'image/jpeg';
306
-		}
307
-
308
-		$text = '      <p>'.$questionStatment.'</p>'."\n";
309
-		$text .= '      <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n";
310
-		$text .= '        <prompt>'.$questionDesc.'</prompt>'."\n";
311
-		$text .= '        <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n";
301
+        $this->answerList = $this->getAnswersList(true);
302
+        $questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia;
303
+        $mimetype = mime_content_type($questionMedia);
304
+        if(empty($mimetype)){
305
+            $mimetype = 'image/jpeg';
306
+        }
307
+
308
+        $text = '      <p>'.$questionStatment.'</p>'."\n";
309
+        $text .= '      <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n";
310
+        $text .= '        <prompt>'.$questionDesc.'</prompt>'."\n";
311
+        $text .= '        <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n";
312 312
         if (is_array($this->answerList)) {
313
-	        foreach ($this->answerList as $key=>$answer) {
314
-	        	$key = $answer['id'];
315
-	        	$answerTxt = $answer['answer'];
316
-	        	$len = api_strlen($answerTxt);
317
-	        	//coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
318
-	        	$coords = '';
319
-	        	$type = 'default';
320
-	        	switch($answer['hotspot_type']){
321
-	        		case 'square':
322
-	        			$type = 'rect';
323
-						$res = array();
324
-						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
325
-						$coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]);
326
-	        			break;
327
-	        		case 'circle':
328
-	        			$type = 'circle';
329
-			 			$res = array();
330
-						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
331
-						$coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4])));
332
-	        			break;
333
-	        		case 'poly':
334
-	        			$type = 'poly';
335
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
336
-	        			break;
337
-	        		 case 'delineation' :
338
-	        			$type = 'delineation';
339
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
340
-	        			break;
341
-	        	}
342
-	            $text .= '        <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";
343
-	        }
313
+            foreach ($this->answerList as $key=>$answer) {
314
+                $key = $answer['id'];
315
+                $answerTxt = $answer['answer'];
316
+                $len = api_strlen($answerTxt);
317
+                //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
318
+                $coords = '';
319
+                $type = 'default';
320
+                switch($answer['hotspot_type']){
321
+                    case 'square':
322
+                        $type = 'rect';
323
+                        $res = array();
324
+                        $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
325
+                        $coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]);
326
+                        break;
327
+                    case 'circle':
328
+                        $type = 'circle';
329
+                            $res = array();
330
+                        $coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
331
+                        $coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4])));
332
+                        break;
333
+                    case 'poly':
334
+                        $type = 'poly';
335
+                        $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
336
+                        break;
337
+                        case 'delineation' :
338
+                        $type = 'delineation';
339
+                        $coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
340
+                        break;
341
+                }
342
+                $text .= '        <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";
343
+            }
344 344
         }
345 345
         $text .= '      </graphicOrderInteraction>'."\n";
346 346
         $out = $text;
@@ -353,23 +353,23 @@  discard block
 block discarded – undo
353 353
      */
354 354
     public function imsExportResponsesDeclaration($questionIdent)
355 355
     {
356
-		$this->answerList = $this->getAnswersList(true);
357
-		$this->gradeList = $this->getGradesList();
356
+        $this->answerList = $this->getAnswersList(true);
357
+        $this->gradeList = $this->getGradesList();
358 358
         $out = '';
359 359
         $out .= '  <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n";
360 360
         $out .= '    <correctResponse>'. "\n";
361 361
 
362
-		if (is_array($this->answerList)) {
363
-	        foreach ($this->answerList as $answerKey=>$answer)  {
364
-	        	$answerKey = $answer['id'];
365
-	        	$answer = $answer['answer'];
366
-	            $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>';
367
-	        }
368
-		}
362
+        if (is_array($this->answerList)) {
363
+            foreach ($this->answerList as $answerKey=>$answer)  {
364
+                $answerKey = $answer['id'];
365
+                $answer = $answer['answer'];
366
+                $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>';
367
+            }
368
+        }
369 369
         $out .= '    </correctResponse>'. "\n";
370 370
         $out .= '  </responseDeclaration>'. "\n";
371 371
 
372
-       return $out;
372
+        return $out;
373 373
     }
374 374
 }
375 375
 
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
      * Export the question part as a matrix-choice, with only one possible answer per line.
385 385
      */
386 386
     public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
387
-	{
388
-		return '';
389
-	}
387
+    {
388
+        return '';
389
+    }
390 390
     /**
391 391
      *
392 392
      */
393 393
     public function imsExportResponsesDeclaration($questionIdent)
394 394
     {
395
-    	return '';
395
+        return '';
396 396
     }
397 397
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      */
15 15
     public function setAnswer()
16 16
     {
17
-        switch($this->type) {
17
+        switch ($this->type) {
18 18
             case MCUA:
19 19
                 $answer = new ImsAnswerMultipleChoice($this->id);
20 20
 
@@ -77,21 +77,21 @@  discard block
 block discarded – undo
77 77
     {
78 78
         // @todo getAnswersList() converts the answers using api_html_entity_decode()
79 79
 		$this->answerList = $this->getAnswersList(true);
80
-        $out  = '    <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n";
81
-        $out .= '      <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment) . ']]></prompt>'. "\n";
80
+        $out  = '    <choiceInteraction responseIdentifier="'.$questionIdent.'" >'."\n";
81
+        $out .= '      <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment).']]></prompt>'."\n";
82 82
 		if (is_array($this->answerList)) {
83 83
 	        foreach ($this->answerList as $current_answer) {
84
-	            $out .= '<simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false">
84
+	            $out .= '<simpleChoice identifier="answer_'.$current_answer['id'].'" fixed="false">
85 85
                          <![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>';
86 86
 	            if (isset($current_answer['comment']) && $current_answer['comment'] != '') {
87
-	                $out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '">
87
+	                $out .= '<feedbackInline identifier="answer_'.$current_answer['id'].'">
88 88
 	                         <![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]>
89 89
 	                         </feedbackInline>';
90 90
 	            }
91
-	            $out .= '</simpleChoice>'. "\n";
91
+	            $out .= '</simpleChoice>'."\n";
92 92
 	        }
93 93
 		}
94
-        $out .= '    </choiceInteraction>'. "\n";
94
+        $out .= '    </choiceInteraction>'."\n";
95 95
 
96 96
         return $out;
97 97
     }
@@ -106,32 +106,32 @@  discard block
 block discarded – undo
106 106
 		$type = $this->getQuestionType();
107 107
         if ($type == MCMA)  $cardinality = 'multiple'; else $cardinality = 'single';
108 108
 
109
-        $out = '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n";
109
+        $out = '  <responseDeclaration identifier="'.$questionIdent.'" cardinality="'.$cardinality.'" baseType="identifier">'."\n";
110 110
 
111 111
         // Match the correct answers.
112 112
 
113
-        $out .= '    <correctResponse>'. "\n";
113
+        $out .= '    <correctResponse>'."\n";
114 114
 		if (is_array($this->answerList)) {
115
-	        foreach($this->answerList as $current_answer) {
115
+	        foreach ($this->answerList as $current_answer) {
116 116
 	            if ($current_answer['correct']) {
117
-	                $out .= '      <value>answer_'. $current_answer['id'] .'</value>'. "\n";
117
+	                $out .= '      <value>answer_'.$current_answer['id'].'</value>'."\n";
118 118
 	            }
119 119
 	        }
120 120
 		}
121
-        $out .= '    </correctResponse>'. "\n";
121
+        $out .= '    </correctResponse>'."\n";
122 122
 
123 123
         //Add the grading
124 124
 
125
-        $out .= '    <mapping>'. "\n";
125
+        $out .= '    <mapping>'."\n";
126 126
 		if (is_array($this->answerList)) {
127
-	        foreach($this->answerList as $current_answer) {
127
+	        foreach ($this->answerList as $current_answer) {
128 128
 	            if (isset($current_answer['grade'])) {
129
-	                $out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n";
129
+	                $out .= ' <mapEntry mapKey="answer_'.$current_answer['id'].'" mappedValue="'.$current_answer['grade'].'" />'."\n";
130 130
 	            }
131 131
 	        }
132 132
 		}
133
-        $out .= '    </mapping>'. "\n";
134
-        $out .= '  </responseDeclaration>'. "\n";
133
+        $out .= '    </mapping>'."\n";
134
+        $out .= '  </responseDeclaration>'."\n";
135 135
 
136 136
         return $out;
137 137
     }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
                 $key = $answer['id'];
159 159
                 $answer = $answer['answer'];
160 160
                 $len = api_strlen($answer);
161
-                $text = str_replace('['.$answer.']','<textEntryInteraction responseIdentifier="fill_'.$key.'" expectedLength="'.api_strlen($answer).'"/>', $text);
161
+                $text = str_replace('['.$answer.']', '<textEntryInteraction responseIdentifier="fill_'.$key.'" expectedLength="'.api_strlen($answer).'"/>', $text);
162 162
             }
163 163
         }
164 164
         $out = $text;
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
 	        foreach ($this->answerList as $answer) {
179 179
 	        	$answerKey = $answer['id'];
180 180
 	        	$answer = $answer['answer'];
181
-	            $out .= '  <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n";
182
-	            $out .= '    <correctResponse>'. "\n";
183
-                $out .= '      <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'. "\n";
184
-	            $out .= '    </correctResponse>'. "\n";
181
+	            $out .= '  <responseDeclaration identifier="fill_'.$answerKey.'" cardinality="single" baseType="identifier">'."\n";
182
+	            $out .= '    <correctResponse>'."\n";
183
+                $out .= '      <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'."\n";
184
+	            $out .= '    </correctResponse>'."\n";
185 185
 	            if (isset($this->gradeList[$answerKey])) {
186
-	                $out .= '    <mapping>'. "\n";
187
-	                $out .= '      <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n";
188
-	                $out .= '    </mapping>'. "\n";
186
+	                $out .= '    <mapping>'."\n";
187
+	                $out .= '      <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'."\n";
188
+	                $out .= '    </mapping>'."\n";
189 189
 	            }
190 190
 
191
-	            $out .= '  </responseDeclaration>'. "\n";
191
+	            $out .= '  </responseDeclaration>'."\n";
192 192
 	        }
193 193
 		}
194 194
 
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
 
213 213
         $out = "";
214 214
 
215
-        $out .= '<matchInteraction responseIdentifier="' . $questionIdent . '" maxAssociations="'. $maxAssociation .'">'. "\n";
215
+        $out .= '<matchInteraction responseIdentifier="'.$questionIdent.'" maxAssociations="'.$maxAssociation.'">'."\n";
216 216
         $out .= $questionStatment;
217 217
 
218 218
         //add left column
219 219
 
220
-        $out .= '  <simpleMatchSet>'. "\n";
220
+        $out .= '  <simpleMatchSet>'."\n";
221 221
 		if (is_array($this->leftList)) {
222 222
 	        foreach ($this->leftList as $leftKey=>$leftElement) {
223 223
 	            $out .= '
@@ -227,24 +227,24 @@  discard block
 block discarded – undo
227 227
 	        }
228 228
     	}
229 229
 
230
-        $out .= '  </simpleMatchSet>'. "\n";
230
+        $out .= '  </simpleMatchSet>'."\n";
231 231
 
232 232
         //add right column
233 233
 
234
-        $out .= '  <simpleMatchSet>'. "\n";
234
+        $out .= '  <simpleMatchSet>'."\n";
235 235
 
236 236
         $i = 0;
237 237
 
238 238
 		if (is_array($this->rightList)) {
239
-	        foreach($this->rightList as $rightKey=>$rightElement) {
239
+	        foreach ($this->rightList as $rightKey=>$rightElement) {
240 240
 	            $out .= '<simpleAssociableChoice identifier="right_'.$i.'" >
241 241
 	                    <![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]>
242 242
 	                    </simpleAssociableChoice>'. "\n";
243 243
 	            $i++;
244 244
 	        }
245 245
 		}
246
-        $out .= '  </simpleMatchSet>'. "\n";
247
-        $out .= '</matchInteraction>'. "\n";
246
+        $out .= '  </simpleMatchSet>'."\n";
247
+        $out .= '</matchInteraction>'."\n";
248 248
 
249 249
         return $out;
250 250
     }
@@ -255,32 +255,32 @@  discard block
 block discarded – undo
255 255
     public function imsExportResponsesDeclaration($questionIdent)
256 256
     {
257 257
 		$this->answerList = $this->getAnswersList(true);
258
-        $out =  '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="single" baseType="identifier">' . "\n";
259
-        $out .= '    <correctResponse>' . "\n";
258
+        $out = '  <responseDeclaration identifier="'.$questionIdent.'" cardinality="single" baseType="identifier">'."\n";
259
+        $out .= '    <correctResponse>'."\n";
260 260
 
261 261
         $gradeArray = array();
262 262
 		if (is_array($this->leftList)) {
263 263
 	        foreach ($this->leftList as $leftKey=>$leftElement) {
264
-	            $i=0;
264
+	            $i = 0;
265 265
 	            foreach ($this->rightList as $rightKey=>$rightElement) {
266 266
 	                if (($leftElement['match'] == $rightElement['code'])) {
267
-	                    $out .= '      <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n";
267
+	                    $out .= '      <value>left_'.$leftKey.' right_'.$i.'</value>'."\n";
268 268
 
269
-	                    $gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade'];
269
+	                    $gradeArray['left_'.$leftKey.' right_'.$i] = $leftElement['grade'];
270 270
 	                }
271 271
 	                $i++;
272 272
 	            }
273 273
 	        }
274 274
 		}
275
-        $out .= '    </correctResponse>'. "\n";
276
-        $out .= '    <mapping>' . "\n";
275
+        $out .= '    </correctResponse>'."\n";
276
+        $out .= '    <mapping>'."\n";
277 277
         if (is_array($gradeArray)) {
278 278
 	        foreach ($gradeArray as $gradeKey=>$grade) {
279
-	            $out .= '          <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n";
279
+	            $out .= '          <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>'."\n";
280 280
 	        }
281 281
         }
282
-        $out .= '    </mapping>' . "\n";
283
-        $out .= '  </responseDeclaration>'. "\n";
282
+        $out .= '    </mapping>'."\n";
283
+        $out .= '  </responseDeclaration>'."\n";
284 284
 
285 285
         return $out;
286 286
     }
@@ -296,12 +296,12 @@  discard block
 block discarded – undo
296 296
      * TODO update this to match hot spots instead of copying matching
297 297
      * Export the question part as a matrix-choice, with only one possible answer per line.
298 298
      */
299
-    public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
299
+    public function imsExportResponses($questionIdent, $questionStatment, $questionDesc = '', $questionMedia = '')
300 300
     {
301 301
 		$this->answerList = $this->getAnswersList(true);
302 302
 		$questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia;
303 303
 		$mimetype = mime_content_type($questionMedia);
304
-		if(empty($mimetype)){
304
+		if (empty($mimetype)) {
305 305
 			$mimetype = 'image/jpeg';
306 306
 		}
307 307
 
@@ -317,26 +317,26 @@  discard block
 block discarded – undo
317 317
 	        	//coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
318 318
 	        	$coords = '';
319 319
 	        	$type = 'default';
320
-	        	switch($answer['hotspot_type']){
320
+	        	switch ($answer['hotspot_type']) {
321 321
 	        		case 'square':
322 322
 	        			$type = 'rect';
323 323
 						$res = array();
324
-						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
325
-						$coords = $res[1].','.$res[2].','.((int)$res[1]+(int)$res[3]).",".((int)$res[2]+(int)$res[4]);
324
+						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res);
325
+						$coords = $res[1].','.$res[2].','.((int) $res[1] + (int) $res[3]).",".((int) $res[2] + (int) $res[4]);
326 326
 	        			break;
327 327
 	        		case 'circle':
328 328
 	        			$type = 'circle';
329 329
 			 			$res = array();
330
-						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/',$answer['hotspot_coord'],$res);
331
-						$coords = $res[1].','.$res[2].','.sqrt(pow(($res[1]-$res[3]),2)+pow(($res[2]-$res[4])));
330
+						$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res);
331
+						$coords = $res[1].','.$res[2].','.sqrt(pow(($res[1] - $res[3]), 2) + pow(($res[2] - $res[4])));
332 332
 	        			break;
333 333
 	        		case 'poly':
334 334
 	        			$type = 'poly';
335
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
335
+						$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
336 336
 	        			break;
337 337
 	        		 case 'delineation' :
338 338
 	        			$type = 'delineation';
339
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
339
+						$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
340 340
 	        			break;
341 341
 	        	}
342 342
 	            $text .= '        <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";
@@ -356,18 +356,18 @@  discard block
 block discarded – undo
356 356
 		$this->answerList = $this->getAnswersList(true);
357 357
 		$this->gradeList = $this->getGradesList();
358 358
         $out = '';
359
-        $out .= '  <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">' . "\n";
360
-        $out .= '    <correctResponse>'. "\n";
359
+        $out .= '  <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">'."\n";
360
+        $out .= '    <correctResponse>'."\n";
361 361
 
362 362
 		if (is_array($this->answerList)) {
363
-	        foreach ($this->answerList as $answerKey=>$answer)  {
363
+	        foreach ($this->answerList as $answerKey=>$answer) {
364 364
 	        	$answerKey = $answer['id'];
365 365
 	        	$answer = $answer['answer'];
366 366
 	            $out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>';
367 367
 	        }
368 368
 		}
369
-        $out .= '    </correctResponse>'. "\n";
370
-        $out .= '  </responseDeclaration>'. "\n";
369
+        $out .= '    </correctResponse>'."\n";
370
+        $out .= '  </responseDeclaration>'."\n";
371 371
 
372 372
        return $out;
373 373
     }
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      * TODO implement
384 384
      * Export the question part as a matrix-choice, with only one possible answer per line.
385 385
      */
386
-    public function imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='')
386
+    public function imsExportResponses($questionIdent, $questionStatment, $questionDesc = '', $questionMedia = '')
387 387
 	{
388 388
 		return '';
389 389
 	}
Please login to merge, or discard this patch.
Braces   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,11 @@
 block discarded – undo
104 104
     {
105 105
 		$this->answerList = $this->getAnswersList(true);
106 106
 		$type = $this->getQuestionType();
107
-        if ($type == MCMA)  $cardinality = 'multiple'; else $cardinality = 'single';
107
+        if ($type == MCMA) {
108
+            $cardinality = 'multiple';
109
+        } else {
110
+            $cardinality = 'single';
111
+        }
108 112
 
109 113
         $out = '  <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n";
110 114
 
Please login to merge, or discard this patch.
main/exercise/hotpotatoes.lib.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
  * @param    reference    Reference to the array to search
260 260
  * @param    string       Node we are looking for in the array
261 261
  * @param string $node
262
- * @return   mixed        Node name or false if not found
262
+ * @return   false|string        Node name or false if not found
263 263
  */
264 264
 function myarraysearch(&$array, $node)
265 265
 {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
  * Searches an image name into an array.
281 281
  * @param    reference        Reference to an array to search
282 282
  * @param    string           String to look for
283
- * @return   mixed            String given if found, false otherwise
283
+ * @return   false|string            String given if found, false otherwise
284 284
  * @uses     myarraysearch    This function is just an additional layer on the myarraysearch() function
285 285
  */
286 286
 function CheckImageName(&$imgparams, $string)
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -344,7 +344,7 @@
 block discarded – undo
344 344
                     if (is_dir($full_name)) {
345 345
                         $filelist[] = $file;
346 346
                     }
347
-               }
347
+                }
348 348
             }
349 349
         }
350 350
     }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     if ($title == '') {
67 67
         $title = basename($fname);
68 68
     }
69
-    return (string)$title;
69
+    return (string) $title;
70 70
 }
71 71
 
72 72
 /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         if ($src == '') {
177 177
             return '';
178 178
         } else {
179
-            $tmp_src = basename($src) ;
179
+            $tmp_src = basename($src);
180 180
             if ($tmp_src == '') {
181 181
                 return $src;
182 182
             } else {
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 {
199 199
     // Select src tag from img tag.
200 200
     $match = array();
201
-    preg_match("|(src=\".*\" )|U", $imgtag, $match);            //src
201
+    preg_match("|(src=\".*\" )|U", $imgtag, $match); //src
202 202
     list($key, $srctag) = each($match);
203 203
     $src = substr($srctag, 5, (strlen($srctag) - 7));
204 204
     if (stristr($src, 'http') === false) {
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
         while (list($key, $imgtag) = each($match)) {
231 231
             $imgname = GetImgName($imgtag);
232 232
             if ($imgname != '' && !in_array($imgname, $imgparams)) {
233
-                array_push($imgparams, $imgname);    // name (+ type) of the images in the html test
234
-                $imgcount = $imgcount + 1;            // number of images in the html test
233
+                array_push($imgparams, $imgname); // name (+ type) of the images in the html test
234
+                $imgcount = $imgcount + 1; // number of images in the html test
235 235
             }
236 236
         }
237 237
     }
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
                 if ($file != '..') {
405 405
                     $full_name = $folder.'/'.$file;
406 406
                     if (is_dir($full_name)) {
407
-                        $dflag = 1;    // first directory
407
+                        $dflag = 1; // first directory
408 408
                     }
409 409
                 }
410 410
             }
Please login to merge, or discard this patch.
main/mySpace/myStudents.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1143,10 +1143,11 @@
 block discarded – undo
1143 1143
                 $result_last_attempt = Database::query($sql);
1144 1144
                 if (Database :: num_rows($result_last_attempt) > 0) {
1145 1145
                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
1146
-                    if ($count_attempts > 0)
1147
-                        echo '<a href="../exercise/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&session_id='.$sessionId.'&student='.$student_id.'&origin='.(empty($origin)?'tracking':$origin).'">
1146
+                    if ($count_attempts > 0) {
1147
+                                            echo '<a href="../exercise/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&session_id='.$sessionId.'&student='.$student_id.'&origin='.(empty($origin)?'tracking':$origin).'">
1148 1148
                         '.Display::return_icon('quiz.gif').'
1149 1149
                      </a>';
1150
+                    }
1150 1151
                 }
1151 1152
                 echo '</td>';
1152 1153
 
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -67,52 +67,52 @@  discard block
 block discarded – undo
67 67
 if (isset($_GET['details'])) {
68 68
     if ($origin === 'user_course') {
69 69
         if (empty ($cidReq)) {
70
-            $interbreadcrumb[] = array (
71
-                "url" => api_get_path(WEB_COURSE_PATH) . $courseInfo['directory'],
70
+            $interbreadcrumb[] = array(
71
+                "url" => api_get_path(WEB_COURSE_PATH).$courseInfo['directory'],
72 72
                 'name' => $courseInfo['title']
73 73
             );
74 74
         }
75
-        $interbreadcrumb[] = array (
76
-            "url" => "../user/user.php?cidReq=" . $course_code,
75
+        $interbreadcrumb[] = array(
76
+            "url" => "../user/user.php?cidReq=".$course_code,
77 77
             "name" => get_lang("Users")
78 78
         );
79 79
     } else
80 80
         if ($origin === 'tracking_course') {
81
-            $interbreadcrumb[] = array (
82
-                "url" => "../tracking/courseLog.php?cidReq=".$course_code.'&id_session=' . api_get_session_id(),
81
+            $interbreadcrumb[] = array(
82
+                "url" => "../tracking/courseLog.php?cidReq=".$course_code.'&id_session='.api_get_session_id(),
83 83
                 "name" => get_lang("Tracking")
84 84
             );
85 85
         } else
86 86
             if ($origin === 'resume_session') {
87
-                $interbreadcrumb[] = array (
87
+                $interbreadcrumb[] = array(
88 88
                     'url' => "../session/session_list.php",
89 89
                     "name" => get_lang('SessionList')
90 90
                 );
91
-                $interbreadcrumb[] = array (
92
-                    'url' => "../session/resume_session.php?id_session=" . $sessionId,
91
+                $interbreadcrumb[] = array(
92
+                    'url' => "../session/resume_session.php?id_session=".$sessionId,
93 93
                     "name" => get_lang('SessionOverview')
94 94
                 );
95 95
             } else {
96
-                $interbreadcrumb[] = array (
97
-                    "url" => api_is_student_boss()?"#":"index.php",
96
+                $interbreadcrumb[] = array(
97
+                    "url" => api_is_student_boss() ? "#" : "index.php",
98 98
                     "name" => get_lang('MySpace')
99 99
                 );
100 100
                 if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
101
-                    $interbreadcrumb[] = array (
102
-                        "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']),
101
+                    $interbreadcrumb[] = array(
102
+                        "url" => "student.php?id_coach=".Security :: remove_XSS($_GET['id_coach']),
103 103
                         "name" => get_lang("CoachStudents")
104 104
                     );
105
-                    $interbreadcrumb[] = array (
106
-                        "url" => "myStudents.php?student=" . $student_id. '&id_coach=' . Security :: remove_XSS($_GET['id_coach']),
105
+                    $interbreadcrumb[] = array(
106
+                        "url" => "myStudents.php?student=".$student_id.'&id_coach='.Security :: remove_XSS($_GET['id_coach']),
107 107
                         "name" => get_lang("StudentDetails")
108 108
                     );
109 109
                 } else {
110
-                    $interbreadcrumb[] = array (
110
+                    $interbreadcrumb[] = array(
111 111
                         "url" => "student.php",
112 112
                         "name" => get_lang("MyStudents")
113 113
                     );
114
-                    $interbreadcrumb[] = array (
115
-                        "url" => "myStudents.php?student=" . $student_id,
114
+                    $interbreadcrumb[] = array(
115
+                        "url" => "myStudents.php?student=".$student_id,
116 116
                         "name" => get_lang("StudentDetails")
117 117
                     );
118 118
                 }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     $nameTools = get_lang("DetailsStudentInCourse");
121 121
 } else {
122 122
     if ($origin == 'resume_session') {
123
-        $interbreadcrumb[] = array (
123
+        $interbreadcrumb[] = array(
124 124
             'url' => "../session/session_list.php",
125 125
             "name" => get_lang('SessionList')
126 126
         );
@@ -131,24 +131,24 @@  discard block
 block discarded – undo
131 131
             );
132 132
         }
133 133
     } else {
134
-        $interbreadcrumb[] = array (
135
-            "url" => api_is_student_boss()?"#":"index.php",
134
+        $interbreadcrumb[] = array(
135
+            "url" => api_is_student_boss() ? "#" : "index.php",
136 136
             "name" => get_lang('MySpace')
137 137
         );
138 138
         if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
139 139
             if ($sessionId) {
140
-                $interbreadcrumb[] = array (
141
-                    "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']) . "&id_session=" . $sessionId,
140
+                $interbreadcrumb[] = array(
141
+                    "url" => "student.php?id_coach=".Security :: remove_XSS($_GET['id_coach'])."&id_session=".$sessionId,
142 142
                     "name" => get_lang("CoachStudents")
143 143
                 );
144 144
             } else {
145
-                $interbreadcrumb[] = array (
146
-                    "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']),
145
+                $interbreadcrumb[] = array(
146
+                    "url" => "student.php?id_coach=".Security :: remove_XSS($_GET['id_coach']),
147 147
                     "name" => get_lang("CoachStudents")
148 148
                 );
149 149
             }
150 150
         } else {
151
-            $interbreadcrumb[] = array (
151
+            $interbreadcrumb[] = array(
152 152
                 "url" => "student.php",
153 153
                 "name" => get_lang("MyStudents")
154 154
             );
@@ -330,28 +330,28 @@  discard block
 block discarded – undo
330 330
     // Actions bar
331 331
     echo '<div class="actions">';
332 332
     echo '<a href="javascript: window.history.go(-1);">'.
333
-            Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
333
+            Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>';
334 334
 
335 335
     echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.
336
-            Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
336
+            Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).'</a>';
337 337
 
338
-    echo '<a href="' . api_get_self() . '?' . Security :: remove_XSS($_SERVER['QUERY_STRING']) . '&export=csv">'.
339
-            Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
338
+    echo '<a href="'.api_get_self().'?'.Security :: remove_XSS($_SERVER['QUERY_STRING']).'&export=csv">'.
339
+            Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a> ';
340 340
 
341
-    echo '<a href="' . api_get_self() . '?' . Security :: remove_XSS($_SERVER['QUERY_STRING']) . '&export=xls">'.
342
-    Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> ';
341
+    echo '<a href="'.api_get_self().'?'.Security :: remove_XSS($_SERVER['QUERY_STRING']).'&export=xls">'.
342
+    Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a> ';
343 343
 
344 344
     if (!empty ($user_info['email'])) {
345 345
         $send_mail = '<a href="mailto:'.$user_info['email'].'">'.
346
-            Display :: return_icon('mail_send.png', get_lang('SendMail'),'',ICON_SIZE_MEDIUM).'</a>';
346
+            Display :: return_icon('mail_send.png', get_lang('SendMail'), '', ICON_SIZE_MEDIUM).'</a>';
347 347
     } else {
348
-        $send_mail = Display :: return_icon('mail_send_na.png', get_lang('SendMail'),'',ICON_SIZE_MEDIUM);
348
+        $send_mail = Display :: return_icon('mail_send_na.png', get_lang('SendMail'), '', ICON_SIZE_MEDIUM);
349 349
     }
350 350
     echo $send_mail;
351 351
     if (!empty($student_id) && !empty($course_code)) {
352 352
         // Only show link to connection details if course and student were defined in the URL
353
-        echo '<a href="access_details.php?student=' . $student_id . '&course=' . $course_code . '&origin=' . $origin. '&cidReq='.$course_code.'&id_session='.$sessionId.'">'.
354
-            Display :: return_icon('statistics.png', get_lang('AccessDetails'),'',ICON_SIZE_MEDIUM).'</a>';
353
+        echo '<a href="access_details.php?student='.$student_id.'&course='.$course_code.'&origin='.$origin.'&cidReq='.$course_code.'&id_session='.$sessionId.'">'.
354
+            Display :: return_icon('statistics.png', get_lang('AccessDetails'), '', ICON_SIZE_MEDIUM).'</a>';
355 355
     }
356 356
     if (api_can_login_as($student_id)) {
357 357
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$student_id.'&sec_token='.$token.'">'.
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 
361 361
     echo Display::url(
362 362
         Display::return_icon('skill-badges.png', get_lang('AssignSkill'), null, ICON_SIZE_MEDIUM),
363
-        api_get_path(WEB_CODE_PATH) . 'badge/assign.php?' . http_build_query(['user' => $student_id])
363
+        api_get_path(WEB_CODE_PATH).'badge/assign.php?'.http_build_query(['user' => $student_id])
364 364
     );
365 365
 
366 366
 
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
     $csv_content[] = array(
422 422
         get_lang('Information', '')
423 423
     );
424
-    $csv_content[] = array (
424
+    $csv_content[] = array(
425 425
         get_lang('Name', ''),
426 426
         get_lang('Email', ''),
427 427
         get_lang('Tel', '')
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
         strip_tags($first_connection_date),
450 450
         strip_tags($last_connection_date),
451 451
         $time_spent_on_the_course,
452
-        $avg_student_progress . '%',
452
+        $avg_student_progress.'%',
453 453
         $avg_student_score
454 454
     );
455 455
 
@@ -479,19 +479,19 @@  discard block
 block discarded – undo
479 479
             </thead>
480 480
             <tbody>
481 481
             <tr>
482
-                <td><?php echo get_lang('Name') . ' : '.$user_info['complete_name']; ?></td>
482
+                <td><?php echo get_lang('Name').' : '.$user_info['complete_name']; ?></td>
483 483
             </tr>
484 484
             <tr>
485
-                <td><?php echo get_lang('Email') . ' : ';
485
+                <td><?php echo get_lang('Email').' : ';
486 486
                     if (!empty ($user_info['email'])) {
487
-                        echo '<a href="mailto:' . $user_info['email'] . '">' . $user_info['email'] . '</a>';
487
+                        echo '<a href="mailto:'.$user_info['email'].'">'.$user_info['email'].'</a>';
488 488
                     } else {
489 489
                         echo get_lang('NoEmail');
490 490
                     } ?>
491 491
                 </td>
492 492
             </tr>
493 493
             <tr>
494
-                <td> <?php echo get_lang('Tel') . ' : ';
494
+                <td> <?php echo get_lang('Tel').' : ';
495 495
                     if (!empty ($user_info['phone'])) {
496 496
                         echo $user_info['phone'];
497 497
                     } else {
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
                 </td>
502 502
             </tr>
503 503
             <tr>
504
-                <td> <?php echo get_lang('OfficialCode') . ' : ';
504
+                <td> <?php echo get_lang('OfficialCode').' : ';
505 505
                     if (!empty ($user_info['official_code'])) {
506 506
                         echo $user_info['official_code'];
507 507
                     } else {
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
                 </td>
512 512
             </tr>
513 513
             <tr>
514
-                <td><?php echo get_lang('OnLine') . ' : '.$online; ?> </td>
514
+                <td><?php echo get_lang('OnLine').' : '.$online; ?> </td>
515 515
             </tr>
516 516
             <?php
517 517
 
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
             if ($timezone !== null) {
526 526
                 ?>
527 527
                 <tr>
528
-                    <td> <?php echo get_lang('Timezone') . ' : '.$timezone; ?> </td>
528
+                    <td> <?php echo get_lang('Timezone').' : '.$timezone; ?> </td>
529 529
                 </tr>
530 530
             <?php
531 531
             }
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
                 }
673 673
 
674 674
                 if (!empty($access_start_date) && !empty($access_end_date)) {
675
-                    $date_session = get_lang('From') . ' ' . $access_start_date . ' ' . get_lang('Until') . ' ' . $access_end_date;
675
+                    $date_session = get_lang('From').' '.$access_start_date.' '.get_lang('Until').' '.$access_end_date;
676 676
                 }
677
-                $title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.($date_session?' ('.$date_session.')':'');
677
+                $title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.($date_session ? ' ('.$date_session.')' : '');
678 678
             }
679 679
 
680 680
             // Courses
@@ -729,16 +729,16 @@  discard block
 block discarded – undo
729 729
                         $scoretotal = array();
730 730
                         if (isset($cats) && isset($cats[0])) {
731 731
                             if (!empty($sId)) {
732
-                                $scoretotal= $cats[0]->calc_score($student_id, null, $courseCodeItem, $sId);
732
+                                $scoretotal = $cats[0]->calc_score($student_id, null, $courseCodeItem, $sId);
733 733
                             } else {
734
-                                $scoretotal= $cats[0]->calc_score($student_id, null, $courseCodeItem);
734
+                                $scoretotal = $cats[0]->calc_score($student_id, null, $courseCodeItem);
735 735
                             }
736 736
                         }
737 737
 
738 738
                         $scoretotal_display = '0/0 (0%)';
739 739
                         if (!empty($scoretotal)) {
740 740
                             $scoretotal_display =
741
-                                round($scoretotal[0], 1 ).'/'.
741
+                                round($scoretotal[0], 1).'/'.
742 742
                                 round($scoretotal[1], 1).
743 743
                                 ' ('.round(($scoretotal[0] / $scoretotal[1]) * 100, 2).' %)';
744 744
                         }
@@ -759,9 +759,9 @@  discard block
 block discarded – undo
759 759
                         );
760 760
 
761 761
                         echo '<tr>
762
-                        <td ><a href="' .$courseInfoItem['course_public_url'] .'?id_session=' . $sId . '">'.
762
+                        <td ><a href="' .$courseInfoItem['course_public_url'].'?id_session='.$sId.'">'.
763 763
                             $courseInfoItem['title'].'</a></td>
764
-                        <td >'.$time_spent_on_course .'</td>
764
+                        <td >'.$time_spent_on_course.'</td>
765 765
                         <td >'.$progress.'</td>
766 766
                         <td >'.$score.'</td>
767 767
                         <td >'.$attendances_faults_avg.'</td>
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
                 <table class="table table-striped table-hover">
830 830
                 <thead>
831 831
                 <tr>
832
-                    <th><?php echo get_lang('LearningPath');?></th>
832
+                    <th><?php echo get_lang('LearningPath'); ?></th>
833 833
                     <th>
834 834
                         <?php
835 835
                         echo get_lang('Time').' ';
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
                     if (!empty($start_time)) {
932 932
                         $start_time = api_convert_and_format_date($start_time, DATE_TIME_FORMAT_LONG);
933 933
                     } else {
934
-                        $start_time =  '-';
934
+                        $start_time = '-';
935 935
                     }
936 936
 
937 937
                     if (!empty($total_time)) {
@@ -968,8 +968,8 @@  discard block
 block discarded – undo
968 968
                     $csv_content[] = array(
969 969
                         api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset),
970 970
                         api_time_to_hms($total_time),
971
-                        $score . '%',
972
-                        $score_latest . '%',
971
+                        $score.'%',
972
+                        $score_latest.'%',
973 973
                         $progress.'%',
974 974
                         $start_time
975 975
                     );
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
                     if ($any_result === true) {
1009 1009
                         $from = '';
1010 1010
                         if ($from_myspace) {
1011
-                            $from ='&from=myspace';
1011
+                            $from = '&from=myspace';
1012 1012
                         }
1013 1013
                         $link = Display::url(
1014 1014
                             Display::return_icon('2rightarrow.png', get_lang('Details')),
@@ -1021,14 +1021,14 @@  discard block
 block discarded – undo
1021 1021
                         echo '<td>';
1022 1022
                         if ($any_result === true) {
1023 1023
                             echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.'&cidReq='.$course_code.'&course='.$course_code.'&details='.Security::remove_XSS($_GET['details']).'&origin='.$origin.'&lp_id='.$learnpath->getId().'&student='.$user_info['user_id'].'&details=true&id_session='.$sessionId.'">';
1024
-                            echo Display::return_icon('clean.png', get_lang('Clean'),'',ICON_SIZE_SMALL).'</a>';
1024
+                            echo Display::return_icon('clean.png', get_lang('Clean'), '', ICON_SIZE_SMALL).'</a>';
1025 1025
                             echo '</a>';
1026 1026
                         }
1027 1027
                         echo '</td>';
1028 1028
                         echo '</tr>';
1029 1029
                     }
1030 1030
                     $data_learnpath[$i][] = $lp_name;
1031
-                    $data_learnpath[$i][] = $progress . '%';
1031
+                    $data_learnpath[$i][] = $progress.'%';
1032 1032
                 }
1033 1033
                 ?>
1034 1034
                 </tbody>
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
         <thead>
1045 1045
         <tr>
1046 1046
             <th><?php echo get_lang('Exercises'); ?></th>
1047
-            <th><?php echo get_lang('LearningPath');?></th>
1047
+            <th><?php echo get_lang('LearningPath'); ?></th>
1048 1048
             <th><?php echo get_lang('AvgCourseScore').' '.Display :: return_icon('info3.gif', get_lang('AverageScore'), array('align' => 'absmiddle', 'hspace' => '3px')) ?></th>
1049 1049
             <th><?php echo get_lang('Attempts'); ?></th>
1050 1050
             <th><?php echo get_lang('LatestAttempt'); ?></th>
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
         );
1064 1064
 
1065 1065
         $t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST);
1066
-        $sql = "SELECT quiz.title, id FROM " . $t_quiz . " AS quiz
1066
+        $sql = "SELECT quiz.title, id FROM ".$t_quiz." AS quiz
1067 1067
                 WHERE
1068 1068
                     quiz.c_id = ".$courseInfo['real_id']." AND
1069 1069
                     (quiz.session_id = $sessionId OR quiz.session_id = 0) AND
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
                 echo '<td>';
1129 1129
 
1130 1130
                 if ($count_attempts > 0) {
1131
-                    echo $score_percentage . '%';
1131
+                    echo $score_percentage.'%';
1132 1132
                 } else {
1133 1133
                     echo '-';
1134 1134
                     $score_percentage = 0;
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
                 echo '<td>'.$count_attempts.'</td>';
1139 1139
                 echo '<td>';
1140 1140
 
1141
-                $sql = 'SELECT exe_id FROM ' . $tbl_stats_exercices . '
1141
+                $sql = 'SELECT exe_id FROM '.$tbl_stats_exercices.'
1142 1142
                          WHERE
1143 1143
                             exe_exo_id = "'.$exercise_id.'" AND
1144 1144
                             exe_user_id ="'.$student_id.'" AND
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
                 if (Database :: num_rows($result_last_attempt) > 0) {
1152 1152
                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
1153 1153
                     if ($count_attempts > 0)
1154
-                        echo '<a href="../exercise/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&session_id='.$sessionId.'&student='.$student_id.'&origin='.(empty($origin)?'tracking':$origin).'">
1154
+                        echo '<a href="../exercise/exercise_show.php?id='.$id_last_attempt.'&cidReq='.$course_code.'&session_id='.$sessionId.'&student='.$student_id.'&origin='.(empty($origin) ? 'tracking' : $origin).'">
1155 1155
                         '.Display::return_icon('quiz.gif').'
1156 1156
                      </a>';
1157 1157
                 }
@@ -1159,11 +1159,11 @@  discard block
 block discarded – undo
1159 1159
 
1160 1160
                 echo '<td>';
1161 1161
                 $all_attempt_url = "../exercise/exercise_report.php?exerciseId=$exercise_id&cidReq=$course_code&filter_by_user=$student_id&id_session=$sessionId";
1162
-                echo Display::url(Display::return_icon('test_results.png', get_lang('AllAttempts'), array(), ICON_SIZE_SMALL), $all_attempt_url );
1162
+                echo Display::url(Display::return_icon('test_results.png', get_lang('AllAttempts'), array(), ICON_SIZE_SMALL), $all_attempt_url);
1163 1163
 
1164 1164
                 echo '</td></tr>';
1165 1165
                 $data_exercices[$i][] = $exercices['title'];
1166
-                $data_exercices[$i][] = $score_percentage . '%';
1166
+                $data_exercices[$i][] = $score_percentage.'%';
1167 1167
                 $data_exercices[$i][] = $count_attempts;
1168 1168
 
1169 1169
                 $csv_content[] = array(
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
             $survey_list = SurveyManager::get_surveys($course_code, $sessionId);
1192 1192
 
1193 1193
             $survey_data = array();
1194
-            foreach($survey_list as $survey) {
1194
+            foreach ($survey_list as $survey) {
1195 1195
                 $user_list = SurveyManager::get_people_who_filled_survey($survey['survey_id'], false, $courseInfo['real_id']);
1196 1196
                 $survey_done = Display::return_icon("accept_na.png", get_lang('NoAnswer'), array(), ICON_SIZE_SMALL);
1197 1197
                 if (in_array($student_id, $user_list)) {
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
                         $column = 0;
1217 1217
                         $table->setCellContents($row, $column, $data);
1218 1218
                         $class = 'class="row_odd"';
1219
-                        if($row % 2) {
1219
+                        if ($row % 2) {
1220 1220
                             $class = 'class="row_even"';
1221 1221
                         }
1222 1222
                         $table->setRowAttributes($row, $class, true);
Please login to merge, or discard this patch.
main/exercise/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.
main/exercise/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/exercise/fill_blanks.class.php 2 patches
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
             ['id' => 'answer', 'onkeyup' => "javascript: updateBlanks(this);"],
261 261
             array('ToolbarSet' => 'TestQuestionDescription')
262 262
         );
263
-        $form->addRule('answer',get_lang('GiveText'),'required');
263
+        $form->addRule('answer', get_lang('GiveText'), 'required');
264 264
 
265 265
         //added multiple answers
266
-        $form->addElement('checkbox','multiple_answer','', get_lang('FillInBlankSwitchable'));
266
+        $form->addElement('checkbox', 'multiple_answer', '', get_lang('FillInBlankSwitchable'));
267 267
         $form->addElement(
268 268
             'select',
269 269
             'select_separator',
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
             null,
277 277
             '<input type="button" onclick="updateBlanks()" value="'.get_lang('RefreshBlanks').'" class="btn btn-default" />'
278 278
         );
279
-        $form->addElement('html','<div id="blanks_weighting"></div>');
279
+        $form->addElement('html', '<div id="blanks_weighting"></div>');
280 280
 
281 281
         global $text;
282 282
         // setting the save button here and not in the question class.php
283
-        $form->addElement('html','<div id="defineoneblank" style="color:#D04A66; margin-left:160px">'.get_lang('DefineBlanks').'</div>');
283
+        $form->addElement('html', '<div id="defineoneblank" style="color:#D04A66; margin-left:160px">'.get_lang('DefineBlanks').'</div>');
284 284
         $form->addButtonSave($text, 'submitQuestion');
285 285
 
286 286
         if (!empty($this->id)) {
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         // remove spaces at the beginning and the end of text in square brackets
321 321
         $answer = preg_replace_callback(
322 322
             "/".$blankStartSeparatorRegexp."[^]]+".$blankEndSeparatorRegexp."/",
323
-            function ($matches) use ($blankStartSeparator, $blankEndSeparator) {
323
+            function($matches) use ($blankStartSeparator, $blankEndSeparator) {
324 324
                 $matchingResult = $matches[0];
325 325
                 $matchingResult = trim($matchingResult, $blankStartSeparator);
326 326
                 $matchingResult = trim($matchingResult, $blankEndSeparator);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
         if ($nb > 0) {
366 366
             $answer .= '::';
367 367
             // weighting
368
-            for ($i=0; $i < $nb; ++$i) {
368
+            for ($i = 0; $i < $nb; ++$i) {
369 369
                 // enter the weighting of word $i
370 370
                 $answer .= $form->getSubmitValue('weighting['.$i.']');
371 371
                 // not the last word, add ","
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 
379 379
             // input width
380 380
             $answer .= ":";
381
-            for ($i=0; $i < $nb; ++$i) {
381
+            for ($i = 0; $i < $nb; ++$i) {
382 382
                 // enter the width of input for word $i
383 383
                 $answer .= $form->getSubmitValue('sizeofinput['.$i.']');
384 384
                 // not the last word, add ","
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 
404 404
         // Allow answers order switches
405 405
         $is_multiple = $form -> getSubmitValue('multiple_answer');
406
-        $answer.= '@'.$is_multiple;
406
+        $answer .= '@'.$is_multiple;
407 407
 
408 408
         $this->save();
409 409
         $objAnswer = new Answer($this->id);
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     public function return_header($feedback_type = null, $counter = null, $score = null)
421 421
     {
422 422
         $header = parent::return_header($feedback_type, $counter, $score);
423
-        $header .= '<table class="'.$this->question_table_class .'">
423
+        $header .= '<table class="'.$this->question_table_class.'">
424 424
             <tr>
425 425
                 <th>'.get_lang("Answer").'</th>
426 426
             </tr>';
@@ -464,13 +464,13 @@  discard block
 block discarded – undo
464 464
                 // if display for student, shuffle the correct answer menu
465 465
                 $listMenu = self::getFillTheBlankMenuAnswers($inTeacherSolution, $displayForStudent);
466 466
                 $result .= '<select name="choice['.$questionId.'][]">';
467
-                for ($k=0; $k < count($listMenu); $k++) {
467
+                for ($k = 0; $k < count($listMenu); $k++) {
468 468
                     $selected = "";
469 469
                     if ($correctItem == $listMenu[$k]) {
470 470
                         $selected = " selected=selected ";
471 471
                     }
472 472
                     // if in teacher view, display the first item by default, which is the right answer
473
-                    if ($k==0 && !$displayForStudent) {
473
+                    if ($k == 0 && !$displayForStudent) {
474 474
                         $selected = " selected=selected ";
475 475
                     }
476 476
                     $optionMenu .= '<option '.$selected.' value="'.$listMenu[$k].'">'.$listMenu[$k].'</option>';
@@ -642,10 +642,10 @@  discard block
 block discarded – undo
642 642
         if (count($listDetails) < 3) {
643 643
             $listWeightings = explode(',', $listDetails[0]);
644 644
             $listSizeOfInput = array();
645
-            for ($i=0; $i < count($listWeightings); $i++) {
645
+            for ($i = 0; $i < count($listWeightings); $i++) {
646 646
                 $listSizeOfInput[] = 200;
647 647
             }
648
-            $blankSeparatorNumber = 0;    // 0 is [...]
648
+            $blankSeparatorNumber = 0; // 0 is [...]
649 649
         } else {
650 650
             $listWeightings = explode(',', $listDetails[0]);
651 651
             $listSizeOfInput = explode(',', $listDetails[1]);
@@ -677,9 +677,9 @@  discard block
 block discarded – undo
677 677
             // remove [ and ] in string
678 678
             array_walk(
679 679
                 $listWords[0],
680
-                function (&$value, $key, $tabBlankChar) {
680
+                function(&$value, $key, $tabBlankChar) {
681 681
                     $trimChars = "";
682
-                    for ($i=0; $i < count($tabBlankChar); $i++) {
682
+                    for ($i = 0; $i < count($tabBlankChar); $i++) {
683 683
                         $trimChars .= $tabBlankChar[$i];
684 684
                     }
685 685
                     $value = trim($value, $trimChars);
@@ -699,18 +699,18 @@  discard block
 block discarded – undo
699 699
         // if student answer, the second [] is the student answer,
700 700
         // the third is if student scored or not
701 701
         $listBrackets = array();
702
-        $listWords =  array();
702
+        $listWords = array();
703 703
 
704 704
         if ($isStudentAnswer) {
705
-            for ($i=0; $i < count($listAnswerResults['tabwords']); $i++) {
705
+            for ($i = 0; $i < count($listAnswerResults['tabwords']); $i++) {
706 706
                 $listBrackets[] = $listAnswerResults['tabwordsbracket'][$i];
707 707
                 $listWords[] = $listAnswerResults['tabwords'][$i];
708
-                if ($i+1 < count($listAnswerResults['tabwords'])) {
708
+                if ($i + 1 < count($listAnswerResults['tabwords'])) {
709 709
                     // should always be
710 710
                     $i++;
711 711
                 }
712 712
                 $listAnswerResults['studentanswer'][] = $listAnswerResults['tabwords'][$i];
713
-                if ($i+1 < count($listAnswerResults['tabwords'])) {
713
+                if ($i + 1 < count($listAnswerResults['tabwords'])) {
714 714
                     // should always be
715 715
                     $i++;
716 716
                 }
@@ -802,9 +802,9 @@  discard block
 block discarded – undo
802 802
                            break;
803 803
                        default :
804 804
                            if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) {
805
-                               $tabUserResult[$data['user_id']][$bracketNumber] = 0;   //  right answer
805
+                               $tabUserResult[$data['user_id']][$bracketNumber] = 0; //  right answer
806 806
                            } else {
807
-                               $tabUserResult[$data['user_id']][$bracketNumber] = -1;  // wrong answer
807
+                               $tabUserResult[$data['user_id']][$bracketNumber] = -1; // wrong answer
808 808
                            }
809 809
                    }
810 810
                } else {
@@ -812,11 +812,11 @@  discard block
 block discarded – undo
812 812
                    if ($useLastAnswerredAttempt) {
813 813
                        // if we take into account the last answered attempt
814 814
                        if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) {
815
-                           $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
815
+                           $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered
816 816
                        }
817 817
                    } else {
818 818
                        // we take the last attempt, even if the student answer the question before
819
-                       $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
819
+                       $tabUserResult[$data['user_id']][$bracketNumber] = -2; // not answered
820 820
                    }
821 821
                }
822 822
            }
@@ -837,10 +837,10 @@  discard block
 block discarded – undo
837 837
     {
838 838
         $outRes = 0;
839 839
         // for each student in group
840
-        foreach($resultList as $userId => $tabValue) {
840
+        foreach ($resultList as $userId => $tabValue) {
841 841
             $trouve = false;
842 842
             // for each bracket, if student has at leat one answer ( choice > -2) then he pass the question
843
-            foreach($tabValue as $i => $choice) {
843
+            foreach ($tabValue as $i => $choice) {
844 844
                 if ($choice > -2 && !$trouve) {
845 845
                     $outRes++;
846 846
                     $trouve = true;
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
         $separatorEnd = $listWithStudentAnswer['blankseparatorend'];
863 863
         // lets rebuild the sentence with [correct answer][student answer][answer is correct]
864 864
         $result = "";
865
-        for ($i=0; $i < count($listWithStudentAnswer['commonwords']) - 1; $i++) {
865
+        for ($i = 0; $i < count($listWithStudentAnswer['commonwords']) - 1; $i++) {
866 866
             $result .= $listWithStudentAnswer['commonwords'][$i];
867 867
             $result .= $listWithStudentAnswer['tabwordsbracket'][$i];
868 868
             $result .= $separatorStart.$listWithStudentAnswer['studentanswer'][$i].$separatorEnd;
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
             ")",
945 945
         ];
946 946
         $result = $text;
947
-        for ($i=0; $i < count($listRegexpCharacters); $i++) {
947
+        for ($i = 0; $i < count($listRegexpCharacters); $i++) {
948 948
             $result = str_replace($listRegexpCharacters[$i], "\\".$listRegexpCharacters[$i], $result);
949 949
         }
950 950
 
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
     {
1007 1007
         $listResults = array();
1008 1008
         $fillBlanksAllowedSeparator = self::getAllowedSeparator();
1009
-        for ($i=0; $i < count($fillBlanksAllowedSeparator); $i++) {
1009
+        for ($i = 0; $i < count($fillBlanksAllowedSeparator); $i++) {
1010 1010
             $listResults[] = $fillBlanksAllowedSeparator[$i][0]."...".$fillBlanksAllowedSeparator[$i][1];
1011 1011
         }
1012 1012
 
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
     {
1025 1025
         $listSeparators = self::getAllowedSeparator();
1026 1026
         $result = 0;
1027
-        for ($i=0; $i < count($listSeparators); $i++) {
1027
+        for ($i = 0; $i < count($listSeparators); $i++) {
1028 1028
             if ($listSeparators[$i][0] == $startSeparator &&
1029 1029
                 $listSeparators[$i][1] == $endSeparator
1030 1030
             ) {
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 
1050 1050
         // rebuild the answer with good HTML style
1051 1051
         // this is the student answer, right or wrong
1052
-        for ($i=0; $i < count($listStudentAnswerInfo['studentanswer']); $i++) {
1052
+        for ($i = 0; $i < count($listStudentAnswerInfo['studentanswer']); $i++) {
1053 1053
             if ($listStudentAnswerInfo['studentscore'][$i] == 1) {
1054 1054
                 $listStudentAnswerInfo['studentanswer'][$i] = self::getHtmlRightAnswer(
1055 1055
                     $listStudentAnswerInfo['studentanswer'][$i],
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 
1068 1068
 
1069 1069
         // rebuild the sentence with student answer inserted
1070
-        for ($i=0; $i < count($listStudentAnswerInfo['commonwords']); $i++) {
1070
+        for ($i = 0; $i < count($listStudentAnswerInfo['commonwords']); $i++) {
1071 1071
             $result .= isset($listStudentAnswerInfo['commonwords'][$i]) ? $listStudentAnswerInfo['commonwords'][$i] : '';
1072 1072
             $result .= isset($listStudentAnswerInfo['studentanswer'][$i]) ? $listStudentAnswerInfo['studentanswer'][$i] : '';
1073 1073
         }
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
                 $listPossibleAnswers = FillBlanks::getFillTheBlankMenuAnswers($correct, false);
1101 1101
                 $correctAnswerHtml .= "<span style='color: green'>".$listPossibleAnswers[0]."</span>";
1102 1102
                 $correctAnswerHtml .= " <span style='font-weight:normal'>(";
1103
-                for ($i=1; $i < count($listPossibleAnswers); $i++) {
1103
+                for ($i = 1; $i < count($listPossibleAnswers); $i++) {
1104 1104
                     $correctAnswerHtml .= $listPossibleAnswers[$i];
1105 1105
                     if ($i != count($listPossibleAnswers) - 1) {
1106 1106
                         $correctAnswerHtml .= " | ";
Please login to merge, or discard this patch.
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -728,29 +728,29 @@  discard block
 block discarded – undo
728 728
     }
729 729
 
730 730
     /**
731
-    * Return an array of student state answers for fill the blank questions
732
-    * for each students that answered the question
733
-    * -2  : didn't answer
734
-    * -1  : student answer is wrong
735
-    *  0  : student answer is correct
736
-    * >0  : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0)
737
-    *
738
-    * @param integer $testId
739
-    * @param integer $questionId
740
-    * @param $studentsIdList
741
-    * @param string $startDate
742
-    * @param string $endDate
743
-    * @param bool $useLastAnswerredAttempt
744
-    * @return array
745
-    * (
746
-    *     [student_id] => Array
747
-    *         (
748
-    *             [first fill the blank for question] => -1
749
-    *             [second fill the blank for question] => 2
750
-    *             [third fill the blank for question] => -1
751
-    *         )
752
-    * )
753
-    */
731
+     * Return an array of student state answers for fill the blank questions
732
+     * for each students that answered the question
733
+     * -2  : didn't answer
734
+     * -1  : student answer is wrong
735
+     *  0  : student answer is correct
736
+     * >0  : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0)
737
+     *
738
+     * @param integer $testId
739
+     * @param integer $questionId
740
+     * @param $studentsIdList
741
+     * @param string $startDate
742
+     * @param string $endDate
743
+     * @param bool $useLastAnswerredAttempt
744
+     * @return array
745
+     * (
746
+     *     [student_id] => Array
747
+     *         (
748
+     *             [first fill the blank for question] => -1
749
+     *             [second fill the blank for question] => 2
750
+     *             [third fill the blank for question] => -1
751
+     *         )
752
+     * )
753
+     */
754 754
     public static function getFillTheBlankTabResult(
755 755
         $testId,
756 756
         $questionId,
@@ -759,15 +759,15 @@  discard block
 block discarded – undo
759 759
         $endDate,
760 760
         $useLastAnswerredAttempt = true
761 761
     ) {
762
-       $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
763
-       $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
764
-       $courseId = api_get_course_int_id();
762
+        $tblTrackEAttempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
763
+        $tblTrackEExercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
764
+        $courseId = api_get_course_int_id();
765 765
         // request to have all the answers of student for this question
766
-       // student may have doing it several time
767
-       // student may have not answered the bracket id, in this case, is result of the answer is empty
766
+        // student may have doing it several time
767
+        // student may have not answered the bracket id, in this case, is result of the answer is empty
768 768
 
769
-       // we got the less recent attempt first
770
-       $sql = '
769
+        // we got the less recent attempt first
770
+        $sql = '
771 771
            SELECT * FROM '.$tblTrackEAttempt.' tea
772 772
            LEFT JOIN '.$tblTrackEExercise.' tee
773 773
            ON tee.exe_id = tea.exe_id
@@ -782,51 +782,51 @@  discard block
 block discarded – undo
782 782
            ORDER BY user_id, tea.exe_id;
783 783
        ';
784 784
 
785
-       $res = Database::query($sql);
786
-       $tabUserResult = array();
787
-       $bracketNumber = 0;
788
-       // foreach attempts for all students starting with his older attempt
789
-       while ($data = Database::fetch_array($res)) {
790
-           $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true);
785
+        $res = Database::query($sql);
786
+        $tabUserResult = array();
787
+        $bracketNumber = 0;
788
+        // foreach attempts for all students starting with his older attempt
789
+        while ($data = Database::fetch_array($res)) {
790
+            $tabAnswer = FillBlanks::getAnswerInfo($data['answer'], true);
791 791
 
792
-           // for each bracket to find in this question
793
-           foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) {
792
+            // for each bracket to find in this question
793
+            foreach ($tabAnswer['studentanswer'] as $bracketNumber => $studentAnswer) {
794 794
 
795
-               if ($tabAnswer['studentanswer'][$bracketNumber] != '') {
796
-                   // student has answered this bracket, cool
797
-                   switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) {
798
-                       case self::FILL_THE_BLANK_MENU :
795
+                if ($tabAnswer['studentanswer'][$bracketNumber] != '') {
796
+                    // student has answered this bracket, cool
797
+                    switch (FillBlanks::getFillTheBlankAnswerType($tabAnswer['tabwords'][$bracketNumber])) {
798
+                        case self::FILL_THE_BLANK_MENU :
799 799
                            // get the indice of the choosen answer in the menu
800 800
                            // we know that the right answer is the first entry of the menu, ie 0
801 801
                            // (remember, menu entries are shuffled when taking the test)
802 802
                            $tabUserResult[$data['user_id']][$bracketNumber] = FillBlanks::getFillTheBlankMenuAnswerNum(
803
-                               $tabAnswer['tabwords'][$bracketNumber],
804
-                               $tabAnswer['studentanswer'][$bracketNumber]
805
-                           );
806
-                           break;
807
-                       default :
803
+                                $tabAnswer['tabwords'][$bracketNumber],
804
+                                $tabAnswer['studentanswer'][$bracketNumber]
805
+                            );
806
+                            break;
807
+                        default :
808 808
                            if (FillBlanks::isGoodStudentAnswer($tabAnswer['studentanswer'][$bracketNumber], $tabAnswer['tabwords'][$bracketNumber])) {
809
-                               $tabUserResult[$data['user_id']][$bracketNumber] = 0;   //  right answer
810
-                           } else {
811
-                               $tabUserResult[$data['user_id']][$bracketNumber] = -1;  // wrong answer
812
-                           }
813
-                   }
814
-               } else {
815
-                   // student didn't answer this bracket
816
-                   if ($useLastAnswerredAttempt) {
817
-                       // if we take into account the last answered attempt
818
-                       if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) {
819
-                           $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
820
-                       }
821
-                   } else {
822
-                       // we take the last attempt, even if the student answer the question before
823
-                       $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
824
-                   }
825
-               }
826
-           }
827
-       }
828
-
829
-       return $tabUserResult;
809
+                                $tabUserResult[$data['user_id']][$bracketNumber] = 0;   //  right answer
810
+                            } else {
811
+                                $tabUserResult[$data['user_id']][$bracketNumber] = -1;  // wrong answer
812
+                            }
813
+                    }
814
+                } else {
815
+                    // student didn't answer this bracket
816
+                    if ($useLastAnswerredAttempt) {
817
+                        // if we take into account the last answered attempt
818
+                        if (!isset($tabUserResult[$data['user_id']][$bracketNumber])) {
819
+                            $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
820
+                        }
821
+                    } else {
822
+                        // we take the last attempt, even if the student answer the question before
823
+                        $tabUserResult[$data['user_id']][$bracketNumber] = -2;      // not answered
824
+                    }
825
+                }
826
+            }
827
+        }
828
+
829
+        return $tabUserResult;
830 830
     }
831 831
 
832 832
     /**
Please login to merge, or discard this patch.
main/exercise/result.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	api_not_allowed($show_headers);
27 27
 }
28 28
 
29
-$is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor;
29
+$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor;
30 30
 
31 31
 //Getting results from the exe_id. This variable also contain all the information about the exercise
32 32
 $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
     }
54 54
 }
55 55
 
56
-$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
57
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
56
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
57
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
58 58
 
59 59
 if ($show_headers) {
60 60
     $interbreadcrumb[] = array(
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
     $htmlHeadXtra[] = '<style>
71 71
         body { background: none;}
72 72
     </style>';
73
-	Display::display_reduced_header();
73
+    Display::display_reduced_header();
74 74
 }
75 75
 
76 76
 $message = Session::read('attempt_remaining');
Please login to merge, or discard this patch.
main/exercise/stats.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $result = $objExercise->read($exercise_id);
13 13
 
14 14
 if (!$result) {
15
-	api_not_allowed(true);
15
+    api_not_allowed(true);
16 16
 }
17 17
 
18 18
 $sessionId = api_get_session_id();
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 $data = array();
30 30
 // Question title 	# of students who tool it 	Lowest score 	Average 	Highest score 	Maximum score
31 31
 $headers = array(
32
-	get_lang('Question'),
32
+    get_lang('Question'),
33 33
     get_lang('QuestionType'),
34 34
     get_lang('NumberStudentWhoSelectedIt'),
35
-	get_lang('LowestScore'),
36
-	get_lang('AverageScore'),
37
-	get_lang('HighestScore'),
38
-	get_lang('Weighting')
35
+    get_lang('LowestScore'),
36
+    get_lang('AverageScore'),
37
+    get_lang('HighestScore'),
38
+    get_lang('Weighting')
39 39
 );
40 40
 
41 41
 if (!empty($question_list)) {
42
-	foreach ($question_list as $question_id) {
42
+    foreach ($question_list as $question_id) {
43 43
         $question_obj = Question::read($question_id);
44 44
 
45 45
         $exercise_stats = ExerciseLib::get_student_stats_by_question(
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $data[$question_id]['average_score'] = round($exercise_stats['average'], 2);
74 74
         $data[$question_id]['highest_score'] = round($exercise_stats['max'], 2);
75 75
         $data[$question_id]['max_score'] = round($question_obj->weighting, 2);
76
-	}
76
+    }
77 77
 }
78 78
 
79 79
 // Format A table
@@ -81,37 +81,37 @@  discard block
 block discarded – undo
81 81
 $row = 0;
82 82
 $column = 0;
83 83
 foreach ($headers as $header) {
84
-	$table->setHeaderContents($row, $column, $header);
85
-	$column++;
84
+    $table->setHeaderContents($row, $column, $header);
85
+    $column++;
86 86
 }
87 87
 $row++;
88 88
 foreach ($data as $row_table) {
89
-	$column = 0;
90
-	foreach ($row_table as $cell) {
91
-		$table->setCellContents($row, $column, $cell);
92
-		$table->updateCellAttributes($row, $column, 'align="center"');
93
-		$column++;
94
-	}
95
-	$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
96
-	$row++;
89
+    $column = 0;
90
+    foreach ($row_table as $cell) {
91
+        $table->setCellContents($row, $column, $cell);
92
+        $table->updateCellAttributes($row, $column, 'align="center"');
93
+        $column++;
94
+    }
95
+    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
96
+    $row++;
97 97
 }
98 98
 $content = $table->toHtml();
99 99
 
100 100
 // Format B
101 101
 
102 102
 $headers = array(
103
-	get_lang('Question'),
104
-	get_lang('Answer'),
105
-	get_lang('Correct'),
106
-	get_lang('NumberStudentWhoSelectedIt')
103
+    get_lang('Question'),
104
+    get_lang('Answer'),
105
+    get_lang('Correct'),
106
+    get_lang('NumberStudentWhoSelectedIt')
107 107
 );
108 108
 
109 109
 $data = array();
110 110
 
111 111
 if (!empty($question_list)) {
112 112
     $id = 0;
113
-	foreach ($question_list as $question_id) {
114
-		$question_obj = Question::read($question_id);
113
+    foreach ($question_list as $question_id) {
114
+        $question_obj = Question::read($question_id);
115 115
         $exercise_stats = ExerciseLib::get_student_stats_by_question(
116 116
             $question_id,
117 117
             $exercise_id,
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         );
121 121
 
122 122
         $answer = new Answer($question_id);
123
-		$answer_count = $answer->selectNbrAnswers();
123
+        $answer_count = $answer->selectNbrAnswers();
124 124
 
125 125
         for ($answer_id = 1; $answer_id <= $answer_count; $answer_id++) {
126 126
             $answer_info = $answer->selectAnswer($answer_id);
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
                         $correct = '';
176 176
 
177 177
                         for ($i = 1; $i <= $answer_count; $i++) {
178
-                             $is_correct_i = $answer->isCorrect($i);
179
-                             if ($is_correct_i != 0 && $is_correct_i == $answer_id) {
180
-                                 $correct = $answer->selectAnswer($i);
181
-                                 break;
182
-                             }
178
+                                $is_correct_i = $answer->isCorrect($i);
179
+                                if ($is_correct_i != 0 && $is_correct_i == $answer_id) {
180
+                                    $correct = $answer->selectAnswer($i);
181
+                                    break;
182
+                                }
183 183
                         }
184 184
                         $data[$id]['answer'] = $correct;
185 185
                         $data[$id]['correct'] = $answer_info;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             }
246 246
             $id++;
247 247
         }
248
-	}
248
+    }
249 249
 }
250 250
 
251 251
 // Format A table
@@ -253,19 +253,19 @@  discard block
 block discarded – undo
253 253
 $row = 0;
254 254
 $column = 0;
255 255
 foreach ($headers as $header) {
256
-	$table->setHeaderContents($row, $column, $header);
257
-	$column++;
256
+    $table->setHeaderContents($row, $column, $header);
257
+    $column++;
258 258
 }
259 259
 $row++;
260 260
 foreach ($data as $row_table) {
261
-	$column = 0;
262
-	foreach ($row_table as $cell) {
263
-		$table->setCellContents($row, $column, $cell);
264
-		$table->updateCellAttributes($row, $column, 'align="center"');
265
-		$column++;
266
-	}
267
-	$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
268
-	$row++;
261
+    $column = 0;
262
+    foreach ($row_table as $cell) {
263
+        $table->setCellContents($row, $column, $cell);
264
+        $table->updateCellAttributes($row, $column, 'align="center"');
265
+        $column++;
266
+    }
267
+    $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
268
+    $row++;
269 269
 }
270 270
 $content .= $table->toHtml();
271 271
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
         $data[$question_id]['type'] = $question_obj->get_question_type_name();
62 62
         $percentange = 0;
63 63
         if ($count_students) {
64
-            $percentange = $count_users / $count_students*100;
64
+            $percentange = $count_users / $count_students * 100;
65 65
         }
66 66
 
67 67
         $data[$question_id]['students_who_try_exercise'] = Display::bar_progress(
68 68
             $percentange,
69 69
             false,
70
-            $count_users .' / '.$count_students
70
+            $count_users.' / '.$count_students
71 71
         );
72 72
         $data[$question_id]['lowest_score'] = round($exercise_stats['min'], 2);
73 73
         $data[$question_id]['average_score'] = round($exercise_stats['average'], 2);
@@ -142,23 +142,23 @@  discard block
 block discarded – undo
142 142
                         } else {
143 143
                             $data[$id]['name'] = '-';
144 144
                         }
145
-                        $data[$id]['answer'] 	= $answer_item;
145
+                        $data[$id]['answer'] = $answer_item;
146 146
 
147 147
                         $answer_item = api_substr($answer_item, 1);
148
-                        $answer_item = api_substr($answer_item, 0, api_strlen($answer_item) -1);
148
+                        $answer_item = api_substr($answer_item, 0, api_strlen($answer_item) - 1);
149 149
                         
150
-                        $data[$id]['answer'] 	= $answer_item;
150
+                        $data[$id]['answer'] = $answer_item;
151 151
 
152
-                        $data[$id]['correct'] 	= '-';
152
+                        $data[$id]['correct'] = '-';
153 153
 
154 154
                         $count = ExerciseLib::getNumberStudentsFillBlanksAnwserCount($question_id, $exercise_id);
155 155
                         $count = $count[$counter];
156 156
                         
157 157
                         $percentange = 0;
158 158
                         if (!empty($count_students)) {
159
-                            $percentange = $count/$count_students*100;
159
+                            $percentange = $count / $count_students * 100;
160 160
                         }
161
-                        $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
161
+                        $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count.' / '.$count_students);
162 162
                         $id++;
163 163
                         $counter++;
164 164
                     }
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
                         );
195 195
                         $percentange = 0;
196 196
                         if (!empty($count_students)) {
197
-                            $percentange = $count/$count_students*100;
197
+                            $percentange = $count / $count_students * 100;
198 198
                         }
199
-                        $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
199
+                        $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count.' / '.$count_students);
200 200
                     }
201 201
                     break;
202 202
                 case HOT_SPOT:
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
                     );
218 218
                     $percentange = 0;
219 219
                     if (!empty($count_students)) {
220
-                        $percentange = $count/$count_students*100;
220
+                        $percentange = $count / $count_students * 100;
221 221
                     }
222
-                    $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
222
+                    $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count.' / '.$count_students);
223 223
                     break;
224 224
                 default:
225 225
                     if ($answer_id == 1) {
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
                     );
240 240
                     $percentange = 0;
241 241
                     if (!empty($count_students)) {
242
-                        $percentange = $count/$count_students*100;
242
+                        $percentange = $count / $count_students * 100;
243 243
                     }
244
-                    $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
244
+                    $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count.' / '.$count_students);
245 245
             }
246 246
             $id++;
247 247
         }
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 $interbreadcrumb[] = array("url" => "admin.php?exerciseId=$exercise_id&".api_get_cidreq(), "name" => $objExercise->name);
274 274
 
275 275
 $tpl = new Template(get_lang('ReportByQuestion'));
276
-$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">' .
277
-    Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
276
+$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">'.
277
+    Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
278 278
 $actions = Display::div($actions, array('class'=> 'actions'));
279 279
 $content = $actions.$content;
280 280
 $tpl->assign('content', $content);
Please login to merge, or discard this patch.