Test Setup Failed
Push — master ( 7e2e55...b97dd0 )
by Angel Fernando Quiroz
431:37 queued 367:13
created
main/exercice/oral_expression.class.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
      * @param null $feedback_type
59 59
      * @param null $counter
60 60
      * @param null $score
61
-     * @return null|string
61
+     * @return string
62 62
      */
63 63
     function return_header($feedback_type = null, $counter = null, $score = null)
64 64
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
     function createAnswersForm($form)
32 32
     {
33 33
 
34
-        $form -> addElement('text','weighting', get_lang('Weighting'), array('class' => 'span1'));
34
+        $form -> addElement('text', 'weighting', get_lang('Weighting'), array('class' => 'span1'));
35 35
         global $text, $class;
36 36
         // setting the save button here and not in the question class.php
37 37
         $form->addButtonSave($text, 'submitQuestion');
Please login to merge, or discard this patch.
main/exercice/question.class.php 3 patches
Doc Comments   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
     }
266 266
 
267 267
     /**
268
-     * @return bool|string
268
+     * @return string|false
269 269
      */
270 270
     public function selectPicturePath()
271 271
     {
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
      * @param string $Dimension - Resizing happens proportional according to given dimension: height|width|any
591 591
      * @param integer $Max - Maximum size
592 592
      *
593
-     * @return boolean - true if success, false if failed
593
+     * @return boolean|null - true if success, false if failed
594 594
      *
595 595
      * @author Toon Keppens
596 596
      */
@@ -751,6 +751,7 @@  discard block
 block discarded – undo
751 751
 
752 752
     /**
753 753
      * Sets extra info
754
+     * @param string $extra
754 755
      */
755 756
     public function setExtra($extra)
756 757
     {
@@ -1261,7 +1262,7 @@  discard block
 block discarded – undo
1261 1262
      *
1262 1263
      * @author Olivier Brouckaert
1263 1264
      * @param  array   Course info of the destination course
1264
-     * @return int     ID of the new question
1265
+     * @return false|string     ID of the new question
1265 1266
      */
1266 1267
     public function duplicate($course_info = null)
1267 1268
     {
@@ -1636,7 +1637,7 @@  discard block
 block discarded – undo
1636 1637
      * @param string $name
1637 1638
      * @param int $course_id
1638 1639
      * @param int $position
1639
-     * @return bool|int
1640
+     * @return false|string
1640 1641
      */
1641 1642
     static function saveQuestionOption($question_id, $name, $course_id, $position = 0)
1642 1643
     {
@@ -1775,6 +1776,7 @@  discard block
 block discarded – undo
1775 1776
      * @param   int     Maximum result for the question
1776 1777
      * @param   int     Type of question (see constants at beginning of question.class.php)
1777 1778
      * @param   int     Question level/category
1779
+     * @param string $quiz_id
1778 1780
      */
1779 1781
     public function create_question(
1780 1782
         $quiz_id,
@@ -1857,6 +1859,7 @@  discard block
 block discarded – undo
1857 1859
     /**
1858 1860
      * Get course medias
1859 1861
      * @param int course id
1862
+     * @param integer $course_id
1860 1863
      */
1861 1864
     static function get_course_medias(
1862 1865
         $course_id,
@@ -1922,7 +1925,7 @@  discard block
 block discarded – undo
1922 1925
     }
1923 1926
 
1924 1927
     /**
1925
-     * @return array
1928
+     * @return integer[]
1926 1929
      */
1927 1930
     public static function get_default_levels()
1928 1931
     {
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -607,10 +607,11 @@
 block discarded – undo
607 607
             $current_width = $current_image_size['width'];
608 608
             $current_height = $current_image_size['height'];
609 609
 
610
-            if ($current_width < $Max && $current_height < $Max)
611
-                return true;
612
-            elseif ($current_height == "")
613
-                return false;
610
+            if ($current_width < $Max && $current_height < $Max) {
611
+                            return true;
612
+            } elseif ($current_height == "") {
613
+                            return false;
614
+            }
614 615
 
615 616
             // Resize according to height.
616 617
             if ($Dimension == "height") {
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public $type;
23 23
     public $level;
24 24
     public $picture;
25
-    public $exerciseList;  // array with the list of exercises which this question is in
25
+    public $exerciseList; // array with the list of exercises which this question is in
26 26
     public $category_list;
27 27
     public $parent_id;
28 28
     public $category;
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
             'multiple_answer_combination_true_false.class.php',
48 48
             'MultipleAnswerCombinationTrueFalse'
49 49
         ),
50
-        GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php' , 'GlobalMultipleAnswer'),
51
-        CALCULATED_ANSWER => array('calculated_answer.class.php' , 'CalculatedAnswer'),
50
+        GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php', 'GlobalMultipleAnswer'),
51
+        CALCULATED_ANSWER => array('calculated_answer.class.php', 'CalculatedAnswer'),
52 52
         UNIQUE_ANSWER_IMAGE => ['UniqueAnswerImage.php', 'UniqueAnswerImage'],
53 53
         DRAGGABLE => ['Draggable.php', 'Draggable'],
54 54
         MATCHING_DRAGGABLE => ['MatchingDraggable.php', 'MatchingDraggable']
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
         $id = intval($id);
108 108
 
109 109
         if (!empty($course_id)) {
110
-            $course_info =  api_get_course_info_by_id($course_id);
110
+            $course_info = api_get_course_info_by_id($course_id);
111 111
         } else {
112 112
             $course_info = api_get_course_info();
113 113
         }
114 114
 
115 115
         $course_id = $course_info['real_id'];
116 116
 
117
-        if (empty($course_id) || $course_id == -1 ) {
117
+        if (empty($course_id) || $course_id == -1) {
118 118
             return false;
119 119
         }
120 120
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     public function selectPicturePath()
271 271
     {
272 272
         if (!empty($this->picture)) {
273
-            return api_get_path(WEB_COURSE_PATH) . $this->course['path'] . '/document/images/' . $this->picture;
273
+            return api_get_path(WEB_COURSE_PATH).$this->course['path'].'/document/images/'.$this->picture;
274 274
         }
275 275
 
276 276
         return false;
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
      */
308 308
     public function updateTitle($title)
309 309
     {
310
-        $this->question=$title;
310
+        $this->question = $title;
311 311
     }
312 312
 
313 313
     /**
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
                     // DO nothing
407 407
                 } else {
408 408
                     $sql = "INSERT INTO $TBL_QUESTION_REL_CATEGORY (c_id, question_id, category_id)
409
-                            VALUES (" . api_get_course_int_id() . ", $question_id, $category_id)";
409
+                            VALUES (".api_get_course_int_id().", $question_id, $category_id)";
410 410
                     Database::query($sql);
411 411
                 }
412 412
             }
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             $sql = "SELECT count(*) AS nb FROM $table
434 434
                     WHERE
435 435
                         question_id = $question_id AND
436
-                        c_id=" . api_get_course_int_id();
436
+                        c_id=".api_get_course_int_id();
437 437
             $res = Database::query($sql);
438 438
             $row = Database::fetch_array($res);
439 439
             if ($row['nb'] > 0) {
@@ -441,11 +441,11 @@  discard block
 block discarded – undo
441 441
                         SET category_id = $category_id
442 442
                         WHERE
443 443
                             question_id = $question_id AND
444
-                            c_id = " . api_get_course_int_id();
444
+                            c_id = ".api_get_course_int_id();
445 445
                 Database::query($sql);
446 446
             } else {
447 447
                 $sql = "INSERT INTO $table (c_id, question_id, category_id)
448
-                        VALUES (" . api_get_course_int_id().", $question_id, $category_id)";
448
+                        VALUES (".api_get_course_int_id().", $question_id, $category_id)";
449 449
                 Database::query($sql);
450 450
             }
451 451
         }
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
         $sql = "DELETE FROM $table
464 464
                 WHERE
465 465
                     question_id = $question_id AND
466
-                    c_id = " . api_get_course_int_id();
466
+                    c_id = ".api_get_course_int_id();
467 467
         Database::query($sql);
468 468
     }
469 469
 
@@ -516,11 +516,11 @@  discard block
 block discarded – undo
516 516
             ) {
517 517
                 // removes old answers
518 518
                 $sql = "DELETE FROM $TBL_REPONSES
519
-                        WHERE c_id = $course_id AND question_id = " . intval($this->id);
519
+                        WHERE c_id = $course_id AND question_id = ".intval($this->id);
520 520
                 Database::query($sql);
521 521
             }
522 522
 
523
-            $this->type=$type;
523
+            $this->type = $type;
524 524
         }
525 525
     }
526 526
 
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
         if (!file_exists($picturePath)) {
545 545
             if (mkdir($picturePath, api_get_permissions_for_new_directories())) {
546 546
                 // document path
547
-                $documentPath = api_get_path(SYS_COURSE_PATH) . $this->course['path'] . "/document";
547
+                $documentPath = api_get_path(SYS_COURSE_PATH).$this->course['path']."/document";
548 548
                 $path = str_replace($documentPath, '', $picturePath);
549 549
                 $title_path = basename($picturePath);
550 550
                 $doc_id = add_document($this->course, $path, 'folder', 0, $title_path);
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
 
561 561
         // if the question has got an ID
562 562
         if ($this->id) {
563
-            $this->picture = 'quiz-' . $this->id . '.jpg';
563
+            $this->picture = 'quiz-'.$this->id.'.jpg';
564 564
             $o_img = new Image($Picture);
565
-            $o_img->send_image($picturePath . '/' . $this->picture, -1, 'jpg');
565
+            $o_img->send_image($picturePath.'/'.$this->picture, -1, 'jpg');
566 566
             $document_id = add_document(
567 567
                 $this->course,
568
-                '/images/' . $this->picture,
568
+                '/images/'.$this->picture,
569 569
                 'file',
570
-                filesize($picturePath . '/' . $this->picture),
570
+                filesize($picturePath.'/'.$this->picture),
571 571
                 $this->picture
572 572
             );
573 573
             if ($document_id) {
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
         // if the question has an ID
602 602
         if ($this->id) {
603 603
             // Get dimensions from current image.
604
-            $my_image = new Image($picturePath . '/' . $this->picture);
604
+            $my_image = new Image($picturePath.'/'.$this->picture);
605 605
 
606 606
             $current_image_size = $my_image->get_image_size();
607 607
             $current_width = $current_image_size['width'];
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
             }
642 642
 
643 643
             $my_image->resize($new_width, $new_height);
644
-            $result = $my_image->send_image($picturePath . '/' . $this->picture);
644
+            $result = $my_image->send_image($picturePath.'/'.$this->picture);
645 645
 
646 646
             if ($result) {
647 647
                 return true;
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
             $picture = $this->picture;
667 667
             $this->picture = '';
668 668
 
669
-            return @unlink($picturePath . '/' . $picture) ? true : false;
669
+            return @unlink($picturePath.'/'.$picture) ? true : false;
670 670
         }
671 671
 
672 672
         return false;
@@ -683,27 +683,27 @@  discard block
 block discarded – undo
683 683
     {
684 684
         $course_id = $course_info['real_id'];
685 685
         $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
686
-        $destination_path = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . '/document/images';
687
-        $source_path = api_get_path(SYS_COURSE_PATH) . $this->course['path'] . '/document/images';
686
+        $destination_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/images';
687
+        $source_path = api_get_path(SYS_COURSE_PATH).$this->course['path'].'/document/images';
688 688
 
689 689
         // if the question has got an ID and if the picture exists
690 690
         if ($this->id && !empty($this->picture)) {
691 691
             $picture = explode('.', $this->picture);
692 692
             $extension = $picture[sizeof($picture) - 1];
693
-            $picture = 'quiz-' . $questionId . '.' . $extension;
694
-            $result = @copy($source_path . '/' . $this->picture, $destination_path . '/' . $picture) ? true : false;
693
+            $picture = 'quiz-'.$questionId.'.'.$extension;
694
+            $result = @copy($source_path.'/'.$this->picture, $destination_path.'/'.$picture) ? true : false;
695 695
             // If copy was correct then add to the database
696 696
             if ($result) {
697 697
                 $sql = "UPDATE $TBL_QUESTIONS SET
698
-                        picture = '" . Database::escape_string($picture) . "'
699
-                        WHERE c_id = $course_id AND id='" . intval($questionId) . "'";
698
+                        picture = '".Database::escape_string($picture)."'
699
+                        WHERE c_id = $course_id AND id='".intval($questionId)."'";
700 700
                 Database::query($sql);
701 701
 
702 702
                 $document_id = add_document(
703 703
                     $course_info,
704
-                    '/images/' . $picture,
704
+                    '/images/'.$picture,
705 705
                     'file',
706
-                    filesize($destination_path . '/' . $picture),
706
+                    filesize($destination_path.'/'.$picture),
707 707
                     $picture
708 708
                 );
709 709
                 if ($document_id) {
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
         $Extension = $PictureName[sizeof($PictureName) - 1];
739 739
 
740 740
         // saves the picture into a temporary file
741
-        @move_uploaded_file($Picture, $picturePath . '/tmp.' . $Extension);
741
+        @move_uploaded_file($Picture, $picturePath.'/tmp.'.$Extension);
742 742
     }
743 743
 
744 744
     /**
@@ -771,15 +771,15 @@  discard block
 block discarded – undo
771 771
 
772 772
         // if the question has got an ID and if the picture exists
773 773
         if ($this->id) {
774
-            if (file_exists($picturePath . '/tmp.jpg')) {
774
+            if (file_exists($picturePath.'/tmp.jpg')) {
775 775
                 $Extension = 'jpg';
776
-            } elseif (file_exists($picturePath . '/tmp.gif')) {
776
+            } elseif (file_exists($picturePath.'/tmp.gif')) {
777 777
                 $Extension = 'gif';
778
-            } elseif (file_exists($picturePath . '/tmp.png')) {
778
+            } elseif (file_exists($picturePath.'/tmp.png')) {
779 779
                 $Extension = 'png';
780 780
             }
781
-            $this->picture = 'quiz-' . $this->id . '.' . $Extension;
782
-            return @rename($picturePath . '/tmp.' . $Extension, $picturePath . '/' . $this->picture) ? true : false;
781
+            $this->picture = 'quiz-'.$this->id.'.'.$Extension;
782
+            return @rename($picturePath.'/tmp.'.$Extension, $picturePath.'/'.$this->picture) ? true : false;
783 783
         }
784 784
         return false;
785 785
     }
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
         $category = $this->category;
810 810
 
811 811
         // question already exists
812
-        if(!empty($id)) {
812
+        if (!empty($id)) {
813 813
 
814 814
             $params = [
815 815
                 'question' => $question,
@@ -855,12 +855,12 @@  discard block
 block discarded – undo
855 855
                     $TBL_EXERCISE_QUESTION as test_question
856 856
                     WHERE
857 857
                         question.id = test_question.question_id AND
858
-                        test_question.exercice_id = " . intval($exerciseId) . " AND
858
+                        test_question.exercice_id = ".intval($exerciseId)." AND
859 859
                         question.c_id = $c_id AND
860 860
                         test_question.c_id = $c_id ";
861
-            $result	= Database::query($sql);
862
-            $current_position = Database::result($result,0,0);
863
-            $this->updatePosition($current_position+1);
861
+            $result = Database::query($sql);
862
+            $current_position = Database::result($result, 0, 0);
863
+            $this->updatePosition($current_position + 1);
864 864
             $position = $this->position;
865 865
 
866 866
             $params = [
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
         }
957 957
     }
958 958
 
959
-    public function search_engine_edit($exerciseId, $addQs=false, $rmQs=false)
959
+    public function search_engine_edit($exerciseId, $addQs = false, $rmQs = false)
960 960
     {
961 961
         // update search engine and its values table if enabled
962 962
         if (api_get_setting(
@@ -987,8 +987,8 @@  discard block
 block discarded – undo
987 987
             }
988 988
 
989 989
             if ($se_ref || $addQs) {
990
-                require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php');
991
-                require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php');
990
+                require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php');
991
+                require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php');
992 992
 
993 993
                 $di = new ChamiloIndexer();
994 994
                 if ($addQs) {
@@ -1038,9 +1038,9 @@  discard block
 block discarded – undo
1038 1038
                     SE_DATA => array(
1039 1039
                         'type' => SE_DOCTYPE_EXERCISE_QUESTION,
1040 1040
                         'exercise_ids' => $question_exercises,
1041
-                        'question_id' => (int)$this->id
1041
+                        'question_id' => (int) $this->id
1042 1042
                     ),
1043
-                    SE_USER => (int)api_get_user_id(),
1043
+                    SE_USER => (int) api_get_user_id(),
1044 1044
                 );
1045 1045
                 $ic_slide->xapian_data = serialize($xapian_data);
1046 1046
                 $ic_slide->addValue("content", $this->description);
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
             $count = $new_exercise->selectNbrQuestions();
1125 1125
             $count++;
1126 1126
             $sql = "INSERT INTO $exerciseRelQuestionTable (c_id, question_id, exercice_id, question_order)
1127
-                    VALUES ({$this->course['real_id']}, " . intval($id) . ", " . intval($exerciseId) . ", '$count')";
1127
+                    VALUES ({$this->course['real_id']}, ".intval($id).", ".intval($exerciseId).", '$count')";
1128 1128
             Database::query($sql);
1129 1129
 
1130 1130
             // we do not want to reindex if we had just saved adnd indexed the question
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
         $course_id = api_get_course_int_id();
1154 1154
 
1155 1155
         // exercise not found
1156
-        if($pos === false) {
1156
+        if ($pos === false) {
1157 1157
             return false;
1158 1158
         } else {
1159 1159
             // deletes the position in the array containing the wanted exercise ID
@@ -1163,17 +1163,17 @@  discard block
 block discarded – undo
1163 1163
                     FROM $TBL_EXERCISE_QUESTION
1164 1164
                     WHERE
1165 1165
                         c_id = $course_id
1166
-                        AND question_id = " . intval($id) . "
1166
+                        AND question_id = ".intval($id)."
1167 1167
                         AND exercice_id = " . intval($exerciseId);
1168 1168
             $res = Database::query($sql);
1169
-            if (Database::num_rows($res)>0) {
1169
+            if (Database::num_rows($res) > 0) {
1170 1170
                 $row = Database::fetch_array($res);
1171 1171
                 if (!empty($row['question_order'])) {
1172 1172
                     $sql = "UPDATE $TBL_EXERCISE_QUESTION
1173 1173
                         SET question_order = question_order-1
1174 1174
                         WHERE
1175 1175
                             c_id = $course_id
1176
-                            AND exercice_id = " . intval($exerciseId) . "
1176
+                            AND exercice_id = ".intval($exerciseId)."
1177 1177
                             AND question_order > " . $row['question_order'];
1178 1178
                     Database::query($sql);
1179 1179
                 }
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
             $sql = "DELETE FROM $TBL_EXERCISE_QUESTION
1183 1183
                     WHERE
1184 1184
                         c_id = $course_id
1185
-                        AND question_id = " . intval($id) . "
1185
+                        AND question_id = ".intval($id)."
1186 1186
                         AND exercice_id = " . intval($exerciseId);
1187 1187
             Database::query($sql);
1188 1188
 
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
                                 SET question_order = question_order-1
1224 1224
                                 WHERE
1225 1225
                                     c_id= $course_id
1226
-                                    AND exercice_id = " . intval($row['exercice_id']) . "
1226
+                                    AND exercice_id = ".intval($row['exercice_id'])."
1227 1227
                                     AND question_order > " . $row['question_order'];
1228 1228
                         Database::query($sql);
1229 1229
                     }
@@ -1231,20 +1231,20 @@  discard block
 block discarded – undo
1231 1231
             }
1232 1232
 
1233 1233
             $sql = "DELETE FROM $TBL_EXERCISE_QUESTION
1234
-                    WHERE c_id = $course_id AND question_id = " . intval($id) . "";
1234
+                    WHERE c_id = $course_id AND question_id = ".intval($id)."";
1235 1235
             Database::query($sql);
1236 1236
 
1237 1237
             $sql = "DELETE FROM $TBL_QUESTIONS
1238
-                    WHERE c_id = $course_id AND id = " . intval($id) . "";
1238
+                    WHERE c_id = $course_id AND id = ".intval($id)."";
1239 1239
             Database::query($sql);
1240 1240
 
1241 1241
             $sql = "DELETE FROM $TBL_REPONSES
1242
-                    WHERE c_id = $course_id AND question_id = " . intval($id) . "";
1242
+                    WHERE c_id = $course_id AND question_id = ".intval($id)."";
1243 1243
             Database::query($sql);
1244 1244
 
1245 1245
             // remove the category of this question in the question_rel_category table
1246 1246
             $sql = "DELETE FROM $TBL_QUIZ_QUESTION_REL_CATEGORY
1247
-                    WHERE c_id = $course_id AND question_id = " . intval($id) . " AND c_id=" . api_get_course_int_id();
1247
+                    WHERE c_id = $course_id AND question_id = ".intval($id)." AND c_id=".api_get_course_int_id();
1248 1248
             Database::query($sql);
1249 1249
 
1250 1250
             api_item_property_update($this->course, TOOL_QUIZ, $id, 'QuizQuestionDeleted', api_get_user_id());
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
                 if (class_exists($class_name)) {
1408 1408
                     return new $class_name();
1409 1409
                 } else {
1410
-                    echo 'Can\'t instanciate class ' . $class_name . ' of type ' . $type;
1410
+                    echo 'Can\'t instanciate class '.$class_name.' of type '.$type;
1411 1411
                 }
1412 1412
             }
1413 1413
         }
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 
1450 1450
         // Question type
1451 1451
         $answerType = isset($_REQUEST['answerType']) ? intval($_REQUEST['answerType']) : null;
1452
-        $form->addElement('hidden','answerType', $answerType);
1452
+        $form->addElement('hidden', 'answerType', $answerType);
1453 1453
 
1454 1454
         // html editor
1455 1455
         $editorConfig = array(
@@ -1457,7 +1457,7 @@  discard block
 block discarded – undo
1457 1457
             'Height' => '150'
1458 1458
         );
1459 1459
 
1460
-        if (!api_is_allowed_to_edit(null,true)) {
1460
+        if (!api_is_allowed_to_edit(null, true)) {
1461 1461
             $editorConfig['UserStatus'] = 'student';
1462 1462
         }
1463 1463
 
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
 
1595 1595
         if ($feedback_type == 1) {
1596 1596
             //2. but if it is a feedback DIRECT we only show the UNIQUE_ANSWER type that is currently available
1597
-            $question_type_custom_list = array (
1597
+            $question_type_custom_list = array(
1598 1598
                 UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER],
1599 1599
                 HOT_SPOT_DELINEATION => self::$questionTypes[HOT_SPOT_DELINEATION]
1600 1600
             );
@@ -1610,17 +1610,17 @@  discard block
 block discarded – undo
1610 1610
             require_once $a_type[0];
1611 1611
             // get the picture of the type and the langvar which describes it
1612 1612
             $img = $explanation = '';
1613
-            eval('$img = ' . $a_type[1] . '::$typePicture;');
1614
-            eval('$explanation = get_lang(' . $a_type[1] . '::$explanationLangVar);');
1613
+            eval('$img = '.$a_type[1].'::$typePicture;');
1614
+            eval('$explanation = get_lang('.$a_type[1].'::$explanationLangVar);');
1615 1615
             echo '<li>';
1616 1616
             echo '<div class="icon-image">';
1617 1617
             if ($objExercise->exercise_was_added_in_lp == true) {
1618 1618
                 $img = pathinfo($img);
1619
-                $img = $img['filename'] . '_na.' . $img['extension'];
1619
+                $img = $img['filename'].'_na.'.$img['extension'];
1620 1620
                 echo Display::return_icon($img, $explanation, null, ICON_SIZE_BIG);
1621 1621
             } else {
1622
-                echo '<a href="admin.php?' . api_get_cidreq() . '&newQuestion=yes&answerType=' . $i . '">' .
1623
-                Display::return_icon($img, $explanation, null, ICON_SIZE_BIG) . '</a>';
1622
+                echo '<a href="admin.php?'.api_get_cidreq().'&newQuestion=yes&answerType='.$i.'">'.
1623
+                Display::return_icon($img, $explanation, null, ICON_SIZE_BIG).'</a>';
1624 1624
             }
1625 1625
             echo '</div>';
1626 1626
             echo '</li>';
@@ -1632,9 +1632,9 @@  discard block
 block discarded – undo
1632 1632
             echo Display::return_icon('database_na.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG);
1633 1633
         } else {
1634 1634
             if ($feedback_type == 1) {
1635
-                echo $url = "<a href=\"question_pool.php?" . api_get_cidreq() . "&type=1&fromExercise=$exerciseId\">";
1635
+                echo $url = "<a href=\"question_pool.php?".api_get_cidreq()."&type=1&fromExercise=$exerciseId\">";
1636 1636
             } else {
1637
-                echo $url = '<a href="question_pool.php?' . api_get_cidreq() . '&fromExercise=' . $exerciseId . '">';
1637
+                echo $url = '<a href="question_pool.php?'.api_get_cidreq().'&fromExercise='.$exerciseId.'">';
1638 1638
             }
1639 1639
             echo Display::return_icon('database.png', get_lang('GetExistingQuestion'), null, ICON_SIZE_BIG);
1640 1640
         }
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
             $header .= $this->show_media_content();
1772 1772
         }
1773 1773
 
1774
-        $header .= Display::page_subheader2($counter_label . ". " . $question_title);
1774
+        $header .= Display::page_subheader2($counter_label.". ".$question_title);
1775 1775
         $header .= Display::div(
1776 1776
             "<div class=\"rib rib-$class\"><h3>$score_label</h3></div> <h4>{$score['result']}</h4>",
1777 1777
             array('class' => 'ribbon')
@@ -1792,7 +1792,7 @@  discard block
 block discarded – undo
1792 1792
     public function create_question(
1793 1793
         $quiz_id,
1794 1794
         $question_name,
1795
-        $question_description = "" ,
1795
+        $question_description = "",
1796 1796
         $max_score = 0,
1797 1797
         $type = 1,
1798 1798
         $level = 1
@@ -1862,8 +1862,8 @@  discard block
 block discarded – undo
1862 1862
         require_once $tabQuestionList[$type][0];
1863 1863
 
1864 1864
         $img = $explanation = null;
1865
-        eval('$img = ' . $tabQuestionList[$type][1] . '::$typePicture;');
1866
-        eval('$explanation = get_lang(' . $tabQuestionList[$type][1] . '::$explanationLangVar);');
1865
+        eval('$img = '.$tabQuestionList[$type][1].'::$typePicture;');
1866
+        eval('$explanation = get_lang('.$tabQuestionList[$type][1].'::$explanationLangVar);');
1867 1867
         return array($img, $explanation);
1868 1868
     }
1869 1869
 
@@ -1927,7 +1927,7 @@  discard block
 block discarded – undo
1927 1927
         $media_list[0] = get_lang('NoMedia');
1928 1928
 
1929 1929
         if (!empty($medias)) {
1930
-            foreach($medias as $media) {
1930
+            foreach ($medias as $media) {
1931 1931
                 $media_list[$media['id']] = empty($media['question']) ? get_lang('Untitled') : $media['question'];
1932 1932
             }
1933 1933
         }
Please login to merge, or discard this patch.
main/exercice/TestCategory.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -474,6 +474,7 @@  discard block
 block discarded – undo
474 474
 
475 475
 	/**
476 476
 	 * return a tab of $in_number random elements of $in_tab
477
+	 * @param integer $in_number
477 478
 	 */
478 479
     public static function getNElementsFromArray($in_tab, $in_number)
479 480
     {
@@ -650,7 +651,6 @@  discard block
 block discarded – undo
650 651
     /**
651 652
      * Return the id of the test category with title = $in_title
652 653
      * @param $in_title
653
-     * @param int $in_c_id
654 654
      *
655 655
      * @return int is id of test category
656 656
      */
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
      * @param int $questionId
679 679
      * @param int $courseId
680 680
 	 *
681
-	 * @return int
681
+	 * @return string|false
682 682
      */
683 683
     public static function add_category_for_question_id($categoryId, $questionId, $courseId)
684 684
     {
Please login to merge, or discard this patch.
Indentation   +253 added lines, -253 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,196 +251,196 @@  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
-	 */
318
-	public static function getListOfCategoriesIDForTest($in_testid)
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
+     */
318
+    public static function getListOfCategoriesIDForTest($in_testid)
319 319
     {
320
-		// parcourir les questions d'un test, recup les categories uniques dans un tableau
321
-		$result = array();
322
-		$quiz = new Exercise();
323
-		$quiz->read($in_testid);
324
-		$tabQuestionList = $quiz->selectQuestionList();
325
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
326
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
327
-			if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) {
328
-				$result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]);
329
-			}
330
-		}
331
-
332
-		return $result;
333
-	}
334
-
335
-	/**
336
-	 * return the list of different categories NAME for a test
337
-	 * input : test_id
338
-	 * return : array of string
339
-	 * hubert.borderiou 07-04-2011
320
+        // parcourir les questions d'un test, recup les categories uniques dans un tableau
321
+        $result = array();
322
+        $quiz = new Exercise();
323
+        $quiz->read($in_testid);
324
+        $tabQuestionList = $quiz->selectQuestionList();
325
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
326
+        for ($i=1; $i <= count($tabQuestionList); $i++) {
327
+            if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) {
328
+                $result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]);
329
+            }
330
+        }
331
+
332
+        return $result;
333
+    }
334
+
335
+    /**
336
+     * return the list of different categories NAME for a test
337
+     * input : test_id
338
+     * return : array of string
339
+     * hubert.borderiou 07-04-2011
340 340
      * @author function rewrote by jmontoya
341
-	 */
342
-	public static function getListOfCategoriesNameForTest($in_testid)
341
+     */
342
+    public static function getListOfCategoriesNameForTest($in_testid)
343 343
     {
344
-		$tabcatName = array();
345
-		$tabcatID = self::getListOfCategoriesIDForTest($in_testid);
346
-		for ($i=0; $i < count($tabcatID); $i++) {
347
-			$cat = new TestCategory($tabcatID[$i]);
348
-			$tabcatName[$cat->id] = $cat->name;
349
-		}
350
-		return $tabcatName;
351
-	}
352
-
353
-	/**
354
-	 * return the number of differents categories for a test
355
-	 * input : test_id
356
-	 * return : integer
357
-	 * hubert.borderiou 07-04-2011
358
-	 */
359
-	public static function getNumberOfCategoriesForTest($in_testid)
344
+        $tabcatName = array();
345
+        $tabcatID = self::getListOfCategoriesIDForTest($in_testid);
346
+        for ($i=0; $i < count($tabcatID); $i++) {
347
+            $cat = new TestCategory($tabcatID[$i]);
348
+            $tabcatName[$cat->id] = $cat->name;
349
+        }
350
+        return $tabcatName;
351
+    }
352
+
353
+    /**
354
+     * return the number of differents categories for a test
355
+     * input : test_id
356
+     * return : integer
357
+     * hubert.borderiou 07-04-2011
358
+     */
359
+    public static function getNumberOfCategoriesForTest($in_testid)
360 360
     {
361
-		return count(TestCategory::getListOfCategoriesIDForTest($in_testid));
362
-	}
361
+        return count(TestCategory::getListOfCategoriesIDForTest($in_testid));
362
+    }
363 363
 
364
-	/**
365
-	 * return the number of question of a category id in a test
366
-	 * @param int $exerciseId
364
+    /**
365
+     * return the number of question of a category id in a test
366
+     * @param int $exerciseId
367 367
      * @param int $categoryId
368 368
      *
369
-	 * @return integer
369
+     * @return integer
370 370
      *
371
-	 * @author hubert.borderiou 07-04-2011
372
-	 */
373
-	public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId)
371
+     * @author hubert.borderiou 07-04-2011
372
+     */
373
+    public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId)
374 374
     {
375
-		$nbCatResult = 0;
376
-		$quiz = new Exercise();
377
-		$quiz->read($exerciseId);
378
-		$tabQuestionList = $quiz->selectQuestionList();
379
-		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
380
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
381
-			if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
382
-				$nbCatResult++;
383
-			}
384
-		}
385
-
386
-		return $nbCatResult;
387
-	}
388
-
389
-	/**
390
-	 * return the number of question for a test using random by category
391
-	 * input  : test_id, number of random question (min 1)
392
-	 * hubert.borderiou 07-04-2011
393
-	 * question without categories are not counted
394
-	 */
395
-	public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom)
375
+        $nbCatResult = 0;
376
+        $quiz = new Exercise();
377
+        $quiz->read($exerciseId);
378
+        $tabQuestionList = $quiz->selectQuestionList();
379
+        // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
380
+        for ($i=1; $i <= count($tabQuestionList); $i++) {
381
+            if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
382
+                $nbCatResult++;
383
+            }
384
+        }
385
+
386
+        return $nbCatResult;
387
+    }
388
+
389
+    /**
390
+     * return the number of question for a test using random by category
391
+     * input  : test_id, number of random question (min 1)
392
+     * hubert.borderiou 07-04-2011
393
+     * question without categories are not counted
394
+     */
395
+    public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom)
396 396
     {
397
-		$nbquestionresult = 0;
398
-		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
399
-		for ($i=0; $i < count($tabcatid); $i++) {
400
-			if ($tabcatid[$i] > 0) {	// 0 = no category for this questio
401
-				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
402
-				if ($nbQuestionInThisCat > $in_nbrandom) {
403
-					$nbquestionresult += $in_nbrandom;
404
-				}
405
-				else {
406
-					$nbquestionresult += $nbQuestionInThisCat;
407
-				}
408
-			}
409
-		}
410
-		return $nbquestionresult;
411
-	}
412
-
413
-	/**
414
-	 * Return an array (id=>name)
415
-	 * tabresult[0] = get_lang('NoCategory');
397
+        $nbquestionresult = 0;
398
+        $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
399
+        for ($i=0; $i < count($tabcatid); $i++) {
400
+            if ($tabcatid[$i] > 0) {	// 0 = no category for this questio
401
+                $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
402
+                if ($nbQuestionInThisCat > $in_nbrandom) {
403
+                    $nbquestionresult += $in_nbrandom;
404
+                }
405
+                else {
406
+                    $nbquestionresult += $nbQuestionInThisCat;
407
+                }
408
+            }
409
+        }
410
+        return $nbquestionresult;
411
+    }
412
+
413
+    /**
414
+     * Return an array (id=>name)
415
+     * tabresult[0] = get_lang('NoCategory');
416 416
      *
417 417
      * @param int $courseId
418 418
      *
419 419
      * @return array
420
-	 *
421
-	 */
420
+     *
421
+     */
422 422
     public static function getCategoriesIdAndName($courseId = "")
