Passed
Push — 1.10.x ( 6b51fa...7f42c3 )
by
unknown
49:18
created
main/inc/lib/pear/HTML/Table.php 1 patch
Indentation   +58 added lines, -59 removed lines patch added patch discarded remove patch
@@ -1,63 +1,62 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3 3
 /**
4
- * PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and
5
- * efficient.
6
- *
7
- * The PEAR::HTML_Table package provides methods for easy and efficient design
8
- * of HTML tables.
9
- * - Lots of customization options.
10
- * - Tables can be modified at any time.
11
- * - The logic is the same as standard HTML editors.
12
- * - Handles col and rowspans.
13
- * - PHP code is shorter, easier to read and to maintain.
14
- * - Tables options can be reused.
15
- *
16
- * For auto filling of data and such then check out
17
- * http://pear.php.net/package/HTML_Table_Matrix
18
- *
19
- * PHP versions 4 and 5
20
- *
21
- * LICENSE:
22
- *
23
- * Copyright (c) 2005-2007, Adam Daniel <[email protected]>,
24
- *                          Bertrand Mansion <[email protected]>,
25
- *                          Mark Wiesemann <[email protected]>
26
- * All rights reserved.
27
- *
28
- * Redistribution and use in source and binary forms, with or without
29
- * modification, are permitted provided that the following conditions
30
- * are met:
31
- *
32
- *    * Redistributions of source code must retain the above copyright
33
- *      notice, this list of conditions and the following disclaimer.
34
- *    * Redistributions in binary form must reproduce the above copyright
35
- *      notice, this list of conditions and the following disclaimer in the
36
- *      documentation and/or other materials provided with the distribution.
37
- *    * The names of the authors may not be used to endorse or promote products
38
- *      derived from this software without specific prior written permission.
39
- *
40
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
41
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
42
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
44
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
46
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
47
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
48
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
49
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51
-
52
- *
53
- * @category   HTML
54
- * @package    HTML_Table
55
- * @author     Adam Daniel <[email protected]>
56
- * @author     Bertrand Mansion <[email protected]>
57
- * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
58
- * @version    CVS: $Id: Table.php,v 1.39 2007/06/25 16:44:43 wiesemann Exp $
59
- * @link       http://pear.php.net/package/HTML_Table
60
- */
4
+     * PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and
5
+     * efficient.
6
+     *
7
+     * The PEAR::HTML_Table package provides methods for easy and efficient design
8
+     * of HTML tables.
9
+     * - Lots of customization options.
10
+     * - Tables can be modified at any time.
11
+     * - The logic is the same as standard HTML editors.
12
+     * - Handles col and rowspans.
13
+     * - PHP code is shorter, easier to read and to maintain.
14
+     * - Tables options can be reused.
15
+     *
16
+     * For auto filling of data and such then check out
17
+     * http://pear.php.net/package/HTML_Table_Matrix
18
+     *
19
+     * PHP versions 4 and 5
20
+     *
21
+     * LICENSE:
22
+     *
23
+     * Copyright (c) 2005-2007, Adam Daniel <[email protected]>,
24
+     *                          Bertrand Mansion <[email protected]>,
25
+     *                          Mark Wiesemann <[email protected]>
26
+     * All rights reserved.
27
+     *
28
+     * Redistribution and use in source and binary forms, with or without
29
+     * modification, are permitted provided that the following conditions
30
+     * are met:
31
+     *
32
+     *    * Redistributions of source code must retain the above copyright
33
+     *      notice, this list of conditions and the following disclaimer.
34
+     *    * Redistributions in binary form must reproduce the above copyright
35
+     *      notice, this list of conditions and the following disclaimer in the
36
+     *      documentation and/or other materials provided with the distribution.
37
+     *    * The names of the authors may not be used to endorse or promote products
38
+     *      derived from this software without specific prior written permission.
39
+     *
40
+     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
41
+     * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
42
+     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43
+     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
44
+     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45
+     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
46
+     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
47
+     * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
48
+     * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
49
+     * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50
+     * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51
+     *
52
+     * @category   HTML
53
+     * @package    HTML_Table
54
+     * @author     Adam Daniel <[email protected]>
55
+     * @author     Bertrand Mansion <[email protected]>
56
+     * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
57
+     * @version    CVS: $Id: Table.php,v 1.39 2007/06/25 16:44:43 wiesemann Exp $
58
+     * @link       http://pear.php.net/package/HTML_Table
59
+     */
61 60
 
62 61
 /**
63 62
  * PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and efficient.
@@ -256,7 +255,7 @@  discard block
 block discarded – undo
256 255
 
257 256
         $body = $this->_tbodyCount++;
258 257
         $this->_tbodies[$body] = new HTML_Table_Storage($this->_tabOffset,
259
-                                                         $this->_useTGroups);
258
+                                                            $this->_useTGroups);
260 259
         $this->_tbodies[$body]->setAutoFill($this->_autoFill);
261 260
         $this->_tbodies[$body]->setAttributes($attributes);
262 261
         return $body;
@@ -308,7 +307,7 @@  discard block
 block discarded – undo
308 307
         if (isset($colgroup)) {
309 308
             $attributes = $this->_parseAttributes($attributes);
310 309
             $this->_colgroup[] = array('attr' => $attributes,
311
-                                       'contents' => $colgroup);
310
+                                        'contents' => $colgroup);
312 311
         } else {
313 312
             $this->_colgroup = array();
314 313
         }
Please login to merge, or discard this patch.
main/exercice/exercise.class.php 2 patches
Doc Comments   +13 added lines, -8 removed lines patch added patch discarded remove patch
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
     }
355 355
 
356 356
     /**
357
-     * @return int
357
+     * @return string
358 358
      */
359 359
     public function selectPassPercentage()
360 360
     {
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
      * tells if questions are selected randomly, and if so returns the draws
474 474
      *
475 475
      * @author Olivier Brouckaert
476
-     * @return integer - 0 if not random, otherwise the draws
476
+     * @return boolean - 0 if not random, otherwise the draws
477 477
      */
478 478
     public function isRandom()
479 479
     {
@@ -2830,7 +2830,7 @@  discard block
 block discarded – undo
2830 2830
      * @param int  int lp id
2831 2831
      * @param int  int lp item id
2832 2832
      * @param int  int lp item_view id
2833
-     * @param float $weight
2833
+     * @param integer $weight
2834 2834
      * @param array question list
2835 2835
      */
2836 2836
     public function save_stat_track_exercise_info(
@@ -5118,6 +5118,7 @@  discard block
 block discarded – undo
5118 5118
     /**
5119 5119
      * Sends a notification when a user ends an examn
5120 5120
      *
5121
+     * @param integer $exe_id
5121 5122
      */
5122 5123
     public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id)
5123 5124
     {
@@ -5198,6 +5199,7 @@  discard block
 block discarded – undo
5198 5199
     /**
5199 5200
      * Sends a notification when a user ends an examn
5200 5201
      *
5202
+     * @param integer $exe_id
5201 5203
      */
5202 5204
     function send_notification_for_open_questions($question_list_answers, $origin, $exe_id)
5203 5205
     {
@@ -5295,6 +5297,9 @@  discard block
 block discarded – undo
5295 5297
         }
5296 5298
     }
5297 5299
 
5300
+    /**
5301
+     * @param integer $exe_id
5302
+     */
5298 5303
     function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id)
5299 5304
     {
5300 5305
         if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
@@ -5388,7 +5393,7 @@  discard block
 block discarded – undo
5388 5393
 
5389 5394
     /**
5390 5395
      * @param array $user_data result of api_get_user_info()
5391
-     * @param null $start_date
5396
+     * @param string $start_date
5392 5397
      * @param null $duration
5393 5398
      * @param string $ip Optional. The user IP
5394 5399
      * @return string
@@ -5446,7 +5451,7 @@  discard block
 block discarded – undo
5446 5451
      * @param int     Maximum number of attempts (0 if no limit)
5447 5452
      * @param int     Feedback type
5448 5453
      * @todo this was function was added due the import exercise via CSV
5449
-     * @return    int New exercise ID
5454
+     * @return    string New exercise ID
5450 5455
      */
5451 5456
     public function createExercise(
5452 5457
         $title,
@@ -6795,7 +6800,7 @@  discard block
 block discarded – undo
6795 6800
      * @param bool $show_comment
6796 6801
      * @param null $exercise_feedback
6797 6802
      * @param bool $show_answers
6798
-     * @param null $modelType
6803
+     * @param integer $modelType
6799 6804
      * @param bool $categoryMinusOne
6800 6805
      * @return bool|null|string
6801 6806
      */
@@ -7956,8 +7961,8 @@  discard block
 block discarded – undo
7956 7961
     /**
7957 7962
      * Returns an HTML ribbon to show on top of the exercise result, with
7958 7963
      * colouring depending on the success or failure of the student
7959
-     * @param $score
7960
-     * @param $weight
7964
+     * @param integer $score
7965
+     * @param integer $weight
7961 7966
      * @param bool $check_pass_percentage
7962 7967
      * @return string
7963 7968
      */
Please login to merge, or discard this patch.
Spacing   +349 added lines, -349 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     public $feedback_type;
28 28
     public $end_time;
29 29
     public $start_time;
30
-    public $questionList;  // array with the list of this exercise's questions
30
+    public $questionList; // array with the list of this exercise's questions
31 31
     /* including question list of the media */
32 32
     public $questionListUncompressed;
33 33
     public $results_disabled;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
131 131
         $table_lp_item = Database::get_course_table(TABLE_LP_ITEM);
132 132
 
133
-        $id  = intval($id);
133
+        $id = intval($id);
134 134
         if (empty($this->course_id)) {
135 135
             return false;
136 136
         }
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
             }
190 190
 
191 191
             if ($object->end_time != '0000-00-00 00:00:00') {
192
-                $this->end_time 	= $object->end_time;
192
+                $this->end_time = $object->end_time;
193 193
             }
194 194
             if ($object->start_time != '0000-00-00 00:00:00') {
195
-                $this->start_time 	= $object->start_time;
195
+                $this->start_time = $object->start_time;
196 196
             }
197 197
 
198 198
             //control time
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
      */
478 478
     public function isRandom()
479 479
     {
480
-        if($this->random > 0 || $this->random == -1) {
480
+        if ($this->random > 0 || $this->random == -1) {
481 481
             return true;
482 482
         } else {
483 483
             return false;
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
                     $question_media = null;
639 639
                     if (!empty($objQuestionTmp->parent_id)) {
640 640
                         $objQuestionMedia = Question::read($objQuestionTmp->parent_id);
641
-                        $question_media  = Question::getMediaLabel($objQuestionMedia->question);
641
+                        $question_media = Question::getMediaLabel($objQuestionMedia->question);
642 642
                     }
643 643
 
644 644
                     $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), ICON_SIZE_MEDIUM).$question_media);
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 
1032 1032
             foreach ($questions_by_category as $categoryId => $questionList) {
1033 1033
                 $cat = new TestCategory($categoryId);
1034
-                $cat = (array)$cat;
1034
+                $cat = (array) $cat;
1035 1035
                 $cat['iid'] = $cat['id'];
1036 1036
                 //*$cat['name'] = $cat['name'];
1037 1037
 
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
     {
1097 1097
         if ($this->specialCategoryOrders == false) {
1098 1098
             if ($from_db && !empty($this->id)) {
1099
-                $TBL_EXERCISE_QUESTION  = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
1099
+                $TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
1100 1100
                 $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
1101 1101
 
1102 1102
                 $sql = "SELECT DISTINCT e.question_order
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
                 $question_list = array();
1124 1124
 
1125 1125
                 while ($new_object = Database::fetch_object($result)) {
1126
-                    $question_list[$new_object->question_order]=  $new_object->question_id;
1126
+                    $question_list[$new_object->question_order] = $new_object->question_id;
1127 1127
                     $temp_question_list[$counter] = $new_object->question_id;
1128 1128
                     $counter++;
1129 1129
                 }
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
     public function isInList($questionId)
1268 1268
     {
1269 1269
         if (is_array($this->questionList))
1270
-            return in_array($questionId,$this->questionList);
1270
+            return in_array($questionId, $this->questionList);
1271 1271
         else
1272 1272
             return false;
1273 1273
     }
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
      */
1281 1281
     public function updateTitle($title)
1282 1282
     {
1283
-        $this->exercise=$title;
1283
+        $this->exercise = $title;
1284 1284
     }
1285 1285
 
1286 1286
     /**
@@ -1290,7 +1290,7 @@  discard block
 block discarded – undo
1290 1290
      */
1291 1291
     public function updateAttempts($attempts)
1292 1292
     {
1293
-        $this->attempts=$attempts;
1293
+        $this->attempts = $attempts;
1294 1294
     }
1295 1295
 
1296 1296
     /**
@@ -1300,7 +1300,7 @@  discard block
 block discarded – undo
1300 1300
      */
1301 1301
     public function updateFeedbackType($feedback_type)
1302 1302
     {
1303
-        $this->feedback_type=$feedback_type;
1303
+        $this->feedback_type = $feedback_type;
1304 1304
     }
1305 1305
 
1306 1306
     /**
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
      */
1312 1312
     public function updateDescription($description)
1313 1313
     {
1314
-        $this->description=$description;
1314
+        $this->description = $description;
1315 1315
     }
1316 1316
 
1317 1317
     /**
@@ -1441,23 +1441,23 @@  discard block
 block discarded – undo
1441 1441
      * @param string $sound - exercise sound file
1442 1442
      * @param string $delete - ask to delete the file
1443 1443
      */
1444
-    public function updateSound($sound,$delete)
1444
+    public function updateSound($sound, $delete)
1445 1445
     {
1446 1446
         global $audioPath, $documentPath;
1447 1447
         $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
1448 1448
 
1449
-        if ($sound['size'] && (strstr($sound['type'],'audio') || strstr($sound['type'],'video'))) {
1450
-            $this->sound=$sound['name'];
1449
+        if ($sound['size'] && (strstr($sound['type'], 'audio') || strstr($sound['type'], 'video'))) {
1450
+            $this->sound = $sound['name'];
1451 1451
 
1452
-            if (@move_uploaded_file($sound['tmp_name'],$audioPath.'/'.$this->sound)) {
1452
+            if (@move_uploaded_file($sound['tmp_name'], $audioPath.'/'.$this->sound)) {
1453 1453
                 $query = "SELECT 1 FROM $TBL_DOCUMENT
1454
-                        WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath,'',$audioPath).'/'.$this->sound."'";
1455
-                $result=Database::query($query);
1454
+                        WHERE c_id = ".$this->course_id." AND path='".str_replace($documentPath, '', $audioPath).'/'.$this->sound."'";
1455
+                $result = Database::query($query);
1456 1456
 
1457 1457
                 if (!Database::num_rows($result)) {
1458 1458
                     $id = add_document(
1459 1459
                         $this->course,
1460
-                        str_replace($documentPath,'',$audioPath).'/'.$this->sound,
1460
+                        str_replace($documentPath, '', $audioPath).'/'.$this->sound,
1461 1461
                         'file',
1462 1462
                         $sound['size'],
1463 1463
                         $sound['name']
@@ -1476,8 +1476,8 @@  discard block
 block discarded – undo
1476 1476
                     );
1477 1477
                 }
1478 1478
             }
1479
-        } elseif($delete && is_file($audioPath.'/'.$this->sound)) {
1480
-            $this->sound='';
1479
+        } elseif ($delete && is_file($audioPath.'/'.$this->sound)) {
1480
+            $this->sound = '';
1481 1481
         }
1482 1482
     }
1483 1483
 
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
      */
1490 1490
     public function updateType($type)
1491 1491
     {
1492
-        $this->type=$type;
1492
+        $this->type = $type;
1493 1493
     }
1494 1494
 
1495 1495
     /**
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
      */
1526 1526
     public function enable()
1527 1527
     {
1528
-        $this->active=1;
1528
+        $this->active = 1;
1529 1529
     }
1530 1530
 
1531 1531
     /**
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
      */
1536 1536
     public function disable()
1537 1537
     {
1538
-        $this->active=0;
1538
+        $this->active = 0;
1539 1539
     }
1540 1540
 
1541 1541
     /**
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
                 api_get_user_id()
1664 1664
             );
1665 1665
 
1666
-            if (api_get_setting('search_enabled')=='true') {
1666
+            if (api_get_setting('search_enabled') == 'true') {
1667 1667
                 $this->search_engine_edit();
1668 1668
             }
1669 1669
         } else {
@@ -1811,7 +1811,7 @@  discard block
 block discarded – undo
1811 1811
     public function removeFromList($questionId)
1812 1812
     {
1813 1813
         // searches the position of the question ID in the list
1814
-        $pos = array_search($questionId,$this->questionList);
1814
+        $pos = array_search($questionId, $this->questionList);
1815 1815
 
1816 1816
         // question not found
1817 1817
         if ($pos === false) {
@@ -1846,7 +1846,7 @@  discard block
 block discarded – undo
1846 1846
         api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'QuizDeleted', api_get_user_id());
1847 1847
         api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'delete', api_get_user_id());
1848 1848
 
1849
-        if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian') ) {
1849
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
1850 1850
             $this->search_engine_delete();
1851 1851
         }
1852 1852
     }
@@ -1855,7 +1855,7 @@  discard block
 block discarded – undo
1855 1855
      * Creates the form to create / edit an exercise
1856 1856
      * @param FormValidator $form
1857 1857
      */
1858
-    public function createForm($form, $type='full')
1858
+    public function createForm($form, $type = 'full')
1859 1859
     {
1860 1860
         if (empty($type)) {
1861 1861
             $type = 'full';
@@ -1886,7 +1886,7 @@  discard block
 block discarded – undo
1886 1886
             'Width' => '100%',
1887 1887
             'Height' => '150',
1888 1888
         );
1889
-        if (is_array($type)){
1889
+        if (is_array($type)) {
1890 1890
             $editor_config = array_merge($editor_config, $type);
1891 1891
         }
1892 1892
 
@@ -1940,13 +1940,13 @@  discard block
 block discarded – undo
1940 1940
                     '2',
1941 1941
                     array('id' => 'exerciseType_2')
1942 1942
                 );
1943
-                $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions')), '');
1943
+                $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')), '');
1944 1944
 
1945 1945
                 // Type of results display on the final page
1946 1946
                 $radios_results_disabled = array();
1947 1947
                 $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0'));
1948
-                $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
1949
-                $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2', array('id'=>'result_disabled_2'));
1948
+                $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()'));
1949
+                $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2'));
1950 1950
                 //$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ExamModeWithFinalScoreShowOnlyFinalScoreWithCategoriesIfAvailable'),  '3', array('id'=>'result_disabled_3','onclick' => 'check_results_disabled()'));
1951 1951
 
1952 1952
                 $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
@@ -1954,8 +1954,8 @@  discard block
 block discarded – undo
1954 1954
                 // Type of questions disposition on page
1955 1955
                 $radios = array();
1956 1956
 
1957
-                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
1958
-                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
1957
+                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
1958
+                $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
1959 1959
 
1960 1960
                 $form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
1961 1961
 
@@ -1965,33 +1965,33 @@  discard block
 block discarded – undo
1965 1965
 
1966 1966
                     // feedback type
1967 1967
                     $radios_feedback = array();
1968
-                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'),'0',array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()'));
1968
+                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()'));
1969 1969
 
1970 1970
                     if (api_get_setting('enable_quiz_scenario') == 'true') {
1971
-                        $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1' , 'onclick' => 'check_direct_feedback()'));
1971
+                        $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
1972 1972
                     }
1973
-                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2',array('id' =>'exerciseType_2'));
1974
-                    $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions')));
1973
+                    $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' =>'exerciseType_2'));
1974
+                    $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')));
1975 1975
 
1976 1976
                     //$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
1977 1977
                     $radios_results_disabled = array();
1978 1978
                     $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0'));
1979
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
1980
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()'));
1981
-                    $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),'');
1979
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()'));
1980
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()'));
1981
+                    $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
1982 1982
 
1983 1983
                     // Type of questions disposition on page
1984 1984
                     $radios = array();
1985
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1');
1986
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2');
1985
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1');
1986
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2');
1987 1987
                     $form->addGroup($radios, null, get_lang('ExerciseType'));
1988 1988
 
1989 1989
                 } else {
1990 1990
                     //Show options freeze
1991 1991
                     $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0'));
1992
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'),  '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()'));
1993
-                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'),  '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()'));
1994
-                    $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),'');
1992
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()'));
1993
+                    $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()'));
1994
+                    $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
1995 1995
                     $result_disable_group->freeze();
1996 1996
 
1997 1997
                     //we force the options to the DirectFeedback exercisetype
@@ -1999,8 +1999,8 @@  discard block
 block discarded – undo
1999 1999
                     $form->addElement('hidden', 'exerciseType', ONE_PER_PAGE);
2000 2000
 
2001 2001
                     // Type of questions disposition on page
2002
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'),    '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
2003
-                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
2002
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all'));
2003
+                    $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one'));
2004 2004
 
2005 2005
                     $type_group = $form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
2006 2006
                     $type_group->freeze();
@@ -2132,26 +2132,26 @@  discard block
 block discarded – undo
2132 2132
 
2133 2133
                 // number of random question
2134 2134
 
2135
-                $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10 ;
2135
+                $max = ($this->id > 0) ? $this->selectNbrQuestions() : 10;
2136 2136
                 $option = range(0, $max);
2137 2137
                 $option[0] = get_lang('No');
2138 2138
                 $option[-1] = get_lang('AllQuestionsShort');
2139
-                $form->addElement('select', 'randomQuestions',array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions'));
2139
+                $form->addElement('select', 'randomQuestions', array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id'=>'randomQuestions'));
2140 2140
 
2141 2141
                 // Random answers
2142 2142
                 $radios_random_answers = array();
2143
-                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'),'1');
2144
-                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'),'0');
2143
+                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'), '1');
2144
+                $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'), '0');
2145 2145
                 $form->addGroup($radios_random_answers, null, get_lang('RandomAnswers'), '');
2146 2146
 
2147 2147
                 // Random by category
2148
-                $form->addElement('html','<div class="clear">&nbsp;</div>');
2148
+                $form->addElement('html', '<div class="clear">&nbsp;</div>');
2149 2149
                 $radiocat = array();
2150
-                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'),'1');
2151
-                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'),'2');
2152
-                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'),'0');
2150
+                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'), '1');
2151
+                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'), '2');
2152
+                $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'), '0');
2153 2153
                 $radioCatGroup = $form->addGroup($radiocat, null, get_lang('RandomQuestionByCategory'), '');
2154
-                $form->addElement('html','<div class="clear">&nbsp;</div>');
2154
+                $form->addElement('html', '<div class="clear">&nbsp;</div>');
2155 2155
 
2156 2156
                 // add the radio display the category name for student
2157 2157
                 $radio_display_cat_name = array();
@@ -2172,36 +2172,36 @@  discard block
 block discarded – undo
2172 2172
             );
2173 2173
 
2174 2174
             // Exercise time limit
2175
-            $form->addElement('checkbox', 'activate_start_date_check',null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
2175
+            $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
2176 2176
 
2177 2177
             $var = Exercise::selectTimeLimit();
2178 2178
 
2179 2179
             if (($this->start_time != '0000-00-00 00:00:00'))
2180
-                $form->addElement('html','<div id="start_date_div" style="display:block;">');
2180
+                $form->addElement('html', '<div id="start_date_div" style="display:block;">');
2181 2181
             else
2182
-                $form->addElement('html','<div id="start_date_div" style="display:none;">');
2182
+                $form->addElement('html', '<div id="start_date_div" style="display:none;">');
2183 2183
 
2184 2184
             $form->addElement('date_time_picker', 'start_time');
2185 2185
 
2186
-            $form->addElement('html','</div>');
2186
+            $form->addElement('html', '</div>');
2187 2187
 
2188
-            $form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
2188
+            $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
2189 2189
 
2190 2190
             if (($this->end_time != '0000-00-00 00:00:00'))
2191
-                $form->addElement('html','<div id="end_date_div" style="display:block;">');
2191
+                $form->addElement('html', '<div id="end_date_div" style="display:block;">');
2192 2192
             else
2193
-                $form->addElement('html','<div id="end_date_div" style="display:none;">');
2193
+                $form->addElement('html', '<div id="end_date_div" style="display:none;">');
2194 2194
 
2195 2195
             $form->addElement('date_time_picker', 'end_time');
2196
-            $form->addElement('html','</div>');
2196
+            $form->addElement('html', '</div>');
2197 2197
 
2198 2198
             //$check_option=$this->selectType();
2199 2199
             $diplay = 'block';
2200 2200
             $form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults'));
2201
-            $form->addElement('html','<div class="clear">&nbsp;</div>');
2201
+            $form->addElement('html', '<div class="clear">&nbsp;</div>');
2202 2202
             $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers'));
2203 2203
 
2204
-            $form->addElement('html','<div id="divtimecontrol"  style="display:'.$diplay.';">');
2204
+            $form->addElement('html', '<div id="divtimecontrol"  style="display:'.$diplay.';">');
2205 2205
 
2206 2206
             //Timer control
2207 2207
             //$time_hours_option = range(0,12);
@@ -2217,12 +2217,12 @@  discard block
 block discarded – undo
2217 2217
                     'onload' => 'check_load_time()',
2218 2218
                 )
2219 2219
             );
2220
-            $expired_date = (int)$this->selectExpiredTime();
2220
+            $expired_date = (int) $this->selectExpiredTime();
2221 2221
 
2222
-            if (($expired_date!='0')) {
2223
-                $form->addElement('html','<div id="timercontrol" style="display:block;">');
2222
+            if (($expired_date != '0')) {
2223
+                $form->addElement('html', '<div id="timercontrol" style="display:block;">');
2224 2224
             } else {
2225
-                $form->addElement('html','<div id="timercontrol" style="display:none;">');
2225
+                $form->addElement('html', '<div id="timercontrol" style="display:none;">');
2226 2226
             }
2227 2227
             $form->addText(
2228 2228
                 'enabletimercontroltotalminutes',
@@ -2233,7 +2233,7 @@  discard block
 block discarded – undo
2233 2233
                     'cols-size' => [2, 2, 8]
2234 2234
                 ]
2235 2235
             );
2236
-            $form->addElement('html','</div>');
2236
+            $form->addElement('html', '</div>');
2237 2237
 
2238 2238
             $form->addElement(
2239 2239
                 'text',
@@ -2255,23 +2255,23 @@  discard block
 block discarded – undo
2255 2255
             $defaults = array();
2256 2256
 
2257 2257
             if (api_get_setting('search_enabled') === 'true') {
2258
-                require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
2258
+                require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2259 2259
 
2260
-                $form->addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
2261
-                $form->addElement ('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
2260
+                $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
2261
+                $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
2262 2262
 
2263 2263
                 $specific_fields = get_specific_field_list();
2264 2264
 
2265 2265
                 foreach ($specific_fields as $specific_field) {
2266
-                    $form->addElement ('text', $specific_field['code'], $specific_field['name']);
2266
+                    $form->addElement('text', $specific_field['code'], $specific_field['name']);
2267 2267
                     $filter = array(
2268 2268
                         'c_id' => api_get_course_int_id(),
2269 2269
                         'field_id' => $specific_field['id'],
2270 2270
                         'ref_id' => $this->id,
2271
-                        'tool_id' => "'" . TOOL_QUIZ . "'"
2271
+                        'tool_id' => "'".TOOL_QUIZ."'"
2272 2272
                     );
2273 2273
                     $values = get_specific_field_values_list($filter, array('value'));
2274
-                    if ( !empty($values) ) {
2274
+                    if (!empty($values)) {
2275 2275
                         $arr_str_values = array();
2276 2276
                         foreach ($values as $value) {
2277 2277
                             $arr_str_values[] = $value['value'];
@@ -2282,8 +2282,8 @@  discard block
 block discarded – undo
2282 2282
                 //$form->addElement ('html','</div>');
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
                 }
@@ -2333,8 +2333,8 @@  discard block
 block discarded – undo
2333 2333
                     $defaults['activate_end_date_check'] = 1;
2334 2334
                 }
2335 2335
 
2336
-                $defaults['start_time'] = ($this->start_time!='0000-00-00 00:00:00') ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00');
2337
-                $defaults['end_time'] = ($this->end_time!='0000-00-00 00:00:00') ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time()+84600);
2336
+                $defaults['start_time'] = ($this->start_time != '0000-00-00 00:00:00') ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00');
2337
+                $defaults['end_time'] = ($this->end_time != '0000-00-00 00:00:00') ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time() + 84600);
2338 2338
 
2339 2339
                 // Get expired time
2340 2340
                 if ($this->expired_time != '0') {
@@ -2355,7 +2355,7 @@  discard block
 block discarded – undo
2355 2355
                 $defaults['text_when_finished'] = "";
2356 2356
                 $defaults['start_time'] = date('Y-m-d 12:00:00');
2357 2357
                 $defaults['display_category_name'] = 1;
2358
-                $defaults['end_time']   = date('Y-m-d 12:00:00', time()+84600);
2358
+                $defaults['end_time']   = date('Y-m-d 12:00:00', time() + 84600);
2359 2359
                 $defaults['pass_percentage'] = '';
2360 2360
                 $defaults['end_button'] = $this->selectEndButton();
2361 2361
                 $defaults['question_selection_type'] = 1;
@@ -2441,7 +2441,7 @@  discard block
 block discarded – undo
2441 2441
             $end_time = $form->getSubmitValue('end_time');
2442 2442
             $this->end_time = api_get_utc_datetime($end_time);
2443 2443
         } else {
2444
-            $this->end_time   = '0000-00-00 00:00:00';
2444
+            $this->end_time = '0000-00-00 00:00:00';
2445 2445
         }
2446 2446
 
2447 2447
         if ($form->getSubmitValue('enabletimercontrol') == 1) {
@@ -2454,9 +2454,9 @@  discard block
 block discarded – undo
2454 2454
         }
2455 2455
 
2456 2456
         if ($form->getSubmitValue('randomAnswers') == 1) {
2457
-            $this->random_answers=1;
2457
+            $this->random_answers = 1;
2458 2458
         } else {
2459
-            $this->random_answers=0;
2459
+            $this->random_answers = 0;
2460 2460
         }
2461 2461
         $this->save($type);
2462 2462
     }
@@ -2468,9 +2468,9 @@  discard block
 block discarded – undo
2468 2468
         }
2469 2469
         $course_id = api_get_course_id();
2470 2470
 
2471
-        require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
2472
-        require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
2473
-        require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
2471
+        require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
2472
+        require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php';
2473
+        require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2474 2474
 
2475 2475
         $specific_fields = get_specific_field_list();
2476 2476
         $ic_slide = new IndexableChunk();
@@ -2480,7 +2480,7 @@  discard block
 block discarded – undo
2480 2480
             if (isset($_REQUEST[$specific_field['code']])) {
2481 2481
                 $sterms = trim($_REQUEST[$specific_field['code']]);
2482 2482
                 if (!empty($sterms)) {
2483
-                    $all_specific_terms .= ' '. $sterms;
2483
+                    $all_specific_terms .= ' '.$sterms;
2484 2484
                     $sterms = explode(',', $sterms);
2485 2485
                     foreach ($sterms as $sterm) {
2486 2486
                         $ic_slide->addTerm(trim($sterm), $specific_field['code']);
@@ -2497,15 +2497,15 @@  discard block
 block discarded – undo
2497 2497
         $xapian_data = array(
2498 2498
             SE_COURSE_ID => $course_id,
2499 2499
             SE_TOOL_ID => TOOL_QUIZ,
2500
-            SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id),
2501
-            SE_USER => (int)api_get_user_id(),
2500
+            SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id),
2501
+            SE_USER => (int) api_get_user_id(),
2502 2502
         );
2503 2503
         $ic_slide->xapian_data = serialize($xapian_data);
2504
-        $exercise_description = $all_specific_terms .' '. $this->description;
2504
+        $exercise_description = $all_specific_terms.' '.$this->description;
2505 2505
         $ic_slide->addValue("content", $exercise_description);
2506 2506
 
2507 2507
         $di = new ChamiloIndexer();
2508
-        isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
2508
+        isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english';
2509 2509
         $di->connectDb(NULL, NULL, $lang);
2510 2510
         $di->addChunk($ic_slide);
2511 2511
 
@@ -2524,7 +2524,7 @@  discard block
 block discarded – undo
2524 2524
     function search_engine_edit()
2525 2525
     {
2526 2526
         // update search enchine and its values table if enabled
2527
-        if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) {
2527
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
2528 2528
             $course_id = api_get_course_id();
2529 2529
 
2530 2530
             // actually, it consists on delete terms from db,
@@ -2536,9 +2536,9 @@  discard block
 block discarded – undo
2536 2536
             $res = Database::query($sql);
2537 2537
 
2538 2538
             if (Database::num_rows($res) > 0) {
2539
-                require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php');
2540
-                require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php');
2541
-                require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
2539
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
2540
+                require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php');
2541
+                require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php');
2542 2542
 
2543 2543
                 $se_ref = Database::fetch_array($res);
2544 2544
                 $specific_fields = get_specific_field_list();
@@ -2549,7 +2549,7 @@  discard block
 block discarded – undo
2549 2549
                     delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_QUIZ, $this->id);
2550 2550
                     if (isset($_REQUEST[$specific_field['code']])) {
2551 2551
                         $sterms = trim($_REQUEST[$specific_field['code']]);
2552
-                        $all_specific_terms .= ' '. $sterms;
2552
+                        $all_specific_terms .= ' '.$sterms;
2553 2553
                         $sterms = explode(',', $sterms);
2554 2554
                         foreach ($sterms as $sterm) {
2555 2555
                             $ic_slide->addTerm(trim($sterm), $specific_field['code']);
@@ -2565,17 +2565,17 @@  discard block
 block discarded – undo
2565 2565
                 $xapian_data = array(
2566 2566
                     SE_COURSE_ID => $course_id,
2567 2567
                     SE_TOOL_ID => TOOL_QUIZ,
2568
-                    SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id),
2569
-                    SE_USER => (int)api_get_user_id(),
2568
+                    SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id),
2569
+                    SE_USER => (int) api_get_user_id(),
2570 2570
                 );
2571 2571
                 $ic_slide->xapian_data = serialize($xapian_data);
2572
-                $exercise_description = $all_specific_terms .' '. $this->description;
2572
+                $exercise_description = $all_specific_terms.' '.$this->description;
2573 2573
                 $ic_slide->addValue("content", $exercise_description);
2574 2574
 
2575 2575
                 $di = new ChamiloIndexer();
2576
-                isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
2576
+                isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english';
2577 2577
                 $di->connectDb(NULL, NULL, $lang);
2578
-                $di->remove_document((int)$se_ref['search_did']);
2578
+                $di->remove_document((int) $se_ref['search_did']);
2579 2579
                 $di->addChunk($ic_slide);
2580 2580
 
2581 2581
                 //index and return search engine document id
@@ -2600,7 +2600,7 @@  discard block
 block discarded – undo
2600 2600
     function search_engine_delete()
2601 2601
     {
2602 2602
         // remove from search engine if enabled
2603
-        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian') ) {
2603
+        if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
2604 2604
             $course_id = api_get_course_id();
2605 2605
             $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
2606 2606
             $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';
@@ -2608,19 +2608,19 @@  discard block
 block discarded – undo
2608 2608
             $res = Database::query($sql);
2609 2609
             if (Database::num_rows($res) > 0) {
2610 2610
                 $row = Database::fetch_array($res);
2611
-                require_once(api_get_path(LIBRARY_PATH) .'search/ChamiloIndexer.class.php');
2611
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
2612 2612
                 $di = new ChamiloIndexer();
2613
-                $di->remove_document((int)$row['search_did']);
2613
+                $di->remove_document((int) $row['search_did']);
2614 2614
                 unset($di);
2615 2615
                 $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
2616
-                foreach ( $this->questionList as $question_i) {
2616
+                foreach ($this->questionList as $question_i) {
2617 2617
                     $sql = 'SELECT type FROM %s WHERE id=%s';
2618 2618
                     $sql = sprintf($sql, $tbl_quiz_question, $question_i);
2619 2619
                     $qres = Database::query($sql);
2620 2620
                     if (Database::num_rows($qres) > 0) {
2621 2621
                         $qrow = Database::fetch_array($qres);
2622 2622
                         $objQuestion = Question::getInstance($qrow['type']);
2623
-                        $objQuestion = Question::read((int)$question_i);
2623
+                        $objQuestion = Question::read((int) $question_i);
2624 2624
                         $objQuestion->search_engine_edit($this->id, FALSE, TRUE);
2625 2625
                         unset($objQuestion);
2626 2626
                     }
@@ -2631,7 +2631,7 @@  discard block
 block discarded – undo
2631 2631
             Database::query($sql);
2632 2632
 
2633 2633
             // remove terms from db
2634
-            require_once api_get_path(LIBRARY_PATH) .'specific_fields_manager.lib.php';
2634
+            require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
2635 2635
             delete_all_values_for_item($course_id, TOOL_QUIZ, $this->id);
2636 2636
         }
2637 2637
     }
@@ -2726,7 +2726,7 @@  discard block
 block discarded – undo
2726 2726
      */
2727 2727
     public function copy_exercise()
2728 2728
     {
2729
-        $exercise_obj= new Exercise();
2729
+        $exercise_obj = new Exercise();
2730 2730
         $exercise_obj = $this;
2731 2731
 
2732 2732
         // force the creation of a new exercise
@@ -2798,25 +2798,25 @@  discard block
 block discarded – undo
2798 2798
             $lp_id = 0;
2799 2799
         }
2800 2800
         if (empty($lp_item_id)) {
2801
-            $lp_item_id   = 0;
2801
+            $lp_item_id = 0;
2802 2802
         }
2803 2803
         if (empty($lp_item_view_id)) {
2804 2804
             $lp_item_view_id = 0;
2805 2805
         }
2806
-        $condition = ' WHERE exe_exo_id 	= ' . "'" . $this->id . "'" .' AND
2807
-					   exe_user_id 			= ' . "'" . api_get_user_id() . "'" . ' AND
2808
-					   c_id                 = ' . api_get_course_int_id() . ' AND
2809
-					   status 				= ' . "'" . Database::escape_string($status). "'" . ' AND
2810
-					   orig_lp_id 			= ' . "'" . $lp_id . "'" . ' AND
2811
-					   orig_lp_item_id 		= ' . "'" . $lp_item_id . "'" . ' AND
2812
-                       orig_lp_item_view_id = ' . "'" . $lp_item_view_id . "'" . ' AND
2813
-					   session_id 			= ' . "'" . api_get_session_id() . "' LIMIT 1"; //Adding limit 1 just in case
2806
+        $condition = ' WHERE exe_exo_id 	= '."'".$this->id."'".' AND
2807
+					   exe_user_id 			= ' . "'".api_get_user_id()."'".' AND
2808
+					   c_id                 = ' . api_get_course_int_id().' AND
2809
+					   status 				= ' . "'".Database::escape_string($status)."'".' AND
2810
+					   orig_lp_id 			= ' . "'".$lp_id."'".' AND
2811
+					   orig_lp_item_id 		= ' . "'".$lp_item_id."'".' AND
2812
+                       orig_lp_item_view_id = ' . "'".$lp_item_view_id."'".' AND
2813
+					   session_id 			= ' . "'".api_get_session_id()."' LIMIT 1"; //Adding limit 1 just in case
2814 2814
 
2815 2815
         $sql_track = 'SELECT * FROM '.$track_exercises.$condition;
2816 2816
 
2817 2817
         $result = Database::query($sql_track);
2818 2818
         $new_array = array();
2819
-        if (Database::num_rows($result) > 0 ) {
2819
+        if (Database::num_rows($result) > 0) {
2820 2820
             $new_array = Database::fetch_array($result, 'ASSOC');
2821 2821
             $new_array['num_exe'] = Database::num_rows($result);
2822 2822
         }
@@ -2859,12 +2859,12 @@  discard block
 block discarded – undo
2859 2859
         $questionList = array_map('intval', $questionList);
2860 2860
 
2861 2861
         $params = array(
2862
-            'exe_exo_id' => $this->id ,
2862
+            'exe_exo_id' => $this->id,
2863 2863
             'exe_user_id' => api_get_user_id(),
2864 2864
             'c_id' => api_get_course_int_id(),
2865 2865
             'status' =>  'incomplete',
2866 2866
             'session_id'  => api_get_session_id(),
2867
-            'data_tracking'  => implode(',', $questionList) ,
2867
+            'data_tracking'  => implode(',', $questionList),
2868 2868
             'start_date' => api_get_utc_datetime(),
2869 2869
             'orig_lp_id' => $safe_lp_id,
2870 2870
             'orig_lp_item_id'  => $safe_lp_item_id,
@@ -2896,7 +2896,7 @@  discard block
 block discarded – undo
2896 2896
         $nbrQuestions = $this->get_count_question_list();
2897 2897
 
2898 2898
         $all_button = $html = $label = '';
2899
-        $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']):null;
2899
+        $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null;
2900 2900
 
2901 2901
         if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) {
2902 2902
             $urlTitle = get_lang('ContinueTest');
@@ -2907,7 +2907,7 @@  discard block
 block discarded – undo
2907 2907
 
2908 2908
             $html .= Display::url(
2909 2909
                 $urlTitle,
2910
-                'exercise_submit_modal.php?' . http_build_query([
2910
+                'exercise_submit_modal.php?'.http_build_query([
2911 2911
                     'learnpath_id' => $safe_lp_id,
2912 2912
                     'learnpath_item_id' => $safe_lp_item_id,
2913 2913
                     'learnpath_item_view_id' => $safe_lp_item_view_id,
@@ -2924,7 +2924,7 @@  discard block
 block discarded – undo
2924 2924
                     'data-size' => 'md'
2925 2925
                 ]
2926 2926
             );
2927
-            $html .='<br />';
2927
+            $html .= '<br />';
2928 2928
         } else {
2929 2929
             // User
2930 2930
             if (api_is_allowed_to_session_edit()) {
@@ -2949,7 +2949,7 @@  discard block
 block discarded – undo
2949 2949
 
2950 2950
                     //Next question
2951 2951
                     if (!empty($questions_in_media)) {
2952
-                        $questions_in_media = "['".implode("','",$questions_in_media)."']";
2952
+                        $questions_in_media = "['".implode("','", $questions_in_media)."']";
2953 2953
                         $all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_question_list('.$questions_in_media.'); ">'.$label.'</a>';
2954 2954
                     } else {
2955 2955
                         $all_button .= '&nbsp;<a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.', \'\', \''.$currentAnswer.'\'); ">'.$label.'</a>';
@@ -2967,7 +2967,7 @@  discard block
 block discarded – undo
2967 2967
                     }
2968 2968
 					$class .= ' question-validate-btn'; // used to select it with jquery
2969 2969
                     $all_button = '&nbsp;<a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>';
2970
-                    $all_button .= '&nbsp;' . Display::span(null, ['id' => 'save_all_reponse']);
2970
+                    $all_button .= '&nbsp;'.Display::span(null, ['id' => 'save_all_reponse']);
2971 2971
                     $html .= $all_button;
2972 2972
                 }
2973 2973
             }
@@ -3209,8 +3209,8 @@  discard block
 block discarded – undo
3209 3209
             $params = array();
3210 3210
             $params['course_id'] = $course_id;
3211 3211
             $params['session_id'] = api_get_session_id();
3212
-            $params['user_id'] = isset($exe_info['exe_user_id'])? $exe_info['exe_user_id'] : api_get_user_id();
3213
-            $params['exercise_id'] = isset($exe_info['exe_exo_id'])? $exe_info['exe_exo_id'] : $this->id;
3212
+            $params['user_id'] = isset($exe_info['exe_user_id']) ? $exe_info['exe_user_id'] : api_get_user_id();
3213
+            $params['exercise_id'] = isset($exe_info['exe_exo_id']) ? $exe_info['exe_exo_id'] : $this->id;
3214 3214
             $params['question_id'] = $questionId;
3215 3215
             $params['exe_id'] = isset($exe_info['exe_id']) ? $exe_info['exe_id'] : $exeId;
3216 3216
 
@@ -3266,10 +3266,10 @@  discard block
 block discarded – undo
3266 3266
             $answer = $objAnswerTmp->selectAnswer($answerId);
3267 3267
             $answerComment = $objAnswerTmp->selectComment($answerId);
3268 3268
             $answerCorrect = $objAnswerTmp->isCorrect($answerId);
3269
-            $answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId);
3269
+            $answerWeighting = (float) $objAnswerTmp->selectWeighting($answerId);
3270 3270
             $answerAutoId = $objAnswerTmp->selectAutoId($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 {
@@ -3753,10 +3753,10 @@  discard block
 block discarded – undo
3753 3753
                         }
3754 3754
                         // adds the piece of text that is before the blank
3755 3755
                         //and ends with '[' into a general storage array
3756
-                        $realText[] = api_substr($temp, 0, $pos +1);
3757
-                        $answer .= api_substr($temp, 0, $pos +1);
3756
+                        $realText[] = api_substr($temp, 0, $pos + 1);
3757
+                        $answer .= api_substr($temp, 0, $pos + 1);
3758 3758
                         //take the string remaining (after the last "[" we found)
3759
-                        $temp = api_substr($temp, $pos +1);
3759
+                        $temp = api_substr($temp, $pos + 1);
3760 3760
                         // quit the loop if there are no more blanks, and update $pos to the position of next ']'
3761 3761
                         if (($pos = api_strpos($temp, ']')) === false) {
3762 3762
                             // adds the end of the text
@@ -3790,7 +3790,7 @@  discard block
 block discarded – undo
3790 3790
                         //put the contents of the [] answer tag into correct_tags[]
3791 3791
                         $correctTags[] = api_substr($temp, 0, $pos);
3792 3792
                         $j++;
3793
-                        $temp = api_substr($temp, $pos +1);
3793
+                        $temp = api_substr($temp, $pos + 1);
3794 3794
                     }
3795 3795
                     $answer = '';
3796 3796
                     $realCorrectTags = $correctTags;
@@ -3810,22 +3810,22 @@  discard block
 block discarded – undo
3810 3810
                         } elseif (!empty($userTags[$i])) {
3811 3811
                             // else if the word entered by the student IS NOT the same as the one defined by the professor
3812 3812
                             // adds the word in red at the end of the string, and strikes it
3813
-                            $answer .= '<font color="red"><s>' . $userTags[$i] . '</s></font>';
3813
+                            $answer .= '<font color="red"><s>'.$userTags[$i].'</s></font>';
3814 3814
                         } else {
3815 3815
                             // adds a tabulation if no word has been typed by the student
3816 3816
                             $answer .= ''; // remove &nbsp; that causes issue
3817 3817
                         }
3818 3818
                         // adds the correct word, followed by ] to close the blank
3819
-                        $answer .= ' / <font color="green"><b>' . $realCorrectTags[$i] . '</b></font>]';
3820
-                        if (isset($realText[$i +1])) {
3821
-                            $answer .= $realText[$i +1];
3819
+                        $answer .= ' / <font color="green"><b>'.$realCorrectTags[$i].'</b></font>]';
3820
+                        if (isset($realText[$i + 1])) {
3821
+                            $answer .= $realText[$i + 1];
3822 3822
                         }
3823 3823
                     }
3824 3824
                     break;
3825 3825
                 // for free answer
3826 3826
                 case FREE_ANSWER:
3827 3827
                     if ($from_database) {
3828
-                        $query  = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3828
+                        $query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3829 3829
                                    WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3830 3830
                         $resq = Database::query($query);
3831 3831
                         $data = Database::fetch_array($resq);
@@ -3836,9 +3836,9 @@  discard block
 block discarded – undo
3836 3836
                         $questionScore = $data['marks'];
3837 3837
 
3838 3838
                         if ($questionScore == -1) {
3839
-                            $totalScore+= 0;
3839
+                            $totalScore += 0;
3840 3840
                         } else {
3841
-                            $totalScore+= $questionScore;
3841
+                            $totalScore += $questionScore;
3842 3842
                         }
3843 3843
                         if ($questionScore == '') {
3844 3844
                             $questionScore = 0;
@@ -3859,14 +3859,14 @@  discard block
 block discarded – undo
3859 3859
                         $query  = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
3860 3860
                                    WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3861 3861
                         $resq   = Database::query($query);
3862
-                        $choice = Database::result($resq,0,'answer');
3862
+                        $choice = Database::result($resq, 0, 'answer');
3863 3863
                         $choice = str_replace('\r\n', '', $choice);
3864 3864
                         $choice = stripslashes($choice);
3865
-                        $questionScore = Database::result($resq,0,"marks");
3866
-                        if ($questionScore==-1) {
3867
-                            $totalScore+=0;
3865
+                        $questionScore = Database::result($resq, 0, "marks");
3866
+                        if ($questionScore == -1) {
3867
+                            $totalScore += 0;
3868 3868
                         } else {
3869
-                            $totalScore+=$questionScore;
3869
+                            $totalScore += $questionScore;
3870 3870
                         }
3871 3871
                         $arrques = $questionName;
3872 3872
                         $arrans  = $choice;
@@ -3911,7 +3911,7 @@  discard block
 block discarded – undo
3911 3911
 
3912 3912
                         while ($a_answers = Database::fetch_array($res_answers)) {
3913 3913
                             $i_answer_id = $a_answers['id']; //3
3914
-                            $s_answer_label = $a_answers['answer'];  // your daddy - your mother
3914
+                            $s_answer_label = $a_answers['answer']; // your daddy - your mother
3915 3915
                             $i_answer_correct_answer = $a_answers['correct']; //1 - 2
3916 3916
                             $i_answer_id_auto = $a_answers['id_auto']; // 3 - 4
3917 3917
 
@@ -3963,8 +3963,8 @@  discard block
 block discarded – undo
3963 3963
 
3964 3964
                             if ($show_result) {
3965 3965
                                 echo '<tr>';
3966
-                                echo '<td>' . $s_answer_label . '</td>';
3967
-                                echo '<td>' . $user_answer;
3966
+                                echo '<td>'.$s_answer_label.'</td>';
3967
+                                echo '<td>'.$user_answer;
3968 3968
 
3969 3969
                                 if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
3970 3970
                                     if (isset($real_list[$i_answer_correct_answer])) {
@@ -4073,7 +4073,7 @@  discard block
 block discarded – undo
4073 4073
                     if ($from_database) {
4074 4074
                         // getting the user answer
4075 4075
                         $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
4076
-                        $query   = "SELECT hotspot_correct, hotspot_coordinate
4076
+                        $query = "SELECT hotspot_correct, hotspot_coordinate
4077 4077
                                     FROM $TBL_TRACK_HOTSPOT
4078 4078
                                     WHERE
4079 4079
                                         hotspot_exe_id = '".$exeId."' AND
@@ -4081,20 +4081,20 @@  discard block
 block discarded – undo
4081 4081
                                         hotspot_answer_id='1'";
4082 4082
                         //by default we take 1 because it's a delineation
4083 4083
                         $resq = Database::query($query);
4084
-                        $row = Database::fetch_array($resq,'ASSOC');
4084
+                        $row = Database::fetch_array($resq, 'ASSOC');
4085 4085
 
4086 4086
                         $choice = $row['hotspot_correct'];
4087 4087
                         $user_answer = $row['hotspot_coordinate'];
4088 4088
 
4089 4089
                         // THIS is very important otherwise the poly_compile will throw an error!!
4090 4090
                         // round-up the coordinates
4091
-                        $coords = explode('/',$user_answer);
4091
+                        $coords = explode('/', $user_answer);
4092 4092
                         $user_array = '';
4093 4093
                         foreach ($coords as $coord) {
4094
-                            list($x,$y) = explode(';',$coord);
4094
+                            list($x, $y) = explode(';', $coord);
4095 4095
                             $user_array .= round($x).';'.round($y).'/';
4096 4096
                         }
4097
-                        $user_array = substr($user_array,0,-1);
4097
+                        $user_array = substr($user_array, 0, -1);
4098 4098
                     } else {
4099 4099
                         if (!empty($studentChoice)) {
4100 4100
                             $newquestionList[] = $questionId;
@@ -4104,13 +4104,13 @@  discard block
 block discarded – undo
4104 4104
                             $studentChoice = $choice[$answerId];
4105 4105
                             $questionScore += $answerWeighting;
4106 4106
 
4107
-                            if ($hotspot_delineation_result[1]==1) {
4107
+                            if ($hotspot_delineation_result[1] == 1) {
4108 4108
                                 $totalScore += $answerWeighting; //adding the total
4109 4109
                             }
4110 4110
                         }
4111 4111
                     }
4112
-                    $_SESSION['hotspot_coord'][1]	= $delineation_cord;
4113
-                    $_SESSION['hotspot_dest'][1]	= $answer_delineation_destination;
4112
+                    $_SESSION['hotspot_coord'][1] = $delineation_cord;
4113
+                    $_SESSION['hotspot_dest'][1] = $answer_delineation_destination;
4114 4114
                     break;
4115 4115
             } // end switch Answertype
4116 4116
 
@@ -4168,7 +4168,7 @@  discard block
 block discarded – undo
4168 4168
                                 $results_disabled
4169 4169
                             );
4170 4170
                             //}
4171
-                        } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
4171
+                        } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
4172 4172
                             //	if ($origin!='learnpath') {
4173 4173
                             ExerciseShowFunctions::display_multiple_answer_combination_true_false(
4174 4174
                                 $feedback_type,
@@ -4185,11 +4185,11 @@  discard block
 block discarded – undo
4185 4185
                             //}
4186 4186
                         } elseif ($answerType == FILL_IN_BLANKS) {
4187 4187
                             //if ($origin!='learnpath') {
4188
-                            ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer,0,0, $results_disabled);
4188
+                            ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer, 0, 0, $results_disabled);
4189 4189
                             //	}
4190 4190
                         } elseif ($answerType == CALCULATED_ANSWER) {
4191 4191
                             //if ($origin!='learnpath') {
4192
-                            ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer,0,0);
4192
+                            ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer, 0, 0);
4193 4193
                             //  }
4194 4194
                         } elseif ($answerType == FREE_ANSWER) {
4195 4195
                             //if($origin != 'learnpath') {
@@ -4243,13 +4243,13 @@  discard block
 block discarded – undo
4243 4243
                             $user_answer = $_SESSION['exerciseResultCoordinates'][$questionId];
4244 4244
 
4245 4245
                             //round-up the coordinates
4246
-                            $coords = explode('/',$user_answer);
4246
+                            $coords = explode('/', $user_answer);
4247 4247
                             $user_array = '';
4248 4248
                             foreach ($coords as $coord) {
4249
-                                list($x,$y) = explode(';',$coord);
4249
+                                list($x, $y) = explode(';', $coord);
4250 4250
                                 $user_array .= round($x).';'.round($y).'/';
4251 4251
                             }
4252
-                            $user_array = substr($user_array,0,-1);
4252
+                            $user_array = substr($user_array, 0, -1);
4253 4253
 
4254 4254
                             if ($next) {
4255 4255
 
@@ -4276,7 +4276,7 @@  discard block
 block discarded – undo
4276 4276
                                 //$overlap = round(polygons_overlap($poly_answer,$poly_user));
4277 4277
                                 // //this is an area in pixels
4278 4278
                                 if ($debug > 0) {
4279
-                                    error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0);
4279
+                                    error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0);
4280 4280
                                 }
4281 4281
 
4282 4282
                                 if ($overlap < 1) {
@@ -4289,43 +4289,43 @@  discard block
 block discarded – undo
4289 4289
                                     // that is overlapped by the user's polygon
4290 4290
                                     $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
4291 4291
                                     if ($debug > 1) {
4292
-                                        error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
4292
+                                        error_log(__LINE__.' - Final overlap is '.$final_overlap, 0);
4293 4293
                                     }
4294 4294
                                     // the final missing area is the percentage of the initial polygon
4295 4295
                                     // that is not overlapped by the user's polygon
4296 4296
                                     $final_missing = 100 - $final_overlap;
4297 4297
                                     if ($debug > 1) {
4298
-                                        error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
4298
+                                        error_log(__LINE__.' - Final missing is '.$final_missing, 0);
4299 4299
                                     }
4300 4300
                                     // the final excess area is the percentage of the initial polygon's size
4301 4301
                                     // that is covered by the user's polygon outside of the initial polygon
4302 4302
                                     $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
4303 4303
                                     if ($debug > 1) {
4304
-                                        error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0);
4304
+                                        error_log(__LINE__.' - Final excess is '.$final_excess, 0);
4305 4305
                                     }
4306 4306
                                 }
4307 4307
 
4308 4308
                                 //checking the destination parameters parsing the "@@"
4309
-                                $destination_items= explode('@@', $answerDestination);
4309
+                                $destination_items = explode('@@', $answerDestination);
4310 4310
                                 $threadhold_total = $destination_items[0];
4311
-                                $threadhold_items=explode(';',$threadhold_total);
4311
+                                $threadhold_items = explode(';', $threadhold_total);
4312 4312
                                 $threadhold1 = $threadhold_items[0]; // overlap
4313 4313
                                 $threadhold2 = $threadhold_items[1]; // excess
4314
-                                $threadhold3 = $threadhold_items[2];	 //missing
4314
+                                $threadhold3 = $threadhold_items[2]; //missing
4315 4315
 
4316 4316
                                 // if is delineation
4317
-                                if ($answerId===1) {
4317
+                                if ($answerId === 1) {
4318 4318
                                     //setting colors
4319
-                                    if ($final_overlap>=$threadhold1) {
4320
-                                        $overlap_color=true; //echo 'a';
4319
+                                    if ($final_overlap >= $threadhold1) {
4320
+                                        $overlap_color = true; //echo 'a';
4321 4321
                                     }
4322 4322
                                     //echo $excess.'-'.$threadhold2;
4323
-                                    if ($final_excess<=$threadhold2) {
4324
-                                        $excess_color=true; //echo 'b';
4323
+                                    if ($final_excess <= $threadhold2) {
4324
+                                        $excess_color = true; //echo 'b';
4325 4325
                                     }
4326 4326
                                     //echo '--------'.$missing.'-'.$threadhold3;
4327
-                                    if ($final_missing<=$threadhold3) {
4328
-                                        $missing_color=true; //echo 'c';
4327
+                                    if ($final_missing <= $threadhold3) {
4328
+                                        $missing_color = true; //echo 'c';
4329 4329
                                     }
4330 4330
 
4331 4331
                                     // if pass
@@ -4334,67 +4334,67 @@  discard block
 block discarded – undo
4334 4334
                                         $final_missing <= $threadhold3 &&
4335 4335
                                         $final_excess <= $threadhold2
4336 4336
                                     ) {
4337
-                                        $next=1; //go to the oars
4338
-                                        $result_comment=get_lang('Acceptable');
4339
-                                        $final_answer = 1;	// do not update with  update_exercise_attempt
4337
+                                        $next = 1; //go to the oars
4338
+                                        $result_comment = get_lang('Acceptable');
4339
+                                        $final_answer = 1; // do not update with  update_exercise_attempt
4340 4340
                                     } else {
4341
-                                        $next=0;
4342
-                                        $result_comment=get_lang('Unacceptable');
4343
-                                        $comment=$answerDestination=$objAnswerTmp->selectComment(1);
4344
-                                        $answerDestination=$objAnswerTmp->selectDestination(1);
4341
+                                        $next = 0;
4342
+                                        $result_comment = get_lang('Unacceptable');
4343
+                                        $comment = $answerDestination = $objAnswerTmp->selectComment(1);
4344
+                                        $answerDestination = $objAnswerTmp->selectDestination(1);
4345 4345
                                         //checking the destination parameters parsing the "@@"
4346
-                                        $destination_items= explode('@@', $answerDestination);
4346
+                                        $destination_items = explode('@@', $answerDestination);
4347 4347
                                     }
4348
-                                } elseif($answerId>1) {
4348
+                                } elseif ($answerId > 1) {
4349 4349
                                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
4350
-                                        if ($debug>0) {
4351
-                                            error_log(__LINE__.' - answerId is of type noerror',0);
4350
+                                        if ($debug > 0) {
4351
+                                            error_log(__LINE__.' - answerId is of type noerror', 0);
4352 4352
                                         }
4353 4353
                                         //type no error shouldn't be treated
4354 4354
                                         $next = 1;
4355 4355
                                         continue;
4356 4356
                                     }
4357
-                                    if ($debug>0) {
4358
-                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);
4357
+                                    if ($debug > 0) {
4358
+                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
4359 4359
                                     }
4360 4360
                                     //check the intersection between the oar and the user
4361 4361
                                     //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
4362 4362
                                     //echo 'official';print_r($x_list);print_r($y_list);
4363 4363
                                     //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
4364
-                                    $inter= $result['success'];
4364
+                                    $inter = $result['success'];
4365 4365
 
4366 4366
                                     //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
4367
-                                    $delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
4367
+                                    $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId);
4368 4368
 
4369
-                                    $poly_answer = convert_coordinates($delineation_cord,'|');
4370
-                                    $max_coord = poly_get_max($poly_user,$poly_answer);
4371
-                                    $poly_answer_compiled = poly_compile($poly_answer,$max_coord);
4372
-                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
4369
+                                    $poly_answer = convert_coordinates($delineation_cord, '|');
4370
+                                    $max_coord = poly_get_max($poly_user, $poly_answer);
4371
+                                    $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
4372
+                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
4373 4373
 
4374 4374
                                     if ($overlap == false) {
4375 4375
                                         //all good, no overlap
4376 4376
                                         $next = 1;
4377 4377
                                         continue;
4378 4378
                                     } else {
4379
-                                        if ($debug>0) {
4380
-                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);
4379
+                                        if ($debug > 0) {
4380
+                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0);
4381 4381
                                         }
4382 4382
                                         $organs_at_risk_hit++;
4383 4383
                                         //show the feedback
4384
-                                        $next=0;
4385
-                                        $comment=$answerDestination=$objAnswerTmp->selectComment($answerId);
4386
-                                        $answerDestination=$objAnswerTmp->selectDestination($answerId);
4387
-
4388
-                                        $destination_items= explode('@@', $answerDestination);
4389
-                                        $try_hotspot=$destination_items[1];
4390
-                                        $lp_hotspot=$destination_items[2];
4391
-                                        $select_question_hotspot=$destination_items[3];
4392
-                                        $url_hotspot=$destination_items[4];
4384
+                                        $next = 0;
4385
+                                        $comment = $answerDestination = $objAnswerTmp->selectComment($answerId);
4386
+                                        $answerDestination = $objAnswerTmp->selectDestination($answerId);
4387
+
4388
+                                        $destination_items = explode('@@', $answerDestination);
4389
+                                        $try_hotspot = $destination_items[1];
4390
+                                        $lp_hotspot = $destination_items[2];
4391
+                                        $select_question_hotspot = $destination_items[3];
4392
+                                        $url_hotspot = $destination_items[4];
4393 4393
                                     }
4394 4394
                                 }
4395 4395
                             } else {	// the first delineation feedback
4396
-                                if ($debug>0) {
4397
-                                    error_log(__LINE__.' first',0);
4396
+                                if ($debug > 0) {
4397
+                                    error_log(__LINE__.' first', 0);
4398 4398
                                 }
4399 4399
                             }
4400 4400
                         } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
@@ -4402,7 +4402,7 @@  discard block
 block discarded – undo
4402 4402
                             echo Display::tag('td', $answerMatching[$answerId]);
4403 4403
                             echo Display::tag(
4404 4404
                                 'td',
4405
-                                "$user_answer / " . Display::tag(
4405
+                                "$user_answer / ".Display::tag(
4406 4406
                                     'strong',
4407 4407
                                     $answerMatching[$answerCorrect],
4408 4408
                                     ['style' => 'color: #008000; font-weight: bold;']
@@ -4542,7 +4542,7 @@  discard block
 block discarded – undo
4542 4542
                                     $exeId,
4543 4543
                                     $questionId,
4544 4544
                                     $nano
4545
-                                ) . '</td>
4545
+                                ).'</td>
4546 4546
                                 </tr>
4547 4547
                                 </table>';
4548 4548
                             break;
@@ -4601,7 +4601,7 @@  discard block
 block discarded – undo
4601 4601
 
4602 4602
                                 //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
4603 4603
                                 if ($debug > 0) {
4604
-                                    error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0);
4604
+                                    error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0);
4605 4605
                                 }
4606 4606
                                 if ($overlap < 1) {
4607 4607
                                     //shortcut to avoid complicated calculations
@@ -4612,17 +4612,17 @@  discard block
 block discarded – undo
4612 4612
                                     // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
4613 4613
                                     $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100);
4614 4614
                                     if ($debug > 1) {
4615
-                                        error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
4615
+                                        error_log(__LINE__.' - Final overlap is '.$final_overlap, 0);
4616 4616
                                     }
4617 4617
                                     // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
4618 4618
                                     $final_missing = 100 - $final_overlap;
4619 4619
                                     if ($debug > 1) {
4620
-                                        error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
4620
+                                        error_log(__LINE__.' - Final missing is '.$final_missing, 0);
4621 4621
                                     }
4622 4622
                                     // 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
4623 4623
                                     $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100);
4624 4624
                                     if ($debug > 1) {
4625
-                                        error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0);
4625
+                                        error_log(__LINE__.' - Final excess is '.$final_excess, 0);
4626 4626
                                     }
4627 4627
                                 }
4628 4628
 
@@ -4632,7 +4632,7 @@  discard block
 block discarded – undo
4632 4632
                                 $threadhold_items = explode(';', $threadhold_total);
4633 4633
                                 $threadhold1 = $threadhold_items[0]; // overlap
4634 4634
                                 $threadhold2 = $threadhold_items[1]; // excess
4635
-                                $threadhold3 = $threadhold_items[2];  //missing
4635
+                                $threadhold3 = $threadhold_items[2]; //missing
4636 4636
                                 // if is delineation
4637 4637
                                 if ($answerId === 1) {
4638 4638
                                     //setting colors
@@ -4664,14 +4664,14 @@  discard block
 block discarded – undo
4664 4664
                                 } elseif ($answerId > 1) {
4665 4665
                                     if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
4666 4666
                                         if ($debug > 0) {
4667
-                                            error_log(__LINE__ . ' - answerId is of type noerror', 0);
4667
+                                            error_log(__LINE__.' - answerId is of type noerror', 0);
4668 4668
                                         }
4669 4669
                                         //type no error shouldn't be treated
4670 4670
                                         $next = 1;
4671 4671
                                         continue;
4672 4672
                                     }
4673 4673
                                     if ($debug > 0) {
4674
-                                        error_log(__LINE__ . ' - answerId is >1 so we\'re probably in OAR', 0);
4674
+                                        error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0);
4675 4675
                                     }
4676 4676
                                     //check the intersection between the oar and the user
4677 4677
                                     //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
@@ -4685,7 +4685,7 @@  discard block
 block discarded – undo
4685 4685
                                     $poly_answer = convert_coordinates($delineation_cord, '|');
4686 4686
                                     $max_coord = poly_get_max($poly_user, $poly_answer);
4687 4687
                                     $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
4688
-                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord);
4688
+                                    $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
4689 4689
 
4690 4690
                                     if ($overlap == false) {
4691 4691
                                         //all good, no overlap
@@ -4693,7 +4693,7 @@  discard block
 block discarded – undo
4693 4693
                                         continue;
4694 4694
                                     } else {
4695 4695
                                         if ($debug > 0) {
4696
-                                            error_log(__LINE__ . ' - Overlap is ' . $overlap . ': OAR hit', 0);
4696
+                                            error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0);
4697 4697
                                         }
4698 4698
                                         $organs_at_risk_hit++;
4699 4699
                                         //show the feedback
@@ -4705,12 +4705,12 @@  discard block
 block discarded – undo
4705 4705
                                         $try_hotspot = $destination_items[1];
4706 4706
                                         $lp_hotspot = $destination_items[2];
4707 4707
                                         $select_question_hotspot = $destination_items[3];
4708
-                                        $url_hotspot=$destination_items[4];
4708
+                                        $url_hotspot = $destination_items[4];
4709 4709
                                     }
4710 4710
                                 }