423 423
     {
424
-		if (empty($courseId)) {
425
-			$courseId = api_get_course_int_id();
426
-		}
427
-	 	$tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
428
-	 	$tabresult = array("0"=>get_lang('NoCategorySelected'));
429
-	 	for ($i=0; $i < count($tabcatobject); $i++) {
430
-	 		$tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
431
-	 	}
432
-	 	return $tabresult;
433
-	}
424
+        if (empty($courseId)) {
425
+            $courseId = api_get_course_int_id();
426
+        }
427
+            $tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
428
+            $tabresult = array("0"=>get_lang('NoCategorySelected'));
429
+            for ($i=0; $i < count($tabcatobject); $i++) {
430
+                $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
431
+            }
432
+            return $tabresult;
433
+    }
434 434
 
435 435
     /**
436
-    * return an array of question_id for each category
437
-    * tabres[0] = array of question id with category id = 0 (i.e. no category)
438
-    * tabres[24] = array of question id with category id = 24
439
-    * In this version, a question has 0 or 1 category
440
-    *
441
-    * @param int $exerciseId
442
-    * @return array
443
-    */
436
+     * return an array of question_id for each category
437
+     * tabres[0] = array of question id with category id = 0 (i.e. no category)
438
+     * tabres[24] = array of question id with category id = 24
439
+     * In this version, a question has 0 or 1 category
440
+     *
441
+     * @param int $exerciseId
442
+     * @return array
443
+     */
444 444
     public static function getQuestionsByCat($exerciseId)
445 445
     {
446 446
         $em = Database::getManager();
@@ -469,29 +469,29 @@  discard block
 block discarded – undo
469 469
             }
470 470
             $list[$data['categoryId']][] = $data['questionId'];
471 471
         }
472
-		return $list;
473
-	}
472
+        return $list;
473
+    }
474 474
 
475
-	/**
476
-	 * return a tab of $in_number random elements of $in_tab
477
-	 */
475
+    /**
476
+     * return a tab of $in_number random elements of $in_tab
477
+     */
478 478
     public static function getNElementsFromArray($in_tab, $in_number)
479 479
     {
480
-		$tabres = $in_tab;
481
-		shuffle($tabres);
482
-		if ($in_number < count($tabres)) {
483
-			$tabres = array_slice($tabres, 0, $in_number);
484
-		}
485
-		return $tabres;
486
-	}
487
-
488
-	/**
489
-	 * display the category
490
-	 */
491
-	public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1)
480
+        $tabres = $in_tab;
481
+        shuffle($tabres);
482
+        if ($in_number < count($tabres)) {
483
+            $tabres = array_slice($tabres, 0, $in_number);
484
+        }
485
+        return $tabres;
486
+    }
487
+
488
+    /**
489
+     * display the category
490
+     */
491
+    public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1)
492 492
     {
493 493
         echo self::returnCategoryAndTitle($questionId, $in_display_category_name);
494
-	}
494
+    }
495 495
 
496 496
     /**
497 497
      * @param int $questionId
@@ -507,71 +507,71 @@  discard block
 block discarded – undo
507 507
             $in_display_category_name = $objExercise->display_category_name;
508 508
         }
509 509
         $content = null;
510
-		if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) {
510
+        if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) {
511 511
             $content .= '<div class="page-header">';
512 512
             $content .= '<h4>'.get_lang('Category').": ".TestCategory::getCategoryNameForQuestion($questionId).'</h4>';
513 513
             $content .= "</div>";
514
-		}
514
+        }
515 515
         return $content;
516
-	}
516
+    }
517 517
 
518 518
     /**
519
-    * Display signs [+] and/or (>0) after question title if question has options
520
-    * scoreAlwaysPositive and/or uncheckedMayScore
521
-    */
519
+     * Display signs [+] and/or (>0) after question title if question has options
520
+     * scoreAlwaysPositive and/or uncheckedMayScore
521
+     */
522 522
     public function displayQuestionOption($in_objQuestion)
523 523
     {
524
-		if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) {
525
-			echo "<span style='font-size:75%'> (>0)</span>";
526
-		}
527
-		if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) {
528
-			echo "<span style='font-size:75%'> [+]</span>";
529
-		}
530
-	}
531
-
532
-	/**
533
-	 * sortTabByBracketLabel ($tabCategoryQuestions)
534
-	 * key of $tabCategoryQuestions are the category id (0 for not in a category)
535
-	 * value is the array of question id of this category
536
-	 * Sort question by Category
537
-	*/
524
+        if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) {
525
+            echo "<span style='font-size:75%'> (>0)</span>";
526
+        }
527
+        if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) {
528
+            echo "<span style='font-size:75%'> [+]</span>";
529
+        }
530
+    }
531
+
532
+    /**
533
+     * sortTabByBracketLabel ($tabCategoryQuestions)
534
+     * key of $tabCategoryQuestions are the category id (0 for not in a category)
535
+     * value is the array of question id of this category
536
+     * Sort question by Category
537
+     */
538 538
     public static function sortTabByBracketLabel($in_tab)
539 539
     {
540
-		$tabResult = array();
541
-		$tabCatName = array();	// tab of category name
542
-		while (list($cat_id, $tabquestion) = each($in_tab)) {
543
-			$catTitle = new TestCategory($cat_id);
544
-			$tabCatName[$cat_id] = $catTitle->name;
545
-		}
546
-		reset($in_tab);
547
-		// sort table by value, keeping keys as they are
548
-		asort($tabCatName);
549
-		// keys of $tabCatName are keys order for $in_tab
550
-		while (list($key, $val) = each($tabCatName)) {
551
-			$tabResult[$key] = $in_tab[$key];
552
-		}
553
-		return $tabResult;
554
-	}
540
+        $tabResult = array();
541
+        $tabCatName = array();	// tab of category name
542
+        while (list($cat_id, $tabquestion) = each($in_tab)) {
543
+            $catTitle = new TestCategory($cat_id);
544
+            $tabCatName[$cat_id] = $catTitle->name;
545
+        }
546
+        reset($in_tab);
547
+        // sort table by value, keeping keys as they are
548
+        asort($tabCatName);
549
+        // keys of $tabCatName are keys order for $in_tab
550
+        while (list($key, $val) = each($tabCatName)) {
551
+            $tabResult[$key] = $in_tab[$key];
552
+        }
553
+        return $tabResult;
554
+    }
555 555
 
556 556
     /**
557 557
      * return the number max of question in a category
558 558
      * count the number of questions in all categories, and return the max
559 559
      * @param int $exerciseId
560 560
      * @author - hubert borderiou
561
-    */
561
+     */
562 562
     public static function getNumberMaxQuestionByCat($exerciseId)
563 563
     {
564 564
         $res_num_max = 0;
565 565
         // foreach question
566
-		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
567
-		for ($i=0; $i < count($tabcatid); $i++) {
568
-			if ($tabcatid[$i] > 0) {	// 0 = no category for this question
569
-				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
566
+        $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
567
+        for ($i=0; $i < count($tabcatid); $i++) {
568
+            if ($tabcatid[$i] > 0) {	// 0 = no category for this question
569
+                $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
570 570
                 if ($nbQuestionInThisCat > $res_num_max) {
571 571
                     $res_num_max = $nbQuestionInThisCat;
572 572
                 }
573
-			}
574
-		}
573
+            }
574
+        }
575 575
         return $res_num_max;
576 576
     }
577 577
 
@@ -677,8 +677,8 @@  discard block
 block discarded – undo
677 677
      * @param int $categoryId
678 678
      * @param int $questionId
679 679
      * @param int $courseId
680
-	 *
681
-	 * @return int
680
+     *
681
+     * @return int
682 682
      */
683 683
     public static function add_category_for_question_id($categoryId, $questionId, $courseId)
684 684
     {
@@ -686,18 +686,18 @@  discard block
 block discarded – undo
686 686
         // if question doesn't have a category
687 687
         // @todo change for 1.10 when a question can have several categories
688 688
         if (TestCategory::getCategoryForQuestion($questionId, $courseId) == 0 &&
689
-			$questionId > 0 &&
690
-			$courseId > 0
689
+            $questionId > 0 &&
690
+            $courseId > 0
691 691
         ) {
692 692
             $sql = "INSERT INTO $table (c_id, question_id, category_id)
693 693
                     VALUES (".intval($courseId).", ".intval($questionId).", ".intval($categoryId).")";
694 694
             Database::query($sql);
695
-			$id = Database::insert_id();
695
+            $id = Database::insert_id();
696 696
 
697
-			return $id;
697
+            return $id;
698 698
         }
699 699
 
700
-		return false;
700
+        return false;
701 701
     }
702 702
 
703 703
     /**
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -401,8 +401,7 @@
 block discarded – undo
401 401
 				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
402 402
 				if ($nbQuestionInThisCat > $in_nbrandom) {
403 403
 					$nbquestionresult += $in_nbrandom;
404
-				}
405
-				else {
404
+				} else {
406 405
 					$nbquestionresult += $nbQuestionInThisCat;
407 406
 				}
408 407
 			}
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             $row = Database::fetch_array($res);
60 60
             $this->id = $row['id'];
61 61
             $this->name = $row['title'];
62
-            $this->description  = $row['description'];
62
+            $this->description = $row['description'];
63 63
         }
64 64
     }
65 65
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
     /**
199 199
      * @param string $in_color
200 200
      */