4711 4711
                             } else {	// the first delineation feedback
4712 4712
                                 if ($debug > 0) {
4713
-                                    error_log(__LINE__ . ' first', 0);
4713
+                                    error_log(__LINE__.' first', 0);
4714 4714
                                 }
4715 4715
                             }
4716 4716
                             break;
@@ -4732,7 +4732,7 @@  discard block
 block discarded – undo
4732 4732
                             echo Display::tag('td', $answerMatching[$answerId]);
4733 4733
                             echo Display::tag(
4734 4734
                                 'td',
4735
-                                "$user_answer / " . Display::tag(
4735
+                                "$user_answer / ".Display::tag(
4736 4736
                                     'strong',
4737 4737
                                     $answerMatching[$answerCorrect],
4738 4738
                                     ['style' => 'color: #008000; font-weight: bold;']
@@ -4818,7 +4818,7 @@  discard block
 block discarded – undo
4818 4818
             //  we use the results from the session (from_db=0)
4819 4819
             // TODO Change this, because it is wrong to show the user
4820 4820
             //  some results that haven't been stored in the database yet
4821
-            if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) {
4821
+            if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION) {
4822 4822
 
4823 4823
                 if ($debug) error_log('$from AND this is a hotspot kind of question ');
4824 4824
 
@@ -4827,19 +4827,19 @@  discard block
 block discarded – undo
4827 4827
                 if ($answerType == HOT_SPOT_DELINEATION) {
4828 4828
                     if (0) {
4829 4829
                         if ($overlap_color) {
4830
-                            $overlap_color='green';
4830
+                            $overlap_color = 'green';
4831 4831
                         } else {
4832
-                            $overlap_color='red';
4832
+                            $overlap_color = 'red';
4833 4833
                         }
4834 4834
                         if ($missing_color) {
4835
-                            $missing_color='green';
4835
+                            $missing_color = 'green';
4836 4836
                         } else {
4837
-                            $missing_color='red';
4837
+                            $missing_color = 'red';
4838 4838
                         }
4839 4839
                         if ($excess_color) {
4840
-                            $excess_color='green';
4840
+                            $excess_color = 'green';
4841 4841
                         } else {
4842
-                            $excess_color='red';
4842
+                            $excess_color = 'red';
4843 4843
                         }
4844 4844
                         if (!is_numeric($final_overlap)) {
4845 4845
                             $final_overlap = 0;
@@ -4851,33 +4851,33 @@  discard block
 block discarded – undo
4851 4851
                             $final_excess = 0;
4852 4852
                         }
4853 4853
 
4854
-                        if ($final_overlap>100) {
4854
+                        if ($final_overlap > 100) {
4855 4855
                             $final_overlap = 100;
4856 4856
                         }
4857 4857
 
4858
-                        $table_resume='<table class="data_table">
4858
+                        $table_resume = '<table class="data_table">
4859 4859
                                 <tr class="row_odd" >
4860 4860
                                     <td></td>
4861
-                                    <td ><b>' . get_lang('Requirements') . '</b></td>
4862
-                                    <td><b>' . get_lang('YourAnswer') . '</b></td>
4861
+                                    <td ><b>' . get_lang('Requirements').'</b></td>
4862
+                                    <td><b>' . get_lang('YourAnswer').'</b></td>
4863 4863
                                 </tr>
4864 4864
                                 <tr class="row_even">
4865
-                                    <td><b>' . get_lang('Overlap') . '</b></td>
4866
-                                    <td>' . get_lang('Min') . ' ' . $threadhold1 . '</td>
4867
-                                    <td><div style="color:' . $overlap_color . '">'
4868
-                                        . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '</div></td>
4865
+                                    <td><b>' . get_lang('Overlap').'</b></td>
4866
+                                    <td>' . get_lang('Min').' '.$threadhold1.'</td>
4867
+                                    <td><div style="color:' . $overlap_color.'">'
4868
+                                        . (($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td>
4869 4869
                                 </tr>
4870 4870
                                 <tr>
4871
-                                    <td><b>' . get_lang('Excess') . '</b></td>
4872
-                                    <td>' . get_lang('Max') . ' ' . $threadhold2 . '</td>
4873
-                                    <td><div style="color:' . $excess_color . '">'
4874
-                                        . (($final_excess < 0) ? 0 : intval($final_excess)) . '</div></td>
4871
+                                    <td><b>' . get_lang('Excess').'</b></td>
4872
+                                    <td>' . get_lang('Max').' '.$threadhold2.'</td>
4873
+                                    <td><div style="color:' . $excess_color.'">'
4874
+                                        . (($final_excess < 0) ? 0 : intval($final_excess)).'</div></td>
4875 4875
                                 </tr>
4876 4876
                                 <tr class="row_even">
4877
-                                    <td><b>' . get_lang('Missing') . '</b></td>
4878
-                                    <td>' . get_lang('Max') . ' ' . $threadhold3 . '</td>
4879
-                                    <td><div style="color:' . $missing_color . '">'
4880
-                                        . (($final_missing < 0) ? 0 : intval($final_missing)) . '</div></td>
4877
+                                    <td><b>' . get_lang('Missing').'</b></td>
4878
+                                    <td>' . get_lang('Max').' '.$threadhold3.'</td>
4879
+                                    <td><div style="color:' . $missing_color.'">'
4880
+                                        . (($final_missing < 0) ? 0 : intval($final_missing)).'</div></td>
4881 4881
                                 </tr>
4882 4882
                             </table>';
4883 4883
                         if ($next == 0) {
@@ -4892,20 +4892,20 @@  discard block
 block discarded – undo
4892 4892
                             $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
4893 4893
                         }
4894 4894
 
4895
-                        echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1>
4895
+                        echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>
4896 4896
                             <p style="text-align:center">';
4897 4897
 
4898
-                        $message = '<p>' . get_lang('YourDelineation') . '</p>';
4898
+                        $message = '<p>'.get_lang('YourDelineation').'</p>';
4899 4899
                         $message .= $table_resume;
4900
-                        $message .= '<br />' . get_lang('ResultIs') . ' ' . $result_comment . '<br />';
4900
+                        $message .= '<br />'.get_lang('ResultIs').' '.$result_comment.'<br />';
4901 4901
                         if ($organs_at_risk_hit > 0) {
4902
-                            $message .= '<p><b>' . get_lang('OARHit') . '</b></p>';
4902
+                            $message .= '<p><b>'.get_lang('OARHit').'</b></p>';
4903 4903
                         }
4904
-                        $message .='<p>' . $comment . '</p>';
4904
+                        $message .= '<p>'.$comment.'</p>';
4905 4905
                         echo $message;
4906 4906
                     } else {
4907 4907
                         echo $hotspot_delineation_result[0]; //prints message
4908
-                        $from_database = 1;  // the hotspot_solution.swf needs this variable
4908
+                        $from_database = 1; // the hotspot_solution.swf needs this variable
4909 4909
                     }
4910 4910
 
4911 4911
                     //save the score attempts
@@ -4927,20 +4927,20 @@  discard block
 block discarded – undo
4927 4927
                             $exerciseResultCoordinates[$quesId]
4928 4928
                         );
4929 4929
                     } else {
4930
-                        if ($final_answer==0) {
4930
+                        if ($final_answer == 0) {
4931 4931
                             $questionScore = 0;
4932
-                            $answer=0;
4932
+                            $answer = 0;
4933 4933
                             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
4934 4934
                             if (is_array($exerciseResultCoordinates[$quesId])) {
4935
-                                foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
4936
-                                    Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,0,$val);
4935
+                                foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
4936
+                                    Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, 0, $val);
4937 4937
                                 }
4938 4938
                             }
4939 4939
                         } else {
4940 4940
                             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
4941 4941
                             if (is_array($exerciseResultCoordinates[$quesId])) {
4942
-                                foreach($exerciseResultCoordinates[$quesId] as $idx => $val) {
4943
-                                    Event::saveExerciseAttemptHotspot($exeId,$quesId,$idx,$choice[$idx],$val);
4942
+                                foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
4943
+                                    Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, $choice[$idx], $val);
4944 4944
                                 }
4945 4945
                             }
4946 4946
                         }
@@ -4959,7 +4959,7 @@  discard block
 block discarded – undo
4959 4959
                     echo "
4960 4960
                         <tr>
4961 4961
                             <td colspan=\"2\">
4962
-                                <p><em>" . get_lang('HotSpot') . "</em></p>
4962
+                                <p><em>" . get_lang('HotSpot')."</em></p>
4963 4963
 
4964 4964
                                 <div id=\"hotspot-solution-$questionId\"></div>
4965 4965
 
@@ -4997,7 +4997,7 @@  discard block
 block discarded – undo
4997 4997
 
4998 4998
         if ($saved_results) {
4999 4999
             if ($debug) error_log("Save question results $saved_results");
5000
-            if ($debug) error_log(print_r($choice ,1 ));
5000
+            if ($debug) error_log(print_r($choice, 1));
5001 5001
 
5002 5002
             if (empty($choice)) {
5003 5003
                 $choice = 0;
@@ -5009,14 +5009,14 @@  discard block
 block discarded – undo
5009 5009
                         $ans = $reply[$i];
5010 5010
                         Event::saveQuestionAttempt(
5011 5011
                             $questionScore,
5012
-                            $ans . ':' . $choice[$ans],
5012
+                            $ans.':'.$choice[$ans],
5013 5013
                             $quesId,
5014 5014
                             $exeId,
5015 5015
                             $i,
5016 5016
                             $this->id
5017 5017
                         );
5018 5018
                         if ($debug) {
5019
-                            error_log('result =>' . $questionScore . ' ' . $ans . ':' . $choice[$ans]);
5019
+                            error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]);
5020 5020
                         }
5021 5021
                     }
5022 5022
                 } else {
@@ -5027,7 +5027,7 @@  discard block
 block discarded – undo
5027 5027
                     $reply = array_keys($choice);
5028 5028
 
5029 5029
                     if ($debug) {
5030
-                        error_log("reply " . print_r($reply, 1) . "");
5030
+                        error_log("reply ".print_r($reply, 1)."");
5031 5031
                     }
5032 5032
                     for ($i = 0; $i < sizeof($reply); $i++) {
5033 5033
                         $ans = $reply[$i];
@@ -5086,7 +5086,7 @@  discard block
 block discarded – undo
5086 5086
 
5087 5087
                 Event::saveQuestionAttempt($questionScore, implode('|', $answer), $quesId, $exeId, 0, $this->id);
5088 5088
             } else {
5089
-                Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0,$this->id);
5089
+                Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
5090 5090
             }
5091 5091
         }