201
-    public function display($in_color="#E0EBF5")
201
+    public function display($in_color = "#E0EBF5")
202 202
     {
203 203
 		echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
204 204
 		print_r($this);
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	 */
214 214
     public static function getCategoryListInfo($in_field = "", $courseId = "")
215 215
     {
216
-        if (empty($courseId) || $courseId=="") {
216
+        if (empty($courseId) || $courseId == "") {
217 217
             $courseId = api_get_course_int_id();
218 218
         }
219 219
         $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
      *
254 254
      * @return int
255 255
      */
256
-	public static function getCategoryForQuestion($questionId, $courseId ="")
256
+	public static function getCategoryForQuestion($questionId, $courseId = "")
257 257
     {
258 258
 		$result = 0;
259 259
         if (empty($courseId) || $courseId == "") {
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
         $questionId,
294 294
         $courseId = ""
295 295
     ) {
296
-		if (empty($courseId) || $courseId=="") {
296
+		if (empty($courseId) || $courseId == "") {
297 297
 			$courseId = api_get_course_int_id();
298 298
 		}
299 299
 		$catid = TestCategory::getCategoryForQuestion($questionId, $courseId);
300
-		$result = "";	// result
300
+		$result = ""; // result
301 301
 		$table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
302 302
 		$catid = intval($catid);
303 303
 		$sql = "SELECT title FROM $table
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		$quiz->read($in_testid);
326 326
 		$tabQuestionList = $quiz->selectQuestionList();
327 327
 		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ???
328
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
328
+		for ($i = 1; $i <= count($tabQuestionList); $i++) {
329 329
 			if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) {
330 330
 				$result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]);
331 331
 			}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
     {
346 346
 		$tabcatName = array();
347 347
 		$tabcatID = self::getListOfCategoriesIDForTest($in_testid);
348
-		for ($i=0; $i < count($tabcatID); $i++) {
348
+		for ($i = 0; $i < count($tabcatID); $i++) {
349 349
 			$cat = new TestCategory($tabcatID[$i]);
350 350
 			$tabcatName[$cat->id] = $cat->name;
351 351
 		}
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 		$quiz->read($exerciseId);
380 380
 		$tabQuestionList = $quiz->selectQuestionList();
381 381
 		// the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
382
-		for ($i=1; $i <= count($tabQuestionList); $i++) {
382
+		for ($i = 1; $i <= count($tabQuestionList); $i++) {
383 383
 			if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
384 384
 				$nbCatResult++;
385 385
 			}
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
     {
399 399
 		$nbquestionresult = 0;
400 400
 		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
401
-		for ($i=0; $i < count($tabcatid); $i++) {
401
+		for ($i = 0; $i < count($tabcatid); $i++) {
402 402
 			if ($tabcatid[$i] > 0) {	// 0 = no category for this questio
403 403
 				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
404 404
 				if ($nbQuestionInThisCat > $in_nbrandom) {
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		}
429 429
 	 	$tabcatobject = TestCategory::getCategoryListInfo("", $courseId);
430 430
 	 	$tabresult = array("0"=>get_lang('NoCategorySelected'));
431
-	 	for ($i=0; $i < count($tabcatobject); $i++) {
431
+	 	for ($i = 0; $i < count($tabcatobject); $i++) {
432 432
 	 		$tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name;
433 433
 	 	}
434 434
 	 	return $tabresult;
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
      */
503 503
     public static function returnCategoryAndTitle($questionId, $in_display_category_name = 1)
504 504
     {
505
-        $is_student = !(api_is_allowed_to_edit(null,true) || api_is_session_admin());
505
+        $is_student = !(api_is_allowed_to_edit(null, true) || api_is_session_admin());
506 506
 
507 507
         $objExercise = Session::read('objExercise');
508 508
         if (!empty($objExercise)) {
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
     public static function sortTabByBracketLabel($in_tab)
541 541
     {
542 542
 		$tabResult = array();
543
-		$tabCatName = array();	// tab of category name
543
+		$tabCatName = array(); // tab of category name
544 544
 		while (list($cat_id, $tabquestion) = each($in_tab)) {
545 545
 			$catTitle = new TestCategory($cat_id);
546 546
 			$tabCatName[$cat_id] = $catTitle->name;
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
         $res_num_max = 0;
567 567
         // foreach question
568 568
 		$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
569
-		for ($i=0; $i < count($tabcatid); $i++) {
569
+		for ($i = 0; $i < count($tabcatid); $i++) {
570 570
 			if ($tabcatid[$i] > 0) {	// 0 = no category for this question
571 571
 				$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
572 572
                 if ($nbQuestionInThisCat > $res_num_max) {
@@ -752,20 +752,20 @@  discard block
 block discarded – undo
752 752
             $tmpobj = new TestCategory($category['id']);
753 753
             $nb_question = $tmpobj->getCategoryQuestionsNumber();
754 754
             $rowname = self::protectJSDialogQuote($category['title']);
755
-            $nb_question_label = $nb_question == 1 ? $nb_question . ' ' . get_lang('Question') : $nb_question . ' ' . get_lang('Questions');
755
+            $nb_question_label = $nb_question == 1 ? $nb_question.' '.get_lang('Question') : $nb_question.' '.get_lang('Questions');
756 756
 
757 757
             //$html .= '<div class="sectiontitle" id="id_cat' . $category['id'] . '">';
758
-            $content = "<span style='float:right'>" . $nb_question_label . "</span>";
758
+            $content = "<span style='float:right'>".$nb_question_label."</span>";
759 759
 
760 760
             $content .= '<div class="sectioncomment">';
761 761
             $content .= $category['description'];
762 762
             $content .= '</div>';
763 763
 
764
-            $links = '<a href="' . api_get_self() . '?action=editcategory&category_id=' . $category['id'] . '&'.api_get_cidreq().'">' .
765
-                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
766
-            $links .= ' <a href="' . api_get_self() . '?'.api_get_cidreq().'&action=deletecategory&category_id=' . $category['id'] . '" ';
767
-            $links .= 'onclick="return confirmDelete(\'' . self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure') . '[' . $rowname) . '] ?\', \'id_cat' . $category['id'] . '\');">';
768
-            $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
764
+            $links = '<a href="'.api_get_self().'?action=editcategory&category_id='.$category['id'].'&'.api_get_cidreq().'">'.
765
+                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
766
+            $links .= ' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=deletecategory&category_id='.$category['id'].'" ';
767
+            $links .= 'onclick="return confirmDelete(\''.self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure').'['.$rowname).'] ?\', \'id_cat'.$category['id'].'\');">';
768
+            $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
769 769
             $html .= Display::panel($content, $category['title'].$links);
770 770
         }
771 771
 
Please login to merge, or discard this patch.
main/exercice/unique_answer.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -417,8 +417,8 @@
 block discarded – undo
417 417
      * @param int $question_id  The question ID (to which the answer is attached)
418 418
      * @param string $title The text of the answer
419 419
      * @param string $comment The feedback for the answer
420
-     * @param float|null $score  The score you get when picking this answer
421
-     * @param int|null $correct  Whether this answer is considered *the* correct one (this is the unique answer type)
420
+     * @param double $score  The score you get when picking this answer
421
+     * @param integer $correct  Whether this answer is considered *the* correct one (this is the unique answer type)
422 422
      */
423 423
     public function addAnswer(
424 424
         $id,
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -447,7 +447,7 @@
 block discarded – undo
447 447
         $position = $row_max->max_position + 1;
448 448
 
449 449
         // Insert a new answer
450
-       $params = [
450
+        $params = [
451 451
             'c_id' => $course_id,
452 452
             'id' => $id,
453 453
             'question_id' => $question_id,
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -59,21 +59,21 @@  discard block
 block discarded – undo
59 59
 
60 60
         if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
61 61
             //Scenario
62
-            $comment_title = '<th width="20%">' . get_lang('Comment') . '</th>';
63
-            $feedback_title = '<th width="20%">' . get_lang('Scenario') . '</th>';
62
+            $comment_title = '<th width="20%">'.get_lang('Comment').'</th>';
63
+            $feedback_title = '<th width="20%">'.get_lang('Scenario').'</th>';
64 64
         } else {
65
-            $comment_title = '<th width="40%">' . get_lang('Comment') . '</th>';
65
+            $comment_title = '<th width="40%">'.get_lang('Comment').'</th>';
66 66
         }
67 67
 
68 68
         $html = '<table class="table table-striped table-hover">
69 69
             <thead>
70 70
                 <tr style="text-align: center;">
71
-                    <th width="5%">' . get_lang('Number') . '</th>
72
-                    <th width="5%"> ' . get_lang('True') . '</th>
73
-                    <th width="40%">' . get_lang('Answer') . '</th>
74
-                        ' . $comment_title . '
75
-                        ' . $feedback_title . '
76
-                    <th width="10%">' . get_lang('Weighting') . '</th>
71
+                    <th width="5%">' . get_lang('Number').'</th>
72
+                    <th width="5%"> ' . get_lang('True').'</th>
73
+                    <th width="40%">' . get_lang('Answer').'</th>
74
+                        ' . $comment_title.'
75
+                        ' . $feedback_title.'
76
+                    <th width="10%">' . get_lang('Weighting').'</th>
77 77
                 </tr>
78 78
             </thead>
79 79
             <tbody>';
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                     continue;
104 104
                 }
105 105
                 $question = Question::read($questionid);
106
-                $select_question[$questionid] = 'Q' . $key . ' :' . cut(
106
+                $select_question[$questionid] = 'Q'.$key.' :'.cut(
107 107
                     $question->selectTitle(), 20
108 108
                 );
109 109
             }
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
                 if ($answer->correct[$i]) {
135 135
                     $correct = $i;
136 136
                 }
137
-                $defaults['answer[' . $i . ']'] = $answer->answer[$i];
138
-                $defaults['comment[' . $i . ']'] = $answer->comment[$i];
139
-                $defaults['weighting[' . $i . ']'] = float_format(
137
+                $defaults['answer['.$i.']'] = $answer->answer[$i];
138
+                $defaults['comment['.$i.']'] = $answer->comment[$i];
139
+                $defaults['weighting['.$i.']'] = float_format(
140 140
                     $answer->weighting[$i],
141 141
                     1
142 142
                 );
@@ -159,18 +159,18 @@  discard block
 block discarded – undo
159 159
                     $url_result = $url;
160 160
                 }
161 161
 
162
-                $temp_scenario['url' . $i] = $url_result;
163
-                $temp_scenario['try' . $i] = $try_result;
164
-                $temp_scenario['lp' . $i] = $lp;
165
-                $temp_scenario['destination' . $i] = $list_dest;
162
+                $temp_scenario['url'.$i] = $url_result;
163
+                $temp_scenario['try'.$i] = $try_result;
164
+                $temp_scenario['lp'.$i] = $lp;
165
+                $temp_scenario['destination'.$i] = $list_dest;
166 166
             } else {
167 167
                 $defaults['answer[1]'] = get_lang('DefaultUniqueAnswer1');
168 168
                 $defaults['weighting[1]'] = 10;
169 169
                 $defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2');
170 170
                 $defaults['weighting[2]'] = 0;
171 171
 
172
-                $temp_scenario['destination' . $i] = array('0');
173
-                $temp_scenario['lp' . $i] = array('0');
172
+                $temp_scenario['destination'.$i] = array('0');
173
+                $temp_scenario['lp'.$i] = array('0');
174 174
             }
175 175
             $defaults['scenario'] = $temp_scenario;
176 176
 
@@ -182,62 +182,62 @@  discard block
 block discarded – undo
182 182
             );
183 183
             $renderer->setElementTemplate(
184 184
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
185
-                'counter[' . $i . ']'
185
+                'counter['.$i.']'
186 186
             );
187 187
             $renderer->setElementTemplate(
188 188
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
189
-                'answer[' . $i . ']'
189
+                'answer['.$i.']'
190 190
             );
191 191
             $renderer->setElementTemplate(
192 192
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
193
-                'comment[' . $i . ']'
193
+                'comment['.$i.']'
194 194
             );
195 195
             $renderer->setElementTemplate(
196 196
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
197
-                'weighting[' . $i . ']'
197
+                'weighting['.$i.']'
198 198
             );
199 199
 
200 200
             $answer_number = $form->addElement(
201
-                'text', 'counter[' . $i . ']', null, ' value = "' . $i . '"'
201
+                'text', 'counter['.$i.']', null, ' value = "'.$i.'"'
202 202
             );
203 203
             $answer_number->freeze();
204 204
             $form->addElement(
205 205
                 'radio', 'correct', null, null, $i, 'class="checkbox"'
206 206
             );
207 207
 
208
-            $form->addHtmlEditor('answer[' . $i . ']', null, null, true, $editor_config);
208
+            $form->addHtmlEditor('answer['.$i.']', null, null, true, $editor_config);
209 209
 
210 210
             $form->addRule(
211
-                'answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'
211
+                'answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required'
212 212
             );
213 213
 
214 214
             if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
215
-                $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editor_config);
215
+                $form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config);
216 216
                 // Direct feedback
217 217
                 //Adding extra feedback fields
218 218
                 $group = array();
219
-                $group['try' . $i] = $form->createElement(
219
+                $group['try'.$i] = $form->createElement(
220 220
                     'checkbox',
221
-                    'try' . $i,
221
+                    'try'.$i,
222 222
                     null,
223 223
                     get_lang('TryAgain')
224 224
                 );
225
-                $group['lp' . $i] = $form->createElement(
225
+                $group['lp'.$i] = $form->createElement(
226 226
                     'select',
227
-                    'lp' . $i,
228
-                    get_lang('SeeTheory') . ': ',
227
+                    'lp'.$i,
228
+                    get_lang('SeeTheory').': ',
229 229
                     $select_lp_id
230 230
                 );
231
-                $group['destination' . $i] = $form->createElement(
231
+                $group['destination'.$i] = $form->createElement(
232 232
                     'select',
233
-                    'destination' . $i,
234
-                    get_lang('GoToQuestion') . ': ',
233
+                    'destination'.$i,
234
+                    get_lang('GoToQuestion').': ',
235 235
                     $select_question
236 236
                 );
237
-                $group['url' . $i] = $form->createElement(
237
+                $group['url'.$i] = $form->createElement(
238 238
                     'text',
239
-                    'url' . $i,
240
-                    get_lang('Other') . ': ',
239
+                    'url'.$i,
240
+                    get_lang('Other').': ',
241 241
                     array(
242 242
                         'class' => 'col-md-2',
243 243
                         'placeholder' => get_lang('Other')
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
                     'scenario'
251 251
                 );
252 252
             } else {
253
-                $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editor_config);
253
+                $form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config);
254 254
             }
255
-            $form->addText('weighting[' . $i . ']', null, null, array('value' => '0'));
255
+            $form->addText('weighting['.$i.']', null, null, array('value' => '0'));
256 256
             $form->addHtml('</tr>');
257 257
         }
258 258
 
@@ -306,19 +306,19 @@  discard block
 block discarded – undo
306 306
         $nb_answers = $form->getSubmitValue('nb_answers');
307 307
 
308 308
         for ($i = 1; $i <= $nb_answers; $i++) {
309
-            $answer = trim($form->getSubmitValue('answer[' . $i . ']'));
310
-            $comment = trim($form->getSubmitValue('comment[' . $i . ']'));
311
-            $weighting = trim($form->getSubmitValue('weighting[' . $i . ']'));
309
+            $answer = trim($form->getSubmitValue('answer['.$i.']'));
310
+            $comment = trim($form->getSubmitValue('comment['.$i.']'));
311
+            $weighting = trim($form->getSubmitValue('weighting['.$i.']'));
312 312
 
313 313
             $scenario = $form->getSubmitValue('scenario');
314 314
 
315 315
             //$list_destination = $form -> getSubmitValue('destination'.$i);
316 316
             //$destination_str = $form -> getSubmitValue('destination'.$i);
317 317
 
318
-            $try = $scenario['try' . $i];
319
-            $lp = $scenario['lp' . $i];
320
-            $destination = $scenario['destination' . $i];
321
-            $url = trim($scenario['url' . $i]);
318
+            $try = $scenario['try'.$i];
319
+            $lp = $scenario['lp'.$i];
320
+            $destination = $scenario['destination'.$i];
321
+            $url = trim($scenario['url'.$i]);
322 322
 
323 323
             /*
324 324
             How we are going to parse the destination value
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
             }
367 367
 
368 368
             //1@@1;2;@@2;4;4;@@http://www.chamilo.org
369
-            $dest = $try . '@@' . $lp . '@@' . $destination . '@@' . $url;
369
+            $dest = $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
370 370
             $objAnswer->createAnswer(
371 371
                 $answer,
372 372
                 $goodAnswer,
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
         $score = null
401 401
     ) {
402 402
         $header = parent::return_header($feedback_type, $counter, $score);
403
-        $header .= '<table class="' . $this->question_table_class . '">
403
+        $header .= '<table class="'.$this->question_table_class.'">
404 404
 			<tr>
405
-				<th>' . get_lang("Choice") . '</th>
406
-				<th>' . get_lang("ExpectedChoice") . '</th>
407
-				<th>' . get_lang("Answer") . '</th>';
408
-        $header .= '<th>' . get_lang("Comment") . '</th>';
405
+				<th>' . get_lang("Choice").'</th>
406
+				<th>' . get_lang("ExpectedChoice").'</th>
407
+				<th>' . get_lang("Answer").'</th>';
408
+        $header .= '<th>'.get_lang("Comment").'</th>';
409 409
         $header .= '</tr>';
410 410
 
411 411
         return $header;
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
         if ($correct) {
470 470
             $sql = "UPDATE $tbl_quiz_question
471 471
                     SET ponderation = (ponderation + $score)
472
-                    WHERE c_id = $course_id AND id = " . $question_id;
472
+                    WHERE c_id = $course_id AND id = ".$question_id;
473 473
             Database::query($sql);
474 474
         }
475 475
     }
Please login to merge, or discard this patch.
main/forum/forumfunction.inc.php 3 patches
Doc Comments   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
  * an up and down icon except for the first (no up icon) and the last (no down icon)
1059 1059
  *          The key of this $list array is the id of the item.
1060 1060
  *
1061
- * @return void HTML
1061
+ * @return string HTML
1062 1062
  **/
1063 1063
 function return_up_down_icon($content, $id, $list)
1064 1064
 {
@@ -2011,7 +2011,7 @@  discard block
 block discarded – undo
2011 2011
  * This function retrieves forum thread users details
2012 2012
  * @param   int Thread ID
2013 2013
  * @param   string  Course DB name (optional)
2014
- * @return  resource array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[])
2014
+ * @return  Doctrine\DBAL\Driver\Statement|null array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[])
2015 2015
  * @author Christian Fasanando <[email protected]>,
2016 2016
  * @todo     this function need to be improved
2017 2017
  * @version octubre 2008, dokeos 1.8
@@ -2066,7 +2066,7 @@  discard block
 block discarded – undo
2066 2066
  * This function retrieves forum thread users qualify
2067 2067
  * @param   int Thread ID
2068 2068
  * @param   string  Course DB name (optional)
2069
- * @return  array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[])
2069
+ * @return  Doctrine\DBAL\Driver\Statement|null Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[])
2070 2070
  * @author Jhon Hinojosa
2071 2071
  * @todo     this function need to be improved
2072 2072
  */
@@ -2133,7 +2133,7 @@  discard block
 block discarded – undo
2133 2133
  * This function retrieves forum thread users not qualify
2134 2134
  * @param   int Thread ID
2135 2135
  * @param   string  Course DB name (optional)
2136
- * @return  array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[])
2136
+ * @return  Doctrine\DBAL\Driver\Statement|null Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[])
2137 2137
  * @author   Jhon Hinojosa<[email protected]>,
2138 2138
  * @version oct 2008, dokeos 1.8
2139 2139
  */
@@ -3163,6 +3163,10 @@  discard block
 block discarded – undo
3163 3163
  * @param integer contains the information the current user id
3164 3164
  * @param integer contains the information the current thread id
3165 3165
  * @param integer contains the information the current qualify
3166
+ * @param string $option
3167
+ * @param integer $course_id
3168
+ * @param integer $user_id
3169
+ * @param integer $thread_id
3166 3170
  * @return void
3167 3171
  * <code>$option=1 obtained the qualification of the current thread</code>
3168 3172
  * @author Isaac Flores <[email protected]>, U.N.A.S University
@@ -3722,6 +3726,8 @@  discard block
 block discarded – undo
3722 3726
  *
3723 3727
  * @author Patrick Cool <[email protected]>, Ghent University
3724 3728
  * @version february 2006, dokeos 1.8
3729
+ * @param string $last_post_id
3730
+ * @param string $post_date
3725 3731
  */
3726 3732
 function updateThreadInfo($thread_id, $last_post_id, $post_date)
3727 3733
 {
@@ -4025,6 +4031,8 @@  discard block
 block discarded – undo
4025 4031
  *
4026 4032
  * @param string  Content type (post, thread, forum, forum_category)
4027 4033
  * @param int     Item DB ID
4034
+ * @param string $content
4035
+ * @param integer $id
4028 4036
  * @return string language variable
4029 4037
  * @author Patrick Cool <[email protected]>, Ghent University
4030 4038
  * @version february 2006, dokeos 1.8
@@ -4461,6 +4469,7 @@  discard block
 block discarded – undo
4461 4469
 /**
4462 4470
  * Display the search results
4463 4471
  * @param string
4472
+ * @param string $search_term
4464 4473
  * @return void display the results
4465 4474
  * @author Patrick Cool <[email protected]>, Ghent University, Belgium
4466 4475
  * @version march 2008, dokeos 1.8.5
@@ -4590,7 +4599,7 @@  discard block
 block discarded – undo
4590 4599
  * This function adds an attachment file into a forum
4591 4600
  * @param string $file_comment  a comment about file
4592 4601
  * @param int $last_id from forum_post table
4593
- * @return int|bool
4602
+ * @return false|null
4594 4603
  */
4595 4604
 function add_forum_attachment_file($file_comment, $last_id)
4596 4605
 {
@@ -4801,7 +4810,7 @@  discard block
 block discarded – undo
4801 4810
  * @param post id
4802 4811
  * @param int $id_attach
4803 4812
  * @param bool $display to show or not result message
4804
- * @return void
4813
+ * @return integer
4805 4814
  * @author Julio Montoya Dokeos
4806 4815
  * @version october 2014, chamilo 1.9.8
4807 4816
  */
@@ -5083,7 +5092,7 @@  discard block
 block discarded – undo
5083 5092
  * @param integer $forum_id the id of the forum
5084 5093
  * @param integer $thread_id the id of the thread
5085 5094
  * @param integer $post_id the id of the post
5086
- * @return bool
5095
+ * @return false|null
5087 5096
  *
5088 5097
  * @author Patrick Cool <[email protected]>, Ghent University, Belgium
5089 5098
  * @version May 2008, dokeos 1.8.5
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -998,8 +998,8 @@  discard block
 block discarded – undo
998 998
                 $html .= $key . '=' . $value . '&';
999 999
             }
1000 1000
         }
1001
-       $html.='action=invisible&content='.$content.'&id='.$id.'">'.
1002
-           Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_SMALL).'</a>';
1001
+        $html.='action=invisible&content='.$content.'&id='.$id.'">'.
1002
+            Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_SMALL).'</a>';
1003 1003
     }
1004 1004
     if ($current_visibility_status == '0') {
1005 1005
         $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&';
@@ -1008,8 +1008,8 @@  discard block
 block discarded – undo
1008 1008
                 $html .= $key . '=' . $value . '&';
1009 1009
             }
1010 1010
         }
1011
-       $html .= 'action=visible&content=' . $content . '&id=' . $id . '">' .
1012
-           Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL) . '</a>';
1011
+        $html .= 'action=visible&content=' . $content . '&id=' . $id . '">' .
1012
+            Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL) . '</a>';
1013 1013
     }
1014 1014
     return $html;
1015 1015
 }
@@ -1317,16 +1317,16 @@  discard block
 block discarded – undo
1317 1317
     }
1318 1318
 }
1319 1319
 /**
1320
- * Retrieve all the information off the forum categories (or one specific) for the current course.
1321
- * The categories are sorted according to their sorting order (cat_order
1322
- *
1323
- * @param int $id default ''. When an id is passed we only find the information
1324
- * about that specific forum category. If no id is passed we get all the forum categories.
1325
- * @return array containing all the information about all the forum categories
1326
- *
1327
- * @author Patrick Cool <[email protected]>, Ghent University
1328
- * @version february 2006, dokeos 1.8
1329
- */
1320
+     * Retrieve all the information off the forum categories (or one specific) for the current course.
1321
+     * The categories are sorted according to their sorting order (cat_order
1322
+     *
1323
+     * @param int $id default ''. When an id is passed we only find the information
1324
+     * about that specific forum category. If no id is passed we get all the forum categories.
1325
+     * @return array containing all the information about all the forum categories
1326
+     *
1327
+     * @author Patrick Cool <[email protected]>, Ghent University
1328
+     * @version february 2006, dokeos 1.8
1329
+     */
1330 1330
 function get_forum_categories($id = '')
1331 1331
 {
1332 1332
     $table_categories = Database :: get_course_table(TABLE_FORUM_CATEGORY);
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
             var l = $(this);
64 64
             var id = l.closest("tr").attr("id");
65 65
             var filename = l.closest("tr").find(".attachFilename").html();
66
-            if (confirm("' . get_lang('AreYouSureToDeleteJS') . '", filename)) {
66
+            if (confirm("' . get_lang('AreYouSureToDeleteJS').'", filename)) {
67 67
                 $.ajax({
68 68
                     type: "POST",
69
-                    url: "'.api_get_path(WEB_AJAX_PATH) . 'forum.ajax.php?'.api_get_cidreq().'&a=delete_file&attachId=" + id +"&thread='.$threadId .'&forum='.$forumId .'",
69
+                    url: "'.api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&a=delete_file&attachId=" + id +"&thread='.$threadId.'&forum='.$forumId.'",
70 70
                     dataType: "json",
71 71
                     success: function(data) {
72 72
                         if (data.error == false) {
@@ -973,24 +973,24 @@  discard block
 block discarded – undo
973 973
     $html = '';
974 974
     $id = Security::remove_XSS($id);
975 975
     if ($current_visibility_status == '1') {
976
-        $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&';
976
+        $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
977 977
         if (is_array($additional_url_parameters)) {
978 978
             foreach ($additional_url_parameters as $key => $value) {
979
-                $html .= $key . '=' . $value . '&';
979
+                $html .= $key.'='.$value.'&';
980 980
             }
981 981
         }
982
-       $html.='action=invisible&content='.$content.'&id='.$id.'">'.
982
+       $html .= 'action=invisible&content='.$content.'&id='.$id.'">'.
983 983
            Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_SMALL).'</a>';
984 984
     }
985 985
     if ($current_visibility_status == '0') {
986
-        $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&';
986
+        $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
987 987
         if (is_array($additional_url_parameters)) {
988 988
             foreach ($additional_url_parameters as $key => $value) {
989
-                $html .= $key . '=' . $value . '&';
989
+                $html .= $key.'='.$value.'&';
990 990
             }
991 991
         }
992
-       $html .= 'action=visible&content=' . $content . '&id=' . $id . '">' .
993
-           Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL) . '</a>';
992
+       $html .= 'action=visible&content='.$content.'&id='.$id.'">'.
993
+           Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL).'</a>';
994 994
     }
995 995
     return $html;
996 996
 }
@@ -1011,21 +1011,21 @@  discard block
 block discarded – undo
1011 1011
         $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
1012 1012
         if (is_array($additional_url_parameters)) {
1013 1013
             foreach ($additional_url_parameters as $key => $value) {
1014
-                $html .= $key . '=' . $value . '&';
1014
+                $html .= $key.'='.$value.'&';
1015 1015
             }
1016 1016
         }
1017
-        $html.= 'action=unlock&content='.$content.'&id='.$id.'">'.
1017
+        $html .= 'action=unlock&content='.$content.'&id='.$id.'">'.
1018 1018
             Display::return_icon('lock.png', get_lang('Unlock'), array(), ICON_SIZE_SMALL).'</a>';
1019 1019
     }
1020 1020
     if ($current_lock_status == '0') {
1021 1021
         $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
1022 1022
         if (is_array($additional_url_parameters)) {
1023 1023
             foreach ($additional_url_parameters as $key => $value) {
1024
-                $html .= $key . '=' . $value . '&';
1024
+                $html .= $key.'='.$value.'&';
1025 1025
             }
1026 1026
         }
1027
-        $html .= 'action=lock&content=' . $content . '&id=' . $id . '">' .
1028
-            Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL) . '</a>';
1027
+        $html .= 'action=lock&content='.$content.'&id='.$id.'">'.
1028
+            Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL).'</a>';
1029 1029
     }
1030 1030
     return $html;
1031 1031
 }
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
                     forum_categories.c_id = $course_id AND
1229 1229
                     item_properties.c_id = $course_id AND
1230 1230
                     forum_categories.cat_id=item_properties.ref AND
1231
-                    item_properties.tool='" . TOOL_FORUM_CATEGORY . "'
1231
+                    item_properties.tool='".TOOL_FORUM_CATEGORY."'
1232 1232
                 ORDER BY forum_categories.cat_order $sort_direction";
1233 1233
     }
1234 1234
     if ($content == 'forum') {
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
             FROM $table
1237 1237
             WHERE
1238 1238
                 c_id = $course_id AND
1239
-                forum_category='" . Database::escape_string($forum_category) . "'
1239
+                forum_category='".Database::escape_string($forum_category)."'
1240 1240
             ORDER BY forum_order $sort_direction";
1241 1241
     }
1242 1242
     // Finding the items that need to be switched.
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 {
1294 1294
     $current_visibility_status = intval($current_visibility_status);
1295 1295
     if ($current_visibility_status == 0) {
1296
-        $status='invisible';
1296
+        $status = 'invisible';
1297 1297
         return $status;
1298 1298
     }
1299 1299
 }
@@ -2202,7 +2202,7 @@  discard block
 block discarded – undo
2202 2202
 {
2203 2203
     $table_forums = Database :: get_course_table(TABLE_FORUM);
2204 2204
     $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
2205
-    $courseId = empty($courseId) ? api_get_course_int_id(): intval($courseId);
2205
+    $courseId = empty($courseId) ? api_get_course_int_id() : intval($courseId);
2206 2206
     $forum_id = intval($forum_id);
2207 2207
 
2208 2208
     $sql = "SELECT *
@@ -2361,7 +2361,7 @@  discard block
 block discarded – undo
2361 2361
  */
2362 2362
 function store_thread($current_forum, $values, $courseInfo = array(), $showMessage = true)
2363 2363
 {
2364
-    $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo ;
2364
+    $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo;
2365 2365
     $_user = api_get_user_info();
2366 2366
     $course_id = $courseInfo['real_id'];
2367 2367
     $courseCode = $courseInfo['code'];
@@ -2603,11 +2603,11 @@  discard block
 block discarded – undo
2603 2603
     $form = new FormValidator(
2604 2604
         'thread',
2605 2605
         'post',
2606
-        api_get_self() . '?' . http_build_query([
2606
+        api_get_self().'?'.http_build_query([
2607 2607
             'forum' => $myForum,
2608 2608
             'gradebook' => $myGradebook,
2609 2609
             'thread' => $myThread,
2610
-        ]) . '&' . api_get_cidreq()
2610
+        ]).'&'.api_get_cidreq()
2611 2611
     );
2612 2612
     
2613 2613
     $form->addElement('header', get_lang('EditThread'));
@@ -2671,7 +2671,7 @@  discard block
 block discarded – undo
2671 2671
     $form->addElement('html', '</div>');
2672 2672
     
2673 2673
     if (!empty($formValues)) {
2674
-        $defaults['thread_qualify_gradebook'] = ($formValues['threadQualifyMax'] > 0 && empty($_POST)) ? 1 : 0 ;
2674
+        $defaults['thread_qualify_gradebook'] = ($formValues['threadQualifyMax'] > 0 && empty($_POST)) ? 1 : 0;
2675 2675
         $defaults['thread_title'] = prepare4display($formValues['threadTitle']);
2676 2676
         $defaults['thread_sticky'] = strval(intval($formValues['threadSticky']));
2677 2677
         $defaults['thread_peer_qualify'] = intval($formValues['threadPeerQualify']);
@@ -2743,13 +2743,13 @@  discard block
 block discarded – undo
2743 2743
     $form = new FormValidator(
2744 2744
         'thread',
2745 2745
         'post',
2746
-        api_get_self() . '?' . http_build_query([
2746
+        api_get_self().'?'.http_build_query([
2747 2747
             'forum' => intval($my_forum),
2748 2748
             'gradebook' => $my_gradebook,
2749 2749
             'thread' => intval($myThread),
2750 2750
             'post' => intval($my_post),
2751 2751
             'action' => $action,
2752
-        ]) . '&' . api_get_cidreq()
2752
+        ]).'&'.api_get_cidreq()
2753 2753
     );
2754 2754
     $form->setConstants(array('forum' => '5'));
2755 2755
 
@@ -3012,7 +3012,7 @@  discard block
 block discarded – undo
3012 3012
 
3013 3013
             if ($row[0] == 0) {
3014 3014
                 $sql = "INSERT INTO $table_threads_qualify (c_id, user_id, thread_id,qualify,qualify_user_id,qualify_time,session_id)
3015
-                        VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float)$thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')";
3015
+                        VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float) $thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')";
3016 3016
                 Database::query($sql);
3017 3017
 
3018 3018
                 $insertId = Database::insert_id();
@@ -4678,9 +4678,9 @@  discard block
 block discarded – undo
4678 4678
             continue;
4679 4679
         }
4680 4680
 
4681
-        $course_dir = $_course['path'] . '/upload/forum';
4681
+        $course_dir = $_course['path'].'/upload/forum';
4682 4682
         $sys_course_path = api_get_path(SYS_COURSE_PATH);
4683
-        $updir = $sys_course_path . $course_dir;
4683
+        $updir = $sys_course_path.$course_dir;
4684 4684
 
4685 4685
         // Try to add an extension to the file if it hasn't one.
4686 4686
         $new_file_name = add_ext_on_mime(
@@ -4697,7 +4697,7 @@  discard block
 block discarded – undo
4697 4697
         }
4698 4698
 
4699 4699
         $new_file_name = uniqid('');
4700
-        $new_path = $updir . '/' . $new_file_name;
4700
+        $new_path = $updir.'/'.$new_file_name;
4701 4701
         $result = @move_uploaded_file($attachment['tmp_name'], $new_path);
4702 4702
         $safe_file_comment = Database::escape_string($file_comment);
4703 4703
         $safe_file_name = Database::escape_string($file_name);
@@ -4862,16 +4862,16 @@  discard block
 block discarded – undo
4862 4862
     $forum_table_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
4863 4863
     $course_id = api_get_course_int_id();
4864 4864
 
4865
-    $cond = (!empty($id_attach)) ? " iid = " . (int) $id_attach . "" : " post_id = " . (int) $post_id . "";
4865
+    $cond = (!empty($id_attach)) ? " iid = ".(int) $id_attach."" : " post_id = ".(int) $post_id."";
4866 4866
     $sql = "SELECT path FROM $forum_table_attachment WHERE c_id = $course_id AND $cond";
4867 4867
     $res = Database::query($sql);
4868 4868
     $row = Database::fetch_array($res);
4869 4869
 
4870
-    $course_dir = $_course['path'] . '/upload/forum';
4870
+    $course_dir = $_course['path'].'/upload/forum';
4871 4871
     $sys_course_path = api_get_path(SYS_COURSE_PATH);
4872
-    $updir = $sys_course_path . $course_dir;
4872
+    $updir = $sys_course_path.$course_dir;
4873 4873
     $my_path = isset($row['path']) ? $row['path'] : null;
4874
-    $file = $updir . '/' . $my_path;
4874
+    $file = $updir.'/'.$my_path;
4875 4875
     if (Security::check_abs_path($file, $updir)) {
4876 4876
         @unlink($file);
4877 4877
     }
@@ -5419,35 +5419,35 @@  discard block
 block discarded – undo
5419 5419
                         $post_list = get_thread_user_post_limit($course_code, $thread['thread_id'], $user_id, 1);
5420 5420
                         $post_counter = count($post_list);
5421 5421
                         if (is_array($post_list) && count($post_list) > 0) {
5422
-                            $hand_forums.= '<div id="social-thread">';
5423
-                            $hand_forums.= Display::return_icon('thread.png', get_lang('Thread'), '', ICON_SIZE_MEDIUM);
5424
-                            $hand_forums.= '&nbsp;'.Security::remove_XSS($thread['thread_title'], STUDENT);
5425
-                            $hand_forums.= '</div>';
5422
+                            $hand_forums .= '<div id="social-thread">';
5423
+                            $hand_forums .= Display::return_icon('thread.png', get_lang('Thread'), '', ICON_SIZE_MEDIUM);
5424
+                            $hand_forums .= '&nbsp;'.Security::remove_XSS($thread['thread_title'], STUDENT);
5425
+                            $hand_forums .= '</div>';
5426 5426
 
5427 5427
                             foreach ($post_list as $posts) {
5428
-                                $hand_forums.= '<div id="social-post">';
5429
-                                $hand_forums.= '<strong>'.Security::remove_XSS($posts['post_title'], STUDENT).'</strong>';
5430
-                                $hand_forums.= '<br / >';
5431
-                                $hand_forums.= Security::remove_XSS($posts['post_text'], STUDENT);
5432
-                                $hand_forums.= '</div>';
5433
-                                $hand_forums.= '<br / >';
5428
+                                $hand_forums .= '<div id="social-post">';
5429
+                                $hand_forums .= '<strong>'.Security::remove_XSS($posts['post_title'], STUDENT).'</strong>';
5430
+                                $hand_forums .= '<br / >';
5431
+                                $hand_forums .= Security::remove_XSS($posts['post_text'], STUDENT);
5432
+                                $hand_forums .= '</div>';
5433
+                                $hand_forums .= '<br / >';
5434 5434
                             }
5435 5435
                         }
5436 5436
                     }
5437 5437
                     $i++;
5438 5438
                 }
5439
-                $forum_results .='<div id="social-forum">';
5440
-                $forum_results .='<div class="clear"></div><br />';
5441
-                $forum_results .='<div id="social-forum-title">'.
5439
+                $forum_results .= '<div id="social-forum">';
5440
+                $forum_results .= '<div class="clear"></div><br />';
5441
+                $forum_results .= '<div id="social-forum-title">'.
5442 5442
                     Display::return_icon('forum.gif', get_lang('Forum')).'&nbsp;'.Security::remove_XSS($forum['forum_title'], STUDENT).
5443 5443
                     '<div style="float:right;margin-top:-35px">
5444 5444
                                         <a href="../forum/viewforum.php?cidReq='.$course_code.'&gidReq=&forum='.$forum['forum_id'].' " >'.get_lang('SeeForum').'</a>
5445 5445
                                     </div></div>';
5446
-                $forum_results .='<br / >';
5446
+                $forum_results .= '<br / >';
5447 5447
                 if ($post_counter > 0) {
5448
-                    $forum_results .=$hand_forums;
5448
+                    $forum_results .= $hand_forums;
5449 5449
                 }
5450
-                $forum_results .='</div>';
5450
+                $forum_results .= '</div>';
5451 5451
             }$j++;