5092 5092
 
@@ -5096,8 +5096,8 @@  discard block
 block discarded – undo
5096 5096
 
5097 5097
         if ($saved_results) {
5098 5098
             $stat_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5099
-            $sql = 'UPDATE ' . $stat_table . ' SET
5100
-                        exe_result = exe_result + ' . floatval($questionScore) . '
5099
+            $sql = 'UPDATE '.$stat_table.' SET
5100
+                        exe_result = exe_result + ' . floatval($questionScore).'
5101 5101
                     WHERE exe_id = ' . $exeId;
5102 5102
             if ($debug) error_log($sql);
5103 5103
             Database::query($sql);
@@ -5121,7 +5121,7 @@  discard block
 block discarded – undo
5121 5121
      */
5122 5122
     public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id)
5123 5123
     {
5124
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5124
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5125 5125
             return null;
5126 5126
         }
5127 5127
         // Email configuration settings
@@ -5172,7 +5172,7 @@  discard block
 block discarded – undo
5172 5172
         $msg = str_replace("#course#", $courseInfo['name'], $msg1);
5173 5173
 
5174 5174
         if ($origin != 'learnpath') {
5175
-            $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5175
+            $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5176 5176
         }
5177 5177
         $msg1 = str_replace("#url#", $url_email, $msg);
5178 5178
         $mail_content = $msg1;
@@ -5201,7 +5201,7 @@  discard block
 block discarded – undo
5201 5201
      */
5202 5202
     function send_notification_for_open_questions($question_list_answers, $origin, $exe_id)
5203 5203
     {
5204
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5204
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5205 5205
             return null;
5206 5206
         }
5207 5207
         // Email configuration settings
@@ -5264,11 +5264,11 @@  discard block
 block discarded – undo
5264 5264
             $msg .= '</table><br />';
5265 5265
 
5266 5266
 
5267
-            $msg1   = str_replace("#exercise#",    $this->exercise, $msg);
5268
-            $msg    = str_replace("#firstName#",   $user_info['firstname'],$msg1);
5269
-            $msg1   = str_replace("#lastName#",    $user_info['lastname'],$msg);
5270
-            $msg    = str_replace("#mail#",        $user_info['email'],$msg1);
5271
-            $msg    = str_replace("#course#",      $course_info['name'],$msg1);
5267
+            $msg1   = str_replace("#exercise#", $this->exercise, $msg);
5268
+            $msg    = str_replace("#firstName#", $user_info['firstname'], $msg1);
5269
+            $msg1   = str_replace("#lastName#", $user_info['lastname'], $msg);
5270
+            $msg    = str_replace("#mail#", $user_info['email'], $msg1);
5271
+            $msg    = str_replace("#course#", $course_info['name'], $msg1);
5272 5272
 
5273 5273
             if ($origin != 'learnpath') {
5274 5274
                 $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
@@ -5297,7 +5297,7 @@  discard block
 block discarded – undo
5297 5297
 
5298 5298
     function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id)
5299 5299
     {
5300
-        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
5300
+        if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
5301 5301
             return null;
5302 5302
         }
5303 5303
         // Email configuration settings
@@ -5321,7 +5321,7 @@  discard block
 block discarded – undo
5321 5321
             $answer_type = $item['answer_type'];
5322 5322
 
5323 5323
             if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) {
5324
-                $oral_question_list.='<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">'
5324
+                $oral_question_list .= '<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">'
5325 5325
                     .'<tr>'
5326 5326
                         .'<td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Question').'</td>'
5327 5327
                         .'<td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>'
@@ -5354,7 +5354,7 @@  discard block
 block discarded – undo
5354 5354
                             .'<td>&nbsp;#mail#</td>'
5355 5355
                         .'</tr>'
5356 5356
                     .'</table>';
5357
-            $msg .=  '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'),$oral_question_list).'<br />';
5357
+            $msg .= '<br />'.sprintf(get_lang('OralQuestionsAttemptedAreX'), $oral_question_list).'<br />';
5358 5358
             $msg1 = str_replace("#exercise#", $this->exercise, $msg);
5359 5359
             $msg = str_replace("#firstName#", $user_info['firstname'], $msg1);
5360 5360
             $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg);
@@ -5362,7 +5362,7 @@  discard block
 block discarded – undo
5362 5362
             $msg = str_replace("#course#", $course_info['name'], $msg1);
5363 5363
 
5364 5364
             if ($origin != 'learnpath') {
5365
-                $msg.= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5365
+                $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
5366 5366
             }
5367 5367
             $msg1 = str_replace("#url#", $url_email, $msg);
5368 5368
             $mail_content = $msg1;
@@ -5428,10 +5428,10 @@  discard block
 block discarded – undo
5428 5428
         }
5429 5429
         $html  = '<div class="question-result">';
5430 5430
         $html .= Display::page_header(
5431
-            Display::return_icon('test-quiz.png', get_lang('Result'),null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result')
5431
+            Display::return_icon('test-quiz.png', get_lang('Result'), null, ICON_SIZE_MEDIUM).' '.$this->exercise.' : '.get_lang('Result')
5432 5432
         );
5433 5433
         $html .= Display::description($array);
5434
-        $html .="</div>";
5434
+        $html .= "</div>";
5435 5435
         return $html;
5436 5436
     }
5437 5437
 
@@ -5548,7 +5548,7 @@  discard block
 block discarded – undo
5548 5548
                     false,
5549 5549
                     $objExercise->selectPropagateNeg()
5550 5550
                 );
5551
-                $totalScore      += $question_result['score'];
5551
+                $totalScore += $question_result['score'];
5552 5552
             }
5553 5553
 
5554 5554
             if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) {
@@ -5754,7 +5754,7 @@  discard block
 block discarded – undo
5754 5754
         }
5755 5755
 
5756 5756
         $rawMessage = "";
5757
-        if (!empty($message)){
5757
+        if (!empty($message)) {
5758 5758
             $rawMessage = $message;
5759 5759
             $message = Display::return_message($message, 'warning', false);
5760 5760
         }
@@ -5770,7 +5770,7 @@  discard block
 block discarded – undo
5770 5770
     {
5771 5771
         $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
5772 5772
         $sql = "SELECT max_score FROM $TBL_LP_ITEM
5773
-            WHERE c_id = {$this->course_id} AND item_type = '" . TOOL_QUIZ . "' AND path = '{$this->id}'";
5773
+            WHERE c_id = {$this->course_id} AND item_type = '".TOOL_QUIZ."' AND path = '{$this->id}'";
5774 5774
         $result = Database::query($sql);
5775 5775
         if (Database::num_rows($result) > 0) {
5776 5776
             return true;
@@ -5797,7 +5797,7 @@  discard block
 block discarded – undo
5797 5797
      */
5798 5798
     private function setMediaList($questionList)
5799 5799
     {
5800
-        $mediaList= array();
5800
+        $mediaList = array();
5801 5801
         if (!empty($questionList)) {
5802 5802
             foreach ($questionList as $questionId) {
5803 5803
                 $objQuestionTmp = Question::read($questionId);
@@ -6098,7 +6098,7 @@  discard block
 block discarded – undo
6098 6098
         $sql_track = "SELECT * FROM $track_exercises WHERE exe_id = $exe_id ";
6099 6099
         $result = Database::query($sql_track);
6100 6100
         $new_array = array();
6101
-        if (Database::num_rows($result) > 0 ) {
6101
+        if (Database::num_rows($result) > 0) {
6102 6102
             $new_array = Database::fetch_array($result, 'ASSOC');
6103 6103
 
6104 6104
             $new_array['duration'] = null;
@@ -6110,11 +6110,11 @@  discard block
 block discarded – undo
6110 6110
                 $start_date = api_strtotime($start_date, 'UTC');
6111 6111
                 $end_date = api_strtotime($end_date, 'UTC');
6112 6112
                 if ($start_date && $end_date) {
6113
-                    $mytime = $end_date- $start_date;
6113
+                    $mytime = $end_date - $start_date;
6114 6114
                     $new_learnpath_item = new learnpathItem(null);
6115 6115
                     $time_attemp = $new_learnpath_item->get_scorm_time('js', $mytime);
6116 6116
                     $h = get_lang('h');
6117
-                    $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
6117
+                    $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp);
6118 6118
                     $new_array['duration'] = $time_attemp;
6119 6119
                 }
6120 6120
             }
@@ -6136,7 +6136,7 @@  discard block
 block discarded – undo
6136 6136
                     $result = Database::query($sql);
6137 6137
                 }
6138 6138
             } else {
6139
-                $remind_list = explode(',',$exercise_info['questions_to_check']);
6139
+                $remind_list = explode(',', $exercise_info['questions_to_check']);
6140 6140
 
6141 6141
                 $remind_list_string = '';
6142 6142
                 if ($action == 'add') {
@@ -6148,7 +6148,7 @@  discard block
 block discarded – undo
6148 6148
                         }
6149 6149
                         $remind_list_string = implode(',', $remind_list);
6150 6150
                     }
6151
-                } elseif ($action == 'delete')  {
6151
+                } elseif ($action == 'delete') {
6152 6152
                     if (!empty($remind_list)) {
6153 6153
                         if (in_array($question_id, $remind_list)) {
6154 6154
                             $remind_list = array_flip($remind_list);
@@ -6390,7 +6390,7 @@  discard block
 block discarded – undo
6390 6390
                     true
6391 6391
                 );
6392 6392
 
6393
-                $counter += count($mediaQuestions[$questionId]) - 1 ;
6393
+                $counter += count($mediaQuestions[$questionId]) - 1;
6394 6394
                 $before = count($questionList);
6395 6395
                 $wasMedia = true;
6396 6396
                 $nextValue += count($questionList);
@@ -6469,7 +6469,7 @@  discard block
 block discarded – undo
6469 6469
                         // If it was already seen, then merge the previous with
6470 6470
                         // the current category
6471 6471
                         $oldQuestionList = $newCategoryList[$rootElement]['question_list'];
6472
-                        $category['question_list'] = array_merge($oldQuestionList , $category['question_list']);
6472
+                        $category['question_list'] = array_merge($oldQuestionList, $category['question_list']);
6473 6473
                         $newCategoryList[$rootElement] = $category;
6474 6474
                     }
6475 6475
                 }
@@ -6495,7 +6495,7 @@  discard block
 block discarded – undo
6495 6495
 
6496 6496
                 if ($useRootAsCategoryTitle) {
6497 6497
                     if (isset($category['parent_info'])) {
6498
-                        $categoryName  = $category['parent_info']['title'];
6498
+                        $categoryName = $category['parent_info']['title'];
6499 6499
                     }
6500 6500
                 }
6501 6501
                 $html .= '<div class="row">';
@@ -6638,7 +6638,7 @@  discard block
 block discarded – undo
6638 6638
         // end foreach()
6639 6639
 
6640 6640
         if ($this->type == ALL_ON_ONE_PAGE) {
6641
-            $exercise_actions =  $this->show_button($questionId, $currentQuestion);
6641
+            $exercise_actions = $this->show_button($questionId, $currentQuestion);
6642 6642
             echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
6643 6643
         }
6644 6644
     }
@@ -6724,7 +6724,7 @@  discard block
 block discarded – undo
6724 6724
 
6725 6725
             // Showing the question
6726 6726
 
6727
-            $exercise_actions  = null;
6727
+            $exercise_actions = null;
6728 6728
 
6729 6729
             echo '<a id="questionanchor'.$questionId.'"></a><br />';
6730 6730
             echo '<div id="question_div_'.$questionId.'" class="main_question '.$remind_highlight.'" >';
@@ -6992,7 +6992,7 @@  discard block
 block discarded – undo
6992 6992
                         $header .= Display::tag('th', get_lang('Feedback'));
6993 6993
                     }
6994 6994
                     $s .= '<table class="data_table">';
6995
-                    $s.= Display::tag('tr', $header, array('style' => 'text-align:left;'));
6995
+                    $s .= Display::tag('tr', $header, array('style' => 'text-align:left;'));
6996 6996
                 }
6997 6997
             }
6998 6998
 
@@ -7092,7 +7092,7 @@  discard block
 block discarded – undo
7092 7092
                             $s .= '<td>';
7093 7093
                             $s .= $comment;
7094 7094
                             $s .= '</td>';
7095
-                            $s .='</tr>';
7095
+                            $s .= '</tr>';
7096 7096
                         } else {
7097 7097
                             $s .= $answer_input;
7098 7098
                         }
@@ -7106,7 +7106,7 @@  discard block
 block discarded – undo
7106 7106
                             }
7107 7107
                         }
7108 7108
 
7109
-                        $s .='<tr>';
7109
+                        $s .= '<tr>';
7110 7110
                         $s .= Display::tag('td', $answer);
7111 7111
 
7112 7112
                         if (!empty($quiz_question_options)) {
@@ -7133,7 +7133,7 @@  discard block
 block discarded – undo
7133 7133
                             $s .= $comment;
7134 7134
                             $s .= '</td>';
7135 7135
                         }
7136
-                        $s.='</tr>';
7136
+                        $s .= '</tr>';
7137 7137
                     }
7138 7138
 
7139 7139
                 } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
@@ -7162,16 +7162,16 @@  discard block
 block discarded – undo
7162 7162
                     $answer_input .= '</label>';
7163 7163
 
7164 7164
                     if ($show_comment) {
7165
-                        $s.= '<tr>';
7165
+                        $s .= '<tr>';
7166 7166
                         $s .= '<td>';
7167
-                        $s.= $answer_input;
7167
+                        $s .= $answer_input;
7168 7168
                         $s .= '</td>';
7169 7169
                         $s .= '<td>';
7170 7170
                         $s .= $comment;
7171 7171
                         $s .= '</td>';
7172
-                        $s.= '</tr>';
7172
+                        $s .= '</tr>';
7173 7173
                     } else {
7174
-                        $s.= $answer_input;
7174
+                        $s .= $answer_input;
7175 7175
                     }
7176 7176
                 } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
7177 7177
                     $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
@@ -7184,7 +7184,7 @@  discard block
 block discarded – undo
7184 7184
                         }
7185 7185
                     }
7186 7186
                     $answer = Security::remove_XSS($answer);
7187
-                    $s .='<tr>';
7187
+                    $s .= '<tr>';
7188 7188
                     $s .= Display::tag('td', $answer);
7189 7189
 
7190 7190
                     foreach ($objQuestionTmp->options as $key => $item) {
@@ -7208,7 +7208,7 @@  discard block
 block discarded – undo
7208 7208
                         $s .= $comment;
7209 7209
                         $s .= '</td>';
7210 7210
                     }
7211
-                    $s.='</tr>';
7211
+                    $s .= '</tr>';
7212 7212
                 } elseif ($answerType == FILL_IN_BLANKS) {
7213 7213
                     list($answer) = explode('::', $answer);
7214 7214
 
@@ -7242,7 +7242,7 @@  discard block
 block discarded – undo
7242 7242
                                     $value = str_replace('&nbsp;', '', trim($value[0]));
7243 7243
                                 }
7244 7244
                                 $correct_item = preg_quote($correct_item);
7245
-                                $correct_item = api_preg_replace('|/|', '\/', $correct_item);   // to prevent error if there is a / in the text to find
7245
+                                $correct_item = api_preg_replace('|/|', '\/', $correct_item); // to prevent error if there is a / in the text to find
7246 7246
                                 $answer = api_preg_replace('/'.$correct_item.'/', Display::input('text', "choice[$questionId][]", $value), $answer, 1);
7247 7247
                             }
7248 7248
                             $i++;
@@ -7299,7 +7299,7 @@  discard block
 block discarded – undo
7299 7299
                         }
7300 7300
 
7301 7301
                         if (!empty($answerCorrect) && !empty($selectedValue)) {
7302
-                            $s.= '<script>
7302
+                            $s .= '<script>
7303 7303
                                 jsPlumb.ready(function() {
7304 7304
                                     jsPlumb.connect({
7305 7305
                                         source: "window_'.$windowId.'",
@@ -7314,14 +7314,14 @@  discard block
 block discarded – undo
7314 7314
                         }
7315 7315
                         $s .= '</select></div></td>';
7316 7316
 
7317
-                        $s.='<td width="45%" valign="top" >';
7317
+                        $s .= '<td width="45%" valign="top" >';
7318 7318
 
7319 7319
                         if (isset($select_items[$lines_count])) {
7320
-                            $s.= '<div id="window_'.$windowId.'_answer" class="window window_right_question">
7320
+                            $s .= '<div id="window_'.$windowId.'_answer" class="window window_right_question">
7321 7321
                                     <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].'
7322 7322
                                   </div>';
7323 7323
                         } else {
7324
-                            $s.='&nbsp;';
7324
+                            $s .= '&nbsp;';
7325 7325
                         }
7326 7326
 
7327 7327
                         $s .= '</td>';
@@ -7335,16 +7335,16 @@  discard block
 block discarded – undo
7335 7335
                                 $s .= '<tr>
7336 7336
                                       <td colspan="2"></td>
7337 7337
                                       <td valign="top">';
7338
-                                $s.='<b>'.$select_items[$lines_count]['letter'].'.</b>';
7338
+                                $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b>';
7339 7339
                                 $s .= $select_items[$lines_count]['answer'];
7340
-                                $s.="</td>
7340
+                                $s .= "</td>
7341 7341
                                 </tr>";
7342 7342
                                 $lines_count++;
7343 7343
                             } // end while()
7344 7344
                         }  // end if()
7345 7345
                         $matching_correct_answer++;
7346 7346
                     }
7347
-                } elseif ($answerType ==  DRAGGABLE) {
7347
+                } elseif ($answerType == DRAGGABLE) {
7348 7348
                     // matching type, showing suggestions and answers
7349 7349
                     // TODO: replace $answerId by $numAnswer
7350 7350
 
@@ -7387,7 +7387,7 @@  discard block
 block discarded – undo
7387 7387
                         $s .= '</select>';
7388 7388
 
7389 7389
                         if (!empty($answerCorrect) && !empty($selectedValue)) {
7390
-                            $s.= '<script>
7390
+                            $s .= '<script>
7391 7391
                                 $(function() {
7392 7392
                                     deleteItem($("#'.$questionId.'_'.$selectedValue.'"), $("#drop_'.$windowId.'"));
7393 7393
                                 });
@@ -7396,11 +7396,11 @@  discard block
 block discarded – undo
7396 7396
 
7397 7397
 
7398 7398
                         if (isset($select_items[$lines_count])) {
7399
-                            $s.= '<div id="window_'.$windowId.'_answer" class="">
7399
+                            $s .= '<div id="window_'.$windowId.'_answer" class="">
7400 7400
                                     <b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'].'
7401 7401
                                   </div>';
7402 7402
                         } else {
7403
-                            $s.='&nbsp;';
7403
+                            $s .= '&nbsp;';
7404 7404
                         }
7405 7405
                         $lines_count++;
7406 7406
                         //if the left side of the "matching" has been completely
@@ -7409,7 +7409,7 @@  discard block
 block discarded – undo
7409 7409
                         if (($lines_count - 1) == $num_suggestions) {
7410 7410
                             // if it remains answers to shown at the right side
7411 7411
                             while (isset($select_items[$lines_count])) {
7412
-                                $s.='<b>'.$select_items[$lines_count]['letter'].'.</b>';
7412
+                                $s .= '<b>'.$select_items[$lines_count]['letter'].'.</b>';
7413 7413
                                 $s .= $select_items[$lines_count]['answer'];
7414 7414
                                 $lines_count++;
7415 7415
                             }
@@ -7512,9 +7512,9 @@  discard block
 block discarded – undo
7512 7512
 
7513 7513
             if (!$only_questions) {
7514 7514
                 if ($show_title) {
7515
-                    $html .=  TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id);
7516
-                    $html .=  '<div class="question_title">'.$current_item.'. '.$questionName.'</div>';
7517
-                    $html .=  $questionDescription;
7515
+                    $html .= TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id);
7516
+                    $html .= '<div class="question_title">'.$current_item.'. '.$questionName.'</div>';
7517
+                    $html .= $questionDescription;
7518 7518
                 } else {
7519 7519
                     $html .= '<div class="media">';
7520 7520
                     $html .= '<div class="pull-left">';
@@ -7530,11 +7530,11 @@  discard block
 block discarded – undo
7530 7530
                     $html .= '</div>';
7531 7531
                 }
7532 7532
                 //@todo I need to the get the feedback type
7533
-                $html .=  '<input type="hidden" name="hidden_hotspot_id" value="'.$questionId.'" />';
7534
-                $html .=  '<table class="exercise_questions">
7533
+                $html .= '<input type="hidden" name="hidden_hotspot_id" value="'.$questionId.'" />';
7534
+                $html .= '<table class="exercise_questions">
7535 7535
                            <tr>
7536 7536
                             <td valign="top" colspan="2">';
7537
-                $html .=  '</td></tr>';
7537
+                $html .= '</td></tr>';
7538 7538
             }
7539 7539
 
7540 7540
             $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
Please login to merge, or discard this patch.
main/exercice/TestCategory.php 3 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	 * Return the list of differents categories NAME for a test
368 368
 	 * @param int exercise id
369 369
 	 * @param bool
370
-	 * @return array of string
370
+	 * @return integer of string
371 371
 	 *
372 372
      * @author function rewrote by jmontoya
373 373
 	 */
@@ -983,7 +983,6 @@  discard block
 block discarded – undo
983 983
     /**
984 984
      * Return the id of the test category with title = $in_title
985 985
      * @param $in_title
986
-     * @param int $in_c_id
987 986
      *
988 987
      * @return int is id of test category
989 988
      */
@@ -1011,7 +1010,7 @@  discard block
 block discarded – undo
1011 1010
      * @param int $questionId
1012 1011
      * @param int $courseId
1013 1012
 	 *
1014
-	 * @return int
1013
+	 * @return string|false
1015 1014
      */
1016 1015
     public static function add_category_for_question_id($categoryId, $questionId, $courseId)
1017 1016
     {
Please login to merge, or discard this patch.
Indentation   +504 added lines, -504 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
     public $name;
14 14
     public $description;
15 15
 
16
-	/**
17
-	 * Constructor of the class Category
18
-	 * If you give an in_id and no in_name, you get info concerning the category of id=in_id
19
-	 * otherwise, you've got an category objet avec your in_id, in_name, in_descr
20
-	 *
16
+    /**
17
+     * Constructor of the class Category
18
+     * If you give an in_id and no in_name, you get info concerning the category of id=in_id
19
+     * otherwise, you've got an category objet avec your in_id, in_name, in_descr
20
+     *
21 21
      * @param int    $id
22 22
      * @param string $name
23 23
      * @param string $description
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
         }
62 62
     }
63 63
 
64
-	/**
64
+    /**
65 65
      * add TestCategory in the database if name doesn't already exists
66
-	 */
66
+     */
67 67
     public function addCategoryInBDD()
68 68
     {
69 69
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 
109 109
             return false;
110 110
         }
111
-	}
111
+    }
112 112
 
113
-	/**
113
+    /**
114 114
      * Removes the category from the database
115 115
      * if there were question in this category, the link between question and category is removed
116
-	 */
116
+     */
117 117
     public function removeCategory()
118 118
     {
119 119
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 
144 144
             return true;
145 145
         }
146
-	}
146
+    }
147 147
 
148
-	/**
148
+    /**
149 149
      * Modify category name or description of category with id=in_id
150
-	 */
150
+     */
151 151
     public function modifyCategory()
152 152
     {
153 153
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -175,40 +175,40 @@  discard block
 block discarded – undo
175 175
 
176 176
             return true;
177 177
         }
178
-	}
178
+    }
179 179
 
180
-	/**
180
+    /**
181 181
      * Gets the number of question of category id=in_id
182
-	 */
182
+     */
183 183
     public function getCategoryQuestionsNumber()
184 184
     {
185
-		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
186
-		$in_id = intval($this->id);
187
-		$sql = "SELECT count(*) AS nb
185
+        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
186
+        $in_id = intval($this->id);
187
+        $sql = "SELECT count(*) AS nb
188 188
 		        FROM $table
189 189
 		        WHERE category_id=$in_id AND c_id=".api_get_course_int_id();
190
-		$res = Database::query($sql);
191
-		$row = Database::fetch_array($res);
190
+        $res = Database::query($sql);
191
+        $row = Database::fetch_array($res);
192 192
 
193
-		return $row['nb'];
194
-	}
193
+        return $row['nb'];
194
+    }
195 195
 
196 196
     /**
197 197
      * @param string $in_color
198 198
      */
199 199
     public function display($in_color="#E0EBF5")
200 200
     {
201
-		echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
202
-		print_r($this);
203
-		echo "</textarea>";
204
-	}
201
+        echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
202
+        print_r($this);
203
+        echo "</textarea>";
204
+    }
205 205
 