5452 5452
         }
5453 5453
     }
@@ -5588,16 +5588,16 @@  discard block
 block discarded – undo
5588 5588
     $courseId = intval($courseId);
5589 5589
     if (empty($courseId)) {
5590 5590
         // $courseId can be null, use api method
5591
-        $courseId= api_get_course_int_id();
5591
+        $courseId = api_get_course_int_id();
5592 5592
     }
5593 5593
     /*
5594 5594
      * Check if Attachment ID and Course ID are greater than zero
5595 5595
      * and array of field values is not empty
5596 5596
      */
5597 5597
     if ($id > 0 && $courseId > 0 && !empty($array) && is_array($array)) {
5598
-        foreach($array as $key => &$item) {
5598
+        foreach ($array as $key => &$item) {
5599 5599
             $item = Database::escape_string($item);
5600
-            $setString .= $key . ' = "' .$item . '", ';
5600
+            $setString .= $key.' = "'.$item.'", ';
5601 5601
         }
5602 5602
         // Delete last comma
5603 5603
         $setString = substr($setString, 0, strlen($setString) - 2);
@@ -5641,7 +5641,7 @@  discard block
 block discarded – undo
5641 5641
         return '';
5642 5642
     }
5643 5643
 
5644
-    $url = api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&forum=' . $forumId . '&thread=' . $threadId . '&postId=' . $postId . '&a=upload_file';
5644
+    $url = api_get_path(WEB_AJAX_PATH).'forum.ajax.php?'.api_get_cidreq().'&forum='.$forumId.'&thread='.$threadId.'&postId='.$postId.'&a=upload_file';
5645 5645
 
5646 5646
     $multipleForm = new FormValidator('post');
5647 5647
     $multipleForm->addMultipleUpload($url);
@@ -5682,10 +5682,10 @@  discard block
 block discarded – undo
5682 5682
         foreach ($uploadedFiles as $k => $uploadedFile) {
5683 5683
             if (!empty($uploadedFile) && in_array($uploadedFile['id'], $attachIds)) {
5684 5684
                 // Buil html table including an input with attachmentID
5685
-                $fileDataContent .= '<tr id="' . $uploadedFile['id'] . '" ><td>' . $uploadedFile['name'] . '</td><td>' . $uploadedFile['size'] . '</td><td>&nbsp;' . $uploadedFile['result'] .
5686
-                    ' </td><td> <input style="width:90%;" type="text" value="' . $uploadedFile['comment'] . '" name="file_comments[]"> </td><td>' .
5687
-                    $uploadedFile['delete'] . '</td>' .
5688
-                    '<input type="hidden" value="' . $uploadedFile['id'] .'" name="file_ids[]">' . '</tr>';
5685
+                $fileDataContent .= '<tr id="'.$uploadedFile['id'].'" ><td>'.$uploadedFile['name'].'</td><td>'.$uploadedFile['size'].'</td><td>&nbsp;'.$uploadedFile['result'].
5686
+                    ' </td><td> <input style="width:90%;" type="text" value="'.$uploadedFile['comment'].'" name="file_comments[]"> </td><td>'.
5687
+                    $uploadedFile['delete'].'</td>'.
5688
+                    '<input type="hidden" value="'.$uploadedFile['id'].'" name="file_ids[]">'.'</tr>';
5689 5689
             } else {
5690 5690
                 /*
5691 5691
                  * If attachment data is empty, then delete it from $_SESSION
@@ -5698,7 +5698,7 @@  discard block
 block discarded – undo
5698 5698
     $style = empty($fileDataContent) ? 'display: none;' : '';
5699 5699
     // Forum attachment Ajax table
5700 5700
     $fileData = '
5701
-    <div class="control-group " style="'. $style . '">
5701
+    <div class="control-group " style="'. $style.'">
5702 5702
         <label class="control-label">'.get_lang('AttachmentList').'</label>
5703 5703
         <div class="controls">
5704 5704
             <table id="attachmentFileList" class="files data_table span10">
@@ -5770,7 +5770,7 @@  discard block
 block discarded – undo
5770 5770
             // name contains an URL to download attachment file and its filename
5771 5771
             $json['name'] = Display::url(
5772 5772
                 api_htmlentities($row['filename']),
5773
-                api_get_path(WEB_CODE_PATH) . 'forum/download.php?file='.$row['path'].'&'.api_get_cidreq(),
5773
+                api_get_path(WEB_CODE_PATH).'forum/download.php?file='.$row['path'].'&'.api_get_cidreq(),
5774 5774
                 array('target'=>'_blank', 'class' => 'attachFilename')
5775 5775
             );
5776 5776
             $json['id'] = $row['iid'];
@@ -5781,9 +5781,9 @@  discard block
 block discarded – undo
5781 5781
             if (!empty($row) && is_array($row)) {
5782 5782
                 // Set result as success and bring delete URL
5783 5783
                 $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded'));
5784
-                $url = api_get_path(WEB_CODE_PATH) . 'forum/viewthread.php?' . api_get_cidreq() . '&action=delete_attach&forum=' . $forumId . '&thread=' . $threadId.'&id_attach=' . $row['iid'];
5784
+                $url = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&action=delete_attach&forum='.$forumId.'&thread='.$threadId.'&id_attach='.$row['iid'];
5785 5785
                 $json['delete'] = Display::url(
5786
-                    Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL),
5786
+                    Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL),
5787 5787
                     $url,
5788 5788
                     array('class' => 'deleteLink')
5789 5789
                 );
@@ -5872,7 +5872,7 @@  discard block
 block discarded – undo
5872 5872
                 WHERE c_id = $courseId AND post_id = $postId";
5873 5873
         $result = Database::query($sql);
5874 5874
         if ($result !== false && Database::num_rows($result) > 0) {
5875
-            while ($row = Database::fetch_array($result,'ASSOC')) {
5875
+            while ($row = Database::fetch_array($result, 'ASSOC')) {
5876 5876
                 $array[] = $row['id'];
5877 5877
             }
5878 5878
         }
Please login to merge, or discard this patch.
main/gradebook/lib/be/exerciselink.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -372,7 +372,7 @@
 block discarded – undo
372 372
     }
373 373
 
374 374
     /**
375
-     * @return array|string
375
+     * @return string
376 376
      */
377 377
     public function get_type_name()
378 378
     {
Please login to merge, or discard this patch.
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
         in exercice/exercice.php, look for note-query-exe-results marker*/
195 195
         $session_id = api_get_session_id();
196 196
         $courseId = $this->getCourseId();
197
-	    $exercise = new Exercise($courseId);
197
+        $exercise = new Exercise($courseId);
198 198
         $exercise->read($this->get_ref_id());
199 199
 
200 200
         if (!$this->is_hp) {
201 201
 
202
-		if ($exercise->exercise_was_added_in_lp == false) {
203
-			$sql = "SELECT * FROM $tblStats
202
+        if ($exercise->exercise_was_added_in_lp == false) {
203
+            $sql = "SELECT * FROM $tblStats
204 204
 			        WHERE
205 205
 			            exe_exo_id = ".intval($this->get_ref_id())." AND
206 206
 			            orig_lp_id = 0 AND
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
209 209
 			            session_id = $session_id AND
210 210
                                     c_id = $courseId 
211 211
                                 ";
212
-		    } else {
213
-		        $lpId = null;
214
-		        if (!empty($exercise->lpList)) {
215
-		            // Taking only the first LP
216
-		            $lpId = current($exercise->lpList);
217
-		            $lpId = $lpId['lp_id'];
218
-		        }
219
-
220
-		        $sql = "SELECT * FROM $tblStats
212
+            } else {
213
+                $lpId = null;
214
+                if (!empty($exercise->lpList)) {
215
+                    // Taking only the first LP
216
+                    $lpId = current($exercise->lpList);
217
+                    $lpId = $lpId['lp_id'];
218
+                }
219
+
220
+                $sql = "SELECT * FROM $tblStats
221 221
 		                WHERE
222 222
 		                    exe_exo_id = ".intval($this->get_ref_id())." AND
223 223
 		                    orig_lp_id = $lpId AND
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		                    session_id = $session_id AND
226 226
                                     c_id = $courseId 
227 227
                                 ";
228
-		    }
228
+            }
229 229
 
230 230
             if (!empty($stud_id) && $type != 'ranking') {
231 231
                 $sql .= " AND exe_user_id = $stud_id ";
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
                     SELECT ref_id FROM '.$tbl_grade_links.'
46 46
                     WHERE
47 47
                         type = '.LINK_EXERCISE." AND
48
-                        c_id = '" . intval($this->course_id) . "'
48
+                        c_id = '" . intval($this->course_id)."'
49 49
                 ) AND
50 50
                 exe.c_id = ".$this->course_id;
51 51
 
52 52
         $result = Database::query($sql);
53 53
         $cats = array();
54
-        while ($data=Database::fetch_array($result)) {
55
-            $cats[] = array ($data['id'], $data['title']);
54
+        while ($data = Database::fetch_array($result)) {
55
+            $cats[] = array($data['id'], $data['title']);
56 56
         }
57 57
 
58 58
         return $cats;
@@ -116,15 +116,15 @@  discard block
 block discarded – undo
116 116
         $cats = array();
117 117
         if (isset($result)) {
118 118
             if (Database::num_rows($result) > 0) {
119
-                while ($data=Database::fetch_array($result)) {
120
-                    $cats[] = array ($data['id'], $data['title']);
119
+                while ($data = Database::fetch_array($result)) {
120
+                    $cats[] = array($data['id'], $data['title']);
121 121
                 }
122 122
             }
123 123
         }
124 124
 
125 125
         if (isset($result2)) {
126 126
             if (Database::num_rows($result2) > 0) {
127
-                while ($row=Database::fetch_array($result2)) {
127
+                while ($row = Database::fetch_array($result2)) {
128 128
                     /*$path = $data['path'];
129 129
                     $fname = GetQuizName($path,$documentPath);
130 130
         			$cats[] = array ($data['id'], $fname);*/
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
                 WHERE
171 171
                     session_id = $session_id AND
172 172
                     c_id = $course_id AND
173
-                    exe_exo_id   = ".(int)$this->get_ref_id();
173
+                    exe_exo_id   = ".(int) $this->get_ref_id();
174 174
         $result = Database::query($sql);
175
-        $number=Database::fetch_row($result);
175
+        $number = Database::fetch_row($result);
176 176
         return ($number[0] != 0);
177 177
     }
178 178
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
         } else {
255 255
             // all students -> get average
256 256
             // normal way of getting the info
257
-            $students = array();  // user list, needed to make sure we only
257
+            $students = array(); // user list, needed to make sure we only
258 258
             // take first attempts into account
259 259
             $student_count = 0;
260 260
             $sum = 0;
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
                         /*if (empty($count)) {
290 290
                             return null;
291 291
                         }*/
292
-                        return array($sumResult/$count , $weight);
292
+                        return array($sumResult / $count, $weight);
293 293
                         break;
294 294
                     case 'ranking':
295 295
                         return AbstractLink::getCurrentUserRanking($stud_id, $students);
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
         $session_id = api_get_session_id();
320 320
 
321 321
         $url = api_get_path(WEB_CODE_PATH).'gradebook/exercise_jump.php?session_id='.$session_id.'&cidReq='.$this->get_course_code().'&gradebook=view&exerciseId='.$this->get_ref_id().'&type='.$this->get_type();
322
-        if ((!api_is_allowed_to_edit() && $this->calc_score(api_get_user_id()) == null) || $status_user!=1) {
322
+        if ((!api_is_allowed_to_edit() && $this->calc_score(api_get_user_id()) == null) || $status_user != 1) {
323 323
             $url .= '&amp;doexercise='.$this->get_ref_id();
324 324
         }
325 325
 
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
     public function is_valid_link()
365 365
     {
366 366
         $sql = 'SELECT count(id) from '.$this->get_exercise_table().'
367
-                WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' ';
367
+                WHERE c_id = '.$this->course_id.' AND id = '.(int) $this->get_ref_id().' ';
368 368
         $result = Database::query($sql);
369 369
         $number = Database::fetch_row($result);
370 370
 
Please login to merge, or discard this patch.
main/gradebook/lib/be/forumthreadlink.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@
 block discarded – undo
121 121
 
122 122
     /**
123 123
     * Has anyone done this exercise yet ?
124
-    * @return int
124
+    * @return boolean
125 125
     */
126 126
     public function has_results()
127 127
     {
Please login to merge, or discard this patch.
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -10,54 +10,54 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class ForumThreadLink extends AbstractLink
12 12
 {
13
-	private $forum_thread_table = null;
14
-	private $itemprop_table = null;
15
-
16
-	/**
17
-	 * Constructor
18
-	 */
19
-	public function __construct()
20
-	{
21
-		parent::__construct();
22
-		$this->set_type(LINK_FORUM_THREAD);
23
-	}
24
-
25
-	/**
26
-	 * @return string
27
-	 */
28
-	public function get_type_name()
29
-	{
30
-		return get_lang('ForumThreads');
31
-	}
32
-
33
-	/**
34
-	 * @return bool
35
-	 */
36
-	public function is_allowed_to_change_name()
37
-	{
38
-		return false;
39
-	}
40
-
41
-	/**
42
-	 * Generate an array of exercises that a teacher hasn't created a link for.
43
-	 * @return array 2-dimensional array - every element contains 2 subelements (id, name)
44
-	 */
45
-	public function get_not_created_links()
46
-	{
47
-		if (empty($this->course_code)) {
48
-			die('Error in get_not_created_links() : course code not set');
49
-		}
50
-
51
-		$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
52
-
53
-		$sql = 'SELECT thread_id,thread_title,thread_title_qualify FROM '.$this->get_forum_thread_table()
54
-			.' forum_thread WHERE thread_id NOT IN'
55
-			.' (SELECT ref_id FROM '.$tbl_grade_links
56
-			.' WHERE type = '.LINK_FORUM_THREAD
57
-			." AND c_id = ".intval($this->course_id)
58
-			.') AND forum_thread.session_id='.api_get_session_id().'';
59
-
60
-		$result = Database::query($sql);
13
+    private $forum_thread_table = null;
14
+    private $itemprop_table = null;
15
+
16
+    /**
17
+     * Constructor
18
+     */
19
+    public function __construct()
20
+    {
21
+        parent::__construct();
22
+        $this->set_type(LINK_FORUM_THREAD);
23
+    }
24
+
25
+    /**
26
+     * @return string
27
+     */
28
+    public function get_type_name()
29
+    {
30
+        return get_lang('ForumThreads');
31
+    }
32
+
33
+    /**
34
+     * @return bool
35
+     */
36
+    public function is_allowed_to_change_name()
37
+    {
38
+        return false;
39
+    }
40
+
41
+    /**
42
+     * Generate an array of exercises that a teacher hasn't created a link for.
43
+     * @return array 2-dimensional array - every element contains 2 subelements (id, name)
44
+     */
45
+    public function get_not_created_links()
46
+    {
47
+        if (empty($this->course_code)) {
48
+            die('Error in get_not_created_links() : course code not set');
49
+        }
50
+
51
+        $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
52
+
53
+        $sql = 'SELECT thread_id,thread_title,thread_title_qualify FROM '.$this->get_forum_thread_table()
54
+            .' forum_thread WHERE thread_id NOT IN'
55
+            .' (SELECT ref_id FROM '.$tbl_grade_links
56
+            .' WHERE type = '.LINK_FORUM_THREAD
57
+            ." AND c_id = ".intval($this->course_id)
58
+            .') AND forum_thread.session_id='.api_get_session_id().'';
59
+
60
+        $result = Database::query($sql);
61 61
 
62 62
         $cats = array();
63 63
         while ($data = Database::fetch_array($result)) {
@@ -72,29 +72,29 @@  discard block
 block discarded – undo
72 72
         }
73 73
 
74 74
         return $cats;
75
-	}
76
-
77
-	/**
78
-	 * Generate an array of all exercises available.
79
-	 * @return array 2-dimensional array - every element contains 2 subelements (id, name)
80
-	 */
81
-	public function get_all_links()
82
-	{
83
-		if (empty($this->course_code)) {
84
-			die('Error in get_not_created_links() : course code not set');
85
-		}
86
-
87
-		$tbl_grade_links 	= Database :: get_course_table(TABLE_FORUM_THREAD);
88
-		$tbl_item_property	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
89
-		$session_id = api_get_session_id();
90
-
91
-		if ($session_id) {
92
-			$session_condition = 'tl.session_id='.api_get_session_id();
93
-		} else {
94
-			$session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)';
95
-		}
96
-
97
-		$sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify
75
+    }
76
+
77
+    /**
78
+     * Generate an array of all exercises available.
79
+     * @return array 2-dimensional array - every element contains 2 subelements (id, name)
80
+     */
81
+    public function get_all_links()
82
+    {
83
+        if (empty($this->course_code)) {
84
+            die('Error in get_not_created_links() : course code not set');
85
+        }
86
+
87
+        $tbl_grade_links 	= Database :: get_course_table(TABLE_FORUM_THREAD);
88
+        $tbl_item_property	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
89
+        $session_id = api_get_session_id();
90
+
91
+        if ($session_id) {
92
+            $session_condition = 'tl.session_id='.api_get_session_id();
93
+        } else {
94
+            $session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)';
95
+        }
96
+
97
+        $sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify
98 98
 				FROM '.$tbl_grade_links.' tl INNER JOIN '.$tbl_item_property.' ip
99 99
 				ON (tl.thread_id = ip.ref AND tl.c_id = ip.c_id )
100 100
 				WHERE
@@ -105,24 +105,24 @@  discard block
 block discarded – undo
105 105
                     '.$session_condition.'
106 106
                 ';
107 107
 
108
-		$result = Database::query($sql);
108
+        $result = Database::query($sql);
109 109
 
110
-		while ($data = Database::fetch_array($result)) {
111
-			if ( isset($data['thread_title_qualify']) and $data['thread_title_qualify']!=""){
112
-				$cats[] = array ($data['thread_id'], $data['thread_title_qualify']);
113
-			} else {
114
-				$cats[] = array ($data['thread_id'], $data['thread_title']);
115
-			}
116
-		}
117
-		$my_cats = isset($cats) ? $cats : null;
110
+        while ($data = Database::fetch_array($result)) {
111
+            if ( isset($data['thread_title_qualify']) and $data['thread_title_qualify']!=""){
112
+                $cats[] = array ($data['thread_id'], $data['thread_title_qualify']);
113
+            } else {
114
+                $cats[] = array ($data['thread_id'], $data['thread_title']);
115
+            }
116
+        }
117
+        $my_cats = isset($cats) ? $cats : null;
118 118
 
119
-		return $my_cats;
120
-	}
119
+        return $my_cats;
120
+    }
121 121
 
122 122
     /**
123
-    * Has anyone done this exercise yet ?
124
-    * @return int
125
-    */
123
+     * Has anyone done this exercise yet ?
124
+     * @return int
125
+     */
126 126
     public function has_results()
127 127
     {
128 128
         $table = Database :: get_course_table(TABLE_FORUM_POST);
@@ -134,40 +134,40 @@  discard block
 block discarded – undo
134 134
         $number = Database::fetch_row($result);
135 135
 
136 136
         return $number[0] != 0;
137
-	}
137
+    }
138 138
 
139
-	/**
140
-	 * @param int    $stud_id
139
+    /**
140
+     * @param int    $stud_id
141 141
      * @param string $type
142 142
      *
143
-	 * @return array|null
144
-	 */
145
-	public function calc_score($stud_id = null, $type = null)
146
-	{
143
+     * @return array|null
144
+     */
145
+    public function calc_score($stud_id = null, $type = null)
146
+    {
147 147
         require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
148 148
         $threadInfo = get_thread_information($this->get_ref_id());
149 149
 
150
-		$thread_qualify = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY);
150
+        $thread_qualify = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY);
151 151
 
152
-		$sql = 'SELECT thread_qualify_max
152
+        $sql = 'SELECT thread_qualify_max
153 153
 		        FROM '.Database :: get_course_table(TABLE_FORUM_THREAD)."
154 154
   				WHERE c_id = ".$this->course_id." AND thread_id = '".$this->get_ref_id()."'";
155
-		$query = Database::query($sql);
156
-		$assignment = Database::fetch_array($query);
155
+        $query = Database::query($sql);
156
+        $assignment = Database::fetch_array($query);
157 157
 
158
-		$sql = "SELECT * FROM $thread_qualify
158
+        $sql = "SELECT * FROM $thread_qualify
159 159
 				WHERE c_id = ".$this->course_id." AND thread_id = ".$this->get_ref_id();
160
-		if (isset($stud_id)) {
161
-			$sql .= ' AND user_id = '.intval($stud_id);
162
-		}
160
+        if (isset($stud_id)) {
161
+            $sql .= ' AND user_id = '.intval($stud_id);
162
+        }
163 163
 
164
-		// order by id, that way the student's first attempt is accessed first
165
-		$sql .= ' ORDER BY qualify_time DESC';
164
+        // order by id, that way the student's first attempt is accessed first
165
+        $sql .= ' ORDER BY qualify_time DESC';
166 166
 
167
-		$scores = Database::query($sql);
167
+        $scores = Database::query($sql);
168 168
 
169
-		// for 1 student
170
-		if (isset($stud_id)) {
169
+        // for 1 student
170
+        if (isset($stud_id)) {
171 171
             if ($threadInfo['thread_peer_qualify'] == 0) {
172 172
                 // Classic way of calculate score
173 173
                 if ($data = Database::fetch_array($scores)) {
@@ -195,174 +195,174 @@  discard block
 block discarded – undo
195 195
                 }
196 196
                 return [$score/$counter, $assignment['thread_qualify_max']];
197 197
             }
198
-		} else {
199
-			// All students -> get average
200
-			$students = array();  // user list, needed to make sure we only
201
-			// take first attempts into account
202
-			$counter = 0;
203
-			$sum = 0;
204
-			$bestResult = 0;
205
-			$weight = 0;
206
-			$sumResult = 0;
207
-
208
-			while ($data = Database::fetch_array($scores)) {
209
-				if (!(array_key_exists($data['user_id'], $students))) {
210
-					if ($assignment['thread_qualify_max'] != 0) {
211
-						$students[$data['user_id']] = $data['qualify'];
212
-						$counter++;
213
-						$sum += $data['qualify'] / $assignment['thread_qualify_max'];
214
-						$sumResult += $data['qualify'];
215
-						if ($data['qualify'] > $bestResult) {
216
-							$bestResult = $data['qualify'];
217
-						}
218
-						$weight = $assignment['thread_qualify_max'];
219
-					}
220
-				}
221
-			}
222
-
223
-			if ($counter == 0) {
224
-				return null;
225
-			} else {
226
-				switch ($type) {
227
-					case 'best':
228
-						return array($bestResult, $weight);
229
-						break;
230
-					case 'average':
231
-						return array($sumResult/$counter, $weight);
232
-						break;
233
-					case 'ranking':
234
-						return AbstractLink::getCurrentUserRanking($stud_id, $students);
235
-						break;
236
-					default:
237
-						return array($sum, $counter);
238
-						break;
239
-				}
240
-			}
241
-		}
242
-	}
243
-
244
-	/**
245
-	 * Lazy load function to get the database table of the student publications
246
-	 */
247
-	private function get_forum_thread_table()
248
-	{
249
-		return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD);
250
-	}
251
-
252
-	public function needs_name_and_description()
253
-	{
254
-		return false;
255
-	}
256
-
257
-	public function needs_max()
258
-	{
259
-		return false;
260
-	}
261
-
262
-	public function needs_results()
263
-	{
264
-		return false;
265
-	}
198
+        } else {
199
+            // All students -> get average
200
+            $students = array();  // user list, needed to make sure we only
201
+            // take first attempts into account
202
+            $counter = 0;
203
+            $sum = 0;
204
+            $bestResult = 0;
205
+            $weight = 0;
206
+            $sumResult = 0;
207
+
208
+            while ($data = Database::fetch_array($scores)) {
209
+                if (!(array_key_exists($data['user_id'], $students))) {
210
+                    if ($assignment['thread_qualify_max'] != 0) {
211
+                        $students[$data['user_id']] = $data['qualify'];
212
+                        $counter++;
213
+                        $sum += $data['qualify'] / $assignment['thread_qualify_max'];
214
+                        $sumResult += $data['qualify'];
215
+                        if ($data['qualify'] > $bestResult) {
216
+                            $bestResult = $data['qualify'];
217
+                        }
218
+                        $weight = $assignment['thread_qualify_max'];
219
+                    }
220
+                }
221
+            }
222
+
223
+            if ($counter == 0) {
224
+                return null;
225
+            } else {
226
+                switch ($type) {
227
+                    case 'best':
228
+                        return array($bestResult, $weight);
229
+                        break;
230
+                    case 'average':
231
+                        return array($sumResult/$counter, $weight);
232
+                        break;
233
+                    case 'ranking':
234
+                        return AbstractLink::getCurrentUserRanking($stud_id, $students);
235
+                        break;
236
+                    default:
237
+                        return array($sum, $counter);
238
+                        break;
239
+                }
240
+            }
241
+        }
242
+    }
243
+
244
+    /**
245
+     * Lazy load function to get the database table of the student publications
246
+     */
247
+    private function get_forum_thread_table()
248
+    {
249
+        return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD);
250
+    }
251
+
252
+    public function needs_name_and_description()
253
+    {
254
+        return false;
255
+    }
256
+
257
+    public function needs_max()
258
+    {
259
+        return false;
260
+    }
261
+
262
+    public function needs_results()
263
+    {
264
+        return false;
265
+    }
266 266
 
267 267
     /**
268 268
      * @return string
269 269
      */
270
-	public function get_name()
271
-	{
272
-		$this->get_exercise_data();
273
-		$thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : '';
274
-		$thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : '';
275
-		if ( isset($thread_title_qualify) && $thread_title_qualify!="") {
276
-			return $this->exercise_data['thread_title_qualify'];
277
-		} else {
278
-			return $thread_title;
279
-		}
280
-	}
270
+    public function get_name()
271
+    {
272
+        $this->get_exercise_data();
273
+        $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : '';
274
+        $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : '';
275
+        if ( isset($thread_title_qualify) && $thread_title_qualify!="") {
276
+            return $this->exercise_data['thread_title_qualify'];
277
+        } else {
278
+            return $thread_title;
279
+        }
280
+    }
281 281
 
282 282
     /**
283 283
      * @return string
284 284
      */
285
-	public function get_description()
286
-	{
287
-		return '';//$this->exercise_data['description'];
288
-	}
289
-
290
-	/**
291
-	 * Check if this still links to an exercise
292
-	 */
293
-	public function is_valid_link()
294
-	{
295
-		$sql = 'SELECT count(id) from '.$this->get_forum_thread_table().'
285
+    public function get_description()
286
+    {
287
+        return '';//$this->exercise_data['description'];
288
+    }
289
+
290
+    /**
291
+     * Check if this still links to an exercise
292
+     */
293
+    public function is_valid_link()
294
+    {
295
+        $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().'
296 296
         		WHERE c_id = '.$this->course_id.' AND thread_id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().'';
297
-		$result = Database::query($sql);
298
-		$number = Database::fetch_row($result);
299
-		return ($number[0] != 0);
300
-	}
301
-
302
-	public function get_test_id()
303
-	{
304
-		return 'DEBUG:ID';
305
-	}
306
-
307
-	public function get_link()
308
-	{
309
-		//it was extracts the forum id
310
-		$sql = 'SELECT * FROM '.$this->get_forum_thread_table()."
297
+        $result = Database::query($sql);
298
+        $number = Database::fetch_row($result);
299
+        return ($number[0] != 0);
300
+    }
301
+
302
+    public function get_test_id()
303
+    {
304
+        return 'DEBUG:ID';
305
+    }
306
+
307
+    public function get_link()
308
+    {
309
+        //it was extracts the forum id
310
+        $sql = 'SELECT * FROM '.$this->get_forum_thread_table()."
311 311
     			WHERE c_id = '.$this->course_id.' AND thread_id = '".$this->get_ref_id()."' AND session_id = ".api_get_session_id()."";
312
-		$result = Database::query($sql);
313
-		$row    = Database::fetch_array($result,'ASSOC');
314
-		$forum_id=$row['forum_id'];
315
-
316
-		$url = api_get_path(WEB_PATH).'main/forum/viewthread.php?cidReq='.$this->get_course_code().'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id;
317
-		return $url;
318
-	}
319
-
320
-	private function get_exercise_data()
321
-	{
322
-		$session_id = api_get_session_id();
323
-		if ($session_id) {
324
-			$session_condition = 'session_id='.api_get_session_id();
325
-		} else {
326
-			$session_condition = '(session_id = 0 OR session_id IS NULL)';
327
-		}
328
-
329
-		if (!isset($this->exercise_data)) {
330
-			$sql = 'SELECT * FROM '.$this->get_forum_thread_table().'
312
+        $result = Database::query($sql);
313
+        $row    = Database::fetch_array($result,'ASSOC');
314
+        $forum_id=$row['forum_id'];
315
+
316
+        $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?cidReq='.$this->get_course_code().'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id;
317
+        return $url;
318
+    }
319
+
320
+    private function get_exercise_data()
321
+    {
322
+        $session_id = api_get_session_id();
323
+        if ($session_id) {
324
+            $session_condition = 'session_id='.api_get_session_id();
325
+        } else {
326
+            $session_condition = '(session_id = 0 OR session_id IS NULL)';
327
+        }
328
+
329
+        if (!isset($this->exercise_data)) {
330
+            $sql = 'SELECT * FROM '.$this->get_forum_thread_table().'
331 331
                     WHERE c_id = '.$this->course_id.' AND  thread_id = '.$this->get_ref_id().' AND '.$session_condition;
332
-			$query = Database::query($sql);
333
-			$this->exercise_data = Database::fetch_array($query);
334
-		}
335
-		return $this->exercise_data;
336
-	}
337
-
338
-	public function get_icon_name()
339
-	{
340
-		return 'forum';
341
-	}
342
-
343
-	function save_linked_data()
344
-	{
345
-		$weight = (float)$this->get_weight();
346
-		$ref_id = $this->get_ref_id();
347
-
348
-		if (!empty($ref_id)) {
349
-			$sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.'
332
+            $query = Database::query($sql);
333
+            $this->exercise_data = Database::fetch_array($query);
334
+        }
335
+        return $this->exercise_data;
336
+    }
337
+
338
+    public function get_icon_name()
339
+    {
340
+        return 'forum';
341
+    }
342
+
343
+    function save_linked_data()
344
+    {
345
+        $weight = (float)$this->get_weight();
346
+        $ref_id = $this->get_ref_id();
347
+
348
+        if (!empty($ref_id)) {
349
+            $sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.'
350 350
                     WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id;
351
-			Database::query($sql);
352
-		}
353
-	}
354
-
355
-	function delete_linked_data()
356
-	{
357
-		$ref_id = $this->get_ref_id();
358
-		if (!empty($ref_id)) {
359
-			//Cleans forum
360
-			$sql = 'UPDATE '.$this->get_forum_thread_table().' SET
351
+            Database::query($sql);
352
+        }
353
+    }
354
+
355
+    function delete_linked_data()
356
+    {
357
+        $ref_id = $this->get_ref_id();
358
+        if (!empty($ref_id)) {
359
+            //Cleans forum
360
+            $sql = 'UPDATE '.$this->get_forum_thread_table().' SET
361 361
 			        thread_qualify_max = 0,
362 362
 			        thread_weight = 0,
363 363
 			        thread_title_qualify = ""
364 364
                     WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id;
365
-			Database::query($sql);
366
-		}
367
-	}
365
+            Database::query($sql);
366
+        }
367
+    }
368 368
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 			die('Error in get_not_created_links() : course code not set');
85 85
 		}
86 86
 
87
-		$tbl_grade_links 	= Database :: get_course_table(TABLE_FORUM_THREAD);
88
-		$tbl_item_property	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
87
+		$tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD);
88
+		$tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
89 89
 		$session_id = api_get_session_id();
90 90
 
91 91
 		if ($session_id) {
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 		$result = Database::query($sql);
109 109
 
110 110
 		while ($data = Database::fetch_array($result)) {
111
-			if ( isset($data['thread_title_qualify']) and $data['thread_title_qualify']!=""){
112
-				$cats[] = array ($data['thread_id'], $data['thread_title_qualify']);
111
+			if (isset($data['thread_title_qualify']) and $data['thread_title_qualify'] != "") {
112
+				$cats[] = array($data['thread_id'], $data['thread_title_qualify']);
113 113
 			} else {
114
-				$cats[] = array ($data['thread_id'], $data['thread_title']);
114
+				$cats[] = array($data['thread_id'], $data['thread_title']);
115 115
 			}
116 116
 		}
117 117
 		$my_cats = isset($cats) ? $cats : null;
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
                 if (empty($counter) || $counter <= 2) {
194 194
                     return array(0, $assignment['thread_qualify_max']);
195 195
                 }
196
-                return [$score/$counter, $assignment['thread_qualify_max']];
196
+                return [$score / $counter, $assignment['thread_qualify_max']];
197 197
             }
198 198
 		} else {
199 199
 			// All students -> get average
200
-			$students = array();  // user list, needed to make sure we only
200
+			$students = array(); // user list, needed to make sure we only
201 201
 			// take first attempts into account
202 202
 			$counter = 0;
203 203
 			$sum = 0;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 						return array($bestResult, $weight);
229 229
 						break;
230 230
 					case 'average':
231
-						return array($sumResult/$counter, $weight);
231
+						return array($sumResult / $counter, $weight);
232 232
 						break;
233 233
 					case 'ranking':
234 234
 						return AbstractLink::getCurrentUserRanking($stud_id, $students);
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 	public function get_name()
271 271
 	{
272 272
 		$this->get_exercise_data();
273
-		$thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : '';
274
-		$thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : '';
275
-		if ( isset($thread_title_qualify) && $thread_title_qualify!="") {
273
+		$thread_title = isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : '';
274
+		$thread_title_qualify = isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : '';
275
+		if (isset($thread_title_qualify) && $thread_title_qualify != "") {
276 276
 			return $this->exercise_data['thread_title_qualify'];
277 277
 		} else {
278 278
 			return $thread_title;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      */
285 285
 	public function get_description()
286 286
 	{
287
-		return '';//$this->exercise_data['description'];
287
+		return ''; //$this->exercise_data['description'];
288 288
 	}
289 289
 
290 290
 	/**
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 		$sql = 'SELECT * FROM '.$this->get_forum_thread_table()."
311 311
     			WHERE c_id = '.$this->course_id.' AND thread_id = '".$this->get_ref_id()."' AND session_id = ".api_get_session_id()."";
312 312
 		$result = Database::query($sql);
313
-		$row    = Database::fetch_array($result,'ASSOC');
314
-		$forum_id=$row['forum_id'];
313
+		$row    = Database::fetch_array($result, 'ASSOC');
314
+		$forum_id = $row['forum_id'];
315 315
 
316 316
 		$url = api_get_path(WEB_PATH).'main/forum/viewthread.php?cidReq='.$this->get_course_code().'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id;
317 317
 		return $url;
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 
343 343
 	function save_linked_data()
344 344
 	{
345
-		$weight = (float)$this->get_weight();
345
+		$weight = (float) $this->get_weight();
346 346
 		$ref_id = $this->get_ref_id();
347 347
 
348 348
 		if (!empty($ref_id)) {
Please login to merge, or discard this patch.
main/gradebook/lib/be/learnpathlink.class.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@
 block discarded – undo
95 95
 
96 96
 	/**
97 97
 	 * Get the progress of this learnpath. Only the last attempt are taken into account.
98
-	 * @param $stud_id student id (default: all students who have results - then the average is returned)
98
+	 * @param integer $stud_id student id (default: all students who have results - then the average is returned)
99 99
 	 * @return	array (score, max) if student is given
100 100
 	 * 			array (sum of scores, number of scores) otherwise
101 101
 	 * 			or null if no scores available
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,8 +29,9 @@  discard block
 block discarded – undo
29 29
 	public function get_not_created_links()
30 30
 	{
31 31
 		return false;
32
-		if (empty($this->course_code))
33
-			die('Error in get_not_created_links() : course code not set');
32
+		if (empty($this->course_code)) {
33
+					die('Error in get_not_created_links() : course code not set');
34
+		}
34 35
 
35 36
 		$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
36 37
 
@@ -57,8 +58,9 @@  discard block
 block discarded – undo
57 58
 	 */
58 59
 	public function get_all_links()
59 60
 	{
60
-		if (empty($this->course_code))
61
-			die('Error in get_not_created_links() : course code not set');
61
+		if (empty($this->course_code)) {
62
+					die('Error in get_not_created_links() : course code not set');
63
+		}
62 64
 
63 65
 		$session_id = api_get_session_id();
64 66
 		if (empty($session_id)) {
@@ -111,8 +113,9 @@  discard block
 block discarded – undo
111 113
                     lp_id = ".$this->get_ref_id()." AND
112 114
                     session_id = $session_id ";
113 115
 
114
-		if (isset($stud_id))
115
-			$sql .= ' AND user_id = '.intval($stud_id);
116
+		if (isset($stud_id)) {
117
+					$sql .= ' AND user_id = '.intval($stud_id);
118
+		}
116 119
 
117 120
 		// order by id, that way the student's first attempt is accessed first
118 121
 		$sql .= ' ORDER BY view_count DESC';
@@ -122,8 +125,9 @@  discard block
 block discarded – undo
122 125
 		if (isset($stud_id)) {
123 126
 			if ($data = Database::fetch_array($scores)) {
124 127
 				return array ($data['progress'], 100);
125
-			} else
126
-				return null;
128
+			} else {
129
+							return null;
130
+			}
127 131
 		} else {
128 132
 			// all students -> get average
129 133
 			$students = array();  // user list, needed to make sure we only
Please login to merge, or discard this patch.
Indentation   +242 added lines, -242 removed lines patch added patch discarded remove patch
@@ -9,260 +9,260 @@
 block discarded – undo
9 9
  */
10 10
 class LearnpathLink extends AbstractLink
11 11
 {
12
-	private $course_info = null;
13
-	private $learnpath_table = null;
14
-	private $learnpath_data = null;
15
-
16
-	/**
17
-	 * Constructor
18
-	 */
19
-	public function __construct()
20
-	{
21
-		parent::__construct();
22
-		$this->set_type(LINK_LEARNPATH);
23
-	}
24
-
25
-	/**
26
-	 * Generate an array of learnpaths that a teacher hasn't created a link for.
27
-	 * @return array 2-dimensional array - every element contains 2 subelements (id, name)
28
-	 */
29
-	public function get_not_created_links()
30
-	{
31
-		return false;
32
-		if (empty($this->course_code))
33
-			die('Error in get_not_created_links() : course code not set');
34
-
35
-		$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
36
-
37
-		$sql = 'SELECT id, name from '.$this->get_learnpath_table().' lp
12
+    private $course_info = null;
13
+    private $learnpath_table = null;
14
+    private $learnpath_data = null;
15
+
16
+    /**
17
+     * Constructor
18
+     */
19
+    public function __construct()
20
+    {
21
+        parent::__construct();
22
+        $this->set_type(LINK_LEARNPATH);
23
+    }
24
+
25
+    /**
26
+     * Generate an array of learnpaths that a teacher hasn't created a link for.
27
+     * @return array 2-dimensional array - every element contains 2 subelements (id, name)
28
+     */
29
+    public function get_not_created_links()
30
+    {
31
+        return false;
32
+        if (empty($this->course_code))
33
+            die('Error in get_not_created_links() : course code not set');
34
+
35
+        $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
36
+
37
+        $sql = 'SELECT id, name from '.$this->get_learnpath_table().' lp
38 38
 				WHERE c_id = '.$this->course_id.' AND id NOT IN '
39
-			.' (SELECT ref_id FROM '.$tbl_grade_links
40
-			.' WHERE type = '.LINK_LEARNPATH
41
-			." AND c_id = '" . intval($this->course_id) . "'"
42
-			.') AND lp.session_id='.api_get_session_id().'';
43
-
44
-		$result = Database::query($sql);
45
-
46
-		$cats=array();
47
-		while ($data=Database::fetch_array($result)) {
48
-			$cats[] = array ($data['id'], $data['name']);
49
-		}
50
-
51
-		return $cats;
52
-	}
53
-
54
-	/**
55
-	 * Generate an array of all learnpaths available.
56
-	 * @return array 2-dimensional array - every element contains 2 subelements (id, name)
57
-	 */
58
-	public function get_all_links()
59
-	{
60
-		if (empty($this->course_code))
61
-			die('Error in get_not_created_links() : course code not set');
62
-
63
-		$session_id = api_get_session_id();
64
-		if (empty($session_id)) {
65
-			$session_condition = api_get_session_condition(0, true);
66
-		} else {
67
-			$session_condition = api_get_session_condition($session_id, true, true);
68
-		}
69
-
70
-		$sql = 'SELECT id, name FROM '.$this->get_learnpath_table().'
39
+            .' (SELECT ref_id FROM '.$tbl_grade_links
40
+            .' WHERE type = '.LINK_LEARNPATH
41
+            ." AND c_id = '" . intval($this->course_id) . "'"
42
+            .') AND lp.session_id='.api_get_session_id().'';
43
+
44
+        $result = Database::query($sql);
45
+
46
+        $cats=array();
47
+        while ($data=Database::fetch_array($result)) {
48
+            $cats[] = array ($data['id'], $data['name']);
49
+        }
50
+
51
+        return $cats;
52
+    }
53
+
54
+    /**
55
+     * Generate an array of all learnpaths available.
56
+     * @return array 2-dimensional array - every element contains 2 subelements (id, name)
57
+     */
58
+    public function get_all_links()
59
+    {
60
+        if (empty($this->course_code))
61
+            die('Error in get_not_created_links() : course code not set');
62
+
63
+        $session_id = api_get_session_id();
64
+        if (empty($session_id)) {
65
+            $session_condition = api_get_session_condition(0, true);
66
+        } else {
67
+            $session_condition = api_get_session_condition($session_id, true, true);
68
+        }
69
+
70
+        $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().'
71 71
                 WHERE c_id = '.$this->course_id.' '.$session_condition.' ';
72
-		$result = Database::query($sql);
72
+        $result = Database::query($sql);
73 73
 
74
-		$cats = array();
75
-		while ($data=Database::fetch_array($result)) {
76
-			$cats[] = array ($data['id'], $data['name']);
77
-		}
74
+        $cats = array();
75
+        while ($data=Database::fetch_array($result)) {
76
+            $cats[] = array ($data['id'], $data['name']);
77
+        }
78 78
 
79
-		return $cats;
80
-	}
79
+        return $cats;
80
+    }
81 81
 
82 82
 
83
-	/**
84
-	 * Has anyone used this learnpath yet ?
85
-	 */
86
-	public function has_results()
87
-	{
88
-		$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
89
-		$sql = "SELECT count(id) AS number FROM $tbl_stats
83
+    /**
84
+     * Has anyone used this learnpath yet ?
85
+     */
86
+    public function has_results()
87
+    {
88
+        $tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
89
+        $sql = "SELECT count(id) AS number FROM $tbl_stats
90 90
 				WHERE c_id = ".$this->course_id." AND lp_id = ".$this->get_ref_id();
91
-		$result = Database::query($sql);
92
-		$number = Database::fetch_array($result,'NUM');
93
-		return ($number[0] != 0);
94
-	}
95
-
96
-	/**
97
-	 * Get the progress of this learnpath. Only the last attempt are taken into account.
98
-	 * @param $stud_id student id (default: all students who have results - then the average is returned)
99
-	 * @return	array (score, max) if student is given
100
-	 * 			array (sum of scores, number of scores) otherwise
101
-	 * 			or null if no scores available
102
-	 */
103
-	public function calc_score($stud_id = null, $type = null)
104
-	{
105
-		$tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
106
-		$session_id = api_get_session_id();
107
-
108
-		$sql = "SELECT * FROM $tbl_stats
91
+        $result = Database::query($sql);
92
+        $number = Database::fetch_array($result,'NUM');
93
+        return ($number[0] != 0);
94
+    }
95
+
96
+    /**
97
+     * Get the progress of this learnpath. Only the last attempt are taken into account.
98
+     * @param $stud_id student id (default: all students who have results - then the average is returned)
99
+     * @return	array (score, max) if student is given
100
+     * 			array (sum of scores, number of scores) otherwise
101
+     * 			or null if no scores available
102
+     */
103
+    public function calc_score($stud_id = null, $type = null)
104
+    {
105
+        $tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
106
+        $session_id = api_get_session_id();
107
+
108
+        $sql = "SELECT * FROM $tbl_stats
109 109
                 WHERE
110 110
                 	c_id = ".$this->course_id." AND
111 111
                     lp_id = ".$this->get_ref_id()." AND
112 112
                     session_id = $session_id ";
113 113
 
114
-		if (isset($stud_id))
115
-			$sql .= ' AND user_id = '.intval($stud_id);
116
-
117
-		// order by id, that way the student's first attempt is accessed first
118
-		$sql .= ' ORDER BY view_count DESC';
119
-
120
-		$scores = Database::query($sql);
121
-		// for 1 student
122
-		if (isset($stud_id)) {
123
-			if ($data = Database::fetch_array($scores)) {
124
-				return array ($data['progress'], 100);
125
-			} else
126
-				return null;
127
-		} else {
128
-			// all students -> get average
129
-			$students = array();  // user list, needed to make sure we only
130
-			// take first attempts into account
131
-			$rescount = 0;
132
-			$sum = 0;
133
-			$bestResult = 0;
134
-			$sumResult = 0;
135
-			while ($data = Database::fetch_array($scores)) {
136
-				if (!(array_key_exists($data['user_id'], $students))) {
137
-					$students[$data['user_id']] = $data['progress'];
138
-					$rescount++;
139
-					$sum += $data['progress'] / 100;
140
-					$sumResult += $data['progress'];
141
-
142
-					if ($data['progress'] > $bestResult) {
143
-						$bestResult = $data['progress'];
144
-					}
145
-				}
146
-			}
147
-
148
-			if ($rescount == 0) {
149
-				return null;
150
-			} else {
151
-
152
-				switch ($type) {
153
-					case 'best':
154
-						return array($bestResult, 100);
155
-						break;
156
-					case 'average':
157
-						return array($sumResult/$rescount, 100);
158
-						break;
159
-					case 'ranking':
160
-						return AbstractLink::getCurrentUserRanking($stud_id, $students);
161
-						break;
162
-					default:
163
-						return array($sum, $rescount);
164
-						break;
165
-				}
166
-			}
167
-		}
168
-	}
169
-
170
-	/**
171
-	 * Get URL where to go to if the user clicks on the link.
172
-	 */
173
-	public function get_link()
174
-	{
175
-		$url = api_get_path(WEB_PATH).'main/newscorm/lp_controller.php?cidReq='.$this->get_course_code().'&gradebook=view';
176
-		$session_id = api_get_session_id();
177
-		if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) {
178
-			$url .= '&action=view&session_id='.$session_id.'&lp_id='.$this->get_ref_id();
179
-		} else {
180
-			$url .= '&action=build&session_id='.$session_id.'&lp_id='.$this->get_ref_id();
181
-		}
182
-		return $url;
183
-	}
184
-
185
-	/**
186
-	 * Get name to display: same as learnpath title
187
-	 */
188
-	public function get_name()
189
-	{
190
-		$data = $this->get_learnpath_data();
191
-		return $data['name'];
192
-	}
193
-
194
-	/**
195
-	 * Get description to display: same as learnpath description
196
-	 */
197
-	public function get_description()
198
-	{
199
-		$data = $this->get_learnpath_data();
200
-		return $data['description'];
201
-	}
202
-
203
-	/**
204
-	 * Check if this still links to a learnpath
205
-	 */
206
-	public function is_valid_link() {
207
-		$sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().'
114
+        if (isset($stud_id))
115
+            $sql .= ' AND user_id = '.intval($stud_id);
116
+
117
+        // order by id, that way the student's first attempt is accessed first
118
+        $sql .= ' ORDER BY view_count DESC';
119
+
120
+        $scores = Database::query($sql);
121
+        // for 1 student
122
+        if (isset($stud_id)) {
123
+            if ($data = Database::fetch_array($scores)) {
124
+                return array ($data['progress'], 100);
125
+            } else
126
+                return null;
127
+        } else {
128
+            // all students -> get average
129
+            $students = array();  // user list, needed to make sure we only
130
+            // take first attempts into account
131
+            $rescount = 0;
132
+            $sum = 0;
133
+            $bestResult = 0;
134
+            $sumResult = 0;
135
+            while ($data = Database::fetch_array($scores)) {
136
+                if (!(array_key_exists($data['user_id'], $students))) {
137
+                    $students[$data['user_id']] = $data['progress'];
138
+                    $rescount++;
139
+                    $sum += $data['progress'] / 100;
140
+                    $sumResult += $data['progress'];
141
+
142
+                    if ($data['progress'] > $bestResult) {
143
+                        $bestResult = $data['progress'];
144
+                    }
145
+                }
146
+            }
147
+
148
+            if ($rescount == 0) {
149
+                return null;
150
+            } else {
151
+
152
+                switch ($type) {
153
+                    case 'best':
154
+                        return array($bestResult, 100);
155
+                        break;
156
+                    case 'average':
157
+                        return array($sumResult/$rescount, 100);
158
+                        break;
159
+                    case 'ranking':
160
+                        return AbstractLink::getCurrentUserRanking($stud_id, $students);
161
+                        break;
162
+                    default:
163
+                        return array($sum, $rescount);
164
+                        break;
165
+                }
166
+            }
167
+        }
168
+    }
169
+
170
+    /**
171
+     * Get URL where to go to if the user clicks on the link.
172
+     */
173
+    public function get_link()
174
+    {
175
+        $url = api_get_path(WEB_PATH).'main/newscorm/lp_controller.php?cidReq='.$this->get_course_code().'&gradebook=view';
176
+        $session_id = api_get_session_id();
177
+        if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) {
178
+            $url .= '&action=view&session_id='.$session_id.'&lp_id='.$this->get_ref_id();
179
+        } else {
180
+            $url .= '&action=build&session_id='.$session_id.'&lp_id='.$this->get_ref_id();
181
+        }
182
+        return $url;
183
+    }
184
+
185
+    /**
186
+     * Get name to display: same as learnpath title
187
+     */
188
+    public function get_name()
189
+    {
190
+        $data = $this->get_learnpath_data();
191
+        return $data['name'];
192
+    }
193
+
194
+    /**
195
+     * Get description to display: same as learnpath description
196
+     */
197
+    public function get_description()
198
+    {
199
+        $data = $this->get_learnpath_data();
200
+        return $data['description'];
201
+    }
202
+
203
+    /**
204
+     * Check if this still links to a learnpath
205
+     */
206
+    public function is_valid_link() {
207
+        $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().'
208 208
                 WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' ';
209
-		$result = Database::query($sql);
210
-		$number = Database::fetch_row($result,'NUM');
211
-		return ($number[0] != 0);
212
-	}
213
-
214
-	public function get_type_name()
215
-	{
216
-		return get_lang('LearningPaths');
217
-	}
218
-
219
-	public function needs_name_and_description()
220
-	{
221
-		return false;
222
-	}
223
-
224
-	public function needs_max()
225
-	{
226
-		return false;
227
-	}
228
-
229
-	public function needs_results()
230
-	{
231
-		return false;
232
-	}
233
-
234
-	public function is_allowed_to_change_name()
235
-	{
236
-		return false;
237
-	}
238
-
239
-	// INTERNAL FUNCTIONS
240
-
241
-	/**
242
-	 * Lazy load function to get the database table of the learnpath
243
-	 */
244
-	private function get_learnpath_table()
245
-	{
246
-		$this->learnpath_table = Database :: get_course_table(TABLE_LP_MAIN);
247
-		return $this->learnpath_table;
248
-	}
249
-
250
-	/**
251
-	 * Lazy load function to get the database contents of this learnpath
252
-	 */
253
-	private function get_learnpath_data()
254
-	{
255
-		if (!isset($this->learnpath_data)) {
256
-			$sql = 'SELECT * FROM '.$this->get_learnpath_table().'
209
+        $result = Database::query($sql);
210
+        $number = Database::fetch_row($result,'NUM');
211
+        return ($number[0] != 0);
212
+    }
213
+
214
+    public function get_type_name()
215
+    {
216
+        return get_lang('LearningPaths');
217
+    }
218
+
219
+    public function needs_name_and_description()
220
+    {
221
+        return false;
222
+    }
223
+
224
+    public function needs_max()
225
+    {
226
+        return false;
227
+    }
228
+
229
+    public function needs_results()
230
+    {
231
+        return false;
232
+    }
233
+
234
+    public function is_allowed_to_change_name()
235
+    {
236
+        return false;
237
+    }
238
+
239
+    // INTERNAL FUNCTIONS
240
+
241
+    /**
242
+     * Lazy load function to get the database table of the learnpath
243
+     */
244
+    private function get_learnpath_table()
245
+    {
246
+        $this->learnpath_table = Database :: get_course_table(TABLE_LP_MAIN);
247
+        return $this->learnpath_table;
248
+    }
249
+
250
+    /**
251
+     * Lazy load function to get the database contents of this learnpath
252
+     */
253
+    private function get_learnpath_data()
254
+    {
255
+        if (!isset($this->learnpath_data)) {
256
+            $sql = 'SELECT * FROM '.$this->get_learnpath_table().'
257 257
                     WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' ';
258
-			$result = Database::query($sql);
259
-			$this->learnpath_data = Database::fetch_array($result);
260
-		}
261
-		return $this->learnpath_data;
262
-	}
263
-
264
-	public function get_icon_name()
265
-	{
266
-		return 'learnpath';
267
-	}
258
+            $result = Database::query($sql);
259
+            $this->learnpath_data = Database::fetch_array($result);
260
+        }
261
+        return $this->learnpath_data;
262
+    }
263
+
264
+    public function get_icon_name()
265
+    {
266
+        return 'learnpath';
267
+    }
268 268
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 				WHERE c_id = '.$this->course_id.' AND id NOT IN '
39 39
 			.' (SELECT ref_id FROM '.$tbl_grade_links
40 40
 			.' WHERE type = '.LINK_LEARNPATH
41
-			." AND c_id = '" . intval($this->course_id) . "'"
41
+			." AND c_id = '".intval($this->course_id)."'"
42 42
 			.') AND lp.session_id='.api_get_session_id().'';
43 43
 
44 44
 		$result = Database::query($sql);
45 45
 
46
-		$cats=array();
47
-		while ($data=Database::fetch_array($result)) {
48
-			$cats[] = array ($data['id'], $data['name']);
46
+		$cats = array();
47
+		while ($data = Database::fetch_array($result)) {
48
+			$cats[] = array($data['id'], $data['name']);
49 49
 		}
50 50
 
51 51
 		return $cats;
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 		$result = Database::query($sql);
73 73
 
74 74
 		$cats = array();
75
-		while ($data=Database::fetch_array($result)) {
76
-			$cats[] = array ($data['id'], $data['name']);
75
+		while ($data = Database::fetch_array($result)) {
76
+			$cats[] = array($data['id'], $data['name']);
77 77
 		}
78 78
 
79 79
 		return $cats;
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$sql = "SELECT count(id) AS number FROM $tbl_stats
90 90
 				WHERE c_id = ".$this->course_id." AND lp_id = ".$this->get_ref_id();
91 91
 		$result = Database::query($sql);
92
-		$number = Database::fetch_array($result,'NUM');
92
+		$number = Database::fetch_array($result, 'NUM');
93 93
 		return ($number[0] != 0);
94 94
 	}
95 95
 
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 		// for 1 student
122 122
 		if (isset($stud_id)) {
123 123
 			if ($data = Database::fetch_array($scores)) {
124
-				return array ($data['progress'], 100);
124
+				return array($data['progress'], 100);
125 125
 			} else
126 126
 				return null;
127 127
 		} else {
128 128
 			// all students -> get average
129
-			$students = array();  // user list, needed to make sure we only
129
+			$students = array(); // user list, needed to make sure we only
130 130
 			// take first attempts into account
131 131
 			$rescount = 0;
132 132
 			$sum = 0;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 						return array($bestResult, 100);
155 155
 						break;
156 156
 					case 'average':
157
-						return array($sumResult/$rescount, 100);
157
+						return array($sumResult / $rescount, 100);
158 158
 						break;
159 159
 					case 'ranking':
160 160
 						return AbstractLink::getCurrentUserRanking($stud_id, $students);
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		$sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().'
208 208
                 WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' ';
209 209
 		$result = Database::query($sql);
210
-		$number = Database::fetch_row($result,'NUM');
210
+		$number = Database::fetch_row($result, 'NUM');
211 211
 		return ($number[0] != 0);
212 212
 	}
213 213
 
Please login to merge, or discard this patch.
main/gradebook/lib/be/result.class.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -59,6 +59,9 @@
 block discarded – undo
59 59
         $this->evaluation = $evaluation_id;
60 60
     }
61 61
 
62
+    /**
63
+     * @param string $creation_date
64
+     */
62 65
     public function set_date($creation_date)
63 66
     {
64 67
         $this->created_at = $creation_date;
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -90,23 +90,23 @@  discard block
 block discarded – undo
90 90
         if (is_null($id) && is_null($user_id) && !is_null($evaluation_id)) {
91 91
             // Verified_if_exist_evaluation
92 92
             $sql = 'SELECT COUNT(*) AS count
93
-                    FROM ' . $tbl_grade_results . '
94
-                    WHERE evaluation_id="' . Database::escape_string($evaluation_id) . '";';
93
+                    FROM ' . $tbl_grade_results.'
94
+                    WHERE evaluation_id="' . Database::escape_string($evaluation_id).'";';
95 95
             $result = Database::query($sql);
96 96
             $existEvaluation = Database::result($result, 0, 0);
97 97
 
98 98
             if ($existEvaluation != 0) {
99 99
                 if ($sessionId) {
100 100
                     $sql = 'SELECT c_id, user_id as user_id, status
101
-                            FROM ' . $tbl_session_rel_course_user . '
101
+                            FROM ' . $tbl_session_rel_course_user.'
102 102
 							WHERE
103 103
 							    status= 0 AND
104
-							    c_id = "' . api_get_course_int_id() . '" AND
104
+							    c_id = "' . api_get_course_int_id().'" AND
105 105
 							    session_id = ' . $sessionId;
106 106
                 } else {
107 107
                     $sql = 'SELECT c_id, user_id, status
108
-                            FROM ' . $tbl_course_rel_course . '
109
-                            WHERE status ="' . STUDENT . '" AND c_id = "' . api_get_course_int_id() . '" ';
108
+                            FROM ' . $tbl_course_rel_course.'
109
+                            WHERE status ="' . STUDENT.'" AND c_id = "'.api_get_course_int_id().'" ';
110 110
                 }
111 111
 
112 112
                 $res_course_rel_user = Database::query($sql);
@@ -116,15 +116,15 @@  discard block
 block discarded – undo
116 116
                 $current_date = api_get_utc_datetime();
117 117
                 for ($i = 0; $i < count($list_user_course_list); $i++) {
118 118
                     $sql_verified = 'SELECT COUNT(*) AS count
119
-                                    FROM ' . $tbl_grade_results . '
119
+                                    FROM ' . $tbl_grade_results.'
120 120
                                     WHERE
121
-                                        user_id="' . intval($list_user_course_list[$i]['user_id']) . '" AND
122
-                                        evaluation_id="' . intval($evaluation_id) . '";';
121
+                                        user_id="' . intval($list_user_course_list[$i]['user_id']).'" AND
122
+                                        evaluation_id="' . intval($evaluation_id).'";';
123 123
                     $res_verified = Database::query($sql_verified);
124 124
                     $info_verified = Database::result($res_verified, 0, 0);
125 125
                     if ($info_verified == 0) {
126
-                        $sql_insert = 'INSERT INTO ' . $tbl_grade_results . '(user_id,evaluation_id,created_at,score)
127
-									   VALUES ("' . intval($list_user_course_list[$i]['user_id']) . '","' . intval($evaluation_id) . '","' . $current_date . '",0);';
126
+                        $sql_insert = 'INSERT INTO '.$tbl_grade_results.'(user_id,evaluation_id,created_at,score)
127
+									   VALUES ("' . intval($list_user_course_list[$i]['user_id']).'","'.intval($evaluation_id).'","'.$current_date.'",0);';
128 128
                         Database::query($sql_insert);
129 129
                     }
130 130
                 }
@@ -148,16 +148,16 @@  discard block
 block discarded – undo
148 148
 
149 149
         $paramcount = 0;
150 150
         if (!empty($id)) {
151
-            $sql.= ' WHERE gr.id = ' . intval($id);
152
-            $paramcount ++;
151
+            $sql .= ' WHERE gr.id = '.intval($id);
152
+            $paramcount++;
153 153
         }
154 154
         if (!empty($user_id)) {
155 155
             if ($paramcount != 0)
156 156
                 $sql .= ' AND';
157 157
             else
158 158
                 $sql .= ' WHERE';
159
-            $sql .= ' gr.user_id = ' . intval($user_id);
160
-            $paramcount ++;
159
+            $sql .= ' gr.user_id = '.intval($user_id);
160
+            $paramcount++;
161 161
         }
162 162
         if (!empty($evaluation_id)) {
163 163
             if ($paramcount != 0) {
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
             } else {
166 166
                 $sql .= ' WHERE';
167 167
             }
168
-            $sql .= ' gr.evaluation_id = ' . intval($evaluation_id);
169
-            $paramcount ++;
168
+            $sql .= ' gr.evaluation_id = '.intval($evaluation_id);
169
+            $paramcount++;
170 170
         }
171 171
         $sql .= ' ORDER BY u.lastname, u.firstname';
172 172
         $result = Database::query($sql);
@@ -191,17 +191,17 @@  discard block
 block discarded – undo
191 191
     {
192 192
         if (isset($this->user_id) && isset($this->evaluation)) {
193 193
             $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
194
-            $sql = "INSERT INTO " . $tbl_grade_results
194
+            $sql = "INSERT INTO ".$tbl_grade_results
195 195
                 . " (user_id, evaluation_id,
196 196
 					created_at";
197 197
             if (isset($this->score)) {
198 198
                 $sql .= ",score";
199 199
             }
200 200
             $sql .= ") VALUES
201
-					(" . (int) $this->get_user_id() . ", " . (int) $this->get_evaluation_id()
202
-                . ", '" . $this->get_date() . "' ";
201
+					(" . (int) $this->get_user_id().", ".(int) $this->get_evaluation_id()
202
+                . ", '".$this->get_date()."' ";
203 203
             if (isset($this->score)) {
204
-                $sql .= ", " . $this->get_score();
204
+                $sql .= ", ".$this->get_score();
205 205
             }
206 206
             $sql .= ")";
207 207
             Database::query($sql);
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
             $arr_result = $result->load(null, $userid, $evaluationid);
223 223
             $arr = get_object_vars($arr_result[0]);
224 224
 
225
-            $sql = 'INSERT INTO ' . $tbl_grade_results_log
225
+            $sql = 'INSERT INTO '.$tbl_grade_results_log
226 226
                 . ' (id_result,user_id, evaluation_id,created_at';
227 227
             if (isset($arr['score'])) {
228 228
                 $sql .= ',score';
229 229
             }
230 230
             $sql .= ') VALUES
231
-					(' . (int) $arr['id'] . ',' . (int) $arr['user_id'] . ', ' . (int) $arr['evaluation']
232
-                . ", '" . api_get_utc_datetime() . "'";
231
+					(' . (int) $arr['id'].','.(int) $arr['user_id'].', '.(int) $arr['evaluation']
232
+                . ", '".api_get_utc_datetime()."'";
233 233
             if (isset($arr['score'])) {
234
-                $sql .= ', ' . $arr['score'];
234
+                $sql .= ', '.$arr['score'];
235 235
             }
236 236
             $sql .= ')';
237 237
 
@@ -247,16 +247,16 @@  discard block
 block discarded – undo
247 247
     public function save()
248 248
     {
249 249
         $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
250
-        $sql = 'UPDATE ' . $tbl_grade_results . '
250
+        $sql = 'UPDATE '.$tbl_grade_results.'
251 251
                 SET user_id = ' . $this->get_user_id()
252
-            . ', evaluation_id = ' . $this->get_evaluation_id()
252
+            . ', evaluation_id = '.$this->get_evaluation_id()
253 253
             . ', score = ';
254 254
         if (isset($this->score)) {
255 255
             $sql .= $this->get_score();
256 256
         } else {
257 257
             $sql .= 'null';
258 258
         }
259
-        $sql .= ' WHERE id = ' . $this->id;
259
+        $sql .= ' WHERE id = '.$this->id;
260 260
         // no need to update creation date
261 261
         Database::query($sql);
262 262
     }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
     public function delete()
268 268
     {
269 269
         $tbl_grade_results = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
270
-        $sql = 'DELETE FROM ' . $tbl_grade_results . ' WHERE id = ' . $this->id;
270
+        $sql = 'DELETE FROM '.$tbl_grade_results.' WHERE id = '.$this->id;
271 271
         Database::query($sql);
272 272
     }
273 273
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -152,10 +152,11 @@
 block discarded – undo
152 152
             $paramcount ++;
153 153
         }
154 154
         if (!empty($user_id)) {
155
-            if ($paramcount != 0)
156
-                $sql .= ' AND';
157
-            else
158
-                $sql .= ' WHERE';
155
+            if ($paramcount != 0) {
156
+                            $sql .= ' AND';
157
+            } else {
158
+                            $sql .= ' WHERE';
159
+            }
159 160
             $sql .= ' gr.user_id = ' . intval($user_id);
160 161
             $paramcount ++;
161 162
         }
Please login to merge, or discard this patch.