206
-	/**
206
+    /**
207 207
      * Return an array of all Category objects in the database
208
-	 * If in_field=="" Return an array of all category objects in the database
209
-	 * Otherwise, return an array of all in_field value
210
-	 * in the database (in_field = id or name or description)
211
-	 */
208
+     * If in_field=="" Return an array of all category objects in the database
209
+     * Otherwise, return an array of all in_field value
210
+     * in the database (in_field = id or name or description)
211
+     */
212 212
     public static function getCategoryListInfo($in_field = "", $courseId = "")
213 213
     {
214 214
         if (empty($courseId) || $courseId=="") {
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
             }
240 240
         }
241 241
 
242
-		return $tabres;
243
-	}
242
+        return $tabres;
243
+    }
244 244
 
245 245
     /**
246 246
      * Return the TestCategory id for question with question_id = $questionId
@@ -251,246 +251,246 @@  discard block
 block discarded – undo
251 251
      *
252 252
      * @return int
253 253
      */
254
-	public static function getCategoryForQuestion($questionId, $courseId ="")
254
+    public static function getCategoryForQuestion($questionId, $courseId ="")
255 255
     {
256
-		$result = 0;
256
+        $result = 0;
257 257
         if (empty($courseId) || $courseId == "") {
258 258
             $courseId = api_get_course_int_id();
259 259
         }
260
-		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
260
+        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
261 261
         $questionId = intval($questionId);
262
-		$sql = "SELECT category_id
262
+        $sql = "SELECT category_id
263 263
 		        FROM $table
264 264
 		        WHERE question_id = $questionId AND c_id = $courseId";
265
-		$res = Database::query($sql);
266
-		if (Database::num_rows($res) > 0) {
265
+        $res = Database::query($sql);
266
+        if (Database::num_rows($res) > 0) {
267 267
             $data = Database::fetch_array($res);
268
-			$result = $data['category_id'];
269
-		}
268
+            $result = $data['category_id'];
269
+        }
270 270
 
271
-		return $result;
272
-	}
271
+        return $result;
272
+    }
273 273
 
274
-	/**
275
-	 * true if question id has a category
276
-	 */
277
-	public static function isQuestionHasCategory($questionId)
274
+    /**
275
+     * true if question id has a category
276
+     */
277
+    public static function isQuestionHasCategory($questionId)
278 278
     {
279
-		if (TestCategory::getCategoryForQuestion($questionId) > 0) {
280
-			return true;
281
-		}
282
-		return false;
283
-	}
279
+        if (TestCategory::getCategoryForQuestion($questionId) > 0) {
280
+            return true;
281
+        }
282
+        return false;
283
+    }
284 284
 
285
-	/**
285
+    /**
286 286
 	 Return the category name for question with question_id = $questionId
287 287
 	 In this version, a question has only 1 category.
288 288
 	 Return the category id, "" if none
289
-	 */
289
+     */
290 290
     public static function getCategoryNameForQuestion(
291 291
         $questionId,
292 292
         $courseId = ""
293 293
     ) {
294
-		if (empty($courseId) || $courseId=="") {
295
-			$courseId = api_get_course_int_id();
296
-		}
297
-		$catid = TestCategory::getCategoryForQuestion($questionId, $courseId);
298
-		$result = "";	// result
299
-		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
300
-		$catid = intval($catid);
301
-		$sql = "SELECT title FROM $table
294
+        if (empty($courseId) || $courseId=="") {
295
+            $courseId = api_get_course_int_id();
296
+        }
297
+        $catid = TestCategory::getCategoryForQuestion($questionId, $courseId);
298
+        $result = "";	// result
299
+        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
300
+        $catid = intval($catid);
301
+        $sql = "SELECT title FROM $table
302 302
 		        WHERE id = $catid  AND c_id = $courseId";
303
-		$res = Database::query($sql);
304
-		$data = Database::fetch_array($res);
305
-		if (Database::num_rows($res) > 0) {
306
-			$result = $data['title'];
307
-		}
308
-
309
-		return $result;
310
-	}
311
-
312
-	/**
313
-	 * Return the list of differents categories ID for a test in the current course
314
-	 * input : test_id
315
-	 * return : array of category id (integer)
316
-	 * hubert.borderiou 07-04-2011
317
-	 * @param int $exerciseId
318
-	 */
319
-	public static function getListOfCategoriesIDForTest($exerciseId)
303
+        $res = Database::query($sql);
304
+        $data = Database::fetch_array($res);
305
+        if (Database::num_rows($res) > 0) {
306
+            $result = $data['title'];
307
+        }
308
+
309
+        return $result;
310
+    }
311
+
312
+    /**
313
+     * Return the list of differents categories ID for a test in the current course
314
+     * input : test_id
315
+     * return : array of category id (integer)
316
+     * hubert.borderiou 07-04-2011
317
+     * @param int $exerciseId
318
+     */
319
+    public static function getListOfCategoriesIDForTest($exerciseId)
320 320
     {
321
-		// parcourir les questions d'un test, recup les categories uniques dans un tableau
322
-		$exercise = new Exercise();
323
-		$exercise->read($exerciseId, false);
324
-		$categoriesInExercise = $exercise->getQuestionWithCategories();
325
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
326
-		$categories = array();
321
+        // parcourir les questions d'un test, recup les categories uniques dans un tableau
322
+        $exercise = new Exercise();
323
+        $exercise->read($exerciseId, false);
324
+        $categoriesInExercise = $exercise->getQuestionWithCategories();
325
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
326
+        $categories = array();
327 327
         if (!empty($categoriesInExercise)) {
328
-			foreach ($categoriesInExercise as $category) {
329
-				//$category['id'] = $category['iid'];
330
-				$categories[$category['id']] = $category;
331
-			}
332
-		}
333
-
334
-		return $categories;
335
-	}
336
-
337
-	/**
338
-	 * @param Exercise $exercise_obj
339
-	 * @return array
340
-	 */
341
-	public static function getListOfCategoriesIDForTestObject(Exercise $exercise_obj)
342
-	{
343
-		// parcourir les questions d'un test, recup les categories uniques dans un tableau
344
-		$categories_in_exercise = array();
345
-		// $question_list = $exercise_obj->getQuestionList();
346
-		$question_list = $exercise_obj->getQuestionOrderedListByName();
347
-
348
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
349
-		foreach ($question_list as $questionInfo) {
350
-			$question_id = $questionInfo['question_id'];
351
-			$category_list = self::getCategoryForQuestion($question_id);
352
-			if (is_numeric($category_list)) {
353
-				$category_list = array($category_list);
354
-			}
355
-
356
-			if (!empty($category_list)) {
357
-				$categories_in_exercise = array_merge($categories_in_exercise, $category_list);
358
-			}
359
-		}
360
-		if (!empty($categories_in_exercise)) {
361
-			$categories_in_exercise = array_unique(array_filter($categories_in_exercise));
362
-		}
363
-		return $categories_in_exercise;
364
-	}
365
-
366
-	/**
367
-	 * Return the list of differents categories NAME for a test
368
-	 * @param int exercise id
369
-	 * @param bool
370
-	 * @return array of string
371
-	 *
328
+            foreach ($categoriesInExercise as $category) {
329
+                //$category['id'] = $category['iid'];
330
+                $categories[$category['id']] = $category;
331
+            }
332
+        }
333
+
334
+        return $categories;
335
+    }
336
+
337
+    /**
338
+     * @param Exercise $exercise_obj
339
+     * @return array
340
+     */
341
+    public static function getListOfCategoriesIDForTestObject(Exercise $exercise_obj)
342
+    {
343
+        // parcourir les questions d'un test, recup les categories uniques dans un tableau
344
+        $categories_in_exercise = array();
345
+        // $question_list = $exercise_obj->getQuestionList();
346
+        $question_list = $exercise_obj->getQuestionOrderedListByName();
347
+
348
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
349
+        foreach ($question_list as $questionInfo) {
350
+            $question_id = $questionInfo['question_id'];
351
+            $category_list = self::getCategoryForQuestion($question_id);
352
+            if (is_numeric($category_list)) {
353
+                $category_list = array($category_list);
354
+            }
355
+
356
+            if (!empty($category_list)) {
357
+                $categories_in_exercise = array_merge($categories_in_exercise, $category_list);
358
+            }
359
+        }
360
+        if (!empty($categories_in_exercise)) {
361
+            $categories_in_exercise = array_unique(array_filter($categories_in_exercise));
362
+        }
363
+        return $categories_in_exercise;
364
+    }
365
+
366
+    /**
367
+     * Return the list of differents categories NAME for a test
368
+     * @param int exercise id
369
+     * @param bool
370
+     * @return array of string
371
+     *
372 372
      * @author function rewrote by jmontoya
373
-	 */
374
-	public static function getListOfCategoriesNameForTest($exercise_id, $grouped_by_category = true)
373
+     */
374
+    public static function getListOfCategoriesNameForTest($exercise_id, $grouped_by_category = true)
375 375
     {
376
-		$result = array();
377
-		$categories = self::getListOfCategoriesIDForTest($exercise_id, $grouped_by_category);
376
+        $result = array();
377
+        $categories = self::getListOfCategoriesIDForTest($exercise_id, $grouped_by_category);
378 378
 
379
-		foreach ($categories as $catInfo) {
380
-			$categoryId = $catInfo['id'];
381
-			if (!empty($categoryId)) {
382
-				$result[$categoryId] = array(
379
+        foreach ($categories as $catInfo) {
380
+            $categoryId = $catInfo['id'];
381
+            if (!empty($categoryId)) {
382
+                $result[$categoryId] = array(
383 383
                     'title' => $catInfo['title'],
384 384
                     //'parent_id' =>  $catInfo['parent_id'],
385
-					'parent_id' => '',
385
+                    'parent_id' => '',
386 386
                     'c_id' => $catInfo['c_id']
387 387
                 );
388
-		}
389
-		}
390
-
391
-		return $result;
392
-	}
393
-
394
-	/**
395
-	 * @param Exercise $exercise_obj
396
-	 * @return array
397
-	 */
398
-	public static function getListOfCategoriesForTest(Exercise $exercise_obj)
399
-	{
400
-		$result = array();
401
-		$categories = self::getListOfCategoriesIDForTestObject($exercise_obj);
402
-		foreach ($categories as $cat_id) {
403
-			$cat = new TestCategory($cat_id);
404
-			$cat = (array)$cat;
405
-			$cat['iid'] = $cat['id'];
406
-			$cat['title'] = $cat['name'];
407
-			$result[$cat['id']] = $cat;
408
-		}
409
-		return $result;
410
-	}
411
-
412
-	/**
413
-	 * return the number of differents categories for a test
414
-	 * input : test_id
415
-	 * return : integer
416
-	 * hubert.borderiou 07-04-2011
417
-	 */
418
-	public static function getNumberOfCategoriesForTest($id)
388
+        }
389
+        }
390
+
391
+        return $result;
392
+    }
393
+
394
+    /**
395
+     * @param Exercise $exercise_obj
396
+     * @return array
397
+     */
398
+    public static function getListOfCategoriesForTest(Exercise $exercise_obj)
399
+    {
400
+        $result = array();
401
+        $categories = self::getListOfCategoriesIDForTestObject($exercise_obj);
402
+        foreach ($categories as $cat_id) {
403
+            $cat = new TestCategory($cat_id);
404
+            $cat = (array)$cat;
405
+            $cat['iid'] = $cat['id'];
406
+            $cat['title'] = $cat['name'];
407
+            $result[$cat['id']] = $cat;
408
+        }
409
+        return $result;
410
+    }
411
+
412
+    /**
413
+     * return the number of differents categories for a test
414
+     * input : test_id
415
+     * return : integer
416
+     * hubert.borderiou 07-04-2011
417
+     */
418
+    public static function getNumberOfCategoriesForTest($id)
419 419
     {
420
-		return count(TestCategory::getListOfCategoriesIDForTest($id));
421
-	}
420
+        return count(TestCategory::getListOfCategoriesIDForTest($id));
421
+    }
422 422
 
423
-	/**
424
-	 * return the number of question of a category id in a test
425
-	 * @param int $exerciseId
423
+    /**
424
+     * return the number of question of a category id in a test
425
+     * @param int $exerciseId
426 426
      * @param int $categoryId
427 427
      *
428
-	 * @return integer
428
+     * @return integer
429 429
      *
430
-	 * @author hubert.borderiou 07-04-2011
431
-	 */
432
-	public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId)
430
+     * @author hubert.borderiou 07-04-2011
431
+     */
432
+    public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId)
433 433
     {
434
-		$nbCatResult = 0;
435
-		$quiz = new Exercise();
436
-		$quiz->read($exerciseId);
437
-		$tabQuestionList = $quiz->selectQuestionList();
438
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
439
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
440
-			if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
441
-				$nbCatResult++;
442
-			}
443
-		}
444
-
445
-		return $nbCatResult;
446
-	}
447
-
448
-	/**
449
-	 * return the number of question for a test using random by category
450
-	 * input  : test_id, number of random question (min 1)
451
-	 * hubert.borderiou 07-04-2011
452
-	 * question without categories are not counted
453
-	 */
454
-	public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom)
434
+        $nbCatResult = 0;
435
+        $quiz = new Exercise();
436
+        $quiz->read($exerciseId);
437
+        $tabQuestionList = $quiz->selectQuestionList();
438
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
439
+        for ($i=1; $i <= count($tabQuestionList); $i++) {
440
+            if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
441
+                $nbCatResult++;
442
+            }
443
+        }
444
+
445
+        return $nbCatResult;
446
+    }
447
+
448
+    /**
449
+     * return the number of question for a test using random by category
450
+     * input  : test_id, number of random question (min 1)
451
+     * hubert.borderiou 07-04-2011
452
+     * question without categories are not counted
453
+     */
454
+    public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom)
455 455
     {
456
-		$nbquestionresult = 0;
457
-		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
458
-		for ($i=0; $i < count($tabcatid); $i++) {
459
-			if ($tabcatid[$i] > 0 && $tabcatid[$i] > 0) {	// 0 = no category for this questio
460
-				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
461
-				if ($nbQuestionInThisCat > $in_nbrandom) {
462
-					$nbquestionresult += $in_nbrandom;
463
-				}
464
-				else {
465
-					$nbquestionresult += $nbQuestionInThisCat;
466
-				}
467
-			}
468
-		}
469
-
470
-		return $nbquestionresult;
471
-	}
472
-
473
-	/**
474
-	 * Return an array (id=>name)
475
-	 * tabresult[0] = get_lang('NoCategory');
456
+        $nbquestionresult = 0;
457
+        $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
458
+        for ($i=0; $i < count($tabcatid); $i++) {
459
+            if ($tabcatid[$i] > 0 && $tabcatid[$i] > 0) {	// 0 = no category for this questio
460
+                $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
461
+                if ($nbQuestionInThisCat > $in_nbrandom) {
462
+                    $nbquestionresult += $in_nbrandom;
463
+                }
464
+                else {
465
+                    $nbquestionresult += $nbQuestionInThisCat;
466
+                }
467
+            }
468
+        }
469
+
470
+        return $nbquestionresult;
471
+    }
472
+
473
+    /**
474
+     * Return an array (id=>name)
475
+     * tabresult[0] = get_lang('NoCategory');
476 476
      *
477 477
      * @param int $courseId
478 478
      *
479 479
      * @return array
480
-	 *
481
-	 */
480
+     *
481
+     */
482 482
     public static function getCategoriesIdAndName($courseId = "")
483 483
     {
484
-		if (empty($courseId)) {
485
-			$courseId = api_get_course_int_id();
486
-		}
487
-	 	$tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
488
-	 	$tabresult = array("0"=>get_lang('NoCategorySelected'));
489
-	 	for ($i=0; $i < count($tabcatobject); $i++) {
490
-	 		$tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
491
-	 	}
492
-	 	return $tabresult;
493
-	}
484
+        if (empty($courseId)) {
485
+            $courseId = api_get_course_int_id();
486
+        }
487
+            $tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
488
+            $tabresult = array("0"=>get_lang('NoCategorySelected'));
489
+            for ($i=0; $i < count($tabcatobject); $i++) {
490
+                $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
491
+            }
492
+            return $tabresult;
493
+    }
494 494
 
495 495
     /**
496 496
      * Returns an array of question ids for each category
@@ -499,10 +499,10 @@  discard block
 block discarded – undo
499 499
      * @param int exercise
500 500
      * @param array $check_in_question_list
501 501
      * @param array $categoriesAddedInExercise
502
-    *
503
-    * @param int $exerciseId
504
-    * @return array
505
-    */
502
+     *
503
+     * @param int $exerciseId
504
+     * @return array
505
+     */
506 506
     static function getQuestionsByCat(
507 507
         $exerciseId,
508 508
         $check_in_question_list = array(),
@@ -580,28 +580,28 @@  discard block
 block discarded – undo
580 580
         }
581 581
 
582 582
         return $categories;
583
-	}
583
+    }
584 584
 
585
-	/**
586
-	 * return a tab of $in_number random elements of $in_tab
587
-	 */
585
+    /**
586
+     * return a tab of $in_number random elements of $in_tab
587
+     */
588 588
     public static function getNElementsFromArray($in_tab, $in_number)
589 589
     {
590
-		$tabres = $in_tab;
591
-		shuffle($tabres);
592
-		if ($in_number < count($tabres)) {
593
-			$tabres = array_slice($tabres, 0, $in_number);
594
-		}
595
-		return $tabres;
596
-	}
597
-
598
-	/**
599
-	 * display the category
600
-	 */
601
-	public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1)
590
+        $tabres = $in_tab;
591
+        shuffle($tabres);
592
+        if ($in_number < count($tabres)) {
593
+            $tabres = array_slice($tabres, 0, $in_number);
594
+        }
595
+        return $tabres;
596
+    }
597
+
598
+    /**
599
+     * display the category
600
+     */
601
+    public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1)
602 602
     {
603 603
         echo self::returnCategoryAndTitle($questionId, $in_display_category_name);
604
-	}
604
+    }
605 605
 
606 606
     /**
607 607
      * @param int $questionId
@@ -617,98 +617,98 @@  discard block
 block discarded – undo
617 617
             $in_display_category_name = $objExercise->display_category_name;
618 618
         }
619 619
         $content = null;
620
-		if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) {
620
+        if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) {
621 621
             $content .= '<div class="page-header">';
622 622
             $content .= '<h4>'.get_lang('Category').": ".TestCategory::getCategoryNameForQuestion($questionId).'</h4>';
623 623
             $content .= "</div>";
624
-		}
624
+        }
625 625
         return $content;
626
-	}
626
+    }
627 627
 
628 628
     /**
629
-    * Display signs [+] and/or (>0) after question title if question has options
630
-    * scoreAlwaysPositive and/or uncheckedMayScore
631
-    */
629
+     * Display signs [+] and/or (>0) after question title if question has options
630
+     * scoreAlwaysPositive and/or uncheckedMayScore
631
+     */
632 632
     public function displayQuestionOption($in_objQuestion)
633 633
     {
634
-		if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) {
635
-			echo "<span style='font-size:75%'> (>0)</span>";
636
-		}
637
-		if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) {
638
-			echo "<span style='font-size:75%'> [+]</span>";
639
-		}
640
-	}
641
-
642
-	/**
643
-	 * sortTabByBracketLabel ($tabCategoryQuestions)
644
-	 * key of $tabCategoryQuestions are the category id (0 for not in a category)
645
-	 * value is the array of question id of this category
646
-	 * Sort question by Category
647
-	*/
634
+        if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) {
635
+            echo "<span style='font-size:75%'> (>0)</span>";
636
+        }
637
+        if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) {
638
+            echo "<span style='font-size:75%'> [+]</span>";
639
+        }
640
+    }
641
+
642
+    /**
643
+     * sortTabByBracketLabel ($tabCategoryQuestions)
644
+     * key of $tabCategoryQuestions are the category id (0 for not in a category)
645
+     * value is the array of question id of this category
646
+     * Sort question by Category
647
+     */
648 648
     public static function sortTabByBracketLabel($in_tab)
649 649
     {
650
-		$tabResult = array();
651
-		$tabCatName = array();	// tab of category name
652
-		while (list($cat_id, $tabquestion) = each($in_tab)) {
653
-			$catTitle = new TestCategory($cat_id);
654
-			$tabCatName[$cat_id] = $catTitle->name;
655
-		}
656
-		reset($in_tab);
657
-		// sort table by value, keeping keys as they are
658
-		asort($tabCatName);
659
-		// keys of $tabCatName are keys order for $in_tab
660
-		while (list($key, $val) = each($tabCatName)) {
661
-			$tabResult[$key] = $in_tab[$key];
662
-		}
663
-		return $tabResult;
664
-	}
650
+        $tabResult = array();
651
+        $tabCatName = array();	// tab of category name
652
+        while (list($cat_id, $tabquestion) = each($in_tab)) {
653
+            $catTitle = new TestCategory($cat_id);
654
+            $tabCatName[$cat_id] = $catTitle->name;
655
+        }
656
+        reset($in_tab);
657
+        // sort table by value, keeping keys as they are
658
+        asort($tabCatName);
659
+        // keys of $tabCatName are keys order for $in_tab
660
+        while (list($key, $val) = each($tabCatName)) {
661
+            $tabResult[$key] = $in_tab[$key];
662
+        }
663
+        return $tabResult;
664
+    }
665 665
 
666 666
     /**
667
-	 * return total score for test exe_id for all question in the category $in_cat_id for user
668
-	 * If no question for this category, return ""
669
-	 */
670
-	public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id)
671
-	{
672
-		$tbl_track_attempt		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
673
-		$tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
674
-		$in_cat_id = intval($in_cat_id);
675
-		$in_exe_id = intval($in_exe_id);
676
-		$in_user_id = intval($in_user_id);
677
-
678
-		$query = "SELECT DISTINCT
667
+     * return total score for test exe_id for all question in the category $in_cat_id for user
668
+     * If no question for this category, return ""
669
+     */
670
+    public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id)
671
+    {
672
+        $tbl_track_attempt		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
673
+        $tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
674
+        $in_cat_id = intval($in_cat_id);
675
+        $in_exe_id = intval($in_exe_id);
676
+        $in_user_id = intval($in_user_id);
677
+
678
+        $query = "SELECT DISTINCT
679 679
 		            marks, exe_id, user_id, ta.question_id, category_id
680 680
                   FROM $tbl_track_attempt ta , $tbl_question_rel_category qrc
681 681
                   WHERE
682 682
                     ta.question_id=qrc.question_id AND
683 683
                     qrc.category_id=$in_cat_id AND
684 684
                     exe_id=$in_exe_id AND user_id=$in_user_id";
685
-		$res = Database::query($query);
686
-		$totalcatscore = "";
687
-		while ($data = Database::fetch_array($res)) {
688
-			$totalcatscore += $data['marks'];
689
-		}
690
-		return $totalcatscore;
691
-	}
692
-
693
-	/**
685
+        $res = Database::query($query);
686
+        $totalcatscore = "";
687
+        while ($data = Database::fetch_array($res)) {
688
+            $totalcatscore += $data['marks'];
689
+        }
690
+        return $totalcatscore;
691
+    }
692
+
693
+    /**
694 694
      * return the number max of question in a category
695 695
      * count the number of questions in all categories, and return the max
696 696
      * @param int $exerciseId
697 697
      * @author - hubert borderiou
698
-    */
698
+     */
699 699
     public static function getNumberMaxQuestionByCat($exerciseId)
700 700
     {
701 701
         $res_num_max = 0;
702 702
         // foreach question
703
-		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
704
-		for ($i=0; $i < count($tabcatid); $i++) {
705
-			if ($tabcatid[$i] > 0) {	// 0 = no category for this question
706
-				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
703
+        $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
704
+        for ($i=0; $i < count($tabcatid); $i++) {
705
+            if ($tabcatid[$i] > 0) {	// 0 = no category for this question
706
+                $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
707 707
                 if ($nbQuestionInThisCat > $res_num_max) {
708 708
                     $res_num_max = $nbQuestionInThisCat;
709 709
                 }
710
-			}
711
-		}
710
+            }
711
+        }
712 712
         return $res_num_max;
713 713
     }
714 714
 
@@ -768,34 +768,34 @@  discard block
 block discarded – undo
768 768
     }
769 769
 
770 770
     /**
771
-	 * @return array
772
-	 */
773
-	function get_all_categories()
774
-	{
775
-		$table = Database::get_course_table(TABLE_QUIZ_CATEGORY);
776
-		$sql = "SELECT * FROM $table ORDER BY title ASC";
777
-		$res = Database::query($sql);
778
-		while ($row = Database::fetch_array($res,'ASSOC')) {
779
-			$array[] = $row;
780
-		}
781
-		return $array;
782
-	}
783
-
784
-	/**
785
-	 * @param Exercise $exercise
786
-	 * @param int $course_id
787
-	 * @param string $order
788
-	 * @param bool $shuffle
789
-	 * @param bool $excludeCategoryWithNoQuestions
790
-	 * @return array|bool
791
-	 */
792
-	public function getCategoryExerciseTree(
793
-		$exercise,
794
-		$course_id,
795
-		$order = null,
796
-		$shuffle = false,
797
-		$excludeCategoryWithNoQuestions = true
798
-	) {
771
+     * @return array
772
+     */
773
+    function get_all_categories()
774
+    {
775
+        $table = Database::get_course_table(TABLE_QUIZ_CATEGORY);
776
+        $sql = "SELECT * FROM $table ORDER BY title ASC";
777
+        $res = Database::query($sql);
778
+        while ($row = Database::fetch_array($res,'ASSOC')) {
779
+            $array[] = $row;
780
+        }
781
+        return $array;
782
+    }
783
+
784
+    /**
785
+     * @param Exercise $exercise
786
+     * @param int $course_id
787
+     * @param string $order
788
+     * @param bool $shuffle
789
+     * @param bool $excludeCategoryWithNoQuestions
790
+     * @return array|bool
791
+     */
792
+    public function getCategoryExerciseTree(
793
+        $exercise,
794
+        $course_id,
795
+        $order = null,
796
+        $shuffle = false,
797
+        $excludeCategoryWithNoQuestions = true
798
+    ) {
799 799
         if (empty($exercise)) {
800 800
             return array();
801 801
         }
@@ -805,165 +805,165 @@  discard block
 block discarded – undo
805 805
         }
806 806
 
807 807
         $course_id = intval($course_id);
808
-		$table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY);
808
+        $table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY);
809 809
         $categoryTable = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
810
-		$sql = "SELECT * FROM $table qc
810
+        $sql = "SELECT * FROM $table qc
811 811
               	LEFT JOIN $categoryTable c
812 812
                 ON (qc.c_id = c.c_id AND c.id = qc.category_id)
813 813
                 WHERE qc.c_id = $course_id AND exercise_id = {$exercise->id} ";
814 814
 
815
-		if (!empty($order)) {
816
-			$sql .= "ORDER BY $order";
817
-		}
818
-
819
-		$categories = array();
820
-
821
-		$result = Database::query($sql);
822
-		if (Database::num_rows($result)) {
823
-			while ($row = Database::fetch_array($result, 'ASSOC')) {
824
-				if ($excludeCategoryWithNoQuestions) {
825
-					if ($row['count_questions'] == 0) {
826
-						continue;
827
-					}
828
-				}
829
-				if (empty($row['title']) && empty($row['category_id'])) {
830
-					$row['title'] = get_lang('NoCategory');
831
-				}
815
+        if (!empty($order)) {
816
+            $sql .= "ORDER BY $order";
817
+        }
818
+
819
+        $categories = array();
820
+
821
+        $result = Database::query($sql);
822
+        if (Database::num_rows($result)) {
823
+            while ($row = Database::fetch_array($result, 'ASSOC')) {
824
+                if ($excludeCategoryWithNoQuestions) {
825
+                    if ($row['count_questions'] == 0) {
826
+                        continue;
827
+                    }
828
+                }
829
+                if (empty($row['title']) && empty($row['category_id'])) {
830
+                    $row['title'] = get_lang('NoCategory');
831
+                }
832 832
                 $categories[$row['category_id']] = $row;
833
-			}
834
-		}
835
-
836
-		if ($shuffle) {
837
-			shuffle_assoc($categories);
838
-		}
839
-
840
-		return $categories;
841
-	}
842
-
843
-	public function getForm(& $form, $action = 'new')
844
-	{
845
-		switch($action) {
846
-			case 'new':
847
-				$header = get_lang('AddACategory');
848
-				$submit = get_lang('AddTestCategory');
849
-				break;
850
-			case 'edit':
851
-				$header = get_lang('EditCategory');
852
-				$submit = get_lang('ModifyCategory');
853
-				break;
854
-		}
855
-
856
-		// settting the form elements
857
-		$form->addElement('header', $header);
858
-		$form->addElement('hidden', 'category_id');
859
-		$form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6'));
860
-		$form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
861
-		$category_parent_list = array();
862
-
863
-		$options = array(
864
-				'1' => get_lang('Visible'),
865
-				'0' => get_lang('Hidden')
866
-		);
867
-		$form->addElement('select', 'visibility', get_lang('Visibility'), $options);
868
-		$script = null;
869
-		if (!empty($this->parent_id)) {
870
-			$parent_cat = new TestCategory($this->parent_id);
871
-			$category_parent_list = array($parent_cat->id => $parent_cat->name);
872
-			$script .= '<script>$(function() { $("#parent_id").trigger("addItem",[{"title": "'.$parent_cat->name.'", "value": "'.$parent_cat->id.'"}]); });</script>';
873
-		}
874
-		$form->addElement('html', $script);
875
-
876
-		$form->addElement('select', 'parent_id', get_lang('Parent'), $category_parent_list, array('id' => 'parent_id'));
877
-		$form->addElement('style_submit_button', 'SubmitNote', $submit, 'class="add"');
878
-
879
-		// setting the defaults
880
-		$defaults = array();
881
-		$defaults["category_id"] = $this->id;
882
-		$defaults["category_name"] = $this->name;
883
-		$defaults["category_description"] = $this->description;
884
-		$defaults["parent_id"] = $this->parent_id;
885
-		$defaults["visibility"] = $this->visibility;
886
-		$form->setDefaults($defaults);
887
-
888
-		// setting the rules
889
-		$form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
890
-	}
891
-
892
-	/**
893
-	 * Returns the category form.
894
-	 * @param Exercise $exercise_obj
895
-	 * @return string
896
-	 */
897
-	public function returnCategoryForm(Exercise $exercise_obj)
898
-	{
899
-		$categories = $this->getListOfCategoriesForTest($exercise_obj);
900
-
901
-		$saved_categories = $exercise_obj->get_categories_in_exercise();
902
-		$return = null;
903
-
904
-		if (!empty($categories)) {
905
-			$nbQuestionsTotal = $exercise_obj->getNumberQuestionExerciseCategory();
906
-			$exercise_obj->setCategoriesGrouping(true);
907
-			$real_question_count = count($exercise_obj->getQuestionList());
908
-
909
-			$warning = null;
910
-			if ($nbQuestionsTotal != $real_question_count) {
911
-				$warning = Display::return_message(get_lang('CheckThatYouHaveEnoughQuestionsInYourCategories'), 'warning');
912
-			}
913
-
914
-			$return .= $warning;
915
-			$return .= '<table class="data_table">';
916
-			$return .= '<tr>';
917
-			$return .= '<th height="24">' . get_lang('Categories') . '</th>';
918
-			$return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>';
919
-
920
-			$emptyCategory = array(
921
-				'id' => '0',
922
-				'name' => get_lang('NoCategory'),
923
-				'description' => '',
924
-				'iid' => '0',
925
-				'title' => get_lang('NoCategory')
926
-			);
927
-
928
-			$categories[] = $emptyCategory;
929
-
930
-			foreach ($categories as $category) {
931
-				$cat_id = $category['iid'];
932
-				$return .= '<tr>';
933
-				$return .= '<td>';
934
-				//$return .= Display::div(isset($category['parent_path']) ? $category['parent_path'] : '');
935
-				$return .= Display::div($category['name']);
936
-				$return .= '</td>';
937
-				$return .= '<td>';
938
-				$value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1;
939
-				$return .= '<input name="category['.$cat_id.']" value="' .$value.'" />';
940
-				$return .= '</td>';
941
-				$return .= '</tr>';
942
-			}
943
-
944
-			$return .= '</table>';
945
-			$return .= get_lang('ZeroMeansNoQuestionWillBeSelectedMinusOneMeansThatAllQuestionsWillBeSelected');
946
-			return $return;
947
-		}
948
-	}
949
-
950
-	/**
951
-	 * Sorts an array
952
-	 * @param $array
953
-	 * @return mixed
954
-	 */
955
-	public function sort_tree_array($array)
956
-	{
957
-		foreach ($array as $key => $row) {
958
-			$parent[$key] = $row['parent_id'];
959
-		}
960
-		if (count($array) > 0) {
961
-			array_multisort($parent, SORT_ASC, $array);
962
-		}
963
-		return $array;
964
-	}
965
-
966
-	/**
833
+            }
834
+        }
835
+
836
+        if ($shuffle) {
837
+            shuffle_assoc($categories);
838
+        }
839
+
840
+        return $categories;
841
+    }
842
+
843
+    public function getForm(& $form, $action = 'new')
844
+    {
845
+        switch($action) {
846
+            case 'new':
847
+                $header = get_lang('AddACategory');
848
+                $submit = get_lang('AddTestCategory');
849
+                break;
850
+            case 'edit':
851
+                $header = get_lang('EditCategory');
852
+                $submit = get_lang('ModifyCategory');
853
+                break;
854
+        }
855
+
856
+        // settting the form elements
857
+        $form->addElement('header', $header);
858
+        $form->addElement('hidden', 'category_id');
859
+        $form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6'));
860
+        $form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
861
+        $category_parent_list = array();
862
+
863
+        $options = array(
864
+                '1' => get_lang('Visible'),
865
+                '0' => get_lang('Hidden')
866
+        );
867
+        $form->addElement('select', 'visibility', get_lang('Visibility'), $options);
868
+        $script = null;
869
+        if (!empty($this->parent_id)) {
870
+            $parent_cat = new TestCategory($this->parent_id);
871
+            $category_parent_list = array($parent_cat->id => $parent_cat->name);
872
+            $script .= '<script>$(function() { $("#parent_id").trigger("addItem",[{"title": "'.$parent_cat->name.'", "value": "'.$parent_cat->id.'"}]); });</script>';
873
+        }
874
+        $form->addElement('html', $script);
875
+
876
+        $form->addElement('select', 'parent_id', get_lang('Parent'), $category_parent_list, array('id' => 'parent_id'));
877
+        $form->addElement('style_submit_button', 'SubmitNote', $submit, 'class="add"');
878
+
879
+        // setting the defaults
880
+        $defaults = array();
881
+        $defaults["category_id"] = $this->id;
882
+        $defaults["category_name"] = $this->name;
883
+        $defaults["category_description"] = $this->description;
884
+        $defaults["parent_id"] = $this->parent_id;
885
+        $defaults["visibility"] = $this->visibility;
886
+        $form->setDefaults($defaults);
887
+
888
+        // setting the rules
889
+        $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
890
+    }
891
+
892
+    /**
893
+     * Returns the category form.
894
+     * @param Exercise $exercise_obj
895
+     * @return string
896
+     */
897
+    public function returnCategoryForm(Exercise $exercise_obj)
898
+    {
899
+        $categories = $this->getListOfCategoriesForTest($exercise_obj);
900
+
901
+        $saved_categories = $exercise_obj->get_categories_in_exercise();
902
+        $return = null;
903
+
904
+        if (!empty($categories)) {
905
+            $nbQuestionsTotal = $exercise_obj->getNumberQuestionExerciseCategory();
906
+            $exercise_obj->setCategoriesGrouping(true);
907
+            $real_question_count = count($exercise_obj->getQuestionList());
908
+
909
+            $warning = null;
910
+            if ($nbQuestionsTotal != $real_question_count) {
911
+                $warning = Display::return_message(get_lang('CheckThatYouHaveEnoughQuestionsInYourCategories'), 'warning');
912
+            }
913
+
914
+            $return .= $warning;
915
+            $return .= '<table class="data_table">';
916
+            $return .= '<tr>';
917
+            $return .= '<th height="24">' . get_lang('Categories') . '</th>';
918
+            $return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>';
919
+
920
+            $emptyCategory = array(
921
+                'id' => '0',
922
+                'name' => get_lang('NoCategory'),
923
+                'description' => '',
924
+                'iid' => '0',
925
+                'title' => get_lang('NoCategory')
926
+            );
927
+
928
+            $categories[] = $emptyCategory;
929
+
930
+            foreach ($categories as $category) {
931
+                $cat_id = $category['iid'];
932
+                $return .= '<tr>';
933
+                $return .= '<td>';
934
+                //$return .= Display::div(isset($category['parent_path']) ? $category['parent_path'] : '');
935
+                $return .= Display::div($category['name']);
936
+                $return .= '</td>';
937
+                $return .= '<td>';
938
+                $value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1;
939
+                $return .= '<input name="category['.$cat_id.']" value="' .$value.'" />';
940
+                $return .= '</td>';
941
+                $return .= '</tr>';
942
+            }
943
+
944
+            $return .= '</table>';
945
+            $return .= get_lang('ZeroMeansNoQuestionWillBeSelectedMinusOneMeansThatAllQuestionsWillBeSelected');
946
+            return $return;
947
+        }
948
+    }
949
+
950
+    /**
951
+     * Sorts an array
952
+     * @param $array
953
+     * @return mixed
954
+     */
955
+    public function sort_tree_array($array)
956
+    {
957
+        foreach ($array as $key => $row) {
958
+            $parent[$key] = $row['parent_id'];
959
+        }
960
+        if (count($array) > 0) {
961
+            array_multisort($parent, SORT_ASC, $array);
962
+        }
963
+        return $array;
964
+    }
965
+
966
+    /**
967 967
      * Return true if a category already exists with the same name
968 968
      * @param string $in_name
969 969
      *
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
      * @param int $categoryId
1011 1011
      * @param int $questionId
1012 1012
      * @param int $courseId
1013
-	 *
1014
-	 * @return int
1013
+     *
1014
+     * @return int
1015 1015
      */
1016 1016
     public static function add_category_for_question_id($categoryId, $questionId, $courseId)
1017 1017
     {
@@ -1019,18 +1019,18 @@  discard block
 block discarded – undo
1019 1019
         // if question doesn't have a category
1020 1020
         // @todo change for 1.10 when a question can have several categories
1021 1021
         if (TestCategory::getCategoryForQuestion($questionId, $courseId) == 0 &&
1022
-			$questionId > 0 &&
1023
-			$courseId > 0
1022
+            $questionId > 0 &&
1023
+            $courseId > 0
1024 1024
         ) {
1025 1025
             $sql = "INSERT INTO $table (c_id, question_id, category_id)
1026 1026
                     VALUES (".intval($courseId).", ".intval($questionId).", ".intval($categoryId).")";
1027 1027
             Database::query($sql);
1028
-			$id = Database::insert_id();
1028
+            $id = Database::insert_id();
1029 1029
 
1030
-			return $id;
1030
+            return $id;
1031 1031
         }
1032 1032
 
1033
-		return false;
1033
+        return false;
1034 1034
     }
1035 1035
 
1036 1036
     /**
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             $row = Database::fetch_array($res);
58 58
             $this->id = $row['id'];
59 59
             $this->name = $row['title'];
60
-            $this->description  = $row['description'];
60
+            $this->description = $row['description'];
61 61
         }
62 62
     }
63 63
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     /**
197 197
      * @param string $in_color
198 198
      */
199
-    public function display($in_color="#E0EBF5")
199
+    public function display($in_color = "#E0EBF5")
200 200
     {
201 201
 		echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
202 202
 		print_r($this);
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 */
212 212
     public static function getCategoryListInfo($in_field = "", $courseId = "")
213 213
     {
214
-        if (empty($courseId) || $courseId=="") {
214
+        if (empty($courseId) || $courseId == "") {
215 215
             $courseId = api_get_course_int_id();
216 216
         }
217 217
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      *
252 252
      * @return int
253 253
      */
254
-	public static function getCategoryForQuestion($questionId, $courseId ="")
254
+	public static function getCategoryForQuestion($questionId, $courseId = "")
255 255
     {
256 256
 		$result = 0;
257 257
         if (empty($courseId) || $courseId == "") {
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
         $questionId,
292 292
         $courseId = ""
293 293
     ) {
294
-		if (empty($courseId) || $courseId=="") {
294
+		if (empty($courseId) || $courseId == "") {
295 295
 			$courseId = api_get_course_int_id();
296 296
 		}
297 297
 		$catid = TestCategory::getCategoryForQuestion($questionId, $courseId);
298
-		$result = "";	// result
298
+		$result = ""; // result
299 299
 		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
300 300
 		$catid = intval($catid);
301 301
 		$sql = "SELECT title FROM $table
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 		$categories = self::getListOfCategoriesIDForTestObject($exercise_obj);
402 402
 		foreach ($categories as $cat_id) {
403 403
 			$cat = new TestCategory($cat_id);
404
-			$cat = (array)$cat;
404
+			$cat = (array) $cat;
405 405
 			$cat['iid'] = $cat['id'];
406 406
 			$cat['title'] = $cat['name'];
407 407
 			$result[$cat['id']] = $cat;
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		$quiz->read($exerciseId);
437 437
 		$tabQuestionList = $quiz->selectQuestionList();
438 438
 		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
439
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
439
+		for ($i = 1; $i <= count($tabQuestionList); $i++) {
440 440
 			if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
441 441
 				$nbCatResult++;
442 442
 			}
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
     {
456 456
 		$nbquestionresult = 0;
457 457
 		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
458
-		for ($i=0; $i < count($tabcatid); $i++) {
458
+		for ($i = 0; $i < count($tabcatid); $i++) {
459 459
 			if ($tabcatid[$i] > 0 && $tabcatid[$i] > 0) {	// 0 = no category for this questio
460 460
 				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
461 461
 				if ($nbQuestionInThisCat > $in_nbrandom) {
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 		}
487 487
 	 	$tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
488 488
 	 	$tabresult = array("0"=>get_lang('NoCategorySelected'));
489
-	 	for ($i=0; $i < count($tabcatobject); $i++) {
489
+	 	for ($i = 0; $i < count($tabcatobject); $i++) {
490 490
 	 		$tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
491 491
 	 	}
492 492
 	 	return $tabresult;
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
      */
611 611
     public static function returnCategoryAndTitle($questionId, $in_display_category_name = 1)
612 612
     {
613
-        $is_student = !(api_is_allowed_to_edit(null,true) || api_is_session_admin());
613
+        $is_student = !(api_is_allowed_to_edit(null, true) || api_is_session_admin());
614 614
         // @todo fix $_SESSION['objExercise']
615 615
         $objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null;
616 616
         if (!empty($objExercise)) {
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
     public static function sortTabByBracketLabel($in_tab)
649 649
     {
650 650
 		$tabResult = array();
651
-		$tabCatName = array();	// tab of category name
651
+		$tabCatName = array(); // tab of category name
652 652
 		while (list($cat_id, $tabquestion) = each($in_tab)) {
653 653
 			$catTitle = new TestCategory($cat_id);
654 654
 			$tabCatName[$cat_id] = $catTitle->name;
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 	 */
670 670
 	public static function getCatScoreForExeidForUserid($in_cat_id, $in_exe_id, $in_user_id)
671 671
 	{
672
-		$tbl_track_attempt		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
672
+		$tbl_track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
673 673
 		$tbl_question_rel_category = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
674 674
 		$in_cat_id = intval($in_cat_id);
675 675
 		$in_exe_id = intval($in_exe_id);
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
         $res_num_max = 0;
702 702
         // foreach question
703 703
 		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
704
-		for ($i=0; $i < count($tabcatid); $i++) {
704
+		for ($i = 0; $i < count($tabcatid); $i++) {
705 705
 			if ($tabcatid[$i] > 0) {	// 0 = no category for this question
706 706
 				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
707 707
                 if ($nbQuestionInThisCat > $res_num_max) {
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 		$table = Database::get_course_table(TABLE_QUIZ_CATEGORY);
776 776
 		$sql = "SELECT * FROM $table ORDER BY title ASC";
777 777
 		$res = Database::query($sql);
778
-		while ($row = Database::fetch_array($res,'ASSOC')) {
778
+		while ($row = Database::fetch_array($res, 'ASSOC')) {
779 779
 			$array[] = $row;
780 780
 		}
781 781
 		return $array;
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 
843 843
 	public function getForm(& $form, $action = 'new')
844 844
 	{
845
-		switch($action) {
845
+		switch ($action) {
846 846
 			case 'new':
847 847
 				$header = get_lang('AddACategory');
848 848
 				$submit = get_lang('AddTestCategory');
@@ -914,8 +914,8 @@  discard block
 block discarded – undo
914 914
 			$return .= $warning;
915 915
 			$return .= '<table class="data_table">';
916 916
 			$return .= '<tr>';
917
-			$return .= '<th height="24">' . get_lang('Categories') . '</th>';
918
-			$return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>';
917
+			$return .= '<th height="24">'.get_lang('Categories').'</th>';
918
+			$return .= '<th width="70" height="24">'.get_lang('Number').'</th></tr>';
919 919
 
920 920
 			$emptyCategory = array(
921 921
 				'id' => '0',
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 				$return .= '</td>';
937 937
 				$return .= '<td>';
938 938
 				$value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1;
939
-				$return .= '<input name="category['.$cat_id.']" value="' .$value.'" />';
939
+				$return .= '<input name="category['.$cat_id.']" value="'.$value.'" />';
940 940
 				$return .= '</td>';
941 941
 				$return .= '</tr>';
942 942
 			}
@@ -1083,20 +1083,20 @@  discard block
 block discarded – undo
1083 1083
             $tmpobj = new TestCategory($category['id']);
1084 1084
             $nb_question = $tmpobj->getCategoryQuestionsNumber();
1085 1085
             $rowname = self::protectJSDialogQuote($category['title']);
1086
-            $nb_question_label = $nb_question == 1 ? $nb_question . ' ' . get_lang('Question') : $nb_question . ' ' . get_lang('Questions');
1086
+            $nb_question_label = $nb_question == 1 ? $nb_question.' '.get_lang('Question') : $nb_question.' '.get_lang('Questions');
1087 1087
 
1088 1088
             //$html .= '<div class="sectiontitle" id="id_cat' . $category['id'] . '">';
1089
-            $content = "<span style='float:right'>" . $nb_question_label . "</span>";
1089
+            $content = "<span style='float:right'>".$nb_question_label."</span>";
1090 1090
 
1091 1091
             $content .= '<div class="sectioncomment">';
1092 1092
             $content .= $category['description'];
1093 1093
             $content .= '</div>';
1094 1094
 
1095
-            $links = '<a href="' . api_get_self() . '?action=editcategory&category_id=' . $category['id'] . '">' .
1096
-                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
1097
-            $links .= ' <a href="' . api_get_self() . '?action=deletecategory&category_id=' . $category['id'] . '" ';
1098
-            $links .= 'onclick="return confirmDelete(\'' . self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure') . '[' . $rowname) . '] ?\', \'id_cat' . $category['id'] . '\');">';
1099
-            $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
1095
+            $links = '<a href="'.api_get_self().'?action=editcategory&category_id='.$category['id'].'">'.
1096
+                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
1097
+            $links .= ' <a href="'.api_get_self().'?action=deletecategory&category_id='.$category['id'].'" ';
1098
+            $links .= 'onclick="return confirmDelete(\''.self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure').'['.$rowname).'] ?\', \'id_cat'.$category['id'].'\');">';
1099
+            $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
1100 1100
             $html .= Display::panel($content, $category['title'].$links);
1101 1101
         }
1102 1102
 
Please login to merge, or discard this patch.
main/exercice/exercise_submit.php 2 patches
Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     if (!$objExercise->read($exerciseId) ||
117 117
         (!$objExercise->selectStatus() && !$is_allowedToEdit && $origin != 'learnpath')
118 118
     ) {
119
-    	if ($debug) {error_log('1.1. Error while reading the exercise'); };
119
+        if ($debug) {error_log('1.1. Error while reading the exercise'); };
120 120
         unset ($objExercise);
121 121
         $error = get_lang('ExerciseNotFound');
122 122
     } else {
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 
131 131
 //2. Checking if $objExercise is set
132 132
 if (!isset($objExercise) && isset($exerciseInSession)) {
133
-	if ($debug) { error_log('2. Loading $objExercise from session'); };
133
+    if ($debug) { error_log('2. Loading $objExercise from session'); };
134 134
     $objExercise = $exerciseInSession;
135 135
 }
136 136
 
137 137
 //3. $objExercise is not set, then return to the exercise list
138 138
 if (!is_object($objExercise)) {
139
-	if ($debug) {error_log('3. $objExercise was not set, kill the script'); };
139
+    if ($debug) {error_log('3. $objExercise was not set, kill the script'); };
140 140
     header('Location: exercise.php');
141 141
     exit;
142 142
 }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
 $time_control = false;
159 159
 if ($objExercise->expired_time != 0) {
160
-	$time_control = true;
160
+    $time_control = true;
161 161
 }
162 162
 
163 163
 // Generating the time control key for the user
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 $_SESSION['duration_time'][$current_expired_time_key] = $current_timestamp;
167 167
 
168 168
 if ($time_control) {
169
-	// Get the expired time of the current exercise in track_e_exercises
170
-	$total_seconds = $objExercise->expired_time*60;
169
+    // Get the expired time of the current exercise in track_e_exercises
170
+    $total_seconds = $objExercise->expired_time*60;
171 171
 }
172 172
 
173 173
 $show_clock = true;
174 174
 $user_id = api_get_user_id();
175 175
 if ($objExercise->selectAttempts() > 0) {
176
-	$attempt_html = '';
176
+    $attempt_html = '';
177 177
     $attempt_count = Event::get_attempt_count(
178 178
         $user_id,
179 179
         $exerciseId,
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
         $learnpath_item_view_id
183 183
     );
184 184
 
185
-	if ($attempt_count >= $objExercise->selectAttempts()) {
186
-		$show_clock = false;
187
-		if (!api_is_allowed_to_edit(null,true)) {
185
+    if ($attempt_count >= $objExercise->selectAttempts()) {
186
+        $show_clock = false;
187
+        if (!api_is_allowed_to_edit(null,true)) {
188 188
             if ($objExercise->results_disabled == 0 && $origin != 'learnpath') {
189 189
 
190 190
                 // Showing latest attempt according with task BT#1628
@@ -223,29 +223,29 @@  discard block
 block discarded – undo
223 223
                             $attempt_html .= Display::div(get_lang('Score').' '.$marks, array('id'=>'question_question_titlescore'));
224 224
                         }
225 225
                     }
226
-					$score =  ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
227
-					$attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
228
-				} else {
229
-					$attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
230
-				}
231
-			} else {
232
-				$attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
233
-			}
234
-		} else {
235
-			$attempt_html .= Display :: return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
236
-		}
226
+                    $score =  ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
227
+                    $attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
228
+                } else {
229
+                    $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
230
+                }
231
+            } else {
232
+                $attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
233
+            }
234
+        } else {
235
+            $attempt_html .= Display :: return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
236
+        }
237 237
 
238
-		if ($origin == 'learnpath') {
239
-			Display :: display_reduced_header();
240
-		} else {
241
-			Display :: display_header($nameTools,'Exercises');
242
-		}
238
+        if ($origin == 'learnpath') {
239
+            Display :: display_reduced_header();
240
+        } else {
241
+            Display :: display_header($nameTools,'Exercises');
242
+        }
243 243
 
244
-		echo $attempt_html;
245
-		if ($origin != 'learnpath')
246
-			Display :: display_footer();
247
-		exit;
248
-	}
244
+        echo $attempt_html;
245
+        if ($origin != 'learnpath')
246
+            Display :: display_footer();
247
+        exit;
248
+    }
249 249
 }
250 250
 
251 251
 if ($debug) {
@@ -296,26 +296,26 @@  discard block
 block discarded – undo
296 296
 
297 297
 if (empty($exercise_stat_info)) {
298 298
     if ($debug)  error_log('5  $exercise_stat_info is empty ');
299
-	$total_weight = 0;
300
-	$questionList = $objExercise->get_validated_question_list();
301
-	foreach ($questionListUncompressed as $question_id) {
302
-		$objQuestionTmp = Question::read($question_id);
303
-		$total_weight += floatval($objQuestionTmp->weighting);
304
-	}
299
+    $total_weight = 0;
300
+    $questionList = $objExercise->get_validated_question_list();
301
+    foreach ($questionListUncompressed as $question_id) {
302
+        $objQuestionTmp = Question::read($question_id);
303
+        $total_weight += floatval($objQuestionTmp->weighting);
304
+    }
305 305
 
306
-	if ($time_control) {
307
-		$expected_time = $current_timestamp + $total_seconds;
306
+    if ($time_control) {
307
+        $expected_time = $current_timestamp + $total_seconds;
308 308
 
309
-		if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
310
-		if ($debug)  error_log('5.2. $expected_time '.$expected_time);
309
+        if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
310
+        if ($debug)  error_log('5.2. $expected_time '.$expected_time);
311 311
 
312
-		$clock_expired_time 	= api_get_utc_datetime($expected_time);
313
-		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
312
+        $clock_expired_time 	= api_get_utc_datetime($expected_time);
313
+        if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
314 314
 
315
-		//Sessions  that contain the expired time
316
-		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
317
-		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
318
-	}
315
+        //Sessions  that contain the expired time
316
+        $_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
317
+        if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
318
+    }
319 319
 
320 320
     $exe_id = $objExercise->save_stat_track_exercise_info(
321 321
         $clock_expired_time,
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     );
333 333
     if ($debug)  error_log("5.5  exercise_stat_info[] exists getting exe_id $exe_id");
334 334
 } else {
335
-	$exe_id = $exercise_stat_info['exe_id'];
335
+    $exe_id = $exercise_stat_info['exe_id'];
336 336
     // Remember last question id position.
337 337
     $isFirstTime = Session::read('firstTime');
338 338
     if ($isFirstTime && $objExercise->type == ONE_PER_PAGE) {
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 if ($debug) { error_log('6. $objExercise->get_stat_track_exercise_info function called::  '.print_r($exercise_stat_info, 1)); };
363 363
 
364 364
 if (!empty($exercise_stat_info['questions_to_check'])) {
365
-	$my_remind_list = $exercise_stat_info['questions_to_check'];
366
-	$my_remind_list = explode(',', $my_remind_list);
367
-	$my_remind_list = array_filter($my_remind_list);
365
+    $my_remind_list = $exercise_stat_info['questions_to_check'];
366
+    $my_remind_list = explode(',', $my_remind_list);
367
+    $my_remind_list = array_filter($my_remind_list);
368 368
 }
369 369
 
370 370
 $params = "exe_id=$exe_id&exerciseId=$exerciseId&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id&".api_get_cidreq();
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
 
373 373
 if ($reminder == 2 && empty($my_remind_list)) {
374 374
     if ($debug) { error_log("6.2 calling the exercise_reminder.php "); };
375
-	header('Location: exercise_reminder.php?'.$params);
376
-	exit;
375
+    header('Location: exercise_reminder.php?'.$params);
376
+    exit;
377 377
 }
378 378
 
379 379
 /*
@@ -381,56 +381,56 @@  discard block
 block discarded – undo
381 381
  * If the expired time is major that zero(0) then the expired time is compute on this time.
382 382
  */
383 383
 if ($time_control) {
384
-	if ($debug) error_log('7.1. Time control is enabled');
385
-	if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
386
-	if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
384
+    if ($debug) error_log('7.1. Time control is enabled');
385
+    if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
386
+    if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
387 387
 
388 388
     if (!isset($_SESSION['expired_time'][$current_expired_time_key])) {
389 389
         //Timer - Get expired_time for a student
390 390
         if (!empty($exercise_stat_info)) {
391
-        	if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); };
392
-	        $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control'];
393
-			if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }
394
-	        // Get the last attempt of an exercise
395
-	    	$last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']);
391
+            if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); };
392
+            $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control'];
393
+            if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }
394
+            // Get the last attempt of an exercise
395
+            $last_attempt_date = Event::getLastAttemptDateOfExercise($exercise_stat_info['exe_id']);
396 396
 
397
-	    	/* This means that the user enters the exam but do not answer the
397
+            /* This means that the user enters the exam but do not answer the
398 398
 	    	   first question we get the date from the track_e_exercises not from
399 399
 	    	   the track_et_attempt see #2069 */
400
-	    	if (empty($last_attempt_date)) {
401
-	    		$diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
402
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
403
-	    	} else {
404
-	    		//Recalculate the time control due #2069
405
-	    		$diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
406
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
407
-	    	}
408
-	        if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
409
-
410
-	        //New expired time - it is due to the possible closure of session
411
-	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
412
-	        if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
413
-
414
-	        $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
415
-	        if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
416
-
417
-	        $clock_expired_time  = api_get_utc_datetime($expected_time);
418
-	        if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
419
-
420
-			// First we update the attempt to today
421
-			/* How the expired time is changed into "track_e_exercises" table,
400
+            if (empty($last_attempt_date)) {
401
+                $diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
402
+                $last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
403
+            } else {
404
+                //Recalculate the time control due #2069
405
+                $diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
406
+                $last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
407
+            }
408
+            if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
409
+
410
+            //New expired time - it is due to the possible closure of session
411
+            $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
412
+            if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
413
+
414
+            $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
415
+            if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
416
+
417
+            $clock_expired_time  = api_get_utc_datetime($expected_time);
418
+            if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
419
+
420
+            // First we update the attempt to today
421
+            /* How the expired time is changed into "track_e_exercises" table,
422 422
                then the last attempt for this student should be changed too */
423
-	        $sql = "UPDATE $exercise_attempt_table SET
423
+            $sql = "UPDATE $exercise_attempt_table SET
424 424
 	                tms = '".api_get_utc_datetime()."'
425 425
 	                WHERE
426 426
 	                    exe_id = '".$exercise_stat_info['exe_id']."' AND
427 427
 	                    tms = '".$last_attempt_date."' ";
428
-	        if ($debug) {error_log('7.10. $sql: '.$sql); }
429
-	        Database::query($sql);
428
+            if ($debug) {error_log('7.10. $sql: '.$sql); }
429
+            Database::query($sql);
430 430
 
431
-	        //Sessions  that contain the expired time
432
-	        $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
433
-	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
431
+            //Sessions  that contain the expired time
432
+            $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
433
+            if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
434 434
         }
435 435
     } else {
436 436
         $clock_expired_time =  $_SESSION['expired_time'][$current_expired_time_key];
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
  * for more details of how it works see this link : http://eric.garside.name/docs.html?p=epiclock
448 448
  */
449 449
 if ($time_control) { //Sends the exercise form when the expired time is finished
450
-	$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
450
+    $htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
451 451
 }
452 452
 
453 453
 // if the user has submitted the form
@@ -461,14 +461,14 @@  discard block
 block discarded – undo
461 461
     // selects the list of question ID
462 462
     $questionList = $objExercise->get_validated_question_list();
463 463
     if ($objExercise->isRandom() && !empty($exercise_stat_info['data_tracking'])) {
464
-    	$questionList = explode(',', $exercise_stat_info['data_tracking']);
464
+        $questionList = explode(',', $exercise_stat_info['data_tracking']);
465 465
     }
466 466
     Session::write('questionList', $questionList);
467 467
     if ($debug > 0) { error_log('$_SESSION[questionList] was set'); }
468 468
 } else {
469
-	if (isset($objExercise) && isset($_SESSION['objExercise'])) {
470
-    	$questionList = $_SESSION['questionList'];
471
-	}
469
+    if (isset($objExercise) && isset($_SESSION['objExercise'])) {
470
+        $questionList = $_SESSION['questionList'];
471
+    }
472 472
 }
473 473
 
474 474
 if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1));
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 //Real question count
477 477
 $question_count = 0;
478 478
 if (!empty($questionList)) {
479
-	$question_count = count($questionList);
479
+    $question_count = count($questionList);
480 480
 }
481 481
 
482 482
 if ($formSent && isset($_POST)) {
@@ -518,11 +518,11 @@  discard block
 block discarded – undo
518 518
                 //saving each question
519 519
                 if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
520 520
                     $nro_question = $current_question; // - 1;
521
-                 	$questionId   = $key;
521
+                        $questionId   = $key;
522 522
                     // gets the student choice for this question
523 523
                     $choice = $exerciseResult[$questionId];
524 524
                     if (isset($exe_id)) {
525
-                    	// Manage the question and answer attempts
525
+                        // Manage the question and answer attempts
526 526
                         if ($debug) { error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
527 527
                         $objExercise->manage_answer(
528 528
                             $exe_id,
@@ -611,58 +611,58 @@  discard block
 block discarded – undo
611 611
 }
612 612
 
613 613
 if ($question_count != 0) {
614
-	if (($objExercise->type == ALL_ON_ONE_PAGE ||
614
+    if (($objExercise->type == ALL_ON_ONE_PAGE ||
615 615
         $current_question > $question_count)
616 616
     ) {
617
-	    if (api_is_allowed_to_session_edit()) {
618
-	        // goes to the script that will show the result of the exercise
619
-	        if ($objExercise->type == ALL_ON_ONE_PAGE) {
620
-	            if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
621
-
622
-	            //We check if the user attempts before sending to the exercise_result.php
623
-	            if ($objExercise->selectAttempts() > 0) {
624
-	                $attempt_count = Event::get_attempt_count(
617
+        if (api_is_allowed_to_session_edit()) {
618
+            // goes to the script that will show the result of the exercise
619
+            if ($objExercise->type == ALL_ON_ONE_PAGE) {
620
+                if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
621
+
622
+                //We check if the user attempts before sending to the exercise_result.php
623
+                if ($objExercise->selectAttempts() > 0) {
624
+                    $attempt_count = Event::get_attempt_count(
625 625
                         api_get_user_id(),
626 626
                         $exerciseId,
627 627
                         $learnpath_id,
628 628
                         $learnpath_item_id,
629 629
                         $learnpath_item_view_id
630 630
                     );
631
-	                if ($attempt_count >= $objExercise->selectAttempts()) {
632
-	                    Display :: display_warning_message(
631
+                    if ($attempt_count >= $objExercise->selectAttempts()) {
632
+                        Display :: display_warning_message(
633 633
                             sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()),
634 634
                             false
635 635
                         );
636
-	                    if ($origin != 'learnpath') {
637
-	                        //so we are not in learnpath tool
638
-	                        echo '</div>'; //End glossary div
639
-	                        Display :: display_footer();
640
-	                    } else {
641
-	                        echo '</body></html>';
642
-	                    }
643
-	                    exit;
644
-	                }
645
-	            }
646
-	        } else {
647
-	            if ($objExercise->review_answers) {
648
-	            	header('Location: exercise_reminder.php?'.$params);
649
-	            	exit;
650
-	            } else {
636
+                        if ($origin != 'learnpath') {
637
+                            //so we are not in learnpath tool
638
+                            echo '</div>'; //End glossary div
639
+                            Display :: display_footer();
640
+                        } else {
641
+                            echo '</body></html>';
642
+                        }
643
+                        exit;
644
+                    }
645
+                }
646
+            } else {
647
+                if ($objExercise->review_answers) {
648
+                    header('Location: exercise_reminder.php?'.$params);
649
+                    exit;
650
+                } else {
651 651
                     header("Location: exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
652 652
                     exit;
653
-	            }
654
-	        }
655
-	    } else {
656
-	        if ($debug) { error_log('Redirecting to exercise_submit.php'); }
657
-	        exit;
658
-	    }
659
-	}
653
+                }
654
+            }
655
+        } else {
656
+            if ($debug) { error_log('Redirecting to exercise_submit.php'); }
657
+            exit;
658
+        }
659
+    }
660 660
 } else {
661
-	$error = get_lang('ThereAreNoQuestionsForThisExercise');
662
-	// if we are in the case where user select random by category, but didn't choose the number of random question
663
-	if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) {
664
-		$error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion');
665
-	}
661
+    $error = get_lang('ThereAreNoQuestionsForThisExercise');
662
+    // if we are in the case where user select random by category, but didn't choose the number of random question
663
+    if ($objExercise->selectRandomByCat() > 0 && $objExercise->random <= 0) {
664
+        $error .= "<br/>".get_lang('PleaseSelectSomeRandomQuestion');
665
+    }
666 666
 }
667 667
 
668 668
 if (!empty ($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
@@ -701,9 +701,9 @@  discard block
 block discarded – undo
701 701
 if (api_is_course_admin() && $origin != 'learnpath') {
702 702
     echo '<div class="actions">';
703 703
     if ($show_quiz_edition == false) {
704
-    	echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
704
+        echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
705 705
     } else {
706
-    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
706
+        echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
707 707
     }
708 708
     echo '</div>';
709 709
 }
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
             $message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet');
747 747
             Display :: display_warning_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()));
748 748
             if ($origin != 'learnpath') {
749
-            	Display :: display_footer();
749
+                Display :: display_footer();
750 750
             }
751 751
             exit;
752 752
         } else {
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 if (isset($_custom['exercises_hidden_when_no_start_date']) &&
762 762
     $_custom['exercises_hidden_when_no_start_date']
763 763
 ) {
764
-	if (empty($objExercise->start_time) || $objExercise->start_time == '0000-00-00 00:00:00') {
764
+    if (empty($objExercise->start_time) || $objExercise->start_time == '0000-00-00 00:00:00') {
765 765
         Display:: display_warning_message(
766 766
             sprintf(
767 767
                 get_lang('ExerciseNoStartedYet'),
@@ -769,20 +769,20 @@  discard block
 block discarded – undo
769 769
                 $objExercise->selectAttempts()
770 770
             )
771 771
         );
772
-		if ($origin != 'learnpath') {
773
-			Display :: display_footer();
774
-		}
775
-	}
772
+        if ($origin != 'learnpath') {
773
+            Display :: display_footer();
774
+        }
775
+    }
776 776
 }
777 777
 
778 778
 //Timer control
779 779
 if ($time_control) {
780 780
     echo $objExercise->return_time_left_div();
781
-	echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>';
781
+    echo '<div style="display:none" class="warning-message" id="expired-message-id">'.get_lang('ExerciseExpiredTimeMessage').'</div>';
782 782
 }
783 783
 
784 784
 if ($origin != 'learnpath') {
785
-   echo '<div id="highlight-plugin" class="glossary-content">';
785
+    echo '<div id="highlight-plugin" class="glossary-content">';
786 786
 }
787 787
 
788 788
 if ($reminder == 2)  {
@@ -794,53 +794,53 @@  discard block
 block discarded – undo
794 794
     $current_question = 1; //set by default the 1st question
795 795
 
796 796
     if (!empty($my_remind_list)) {
797
-    	// Checking which questions we are going to call from the remind list
798
-		for ($i = 0; $i < count($data_tracking); $i++) {
799
-			for($j = 0; $j < count($my_remind_list); $j++) {
800
-
801
-				if (!empty($remind_question_id)) {
802
-					if ($remind_question_id == $my_remind_list[$j]) {
803
-
804
-			        	if ($remind_question_id == $data_tracking[$i]) {
805
-			        		if (isset($my_remind_list[$j+1])) {
806
-			        			$remind_question_id = $my_remind_list[$j+1];
807
-			        			$current_question = $i + 1;
808
-			        		} else {
797
+        // Checking which questions we are going to call from the remind list
798
+        for ($i = 0; $i < count($data_tracking); $i++) {
799
+            for($j = 0; $j < count($my_remind_list); $j++) {
800
+
801
+                if (!empty($remind_question_id)) {
802
+                    if ($remind_question_id == $my_remind_list[$j]) {
803
+
804
+                        if ($remind_question_id == $data_tracking[$i]) {
805
+                            if (isset($my_remind_list[$j+1])) {
806
+                                $remind_question_id = $my_remind_list[$j+1];
807
+                                $current_question = $i + 1;
808
+                            } else {
809 809
                                 // We end the remind list we go to the exercise_reminder.php please
810
-			        			$remind_question_id = -1;
811
-			        			$current_question = $i + 1; // last question
812
-			        		}
813
-			        		break 2;
814
-			            }
815
-					}
816
-				} else {
817
-					if ($my_remind_list[$j] == $data_tracking[$i]) {
818
-						if (isset($my_remind_list[$j+1])) {
819
-							$remind_question_id = $my_remind_list[$j+1];
820
-							$current_question = $i + 1; // last question
821
-						} else {
810
+                                $remind_question_id = -1;
811
+                                $current_question = $i + 1; // last question
812
+                            }
813
+                            break 2;
814
+                        }
815
+                    }
816
+                } else {
817
+                    if ($my_remind_list[$j] == $data_tracking[$i]) {
818
+                        if (isset($my_remind_list[$j+1])) {
819
+                            $remind_question_id = $my_remind_list[$j+1];
820
+                            $current_question = $i + 1; // last question
821
+                        } else {
822 822
                             // We end the remind list we go to the exercise_reminder.php please
823
-							$remind_question_id = -1;
824
-							$current_question = $i + 1; // last question
825
-						}
826
-						break 2;
827
-					}
828
-				}
829
-			}
823
+                            $remind_question_id = -1;
824
+                            $current_question = $i + 1; // last question
825
+                        }
826
+                        break 2;
827
+                    }
828
+                }
829
+            }
830 830
         }
831 831
     } else {
832
-    	if ($objExercise->review_answers) {
832
+        if ($objExercise->review_answers) {
833 833
             if ($debug) { error_log('. redirecting to exercise_reminder.php '); }
834
-	    	header("Location: exercise_reminder.php?$params");
835
-	    	exit;
836
-    	}
834
+            header("Location: exercise_reminder.php?$params");
835
+            exit;
836
+        }
837 837
     }
838 838
 }
839 839
 
840 840
 if ($objExercise->review_answers) {
841
-	$script_php = 'exercise_reminder.php';
841
+    $script_php = 'exercise_reminder.php';
842 842
 } else {
843
-	$script_php = 'exercise_result.php';
843
+    $script_php = 'exercise_result.php';
844 844
 }
845 845
 
846 846
 if (!empty($error)) {
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
          <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id . '" />
1085 1085
          <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id . '" />';
1086 1086
 
1087
-	// Show list of questions
1087
+    // Show list of questions
1088 1088
     $i = 1;
1089 1089
     $attempt_list = array();
1090 1090
     if (isset($exe_id)) {
@@ -1134,10 +1134,10 @@  discard block
 block discarded – undo
1134 1134
 
1135 1135
         $attributes = array('id' =>'remind_list['.$questionId.']');
1136 1136
         if (in_array($questionId, $remind_list)) {
1137
-        	$is_remind_on = true;
1138
-        	$attributes['checked'] = 1;
1139
-        	$remind_question = true;
1140
-        	$remind_highlight = ' remind_highlight ';
1137
+            $is_remind_on = true;
1138
+            $attributes['checked'] = 1;
1139
+            $remind_question = true;
1140
+            $remind_highlight = ' remind_highlight ';
1141 1141
         }
1142 1142
 
1143 1143
         // Showing the exercise description
@@ -1211,8 +1211,8 @@  discard block
 block discarded – undo
1211 1211
     }
1212 1212
     // end foreach()
1213 1213
     if ($objExercise->type == ALL_ON_ONE_PAGE) {
1214
-    	$exercise_actions =  $objExercise->show_button($questionId, $current_question);
1215
-    	echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1214
+        $exercise_actions =  $objExercise->show_button($questionId, $current_question);
1215
+        echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1216 1216
         echo '<br>';
1217 1217
     }
1218 1218
     echo '</form>';
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 use ChamiloSession as Session;
30 30
 
31 31
 require_once '../inc/global.inc.php';
32
-$current_course_tool  = TOOL_QUIZ;
32
+$current_course_tool = TOOL_QUIZ;
33 33
 $this_section = SECTION_COURSES;
34 34
 $debug = false;
35 35
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
 $origin = isset($_REQUEST['origin']) ? Security::remove_XSS($_REQUEST['origin']) : '';
40 40
 
41
-$is_allowedToEdit = api_is_allowed_to_edit(null,true);
41
+$is_allowedToEdit = api_is_allowed_to_edit(null, true);
42 42
 $glossaryExtraTools = api_get_setting('show_glossary_in_extra_tools');
43 43
 
44 44
 $showGlossary = in_array($glossaryExtraTools, array('true', 'exercise', 'exercise_and_lp'));
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
61 61
 $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
62 62
 $htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
63
-$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
64
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
63
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
64
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
65 65
 
66 66
 $template = new Template();
67 67
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 $learnpath_id = isset($_REQUEST['learnpath_id']) ? intval($_REQUEST['learnpath_id']) : 0;
71 71
 $learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['learnpath_item_id']) : 0;
72
-$learnpath_item_view_id	= isset($_REQUEST['learnpath_item_view_id']) ? intval($_REQUEST['learnpath_item_view_id']) : 0;
72
+$learnpath_item_view_id = isset($_REQUEST['learnpath_item_view_id']) ? intval($_REQUEST['learnpath_item_view_id']) : 0;
73 73
 
74 74
 $reminder = isset($_REQUEST['reminder']) ? intval($_REQUEST['reminder']) : 0;
75 75
 $remind_question_id = isset($_REQUEST['remind_question_id']) ? intval($_REQUEST['remind_question_id']) : 0;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 /*  Teacher takes an exam and want to see a preview,
97 97
     we delete the objExercise from the session in order to get the latest
98 98
     changes in the exercise */
99
-if (api_is_allowed_to_edit(null, true) && isset($_GET['preview']) && $_GET['preview'] == 1 ) {
99
+if (api_is_allowed_to_edit(null, true) && isset($_GET['preview']) && $_GET['preview'] == 1) {
100 100
     Session::erase('objExercise');
101 101
 }
102 102
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
 if ($time_control) {
169 169
 	// Get the expired time of the current exercise in track_e_exercises
170
-	$total_seconds = $objExercise->expired_time*60;
170
+	$total_seconds = $objExercise->expired_time * 60;
171 171
 }
172 172
 
173 173
 $show_clock = true;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 
185 185
 	if ($attempt_count >= $objExercise->selectAttempts()) {
186 186
 		$show_clock = false;
187
-		if (!api_is_allowed_to_edit(null,true)) {
187
+		if (!api_is_allowed_to_edit(null, true)) {
188 188
             if ($objExercise->results_disabled == 0 && $origin != 'learnpath') {
189 189
 
190 190
                 // Showing latest attempt according with task BT#1628
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
                     );
215 215
 
216 216
                     if (!empty($last_attempt_info['question_list'])) {
217
-                        foreach($last_attempt_info['question_list'] as $question_data) {
217
+                        foreach ($last_attempt_info['question_list'] as $question_data) {
218 218
                             $question_id = $question_data['question_id'];
219 219
                             $marks       = $question_data['marks'];
220 220
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
                             $attempt_html .= Display::div(get_lang('Score').' '.$marks, array('id'=>'question_question_titlescore'));
224 224
                         }
225 225
                     }
226
-					$score =  ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
226
+					$score = ExerciseLib::show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
227 227
 					$attempt_html .= Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
228 228
 				} else {
229 229
 					$attempt_html .= Display::return_message(sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()), 'warning', false);
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		if ($origin == 'learnpath') {
239 239
 			Display :: display_reduced_header();
240 240
 		} else {
241
-			Display :: display_header($nameTools,'Exercises');
241
+			Display :: display_header($nameTools, 'Exercises');
242 242
 		}
243 243
 
244 244
 		echo $attempt_html;
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
 		if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
310 310
 		if ($debug)  error_log('5.2. $expected_time '.$expected_time);
311 311
 
312
-		$clock_expired_time 	= api_get_utc_datetime($expected_time);
312
+		$clock_expired_time = api_get_utc_datetime($expected_time);
313 313
 		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
314 314
 
315 315
 		//Sessions  that contain the expired time
316
-		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
317
-		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
316
+		$_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
317
+		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]); };
318 318
 	}
319 319
 
320 320
     $exe_id = $objExercise->save_stat_track_exercise_info(
@@ -399,22 +399,22 @@  discard block
 block discarded – undo
399 399
 	    	   the track_et_attempt see #2069 */
400 400
 	    	if (empty($last_attempt_date)) {
401 401
 	    		$diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
402
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
402
+	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'], 'UTC') + $diff);
403 403
 	    	} else {
404 404
 	    		//Recalculate the time control due #2069
405
-	    		$diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
406
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
405
+	    		$diff = $current_timestamp - api_strtotime($last_attempt_date, 'UTC');
406
+	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date, 'UTC') + $diff);
407 407
 	    	}
408 408
 	        if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
409 409
 
410 410
 	        //New expired time - it is due to the possible closure of session
411
-	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
411
+	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date, 'UTC');
412 412
 	        if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
413 413
 
414
-	        $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
414
+	        $expected_time = $current_timestamp + $new_expired_time_in_seconds;
415 415
 	        if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
416 416
 
417
-	        $clock_expired_time  = api_get_utc_datetime($expected_time);
417
+	        $clock_expired_time = api_get_utc_datetime($expected_time);
418 418
 	        if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
419 419
 
420 420
 			// First we update the attempt to today
@@ -430,17 +430,17 @@  discard block
 block discarded – undo
430 430
 
431 431
 	        //Sessions  that contain the expired time
432 432
 	        $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
433
-	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
433
+	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]); };
434 434
         }
435 435
     } else {
436
-        $clock_expired_time =  $_SESSION['expired_time'][$current_expired_time_key];
436
+        $clock_expired_time = $_SESSION['expired_time'][$current_expired_time_key];
437 437
     }
438 438
 } else {
439 439
     if ($debug) { error_log("7 No time control"); };
440 440
 }
441 441
 
442 442
 // Get time left for expiring time
443
-$time_left = api_strtotime($clock_expired_time,'UTC') - time();
443
+$time_left = api_strtotime($clock_expired_time, 'UTC') - time();
444 444
 
445 445
 /*
446 446
  * The time control feature is enable here - this feature is enable for a jquery plugin called epiclock
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 
491 491
     //Only for hotspot
492 492
     if (!isset($choice) && isset($_REQUEST['hidden_hotspot_id'])) {
493
-        $hotspot_id = (int)($_REQUEST['hidden_hotspot_id']);
493
+        $hotspot_id = (int) ($_REQUEST['hidden_hotspot_id']);
494 494
         $choice     = array($hotspot_id => '');
495 495
     }
496 496
 
@@ -518,12 +518,12 @@  discard block
 block discarded – undo
518 518
                 //saving each question
519 519
                 if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
520 520
                     $nro_question = $current_question; // - 1;
521
-                 	$questionId   = $key;
521
+                 	$questionId = $key;
522 522
                     // gets the student choice for this question
523 523
                     $choice = $exerciseResult[$questionId];
524 524
                     if (isset($exe_id)) {
525 525
                     	// Manage the question and answer attempts
526
-                        if ($debug) { error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
526
+                        if ($debug) { error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice, 1)); }
527 527
                         $objExercise->manage_answer(
528 528
                             $exe_id,
529 529
                             $questionId,
@@ -542,13 +542,13 @@  discard block
 block discarded – undo
542 542
             }
543 543
         }
544 544
         if ($debug) { error_log('9.3.  $choice is an array - end'); }
545
-        if ($debug) { error_log('9.4.  $exerciseResult '.print_r($exerciseResult,1)); }
545
+        if ($debug) { error_log('9.4.  $exerciseResult '.print_r($exerciseResult, 1)); }
546 546
     }
547 547
 
548 548
     // the script "exercise_result.php" will take the variable $exerciseResult from the session
549 549
     Session::write('exerciseResult', $exerciseResult);
550 550
     Session::write('remind_list', $remind_list);
551
-    Session::write('exerciseResultCoordinates',$exerciseResultCoordinates);
551
+    Session::write('exerciseResultCoordinates', $exerciseResultCoordinates);
552 552
 
553 553
     // if all questions on one page OR if it is the last question (only for an exercise with one question per page)
554 554
     if ($objExercise->type == ALL_ON_ONE_PAGE || $current_question >= $question_count) {
@@ -674,15 +674,15 @@  discard block
 block discarded – undo
674 674
 }
675 675
 
676 676
 if (!empty ($gradebook) && $gradebook == 'view') {
677
-    $interbreadcrumb[] = array ('url' => '../gradebook/' . Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('ToolGradebook'));
677
+    $interbreadcrumb[] = array('url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']), 'name' => get_lang('ToolGradebook'));
678 678
 }
679 679
 
680
-$interbreadcrumb[] = array ("url" => "exercise.php?".api_get_cidreq(),	"name" => get_lang('Exercises'));
681
-$interbreadcrumb[] = array ("url" => "#", "name" => $objExercise->name);
680
+$interbreadcrumb[] = array("url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises'));
681
+$interbreadcrumb[] = array("url" => "#", "name" => $objExercise->name);
682 682
 
683 683
 if ($origin != 'learnpath') { //so we are not in learnpath tool
684
-    Display :: display_header(null,'Exercises');
685
-    if (!api_is_allowed_to_session_edit() ) {
684
+    Display :: display_header(null, 'Exercises');
685
+    if (!api_is_allowed_to_session_edit()) {
686 686
         Display :: display_warning_message(get_lang('SessionIsReadOnly'));
687 687
     }
688 688
 } else {
@@ -701,9 +701,9 @@  discard block
 block discarded – undo
701 701
 if (api_is_course_admin() && $origin != 'learnpath') {
702 702
     echo '<div class="actions">';
703 703
     if ($show_quiz_edition == false) {
704
-    	echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
704
+    	echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>';
705 705
     } else {
706
-    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
706
+    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>';
707 707
     }
708 708
     echo '</div>';
709 709
 }
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
     }
743 743
 
744 744
     if (!$permission_to_start || $exercise_timeover) {
745
-        if (!api_is_allowed_to_edit(null,true)) {
745
+        if (!api_is_allowed_to_edit(null, true)) {
746 746
             $message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet');
747 747
             Display :: display_warning_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()));
748 748
             if ($origin != 'learnpath') {
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
    echo '<div id="highlight-plugin" class="glossary-content">';
786 786
 }
787 787
 
788
-if ($reminder == 2)  {
788
+if ($reminder == 2) {
789 789
     if ($debug) { error_log(' $reminder == 2'); }
790 790
 
791 791
     $data_tracking  = $exercise_stat_info['data_tracking'];
@@ -796,14 +796,14 @@  discard block
 block discarded – undo
796 796
     if (!empty($my_remind_list)) {
797 797
     	// Checking which questions we are going to call from the remind list
798 798
 		for ($i = 0; $i < count($data_tracking); $i++) {
799
-			for($j = 0; $j < count($my_remind_list); $j++) {
799
+			for ($j = 0; $j < count($my_remind_list); $j++) {
800 800
 
801 801
 				if (!empty($remind_question_id)) {
802 802
 					if ($remind_question_id == $my_remind_list[$j]) {
803 803
 
804 804
 			        	if ($remind_question_id == $data_tracking[$i]) {
805
-			        		if (isset($my_remind_list[$j+1])) {
806
-			        			$remind_question_id = $my_remind_list[$j+1];
805
+			        		if (isset($my_remind_list[$j + 1])) {
806
+			        			$remind_question_id = $my_remind_list[$j + 1];
807 807
 			        			$current_question = $i + 1;
808 808
 			        		} else {
809 809
                                 // We end the remind list we go to the exercise_reminder.php please
@@ -815,8 +815,8 @@  discard block
 block discarded – undo
815 815
 					}
816 816
 				} else {
817 817
 					if ($my_remind_list[$j] == $data_tracking[$i]) {
818
-						if (isset($my_remind_list[$j+1])) {
819
-							$remind_question_id = $my_remind_list[$j+1];
818
+						if (isset($my_remind_list[$j + 1])) {
819
+							$remind_question_id = $my_remind_list[$j + 1];
820 820
 							$current_question = $i + 1; // last question
821 821
 						} else {
822 822
                             // We end the remind list we go to the exercise_reminder.php please
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
     Display :: display_error_message($error, false);
848 848
 } else {
849 849
     if (!empty ($exercise_sound)) {
850
-        echo "<a href=\"../document/download.php?doc_url=%2Faudio%2F" . Security::remove_XSS($exercise_sound) . "\" target=\"_blank\">", "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=", get_lang('Sound') . "\" /></a>";
850
+        echo "<a href=\"../document/download.php?doc_url=%2Faudio%2F".Security::remove_XSS($exercise_sound)."\" target=\"_blank\">", "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=", get_lang('Sound')."\" /></a>";
851 851
     }
852 852
     // Get number of hotspot questions for javascript validation
853 853
     $number_of_hotspot_questions = 0;
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
     }
883 883
 
884 884
     if ($number_of_hotspot_questions > 0) {
885
-        $onsubmit = "onsubmit=\"return validateFlashVar('" . $number_of_hotspot_questions . "', '" . get_lang('HotspotValidateError1') . "', '" . get_lang('HotspotValidateError2') . "');\"";
885
+        $onsubmit = "onsubmit=\"return validateFlashVar('".$number_of_hotspot_questions."', '".get_lang('HotspotValidateError1')."', '".get_lang('HotspotValidateError2')."');\"";
886 886
     }
887 887
 
888 888
     echo '<script>
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
                 ICON_SIZE_SMALL,
897 897
                 false,
898 898
                 true
899
-            ) . '\';
899
+            ).'\';
900 900
 
901 901
             // Block form submition on enter
902 902
             $(".block_on_enter").keypress(function(event) {
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
             } else {
949 949
                 url = "exercise_submit.php?'.$params.'&num='.$current_question.'&remind_question_id='.$remind_question_id.'";
950 950
             }
951
-            //$("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL) . '\');
951
+            //$("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL).'\');
952 952
             window.location = url;
953 953
         }
954 954
 
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 
981 981
             // Only for the first time
982 982
 
983
-            $("#save_for_now_"+question_id).html(\'' . Display::returnFontAwesomeIcon('spinner', true, null, 'fa-spin') . '\');
983
+            $("#save_for_now_"+question_id).html(\'' . Display::returnFontAwesomeIcon('spinner', true, null, 'fa-spin').'\');
984 984
             $.ajax({
985 985
                 type:"post",
986 986
                 async: false,
@@ -988,9 +988,9 @@  discard block
 block discarded – undo
988 988
                 data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list,
989 989
                 success: function(return_value) {
990 990
                     if (return_value == "ok") {
991
-                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL) . '\');
991
+                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL).'\');
992 992
                     } else if (return_value == "error") {
993
-                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL) . '\');
993
+                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL).'\');
994 994
                     } else if (return_value == "one_per_page") {
995 995
                         var url = "";
996 996
                         if ('.$reminder.' == 1 ) {
@@ -1005,13 +1005,13 @@  discard block
 block discarded – undo
1005 1005
                             url = url_extra;
1006 1006
                         }
1007 1007
 
1008
-                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL) . '\');
1008
+                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL).'\');
1009 1009
 
1010 1010
                         window.location = url;
1011 1011
                     }
1012 1012
                 },
1013 1013
                 error: function() {
1014
-                    $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL) . '\');
1014
+                    $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL).'\');
1015 1015
                 }
1016 1016
             });
1017 1017
             return false;
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 
1045 1045
             free_answers = $.param(free_answers);
1046 1046
 
1047
-            $("#save_all_reponse").html(\'' . Display::returnFontAwesomeIcon('spinner', true, null, 'fa-spin') . '\');
1047
+            $("#save_all_reponse").html(\'' . Display::returnFontAwesomeIcon('spinner', true, null, 'fa-spin').'\');
1048 1048
 
1049 1049
             $.ajax({
1050 1050
                 type:"post",
@@ -1053,14 +1053,14 @@  discard block
 block discarded – undo
1053 1053
                 data: "'.$params.'&type=all&"+my_choice+"&"+hotspot+"&"+free_answers+"&"+remind_list,
1054 1054
                 success: function(return_value) {
1055 1055
                     if (return_value == "ok") {
1056
-                        //$("#save_all_reponse").html(\'' . Display::return_icon('accept.png') . '\');
1056
+                        //$("#save_all_reponse").html(\'' . Display::return_icon('accept.png').'\');
1057 1057
                         if (validate == "validate") {
1058 1058
                             window.location = "'.$script_php.'?'.$params.'";
1059 1059
                         } else {
1060
-                            $("#save_all_reponse").html(\'' . Display::return_icon('accept.png') . '\');
1060
+                            $("#save_all_reponse").html(\'' . Display::return_icon('accept.png').'\');
1061 1061
                         }
1062 1062
                     } else {
1063
-                        $("#save_all_reponse").html(\'' . Display::return_icon('wrong.gif') . '\');
1063
+                        $("#save_all_reponse").html(\'' . Display::return_icon('wrong.gif').'\');
1064 1064
                     }
1065 1065
                 }
1066 1066
             });
@@ -1073,16 +1073,16 @@  discard block
 block discarded – undo
1073 1073
         }
1074 1074
     </script>';
1075 1075
 
1076
-    echo '<form id="exercise_form" method="post" action="'.api_get_self().'?'.api_get_cidreq().'&autocomplete=off&&exerciseId='.$exerciseId .'" name="frm_exercise" '.$onsubmit.'>
1076
+    echo '<form id="exercise_form" method="post" action="'.api_get_self().'?'.api_get_cidreq().'&autocomplete=off&&exerciseId='.$exerciseId.'" name="frm_exercise" '.$onsubmit.'>
1077 1077
          <input type="hidden" name="formSent"				value="1" />
1078
-         <input type="hidden" name="exerciseId" 			value="'.$exerciseId . '" />
1078
+         <input type="hidden" name="exerciseId" 			value="'.$exerciseId.'" />
1079 1079
          <input type="hidden" name="num" 					value="'.$current_question.'" id="num_current_id" />
1080 1080
          <input type="hidden" name="num_answer"             value="'.$currentAnswer.'" id="num_current_answer_id" />
1081
-         <input type="hidden" name="exe_id" 				value="'.$exe_id . '" />
1082
-         <input type="hidden" name="origin" 				value="'.$origin . '" />
1083
-         <input type="hidden" name="learnpath_id" 			value="'.$learnpath_id . '" />
1084
-         <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id . '" />
1085
-         <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id . '" />';
1081
+         <input type="hidden" name="exe_id" 				value="'.$exe_id.'" />
1082
+         <input type="hidden" name="origin" 				value="'.$origin.'" />
1083
+         <input type="hidden" name="learnpath_id" 			value="'.$learnpath_id.'" />
1084
+         <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id.'" />
1085
+         <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id.'" />';
1086 1086
 
1087 1087
 	// Show list of questions
1088 1088
     $i = 1;
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
         $attempt_list = Event::getAllExerciseEventByExeId($exe_id);
1092 1092
     }
1093 1093
 
1094
-    $remind_list  = array();
1094
+    $remind_list = array();
1095 1095
     if (isset($exercise_stat_info['questions_to_check']) && !empty($exercise_stat_info['questions_to_check'])) {
1096 1096
         $remind_list = explode(',', $exercise_stat_info['questions_to_check']);
1097 1097
     }
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
             $remind_highlight = 'no_remind_highlight';
1130 1130
         }
1131 1131
 
1132
-        $exercise_actions  = '';
1132
+        $exercise_actions = '';
1133 1133
         $is_remind_on = false;
1134 1134
 
1135 1135
         $attributes = array('id' =>'remind_list['.$questionId.']');
@@ -1141,10 +1141,10 @@  discard block
 block discarded – undo
1141 1141
         }
1142 1142
 
1143 1143
         // Showing the exercise description
1144
-        if (!empty($objExercise->description)){
1145
-            if ($objExercise->type == ONE_PER_PAGE || ($objExercise->type != ONE_PER_PAGE && $i==1)) {
1146
-                echo Display::panelCollapse('<span>' .
1147
-                    get_lang('ExerciseDescriptionLabel') . '</span>',
1144
+        if (!empty($objExercise->description)) {
1145
+            if ($objExercise->type == ONE_PER_PAGE || ($objExercise->type != ONE_PER_PAGE && $i == 1)) {
1146
+                echo Display::panelCollapse('<span>'.
1147
+                    get_lang('ExerciseDescriptionLabel').'</span>',
1148 1148
                     $objExercise->description,
1149 1149
                     'exercise-description',
1150 1150
                     [],
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
             case ALL_ON_ONE_PAGE :
1179 1179
                 $button  = '<a href="javascript://" class="btn btn-info" onclick="save_now(\''.$questionId.'\'); ">'.get_lang('SaveForNow').'</a>';
1180 1180
                 $button .= '<span id="save_for_now_'.$questionId.'"></span>&nbsp;';
1181
-                $exercise_actions  .= Display::div($button, array('class'=>'exercise_save_now_button'));
1181
+                $exercise_actions .= Display::div($button, array('class'=>'exercise_save_now_button'));
1182 1182
                 break;
1183 1183
         }
1184 1184
 
@@ -1188,13 +1188,13 @@  discard block
 block discarded – undo
1188 1188
                 'label',
1189 1189
                 Display::input(
1190 1190
                     'checkbox',
1191
-                    'remind_list[' . $questionId . ']',
1191
+                    'remind_list['.$questionId.']',
1192 1192
                     '',
1193 1193
                     $attributes
1194
-                ) . get_lang('ReviewQuestionLater'),
1194
+                ).get_lang('ReviewQuestionLater'),
1195 1195
                 array(
1196 1196
                     'class' => 'checkbox',
1197
-                    'for' => 'remind_list[' . $questionId . ']'
1197
+                    'for' => 'remind_list['.$questionId.']'
1198 1198
                 )
1199 1199
             );
1200 1200
             $exercise_actions .= Display::div($remind_question_div, array('class'=>'exercise_save_now_button'));
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
     }
1212 1212
     // end foreach()
1213 1213
     if ($objExercise->type == ALL_ON_ONE_PAGE) {
1214
-    	$exercise_actions =  $objExercise->show_button($questionId, $current_question);
1214
+    	$exercise_actions = $objExercise->show_button($questionId, $current_question);
1215 1215
     	echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
1216 1216
         echo '<br>';
1217 1217
     }
Please login to merge, or discard this patch.
main/inc/lib/browser/Browser.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
      */
346 346
     public function __toString()
347 347
     {
348
-        return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" .
349
-        "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" .
350
-        "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" .
348
+        return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n".
349
+        "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n".
350
+        "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n".
351 351
         "<strong>Platform:</strong> {$this->getPlatform()}<br/>";
352 352
     }
353 353
 
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
             $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'msie'));
586 586
             $this->setBrowser(self::BROWSER_IE);
587 587
             $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1]));
588
-            if(stripos($this->_agent, 'IEMobile') !== false) {
588
+            if (stripos($this->_agent, 'IEMobile') !== false) {
589 589
                 $this->setBrowser(self::BROWSER_POCKET_IE);
590 590
                 $this->setMobile(true);
591 591
             }
592 592
             return true;
593 593
         } // Test for versions > IE 10
594
-		else if(stripos($this->_agent, 'trident') !== false) {
594
+		else if (stripos($this->_agent, 'trident') !== false) {
595 595
 			$this->setBrowser(self::BROWSER_IE);
596 596
 			$result = explode('rv:', $this->_agent);
597 597
 			$this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1]));
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
      */
1013 1013
     protected function checkFacebookExternalHit()
1014 1014
     {
1015
-        if(stristr($this->_agent,'FacebookExternalHit'))
1015
+        if (stristr($this->_agent, 'FacebookExternalHit'))
1016 1016
         {
1017 1017
             $this->setRobot(true);
1018 1018
             $this->setFacebook(true);
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
      */
1028 1028
     protected function checkForFacebookIos()
1029 1029
     {
1030
-        if(stristr($this->_agent,'FBIOS'))
1030
+        if (stristr($this->_agent, 'FBIOS'))
1031 1031
         {
1032 1032
             $this->setFacebook(true);
1033 1033
             return true;
@@ -1041,10 +1041,10 @@  discard block
 block discarded – undo
1041 1041
      */
1042 1042
     protected function getSafariVersionOnIos()
1043 1043
     {
1044
-        $aresult = explode('/',stristr($this->_agent,'Version'));
1045
-        if( isset($aresult[1]) )
1044
+        $aresult = explode('/', stristr($this->_agent, 'Version'));
1045
+        if (isset($aresult[1]))
1046 1046
         {
1047
-            $aversion = explode(' ',$aresult[1]);
1047
+            $aversion = explode(' ', $aresult[1]);
1048 1048
             $this->setVersion($aversion[0]);
1049 1049
             return true;
1050 1050
         }
@@ -1057,10 +1057,10 @@  discard block
 block discarded – undo
1057 1057
      */
1058 1058
     protected function getChromeVersionOnIos()
1059 1059
     {
1060
-        $aresult = explode('/',stristr($this->_agent,'CriOS'));
1061
-        if( isset($aresult[1]) )
1060
+        $aresult = explode('/', stristr($this->_agent, 'CriOS'));
1061
+        if (isset($aresult[1]))
1062 1062
         {
1063
-            $aversion = explode(' ',$aresult[1]);
1063
+            $aversion = explode(' ', $aresult[1]);
1064 1064
             $this->setVersion($aversion[0]);
1065 1065
             $this->setBrowser(self::BROWSER_CHROME);
1066 1066
             return true;
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
      * @return boolean True if the browser is iPhone otherwise false
1074 1074
      */
1075 1075
     protected function checkBrowseriPhone() {
1076
-        if( stripos($this->_agent,'iPhone') !== false ) {
1076
+        if (stripos($this->_agent, 'iPhone') !== false) {
1077 1077
             $this->setVersion(self::VERSION_UNKNOWN);
1078 1078
             $this->setBrowser(self::BROWSER_IPHONE);
1079 1079
             $this->getSafariVersionOnIos();
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
      * @return boolean True if the browser is iPad otherwise false
1091 1091
      */
1092 1092
     protected function checkBrowseriPad() {
1093
-        if( stripos($this->_agent,'iPad') !== false ) {
1093
+        if (stripos($this->_agent, 'iPad') !== false) {
1094 1094
             $this->setVersion(self::VERSION_UNKNOWN);
1095 1095
             $this->setBrowser(self::BROWSER_IPAD);
1096 1096
             $this->getSafariVersionOnIos();
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
      * @return boolean True if the browser is iPod otherwise false
1108 1108
      */
1109 1109
     protected function checkBrowseriPod() {
1110
-        if( stripos($this->_agent,'iPod') !== false ) {
1110
+        if (stripos($this->_agent, 'iPod') !== false) {
1111 1111
             $this->setVersion(self::VERSION_UNKNOWN);
1112 1112
             $this->setBrowser(self::BROWSER_IPOD);
1113 1113
             $this->getSafariVersionOnIos();
Please login to merge, or discard this patch.
Braces   +16 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1152,68 +1152,52 @@
 block discarded – undo
1152 1152
         if (stripos($this->_agent, 'windows') !== false)
1153 1153
         {
1154 1154
             $this->_platform = self::PLATFORM_WINDOWS;
1155
-        }
1156
-        else if (stripos($this->_agent, 'iPad') !== false)
1155
+        } else if (stripos($this->_agent, 'iPad') !== false)
1157 1156
         {
1158 1157
             $this->_platform = self::PLATFORM_IPAD;
1159
-        }
1160
-        else if (stripos($this->_agent, 'iPod') !== false)
1158
+        } else if (stripos($this->_agent, 'iPod') !== false)
1161 1159
         {
1162 1160
             $this->_platform = self::PLATFORM_IPOD;
1163
-        }
1164
-        else if (stripos($this->_agent, 'iPhone') !== false)
1161
+        } else if (stripos($this->_agent, 'iPhone') !== false)
1165 1162
         {
1166 1163
             $this->_platform = self::PLATFORM_IPHONE;
1167
-        }
1168
-        elseif (stripos($this->_agent, 'mac') !== false)
1164
+        } elseif (stripos($this->_agent, 'mac') !== false)
1169 1165
         {
1170 1166
             $this->_platform = self::PLATFORM_APPLE;
1171
-        }
1172
-        elseif (stripos($this->_agent, 'android') !== false)
1167
+        } elseif (stripos($this->_agent, 'android') !== false)
1173 1168
         {
1174 1169
             $this->_platform = self::PLATFORM_ANDROID;
1175
-        }
1176
-        elseif (stripos($this->_agent, 'linux') !== false)
1170
+        } elseif (stripos($this->_agent, 'linux') !== false)
1177 1171
         {
1178 1172
             $this->_platform = self::PLATFORM_LINUX;
1179
-        }
1180
-        else if (stripos($this->_agent, 'Nokia') !== false)
1173
+        } else if (stripos($this->_agent, 'Nokia') !== false)
1181 1174
         {
1182 1175
             $this->_platform = self::PLATFORM_NOKIA;
1183
-        }
1184
-        else if (stripos($this->_agent, 'BlackBerry') !== false)
1176
+        } else if (stripos($this->_agent, 'BlackBerry') !== false)
1185 1177
         {
1186 1178
             $this->_platform = self::PLATFORM_BLACKBERRY;
1187
-        }
1188
-        elseif (stripos($this->_agent, 'FreeBSD') !== false)
1179
+        } elseif (stripos($this->_agent, 'FreeBSD') !== false)
1189 1180
         {
1190 1181
             $this->_platform = self::PLATFORM_FREEBSD;
1191
-        }
1192
-        elseif (stripos($this->_agent, 'OpenBSD') !== false)
1182
+        } elseif (stripos($this->_agent, 'OpenBSD') !== false)
1193 1183
         {
1194 1184
             $this->_platform = self::PLATFORM_OPENBSD;
1195
-        }
1196
-        elseif (stripos($this->_agent, 'NetBSD') !== false)
1185
+        } elseif (stripos($this->_agent, 'NetBSD') !== false)
1197 1186
         {
1198 1187
             $this->_platform = self::PLATFORM_NETBSD;
1199
-        }
1200
-        elseif (stripos($this->_agent, 'OpenSolaris') !== false)
1188
+        } elseif (stripos($this->_agent, 'OpenSolaris') !== false)
1201 1189
         {
1202 1190
             $this->_platform = self::PLATFORM_OPENSOLARIS;
1203
-        }
1204
-        elseif (stripos($this->_agent, 'SunOS') !== false)
1191
+        } elseif (stripos($this->_agent, 'SunOS') !== false)
1205 1192
         {
1206 1193
             $this->_platform = self::PLATFORM_SUNOS;
1207
-        }
1208
-        elseif (stripos($this->_agent, 'OS\/2') !== false)
1194
+        } elseif (stripos($this->_agent, 'OS\/2') !== false)
1209 1195
         {
1210 1196
             $this->_platform = self::PLATFORM_OS2;
1211
-        }
1212
-        elseif (stripos($this->_agent, 'BeOS') !== false)
1197
+        } elseif (stripos($this->_agent, 'BeOS') !== false)
1213 1198
         {
1214 1199
             $this->_platform = self::PLATFORM_BEOS;
1215
-        }
1216
-        elseif (stripos($this->_agent, 'win') !== false)
1200
+        } elseif (stripos($this->_agent, 'win') !== false)
1217 1201
         {
1218 1202
             $this->_platform = self::PLATFORM_WINDOWS;
1219 1203
         }
Please login to merge, or discard this patch.