Completed
Push — 1.11.x ( d84d27...922b6f )
by José
30:17
created
main/gradebook/lib/fe/catform.class.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
      */
53 53
     protected function build_move_form()
54 54
     {
55
-        $renderer =& $this->defaultRenderer();
55
+        $renderer = & $this->defaultRenderer();
56 56
         $renderer->setCustomElementTemplate('<span>{element}</span> ');
57 57
         $this->addElement(
58 58
             'static',
59 59
             null,
60 60
             null,
61
-            '"' . $this->category_object->get_name() . '" '
61
+            '"'.$this->category_object->get_name().'" '
62 62
         );
63
-        $this->addElement('static', null, null, get_lang('MoveTo') . ' : ');
63
+        $this->addElement('static', null, null, get_lang('MoveTo').' : ');
64 64
         $select = $this->addElement('select', 'move_cat', null, null);
65 65
         $line = null;
66 66
         foreach ($this->category_object->get_target_categories() as $cat) {
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
                 $line .= '--';
69 69
             }
70 70
             if ($cat[0] != $this->category_object->get_parent_id()) {
71
-                $select->addoption($line . ' ' . $cat[1], $cat[0]);
71
+                $select->addoption($line.' '.$cat[1], $cat[0]);
72 72
             } else {
73
-                $select->addoption($line . ' ' . $cat[1], $cat[0], 'disabled');
73
+                $select->addoption($line.' '.$cat[1], $cat[0], 'disabled');
74 74
             }
75 75
             $line = '';
76 76
         }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         $grade_model_id = $this->category_object->get_grade_model_id();
154 154
 
155 155
         if (empty($links)) {
156
-            $grade_model_id    = 0;
156
+            $grade_model_id = 0;
157 157
         }
158 158
 
159 159
         $category_name = $this->category_object->get_name();
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
                     [
243 243
                         'id' => 'skills',
244 244
                         'multiple' => 'multiple',
245
-                        'url' => api_get_path(WEB_AJAX_PATH) . 'skill.ajax.php?a=search_skills'
245
+                        'url' => api_get_path(WEB_AJAX_PATH).'skill.ajax.php?a=search_skills'
246 246
                     ]
247 247
                 );
248 248
 
@@ -400,14 +400,14 @@  discard block
 block discarded – undo
400 400
         //only return courses that are not yet created by the teacher
401 401
 
402 402
         foreach ($coursecat as $row) {
403
-            $select->addoption($row[1],$row[0]);
403
+            $select->addoption($row[1], $row[0]);
404 404
         }
405 405
         $this->setDefaults(array(
406 406
             'hid_user_id' => $this->category_object->get_user_id(),
407 407
             'hid_parent_id' => $this->category_object->get_parent_id()
408 408
         ));
409
-        $this->addElement('hidden','hid_user_id');
410
-        $this->addElement('hidden','hid_parent_id');
409
+        $this->addElement('hidden', 'hid_user_id');
410
+        $this->addElement('hidden', 'hid_parent_id');
411 411
         $this->addElement('submit', null, get_lang('Ok'));
412 412
     }
413 413
 
Please login to merge, or discard this patch.
main/gradebook/lib/be/gradebookitem.class.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@
 block discarded – undo
8 8
  */
9 9
 interface GradebookItem
10 10
 {
11
-	public function get_item_type();
12
-	public function get_id();
13
-	public function get_name();
14
-	public function get_description();
15
-	public function get_course_code();
16
-	public function get_weight();
17
-	public function get_date();
18
-	public function is_visible();
19
-	public function get_icon_name();
20
-	public function getStudentList();
21
-	public function setStudentList($list);
22
-	public function calc_score($stud_id = null, $type = null);
11
+    public function get_item_type();
12
+    public function get_id();
13
+    public function get_name();
14
+    public function get_description();
15
+    public function get_course_code();
16
+    public function get_weight();
17
+    public function get_date();
18
+    public function is_visible();
19
+    public function get_icon_name();
20
+    public function getStudentList();
21
+    public function setStudentList($list);
22
+    public function calc_score($stud_id = null, $type = null);
23 23
 }
Please login to merge, or discard this patch.
main/gradebook/lib/be/category.class.php 4 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1179,7 +1179,7 @@
 block discarded – undo
1179 1179
                             cu.status = '.COURSEMANAGER.'
1180 1180
                     )';
1181 1181
             }
1182
-        }elseif (api_is_platform_admin()) {
1182
+        } elseif (api_is_platform_admin()) {
1183 1183
             if (isset($session_id) && $session_id!=0) {
1184 1184
                 $sql.=' AND session_id='.intval($session_id);
1185 1185
             } else {
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1545,7 +1545,7 @@
 block discarded – undo
1545 1545
      * Retrieve all categories inside a course independent category
1546 1546
      * that should be visible to a student.
1547 1547
      * @param integer $cat_id parent category
1548
-     * @param $stud_id student id
1548
+     * @param integer $stud_id student id
1549 1549
      * @param $cats optional: if defined, the categories will be added to this array
1550 1550
      */
1551 1551
     public function get_independent_categories_with_result_for_student($cat_id, $stud_id, $cats = array())
Please login to merge, or discard this patch.
Indentation   -2 removed lines patch added patch discarded remove patch
@@ -1583,7 +1583,6 @@  discard block
 block discarded – undo
1583 1583
      * @param string $course_code Course code (optional)
1584 1584
      * @param int    $session_id Session ID (optional)
1585 1585
      * @param bool   $order
1586
-
1587 1586
      * @return array Array of subcategories
1588 1587
      */
1589 1588
     public function get_subcategories($stud_id = null, $course_code = null, $session_id = null, $order = null)
@@ -1862,7 +1861,6 @@  discard block
 block discarded – undo
1862 1861
      * This function, locks a category , only one who can unlock it is
1863 1862
      * the platform administrator.
1864 1863
      * @param int locked 1 or unlocked 0
1865
-
1866 1864
      * @return boolean|null
1867 1865
      * */
1868 1866
     public function lock($locked)
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
      */
202 202
     public function set_session_id($session_id = 0)
203 203
     {
204
-        $this->session_id = (int)$session_id;
204
+        $this->session_id = (int) $session_id;
205 205
     }
206 206
 
207 207
     /**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
         $skills = $this->get_skills();
291 291
         $skill_select = array();
292 292
         if (!empty($skills)) {
293
-            foreach($skills as $skill) {
293
+            foreach ($skills as $skill) {
294 294
                 $skill_select[$skill['id']] = $skill['name'];
295 295
             }
296 296
         }
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
      */
325 325
     public static function load_session_categories($id = null, $session_id = null)
326 326
     {
327
-        if (isset($id) && (int)$id === 0) {
327
+        if (isset($id) && (int) $id === 0) {
328 328
             $cats = array();
329 329
             $cats[] = Category::create_root_category();
330 330
             return $cats;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
         if (!empty($session_id)) {
338 338
             $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
339 339
             $sql = 'SELECT id, course_code
340
-                    FROM '.$tbl_grade_categories. '
340
+                    FROM '.$tbl_grade_categories.'
341 341
                     WHERE session_id = '.$session_id;
342 342
             $result_session = Database::query($sql);
343 343
             if (Database::num_rows($result_session) > 0) {
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
     ) {
378 378
         //if the category given is explicitly 0 (not null), then create
379 379
         // a root category object (in memory)
380
-        if (isset($id) && (int)$id === 0) {
380
+        if (isset($id) && (int) $id === 0) {
381 381
             $cats = array();
382 382
             $cats[] = Category::create_root_category();
383 383
 
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
         $sql = 'SELECT * FROM '.$tbl_grade_categories;
389 389
         $paramcount = 0;
390 390
         if (isset($id)) {
391
-            $sql.= ' WHERE id = '.intval($id);
392
-            $paramcount ++;
391
+            $sql .= ' WHERE id = '.intval($id);
392
+            $paramcount++;
393 393
         }
394 394
 
395 395
         if (isset($user_id)) {
@@ -425,10 +425,10 @@  discard block
 block discarded – undo
425 425
             if (empty($session_id)) {
426 426
                 $sql .= ' AND (session_id IS NULL OR session_id = 0) ';
427 427
             } else {
428
-                $sql .= ' AND session_id = '.(int)$session_id.' ';
428
+                $sql .= ' AND session_id = '.(int) $session_id.' ';
429 429
             }
430 430
             //}
431
-            $paramcount ++;
431
+            $paramcount++;
432 432
         }
433 433
 
434 434
         if (isset($parent_id)) {
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
                             $default_weight = $default_weight_setting;
597 597
                         }
598 598
                         foreach ($components as $component) {
599
-                            $gradebook =  new Gradebook();
599
+                            $gradebook = new Gradebook();
600 600
                             $params = array();
601 601
 
602 602
                             $params['name'] = $component['acronym'];
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
                 }
614 614
             }
615 615
 
616
-            $gradebook= new Gradebook();
616
+            $gradebook = new Gradebook();
617 617
             $gradebook->update_skills_to_gradebook($this->id, $this->get_skills(false));
618 618
 
619 619
             return $id;
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
                         $params['description']      = $component['title'];
679 679
                         $params['user_id']          = api_get_user_id();
680 680
                         $params['parent_id']        = $this->id;
681
-                        $params['weight']           = $component['percentage']/100*$default_weight;
681
+                        $params['weight']           = $component['percentage'] / 100 * $default_weight;
682 682
                         $params['session_id']       = api_get_session_id();
683 683
                         $params['course_code']      = $this->get_course_code();
684 684
 
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
             }
689 689
         }
690 690
 
691
-        $gradebook= new Gradebook();
691
+        $gradebook = new Gradebook();
692 692
         $gradebook->update_skills_to_gradebook(
693 693
             $this->id,
694 694
             $this->get_skills(false),
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
         if (!empty($links)) {
709 709
             foreach ($links as $link_item) {
710 710
                 if (isset($link_item)) {
711
-                    $new_item_weight =  $new_weight * $link_item->get_weight() / $old_weight;
711
+                    $new_item_weight = $new_weight * $link_item->get_weight() / $old_weight;
712 712
                     $link_item->set_weight($new_item_weight);
713 713
                     $link_item->save();
714 714
                 }
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
                     visible=3';
750 750
         $res = Database::query($sql);
751 751
         $option = Database::fetch_array($res, 'ASSOC');
752
-        if ($option['num']>=1) {
752
+        if ($option['num'] >= 1) {
753 753
             return '&nbsp;&nbsp;<span class="resource-deleted">(&nbsp;'.get_lang('ResourceDeleted').'&nbsp;)</span>';
754 754
         } else {
755 755
             return false;
@@ -810,9 +810,9 @@  discard block
 block discarded – undo
810 810
             $sql .= ' AND user_id = '.api_get_user_id();
811 811
         }
812 812
         if (!isset ($parent)) {
813
-            $sql.= ' AND parent_id is null';
813
+            $sql .= ' AND parent_id is null';
814 814
         } else {
815
-            $sql.= ' AND parent_id = '.intval($parent);
815
+            $sql .= ' AND parent_id = '.intval($parent);
816 816
         }
817 817
 
818 818
         $result = Database::query($sql);
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
                     }
914 914
 
915 915
                     if (isset($score) && !empty($score[1]) && !empty($catweight)) {
916
-                        $ressum += $score[0]/$score[1] * $catweight;
916
+                        $ressum += $score[0] / $score[1] * $catweight;
917 917
                     }
918 918
                 }
919 919
             }
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
                     }
1003 1003
 
1004 1004
                     if (isset($score) && !empty($score[1]) && !empty($catweight)) {
1005
-                        $ressum += $score[0]/$score[1] * $catweight;
1005
+                        $ressum += $score[0] / $score[1] * $catweight;
1006 1006
 
1007 1007
                         if ($ressum > $bestResult) {
1008 1008
                             $bestResult = $ressum;
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
                 // session, we don't check his registration to these, but this
1145 1145
                 // could be an improvement
1146 1146
                 if (!empty($session_id)) {
1147
-                    $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id = ".(int)$session_id;
1147
+                    $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id = ".(int) $session_id;
1148 1148
                 } else {
1149 1149
                     $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id is null OR session_id=0";
1150 1150
                 }
@@ -1168,9 +1168,9 @@  discard block
 block discarded – undo
1168 1168
                 // could be an improvement
1169 1169
                 $sql .= " AND course_code  = '".Database::escape_string($course_code)."'";
1170 1170
                 if (!empty($session_id)) {
1171
-                    $sql .= " AND session_id = ".(int)$session_id;
1171
+                    $sql .= " AND session_id = ".(int) $session_id;
1172 1172
                 } else {
1173
-                    $sql .="AND session_id IS NULL OR session_id=0";
1173
+                    $sql .= "AND session_id IS NULL OR session_id=0";
1174 1174
                 }
1175 1175
             } else {
1176 1176
                 $sql .= ' AND course_code IN
@@ -1184,10 +1184,10 @@  discard block
 block discarded – undo
1184 1184
                     )';
1185 1185
             }
1186 1186
         }elseif (api_is_platform_admin()) {
1187
-            if (isset($session_id) && $session_id!=0) {
1188
-                $sql.=' AND session_id='.intval($session_id);
1187
+            if (isset($session_id) && $session_id != 0) {
1188
+                $sql .= ' AND session_id='.intval($session_id);
1189 1189
             } else {
1190
-                $sql.=' AND coalesce(session_id,0)=0';
1190
+                $sql .= ' AND coalesce(session_id,0)=0';
1191 1191
             }
1192 1192
         }
1193 1193
         $result = Database::query($sql);
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
 
1196 1196
         // course independent categories
1197 1197
         if (empty($course_code)) {
1198
-            $cats = Category::get_independent_categories_with_result_for_student (0, $stud_id, $cats);
1198
+            $cats = Category::get_independent_categories_with_result_for_student(0, $stud_id, $cats);
1199 1199
         }
1200 1200
 
1201 1201
         return $cats;
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
     public function get_root_categories_for_teacher($user_id, $course_code = null, $session_id = null)
1214 1214
     {
1215 1215
         if ($user_id == null) {
1216
-            return Category::load(null,null,$course_code,0,null,$session_id);
1216
+            return Category::load(null, null, $course_code, 0, null, $session_id);
1217 1217
         }
1218 1218
 
1219 1219
         $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE);
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
         if (!empty($course_code)) {
1226 1226
             $sql .= " AND course_code = '".Database::escape_string($course_code)."' ";
1227 1227
             if (!empty($session_id)) {
1228
-                $sql .= " AND session_id = ".(int)$session_id;
1228
+                $sql .= " AND session_id = ".(int) $session_id;
1229 1229
             }
1230 1230
         } else {
1231 1231
             $sql .= ' AND course_code in
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
         $cats = Category::create_category_objects_from_sql_result($result);
1242 1242
         // course independent categories
1243 1243
         if (isset($course_code)) {
1244
-            $indcats = Category::load(null,$user_id,$course_code,0,null,$session_id);
1244
+            $indcats = Category::load(null, $user_id, $course_code, 0, null, $session_id);
1245 1245
             $cats = array_merge($cats, $indcats);
1246 1246
         }
1247 1247
 
@@ -1284,20 +1284,20 @@  discard block
 block discarded – undo
1284 1284
             $targets[] = $root;
1285 1285
 
1286 1286
             if (isset($this->course_code) && !empty($this->course_code)) {
1287
-                $crscats = Category::load(null,null,$this->course_code,0);
1287
+                $crscats = Category::load(null, null, $this->course_code, 0);
1288 1288
                 foreach ($crscats as $cat) {
1289 1289
                     if ($this->can_be_moved_to_cat($cat)) {
1290
-                        $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1291
-                        $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
1290
+                        $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1291
+                        $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
1292 1292
                     }
1293 1293
                 }
1294 1294
             }
1295 1295
 
1296
-            $indcats = Category::load(null,$user,0,0);
1296
+            $indcats = Category::load(null, $user, 0, 0);
1297 1297
             foreach ($indcats as $cat) {
1298 1298
                 if ($this->can_be_moved_to_cat($cat)) {
1299
-                    $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1300
-                    $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
1299
+                    $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1300
+                    $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
1301 1301
                 }
1302 1302
             }
1303 1303
 
@@ -1311,11 +1311,11 @@  discard block
 block discarded – undo
1311 1311
      */
1312 1312
     private function add_target_subcategories($targets, $level, $catid)
1313 1313
     {
1314
-        $subcats = Category::load(null,null,null,$catid);
1314
+        $subcats = Category::load(null, null, null, $catid);
1315 1315
         foreach ($subcats as $cat) {
1316 1316
             if ($this->can_be_moved_to_cat($cat)) {
1317
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1318
-                $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
1317
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1318
+                $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
1319 1319
             }
1320 1320
         }
1321 1321
 
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
      * Impossible when origin and target are the same... children won't be processed
1329 1329
      * either. (a category can't be moved to one of its own children)
1330 1330
      */
1331
-    private function can_be_moved_to_cat ($cat)
1331
+    private function can_be_moved_to_cat($cat)
1332 1332
     {
1333 1333
         return $cat->get_id() != $this->get_id();
1334 1334
     }
@@ -1357,7 +1357,7 @@  discard block
 block discarded – undo
1357 1357
     {
1358 1358
         $cats = Category::load(null, null, null, $this->id, null);
1359 1359
         $evals = Evaluation::load(null, null, null, $this->id, null);
1360
-        $links = LinkFactory::load(null,null,null,null,null,$this->id,null);
1360
+        $links = LinkFactory::load(null, null, null, null, null, $this->id, null);
1361 1361
 
1362 1362
         foreach ($cats as $cat) {
1363 1363
             $cat->set_course_code($this->get_course_code());
@@ -1390,15 +1390,15 @@  discard block
 block discarded – undo
1390 1390
             $user = (api_is_platform_admin() ? null : api_get_user_id());
1391 1391
             $cats = Category::get_root_categories_for_teacher($user);
1392 1392
             foreach ($cats as $cat) {
1393
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1394
-                $targets = Category::add_subtree($targets, $level+1, $cat->get_id(),null);
1393
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1394
+                $targets = Category::add_subtree($targets, $level + 1, $cat->get_id(), null);
1395 1395
             }
1396 1396
         } else {
1397 1397
             // student
1398 1398
             $cats = Category::get_root_categories_for_student(api_get_user_id());
1399 1399
             foreach ($cats as $cat) {
1400
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1401
-                $targets = Category::add_subtree($targets, $level+1, $cat->get_id(), 1);
1400
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1401
+                $targets = Category::add_subtree($targets, $level + 1, $cat->get_id(), 1);
1402 1402
             }
1403 1403
         }
1404 1404
 
@@ -1410,14 +1410,14 @@  discard block
 block discarded – undo
1410 1410
      * @param integer $level
1411 1411
      * @param null|integer $visible
1412 1412
      */
1413
-    private function add_subtree ($targets, $level, $catid, $visible)
1413
+    private function add_subtree($targets, $level, $catid, $visible)
1414 1414
     {
1415
-        $subcats = Category::load(null,null,null,$catid,$visible);
1415
+        $subcats = Category::load(null, null, null, $catid, $visible);
1416 1416
 
1417 1417
         if (!empty($subcats)) {
1418 1418
             foreach ($subcats as $cat) {
1419
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1420
-                $targets = Category::add_subtree($targets, $level+1, $cat->get_id(),$visible);
1419
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1420
+                $targets = Category::add_subtree($targets, $level + 1, $cat->get_id(), $visible);
1421 1421
             }
1422 1422
         }
1423 1423
 
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
      * @param integer $user_id
1430 1430
      * @return array 2-dimensional array - every element contains 2 subelements (code, title)
1431 1431
      */
1432
-    public function get_not_created_course_categories ($user_id)
1432
+    public function get_not_created_course_categories($user_id)
1433 1433
     {
1434 1434
         $tbl_main_courses = Database :: get_main_table(TABLE_MAIN_COURSE);
1435 1435
         $tbl_main_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@@ -1451,9 +1451,9 @@  discard block
 block discarded – undo
1451 1451
                 )';
1452 1452
         $result = Database::query($sql);
1453 1453
 
1454
-        $cats=array();
1455
-        while ($data=Database::fetch_array($result)) {
1456
-            $cats[] = array ($data['code'], $data['title']);
1454
+        $cats = array();
1455
+        while ($data = Database::fetch_array($result)) {
1456
+            $cats[] = array($data['code'], $data['title']);
1457 1457
         }
1458 1458
 
1459 1459
         return $cats;
@@ -1464,7 +1464,7 @@  discard block
 block discarded – undo
1464 1464
      * @param integer $user_id
1465 1465
      * @return array 2-dimensional array - every element contains 2 subelements (code, title)
1466 1466
      */
1467
-    public function get_all_courses ($user_id)
1467
+    public function get_all_courses($user_id)
1468 1468
     {
1469 1469
         $tbl_main_courses = Database :: get_main_table(TABLE_MAIN_COURSE);
1470 1470
         $tbl_main_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@@ -1478,7 +1478,7 @@  discard block
 block discarded – undo
1478 1478
         $result = Database::query($sql);
1479 1479
         $cats = array();
1480 1480
         while ($data = Database::fetch_array($result)) {
1481
-            $cats[] = array ($data['code'], $data['title']);
1481
+            $cats[] = array($data['code'], $data['title']);
1482 1482
         }
1483 1483
 
1484 1484
         return $cats;
@@ -1491,7 +1491,7 @@  discard block
 block discarded – undo
1491 1491
     {
1492 1492
         $cats = Category::load(null, null, null, $this->id, null);
1493 1493
         $evals = Evaluation::load(null, null, null, $this->id, null);
1494
-        $links = LinkFactory::load(null,null,null,null,null,$this->id,null);
1494
+        $links = LinkFactory::load(null, null, null, null, null, $this->id, null);
1495 1495
         if (!empty($cats)) {
1496 1496
             foreach ($cats as $cat) {
1497 1497
                 $cat->set_visible($this->is_visible());
@@ -1846,7 +1846,7 @@  discard block
 block discarded – undo
1846 1846
      * @param string $name_mask search string
1847 1847
      * @return array category objects matching the search criterium
1848 1848
      */
1849
-    public function find_category($name_mask,$allcat)
1849
+    public function find_category($name_mask, $allcat)
1850 1850
     {
1851 1851
         $foundcats = array();
1852 1852
         foreach ($allcat as $search_cat) {
@@ -1889,9 +1889,9 @@  discard block
 block discarded – undo
1889 1889
                 }
1890 1890
             }
1891 1891
 
1892
-            $link_to_lock= $this->get_links();
1892
+            $link_to_lock = $this->get_links();
1893 1893
             if (!empty($link_to_lock)) {
1894
-                foreach ($link_to_lock as $item ) {
1894
+                foreach ($link_to_lock as $item) {
1895 1895
                     $item->lock($locked);
1896 1896
                 }
1897 1897
             }
@@ -1979,7 +1979,7 @@  discard block
 block discarded – undo
1979 1979
                 return [
1980 1980
                     'badge_link' => Display::toolbarButton(
1981 1981
                         get_lang('ExportBadges'),
1982
-                        api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user=$user_id",
1982
+                        api_get_path(WEB_CODE_PATH)."gradebook/get_badges.php?user=$user_id",
1983 1983
                         'external-link'
1984 1984
                     )
1985 1985
                 ];
@@ -2010,7 +2010,7 @@  discard block
 block discarded – undo
2010 2010
             $fileWasGenerated = $certificate_obj->html_file_is_generated();
2011 2011
 
2012 2012
             if (!empty($fileWasGenerated)) {
2013
-                $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id'];
2013
+                $url = api_get_path(WEB_PATH).'certificates/index.php?id='.$my_certificate['id'];
2014 2014
 
2015 2015
                 $certificates = Display::toolbarButton(get_lang('DisplayCertificate'), $url, 'eye', 'primary');
2016 2016
 
@@ -2026,7 +2026,7 @@  discard block
 block discarded – undo
2026 2026
 
2027 2027
                 $hideExportLink = api_get_setting('hide_certificate_export_link');
2028 2028
                 $hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students');
2029
-                if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true') ) {
2029
+                if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true')) {
2030 2030
                     $exportToPDF = null;
2031 2031
                 }
2032 2032
 
@@ -2039,7 +2039,7 @@  discard block
 block discarded – undo
2039 2039
                 if ($skillToolEnabled && $userHasSkills) {
2040 2040
                     $html['badge_link'] = Display::toolbarButton(
2041 2041
                         get_lang('ExportBadges'),
2042
-                        api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user=$user_id",
2042
+                        api_get_path(WEB_CODE_PATH)."gradebook/get_badges.php?user=$user_id",
2043 2043
                         'external-link'
2044 2044
                     );
2045 2045
                 }
@@ -2096,7 +2096,7 @@  discard block
 block discarded – undo
2096 2096
                     $certificate_obj = new Certificate($value_certificate['id']);
2097 2097
                     $certificate_obj->generate(array('hide_print_button' => true));
2098 2098
                     if ($certificate_obj->html_file_is_generated()) {
2099
-                        $certificate_path_list[]= $certificate_obj->html_file;
2099
+                        $certificate_path_list[] = $certificate_obj->html_file;
2100 2100
                     }
2101 2101
                 }
2102 2102
             }
Please login to merge, or discard this patch.
main/gradebook/lib/be/evallink.class.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
         $eval = $this->get_evaluation();
48 48
         // course/platform admin can go to the view_results page
49 49
         if (api_is_allowed_to_edit()) {
50
-            return 'gradebook_view_result.php?' . api_get_cidreq() . '&selecteval=' . $eval->get_id();
50
+            return 'gradebook_view_result.php?'.api_get_cidreq().'&selecteval='.$eval->get_id();
51 51
         } // students can go to the statistics page (if custom display enabled)
52 52
         elseif (ScoreDisplay :: instance()->is_custom()) {
53
-            return 'gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $eval->get_id();
53
+            return 'gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.$eval->get_id();
54 54
         } else {
55 55
             return null;
56 56
         }
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
                 $eval = new Evaluation();
177 177
                 $eval->set_category_id(-1);
178 178
                 $eval->set_date(api_get_utc_datetime()); // these values will be changed
179
-                $eval->set_weight(0);    //   when the link setter
180
-                $eval->set_visible(0);   //     is called
179
+                $eval->set_weight(0); //   when the link setter
180
+                $eval->set_visible(0); //     is called
181 181
                 $eval->set_id(-1); // a 'real' id will be set when eval is added to db
182 182
                 $eval->set_user_id($this->get_user_id());
183 183
                 $eval->set_course_code($this->get_course_code());
Please login to merge, or discard this patch.
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -117,6 +117,9 @@  discard block
 block discarded – undo
117 117
         }
118 118
     }
119 119
 
120
+    /**
121
+     * @param string $name
122
+     */
120 123
     public function set_name($name)
121 124
     {
122 125
         if ($this->is_valid_link()) {
@@ -124,6 +127,9 @@  discard block
 block discarded – undo
124 127
         }
125 128
     }
126 129
 
130
+    /**
131
+     * @param string $description
132
+     */
127 133
     public function set_description($description)
128 134
     {
129 135
         if ($this->is_valid_link()) {
@@ -131,6 +137,9 @@  discard block
 block discarded – undo
131 137
         }
132 138
     }
133 139
 
140
+    /**
141
+     * @param integer $max
142
+     */
134 143
     public function set_max($max)
135 144
     {
136 145
         if ($this->is_valid_link()) {
Please login to merge, or discard this patch.
main/gradebook/lib/be/surveylink.class.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			$links[] = array(
76 76
 				$data['survey_id'],
77 77
 				api_trunc_str(
78
-					$data['code'] . ': ' . self::html_to_text($data['title']),
78
+					$data['code'].': '.self::html_to_text($data['title']),
79 79
 					80
80 80
 				)
81 81
 			);
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	/**
122 122
 	 * Has anyone done this survey yet?
123 123
 	 */
124
-	public function has_results($stud_id=null)
124
+	public function has_results($stud_id = null)
125 125
 	{
126 126
 		$ref_id = intval($this->get_ref_id());
127 127
 		$session_id = api_get_session_id();
Please login to merge, or discard this patch.
Indentation   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -8,98 +8,98 @@  discard block
 block discarded – undo
8 8
  */
9 9
 class SurveyLink extends AbstractLink
10 10
 {
11
-	private $survey_table = null;
12
-
13
-	/**
14
-	 * Constructor
15
-	 */
16
-	public function __construct()
17
-	{
18
-		parent::__construct();
19
-		$this->set_type(LINK_SURVEY);
20
-	}
21
-
22
-	/**
23
-	 * @return string
24
-	 */
25
-	public function get_name()
26
-	{
27
-		$this->get_survey_data();
11
+    private $survey_table = null;
12
+
13
+    /**
14
+     * Constructor
15
+     */
16
+    public function __construct()
17
+    {
18
+        parent::__construct();
19
+        $this->set_type(LINK_SURVEY);
20
+    }
21
+
22
+    /**
23
+     * @return string
24
+     */
25
+    public function get_name()
26
+    {
27
+        $this->get_survey_data();
28 28
 		
29
-		return $this->survey_data['code'].': '.self::html_to_text($this->survey_data['title']);
30
-	}
31
-
32
-	public function get_description()
33
-	{
34
-		$this->get_survey_data();
35
-		return $this->survey_data['subtitle'];
36
-	}
37
-
38
-	public function get_type_name()
39
-	{
40
-		return get_lang('Survey');
41
-	}
42
-
43
-	public function is_allowed_to_change_name()
44
-	{
45
-		return false;
46
-	}
47
-
48
-	public function needs_name_and_description()
49
-	{
50
-		return false;
51
-	}
52
-
53
-	public function needs_max()
54
-	{
55
-		return false;
56
-	}
57
-
58
-	public function needs_results()
59
-	{
60
-		return false;
61
-	}
62
-
63
-	/**
64
-	 * Generates an array of all surveys available.
65
-	 * @return array 2-dimensional array - every element contains 2 subelements (id, name)
66
-	 */
67
-	public function get_all_links()
68
-	{
69
-		if (empty($this->course_code)) {
70
-			die('Error in get_all_links() : course code not set');
71
-		}
72
-		$tbl_survey = $this->get_survey_table();
73
-		$session_id = api_get_session_id();
74
-		$course_id = api_get_course_int_id();
75
-		$sql = 'SELECT survey_id, title, code FROM '.$tbl_survey.'
29
+        return $this->survey_data['code'].': '.self::html_to_text($this->survey_data['title']);
30
+    }
31
+
32
+    public function get_description()
33
+    {
34
+        $this->get_survey_data();
35
+        return $this->survey_data['subtitle'];
36
+    }
37
+
38
+    public function get_type_name()
39
+    {
40
+        return get_lang('Survey');
41
+    }
42
+
43
+    public function is_allowed_to_change_name()
44
+    {
45
+        return false;
46
+    }
47
+
48
+    public function needs_name_and_description()
49
+    {
50
+        return false;
51
+    }
52
+
53
+    public function needs_max()
54
+    {
55
+        return false;
56
+    }
57
+
58
+    public function needs_results()
59
+    {
60
+        return false;
61
+    }
62
+
63
+    /**
64
+     * Generates an array of all surveys available.
65
+     * @return array 2-dimensional array - every element contains 2 subelements (id, name)
66
+     */
67
+    public function get_all_links()
68
+    {
69
+        if (empty($this->course_code)) {
70
+            die('Error in get_all_links() : course code not set');
71
+        }
72
+        $tbl_survey = $this->get_survey_table();
73
+        $session_id = api_get_session_id();
74
+        $course_id = api_get_course_int_id();
75
+        $sql = 'SELECT survey_id, title, code FROM '.$tbl_survey.'
76 76
 				WHERE c_id = '.$course_id.' AND session_id = '.intval($session_id).'';
77
-		$result = Database::query($sql);
78
-		while ($data = Database::fetch_array($result)) {
79
-			$links[] = array(
80
-				$data['survey_id'],
81
-				api_trunc_str(
82
-					$data['code'] . ': ' . self::html_to_text($data['title']),
83
-					80
84
-				)
85
-			);
86
-		}
87
-
88
-		return isset($links) ? $links : null;
89
-	}
90
-
91
-	/**
92
-	 * Generates an array of surveys that a teacher hasn't created a link for.
93
-	 * @return array 2-dimensional array - every element contains 2 subelements (id, name)
94
-	 */
95
-	public function get_not_created_links()
96
-	{
97
-		if (empty($this->course_code)) {
98
-			die('Error in get_not_created_links() : course code not set');
99
-		}
100
-		$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
101
-
102
-		$sql = 'SELECT survey_id, title, code
77
+        $result = Database::query($sql);
78
+        while ($data = Database::fetch_array($result)) {
79
+            $links[] = array(
80
+                $data['survey_id'],
81
+                api_trunc_str(
82
+                    $data['code'] . ': ' . self::html_to_text($data['title']),
83
+                    80
84
+                )
85
+            );
86
+        }
87
+
88
+        return isset($links) ? $links : null;
89
+    }
90
+
91
+    /**
92
+     * Generates an array of surveys that a teacher hasn't created a link for.
93
+     * @return array 2-dimensional array - every element contains 2 subelements (id, name)
94
+     */
95
+    public function get_not_created_links()
96
+    {
97
+        if (empty($this->course_code)) {
98
+            die('Error in get_not_created_links() : course code not set');
99
+        }
100
+        $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
101
+
102
+        $sql = 'SELECT survey_id, title, code
103 103
     			FROM '.$this->get_survey_table().' AS srv
104 104
 				WHERE survey_id NOT IN
105 105
 					(
@@ -110,28 +110,28 @@  discard block
 block discarded – undo
110 110
 					)
111 111
 					AND srv.session_id = '.api_get_session_id();
112 112
 
113
-		$result = Database::query($sql);
114
-
115
-		$links = array();
116
-		while ($data = Database::fetch_array($result)) {
117
-			$links[] = array(
118
-				$data['survey_id'],
119
-				api_trunc_str($data['code'].': '.self::html_to_text($data['title']), 80)
120
-			);
121
-		}
122
-		return $links;
123
-	}
124
-
125
-	/**
126
-	 * Has anyone done this survey yet?
127
-	 */
128
-	public function has_results($stud_id=null)
129
-	{
130
-		$ref_id = intval($this->get_ref_id());
131
-		$session_id = api_get_session_id();
132
-		$tbl_survey = Database::get_course_table(TABLE_SURVEY);
133
-		$tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
134
-		$sql = "SELECT
113
+        $result = Database::query($sql);
114
+
115
+        $links = array();
116
+        while ($data = Database::fetch_array($result)) {
117
+            $links[] = array(
118
+                $data['survey_id'],
119
+                api_trunc_str($data['code'].': '.self::html_to_text($data['title']), 80)
120
+            );
121
+        }
122
+        return $links;
123
+    }
124
+
125
+    /**
126
+     * Has anyone done this survey yet?
127
+     */
128
+    public function has_results($stud_id=null)
129
+    {
130
+        $ref_id = intval($this->get_ref_id());
131
+        $session_id = api_get_session_id();
132
+        $tbl_survey = Database::get_course_table(TABLE_SURVEY);
133
+        $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
134
+        $sql = "SELECT
135 135
 				COUNT(i.answered)
136 136
 				FROM $tbl_survey AS s
137 137
 				JOIN $tbl_survey_invitation AS i ON s.code = i.survey_code
@@ -141,30 +141,30 @@  discard block
 block discarded – undo
141 141
 					s.survey_id = $ref_id AND
142 142
 					i.session_id = $session_id";
143 143
 
144
-		$sql_result = Database::query($sql);
145
-		$data = Database::fetch_array($sql_result);
144
+        $sql_result = Database::query($sql);
145
+        $data = Database::fetch_array($sql_result);
146 146
 
147
-		return ($data[0] != 0);
148
-	}
147
+        return ($data[0] != 0);
148
+    }
149 149
 
150
-	/**
151
-	 * @param int $stud_id
152
-	 * @return array|null
153
-	 */
154
-	public function calc_score($stud_id = null, $type = null)
155
-	{
156
-		// Note: Max score is assumed to be always 1 for surveys,
157
-		// only student's participation is to be taken into account.
158
-		$max_score = 1;
150
+    /**
151
+     * @param int $stud_id
152
+     * @return array|null
153
+     */
154
+    public function calc_score($stud_id = null, $type = null)
155
+    {
156
+        // Note: Max score is assumed to be always 1 for surveys,
157
+        // only student's participation is to be taken into account.
158
+        $max_score = 1;
159 159
 
160
-		$ref_id = intval($this->get_ref_id());
161
-		$session_id = api_get_session_id();
162
-		$tbl_survey = Database::get_course_table(TABLE_SURVEY);
163
-		$tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
160
+        $ref_id = intval($this->get_ref_id());
161
+        $session_id = api_get_session_id();
162
+        $tbl_survey = Database::get_course_table(TABLE_SURVEY);
163
+        $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
164 164
 
165
-		$get_individual_score = !is_null($stud_id);
165
+        $get_individual_score = !is_null($stud_id);
166 166
 
167
-		$sql = "SELECT i.answered
167
+        $sql = "SELECT i.answered
168 168
 				FROM $tbl_survey AS s
169 169
 				JOIN $tbl_survey_invitation AS i
170 170
 				ON s.code = i.survey_code
@@ -175,131 +175,131 @@  discard block
 block discarded – undo
175 175
 					i.session_id = $session_id
176 176
 				";
177 177
 
178
-		if ($get_individual_score) {
179
-			$sql .= ' AND i.user = '.intval($stud_id);
180
-		}
181
-
182
-		$sql_result = Database::query($sql);
183
-
184
-		if ($get_individual_score) {
185
-			// for 1 student
186
-			if ($data = Database::fetch_array($sql_result)) {
187
-				return array($data['answered'] ? $max_score : 0, $max_score);
188
-			}
189
-			return array(0, $max_score);
190
-		} else {
191
-			// for all the students -> get average
192
-			$rescount = 0;
193
-			$sum = 0;
194
-			$bestResult = 0;
195
-			$weight = 0;
196
-			while ($data = Database::fetch_array($sql_result)) {
197
-				$sum += $data['answered'] ? $max_score : 0;
198
-				$rescount++;
199
-				if ($data['answered'] > $bestResult) {
200
-					$bestResult = $data['answered'];
201
-					$weight = $assignment['qualification'];
202
-				}
203
-			}
204
-			$sum = $sum / $max_score;
205
-
206
-			if ($rescount == 0) {
207
-				return null;
208
-			}
209
-
210
-			switch ($type) {
211
-				case 'best':
212
-					return array($bestResult, $rescount);
213
-					break;
214
-				case 'average':
215
-					return array($sum, $rescount);
216
-					break;
217
-				case 'ranking':
218
-					return null;
219
-					break;
220
-				default:
221
-					return array($sum, $rescount);
222
-					break;
223
-			}
224
-		}
225
-	}
226
-
227
-	/**
228
-	 * Lazy load function to get the database table of the surveys
229
-	 */
230
-	private function get_survey_table()
231
-	{
232
-		$this->survey_table = Database :: get_course_table(TABLE_SURVEY);
233
-		return $this->survey_table;
234
-	}
235
-
236
-	/**
237
-	 * Check if this still links to a survey
238
-	 */
239
-	public function is_valid_link()
240
-	{
241
-		$session_id = api_get_session_id();
242
-		$sql = 'SELECT count(survey_id) FROM '.$this->get_survey_table().'
178
+        if ($get_individual_score) {
179
+            $sql .= ' AND i.user = '.intval($stud_id);
180
+        }
181
+
182
+        $sql_result = Database::query($sql);
183
+
184
+        if ($get_individual_score) {
185
+            // for 1 student
186
+            if ($data = Database::fetch_array($sql_result)) {
187
+                return array($data['answered'] ? $max_score : 0, $max_score);
188
+            }
189
+            return array(0, $max_score);
190
+        } else {
191
+            // for all the students -> get average
192
+            $rescount = 0;
193
+            $sum = 0;
194
+            $bestResult = 0;
195
+            $weight = 0;
196
+            while ($data = Database::fetch_array($sql_result)) {
197
+                $sum += $data['answered'] ? $max_score : 0;
198
+                $rescount++;
199
+                if ($data['answered'] > $bestResult) {
200
+                    $bestResult = $data['answered'];
201
+                    $weight = $assignment['qualification'];
202
+                }
203
+            }
204
+            $sum = $sum / $max_score;
205
+
206
+            if ($rescount == 0) {
207
+                return null;
208
+            }
209
+
210
+            switch ($type) {
211
+                case 'best':
212
+                    return array($bestResult, $rescount);
213
+                    break;
214
+                case 'average':
215
+                    return array($sum, $rescount);
216
+                    break;
217
+                case 'ranking':
218
+                    return null;
219
+                    break;
220
+                default:
221
+                    return array($sum, $rescount);
222
+                    break;
223
+            }
224
+        }
225
+    }
226
+
227
+    /**
228
+     * Lazy load function to get the database table of the surveys
229
+     */
230
+    private function get_survey_table()
231
+    {
232
+        $this->survey_table = Database :: get_course_table(TABLE_SURVEY);
233
+        return $this->survey_table;
234
+    }
235
+
236
+    /**
237
+     * Check if this still links to a survey
238
+     */
239
+    public function is_valid_link()
240
+    {
241
+        $session_id = api_get_session_id();
242
+        $sql = 'SELECT count(survey_id) FROM '.$this->get_survey_table().'
243 243
         		 WHERE
244 244
         		 	c_id = '.$this->course_id.' AND
245 245
         		 	survey_id = '.intval($this->get_ref_id()).' AND
246 246
         		 	session_id='.intval($session_id).'';
247
-		$result = Database::query($sql);
248
-		$number = Database::fetch_row($result);
249
-		return ($number[0] != 0);
250
-	}
251
-
252
-	public function get_test_id()
253
-	{
254
-		return 'DEBUG:ID';
255
-	}
256
-
257
-	public function get_link()
258
-	{
259
-		if (api_is_allowed_to_edit()) { // Let students make access only through "Surveys" tool.
260
-			$tbl_name = $this->get_survey_table();
261
-			$session_id = api_get_session_id();
262
-			if ($tbl_name != '') {
263
-				$sql = 'SELECT survey_id FROM '.$this->get_survey_table().'
247
+        $result = Database::query($sql);
248
+        $number = Database::fetch_row($result);
249
+        return ($number[0] != 0);
250
+    }
251
+
252
+    public function get_test_id()
253
+    {
254
+        return 'DEBUG:ID';
255
+    }
256
+
257
+    public function get_link()
258
+    {
259
+        if (api_is_allowed_to_edit()) { // Let students make access only through "Surveys" tool.
260
+            $tbl_name = $this->get_survey_table();
261
+            $session_id = api_get_session_id();
262
+            if ($tbl_name != '') {
263
+                $sql = 'SELECT survey_id FROM '.$this->get_survey_table().'
264 264
     					WHERE
265 265
     						c_id = '.$this->course_id.' AND
266 266
     						survey_id = '.intval($this->get_ref_id()).' AND
267 267
     						session_id = '.intval($session_id).' ';
268
-				$result = Database::query($sql);
269
-				$row = Database::fetch_array($result, 'ASSOC');
270
-				$survey_id = $row['survey_id'];
271
-				return api_get_path(WEB_PATH).'main/survey/reporting.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&survey_id='.$survey_id;
272
-			}
273
-		}
274
-		return null;
275
-	}
276
-
277
-	private function get_survey_data()
278
-	{
279
-		$tbl_name = $this->get_survey_table();
280
-		$session_id = api_get_session_id();
281
-		if ($tbl_name == '') {
282
-			return false;
283
-		} elseif (!isset($this->survey_data)) {
284
-			$sql = 'SELECT * FROM '.$tbl_name.'
268
+                $result = Database::query($sql);
269
+                $row = Database::fetch_array($result, 'ASSOC');
270
+                $survey_id = $row['survey_id'];
271
+                return api_get_path(WEB_PATH).'main/survey/reporting.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&survey_id='.$survey_id;
272
+            }
273
+        }
274
+        return null;
275
+    }
276
+
277
+    private function get_survey_data()
278
+    {
279
+        $tbl_name = $this->get_survey_table();
280
+        $session_id = api_get_session_id();
281
+        if ($tbl_name == '') {
282
+            return false;
283
+        } elseif (!isset($this->survey_data)) {
284
+            $sql = 'SELECT * FROM '.$tbl_name.'
285 285
 					WHERE
286 286
 						c_id = '.$this->course_id.' AND
287 287
 						survey_id = '.intval($this->get_ref_id()).' AND
288 288
 						session_id='.intval($session_id).'';
289
-			$query = Database::query($sql);
290
-			$this->survey_data = Database::fetch_array($query);
291
-		}
292
-		return $this->survey_data;
293
-	}
294
-
295
-	public function get_icon_name()
296
-	{
297
-		return 'survey';
298
-	}
299
-
300
-	private static function html_to_text($string)
301
-	{
302
-		return strip_tags($string);
303
-		//return trim(api_html_entity_decode(strip_tags(str_ireplace(array('<p>', '</p>', '<br />', '<br/>', '<br>'), array('', ' ', ' ', ' ', ' '), $string)), ENT_QUOTES));
304
-	}
289
+            $query = Database::query($sql);
290
+            $this->survey_data = Database::fetch_array($query);
291
+        }
292
+        return $this->survey_data;
293
+    }
294
+
295
+    public function get_icon_name()
296
+    {
297
+        return 'survey';
298
+    }
299
+
300
+    private static function html_to_text($string)
301
+    {
302
+        return strip_tags($string);
303
+        //return trim(api_html_entity_decode(strip_tags(str_ireplace(array('<p>', '</p>', '<br />', '<br/>', '<br>'), array('', ' ', ' ', ' ', ' '), $string)), ENT_QUOTES));
304
+    }
305 305
 }
Please login to merge, or discard this patch.
main/gradebook/lib/be/linkfactory.class.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      * @param string $name_mask search string
59 59
      * @return array link objects matching the search criterium
60 60
      */
61
-    public function find_links($name_mask,$selectcat)
61
+    public function find_links($name_mask, $selectcat)
62 62
     {
63 63
         return AbstractLink::find_links($name_mask, $selectcat);
64 64
     }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     public static function get_all_types()
99 99
     {
100 100
         //LINK_DROPBOX,
101
-        return array (
101
+        return array(
102 102
             LINK_EXERCISE,
103 103
             //LINK_DROPBOX,
104 104
             LINK_HOTPOTATOES,
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@
 block discarded – undo
93 93
 
94 94
     /**
95 95
      * Return an array of all known link types
96
-     * @return array
96
+     * @return integer[]
97 97
      */
98 98
     public static function get_all_types()
99 99
     {
Please login to merge, or discard this patch.
main/gradebook/lib/be/result.class.php 2 patches
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.
main/admin/course_request_accepted.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@
 block discarded – undo
87 87
     $from = intval($from);
88 88
     $number_of_items = intval($number_of_items);
89 89
     $column = intval($column);
90
-    $direction = !in_array(strtolower(trim($direction)), ['asc','desc']) ? 'asc' : $direction;
90
+    $direction = !in_array(strtolower(trim($direction)), ['asc', 'desc']) ? 'asc' : $direction;
91 91
 
92 92
     $sql = "SELECT
93 93
                 id AS col0,
Please login to merge, or discard this patch.
main/admin/ldap_import_students.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -269,8 +269,7 @@
 block discarded – undo
269 269
     echo '<br /><br />';
270 270
     echo '</div>';
271 271
 
272
-}
273
-elseif (!empty($annee) && !empty($course) && ($_POST['confirmed']=='yes'))
272
+} elseif (!empty($annee) && !empty($course) && ($_POST['confirmed']=='yes'))
274 273
 {
275 274
 	$id=$_POST['username_form'];
276 275
 	$UserList=array();
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -56,19 +56,19 @@  discard block
 block discarded – undo
56 56
 //if ($annee == "" && $composante == "" && $etape == "") {
57 57
 if (empty($annee) && empty($course))
58 58
 {
59
-		Display::display_header($tool_name);
60
-		echo '<div style="align:center">';
61
-		Display::display_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU'));
62
-		echo get_lang('LDAPSelectFilterOnUsersOU');
63
-		//echo '<em>'.get_lang('ToDoThisYouMustEnterYearComponentAndComponentStep').'</em><br />';
64
-		///echo get_lang('FollowEachOfTheseStepsStepByStep').'<br />';
65
-
66
-		echo '<form method="get" action="'.api_get_self().'"><br />';
67
-		echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> ';
68
-		echo '<input  type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"><br />';
69
-		echo '<input type="submit" value="'.get_lang('Submit').'">';
70
-		echo '</form>';
71
-		echo '</div>';
59
+        Display::display_header($tool_name);
60
+        echo '<div style="align:center">';
61
+        Display::display_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU'));
62
+        echo get_lang('LDAPSelectFilterOnUsersOU');
63
+        //echo '<em>'.get_lang('ToDoThisYouMustEnterYearComponentAndComponentStep').'</em><br />';
64
+        ///echo get_lang('FollowEachOfTheseStepsStepByStep').'<br />';
65
+
66
+        echo '<form method="get" action="'.api_get_self().'"><br />';
67
+        echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> ';
68
+        echo '<input  type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"><br />';
69
+        echo '<input type="submit" value="'.get_lang('Submit').'">';
70
+        echo '</form>';
71
+        echo '</div>';
72 72
 
73 73
 }
74 74
 /*
@@ -200,71 +200,71 @@  discard block
 block discarded – undo
200 200
 */
201 201
 elseif(!empty($annee) && empty($course))
202 202
 {
203
-	Display::display_header($tool_name);
204
-	echo '<div style="align:center">';
205
-	echo Display::return_icon('course.png', get_lang('SelectCourseToImportUsersTo')).' '.get_lang('SelectCourseToImportUsersTo').'<br />';
206
-	echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />';
207
-	echo '<select name="course">';
208
-	$courses = CourseManager::get_courses_list();
209
-	foreach($courses as $row)
210
-	{
211
-		echo '<option value="'.$row['code'].'">'.api_htmlentities($row['title']).'</option>';
212
-	}
213
-	echo '</select>';
214
-	echo '<input type="submit" value="'.get_lang('Submit').'">';
215
-	echo '</form>';
216
-	echo '</div>';
203
+    Display::display_header($tool_name);
204
+    echo '<div style="align:center">';
205
+    echo Display::return_icon('course.png', get_lang('SelectCourseToImportUsersTo')).' '.get_lang('SelectCourseToImportUsersTo').'<br />';
206
+    echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />';
207
+    echo '<select name="course">';
208
+    $courses = CourseManager::get_courses_list();
209
+    foreach($courses as $row)
210
+    {
211
+        echo '<option value="'.$row['code'].'">'.api_htmlentities($row['title']).'</option>';
212
+    }
213
+    echo '</select>';
214
+    echo '<input type="submit" value="'.get_lang('Submit').'">';
215
+    echo '</form>';
216
+    echo '</div>';
217 217
 }
218 218
 // form4  annee != 0; composante != 0 etape != 0
219 219
 //elseif ($annee <> "" && $composante <> "" && $etape <> "" && $listeok != 'yes') {
220 220
 elseif (!empty($annee) && !empty($course) && empty($_POST['confirmed']))
221 221
 {
222
-	Display::display_header($tool_name);
223
-	echo '<div style="align: center;">';
224
-	echo '<br />';
225
-	echo '<br />';
226
-	echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>';
227
-	//echo "Connection ...";
228
-	$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError'));
229
-	ldap_set_version($ds);
230
-
231
-	if ($ds) {
232
-
233
-		$r = false;
234
-		$res = ldap_handle_bind($ds, $r);
235
-
236
-		//$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))");
237
-		//echo "(ou=*$annee,ou=$composante)";
238
-		$sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)");
239
-
240
-		$info = ldap_get_entries($ds, $sr);
241
-
242
-		for ($key = 0; $key < $info["count"]; $key ++) {
243
-			$nom_form[] = $info[$key]["sn"][0];
244
-			$prenom_form[] = $info[$key]["givenname"][0];
245
-			$email_form[] = $info[$key]["mail"][0];
246
-			// Get uid from dn
247
-			//$dn_array=ldap_explode_dn($info[$key]["dn"],1);
248
-			//$username_form[] = $dn_array[0]; // uid is first key
249
-			$username_form[] = $info[$key]['uid'][0];
250
-			$outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student"
251
-			//$val = ldap_get_values_len($ds, $entry, "userPassword");
252
-			//$password_form[] = $val[0];
253
-			$password_form[] = $info[$key]['userPassword'][0];
254
-		}
255
-		ldap_unbind($ds);
256
-
257
-		/*-----------------------------------------------*/
258
-
259
-		asort($nom_form);
260
-		reset($nom_form);
261
-
262
-		$statut=5;
263
-		include ('ldap_form_add_users_group.php');
264
-	} else {
265
-		echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>';
266
-	}
267
-	echo '<br /><br />';
222
+    Display::display_header($tool_name);
223
+    echo '<div style="align: center;">';
224
+    echo '<br />';
225
+    echo '<br />';
226
+    echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>';
227
+    //echo "Connection ...";
228
+    $ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError'));
229
+    ldap_set_version($ds);
230
+
231
+    if ($ds) {
232
+
233
+        $r = false;
234
+        $res = ldap_handle_bind($ds, $r);
235
+
236
+        //$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))");
237
+        //echo "(ou=*$annee,ou=$composante)";
238
+        $sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)");
239
+
240
+        $info = ldap_get_entries($ds, $sr);
241
+
242
+        for ($key = 0; $key < $info["count"]; $key ++) {
243
+            $nom_form[] = $info[$key]["sn"][0];
244
+            $prenom_form[] = $info[$key]["givenname"][0];
245
+            $email_form[] = $info[$key]["mail"][0];
246
+            // Get uid from dn
247
+            //$dn_array=ldap_explode_dn($info[$key]["dn"],1);
248
+            //$username_form[] = $dn_array[0]; // uid is first key
249
+            $username_form[] = $info[$key]['uid'][0];
250
+            $outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student"
251
+            //$val = ldap_get_values_len($ds, $entry, "userPassword");
252
+            //$password_form[] = $val[0];
253
+            $password_form[] = $info[$key]['userPassword'][0];
254
+        }
255
+        ldap_unbind($ds);
256
+
257
+        /*-----------------------------------------------*/
258
+
259
+        asort($nom_form);
260
+        reset($nom_form);
261
+
262
+        $statut=5;
263
+        include ('ldap_form_add_users_group.php');
264
+    } else {
265
+        echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>';
266
+    }
267
+    echo '<br /><br />';
268 268
     echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>';
269 269
     echo '<br /><br />';
270 270
     echo '</div>';
@@ -272,27 +272,27 @@  discard block
 block discarded – undo
272 272
 }
273 273
 elseif (!empty($annee) && !empty($course) && ($_POST['confirmed']=='yes'))
274 274
 {
275
-	$id=$_POST['username_form'];
276
-	$UserList=array();
277
-	$userid_match_login = array();
278
-	foreach ($id as $form_index=>$user_id)
279
-	{
280
-		if(is_array($_POST['checkboxes']) && in_array($form_index,array_values($_POST['checkboxes'])))
281
-		{
282
-			$tmp = ldap_add_user($user_id);
283
-			$UserList[]= $tmp;
284
-			$userid_match_login[$tmp] = $user_id;
285
-		}
286
-	}
287
-	if (!empty($_POST['course']))
288
-	{
289
-		foreach($UserList as $user_id)
290
-		{
291
-			CourseManager::add_user_to_course($user_id,$_POST['course']);
292
-		}
293
-		header('Location: course_information.php?code='.Security::remove_XSS($_POST['course']));
294
-	}
295
-	/*
275
+    $id=$_POST['username_form'];
276
+    $UserList=array();
277
+    $userid_match_login = array();
278
+    foreach ($id as $form_index=>$user_id)
279
+    {
280
+        if(is_array($_POST['checkboxes']) && in_array($form_index,array_values($_POST['checkboxes'])))
281
+        {
282
+            $tmp = ldap_add_user($user_id);
283
+            $UserList[]= $tmp;
284
+            $userid_match_login[$tmp] = $user_id;
285
+        }
286
+    }
287
+    if (!empty($_POST['course']))
288
+    {
289
+        foreach($UserList as $user_id)
290
+        {
291
+            CourseManager::add_user_to_course($user_id,$_POST['course']);
292
+        }
293
+        header('Location: course_information.php?code='.Security::remove_XSS($_POST['course']));
294
+    }
295
+    /*
296 296
 	else
297 297
 	{
298 298
 		Display :: display_header($tool_name);
@@ -311,13 +311,13 @@  discard block
 block discarded – undo
311 311
 		Display :: display_normal_message($message,false);
312 312
 	}
313 313
 	*/
314
-	else
315
-	{
316
-		Display::display_header($tool_name);
317
-		$message=get_lang('NoUserAdded');
318
-		Display :: display_normal_message($message,false);
319
-	}
320
-	echo '<br /><br />';
314
+    else
315
+    {
316
+        Display::display_header($tool_name);
317
+        $message=get_lang('NoUserAdded');
318
+        Display :: display_normal_message($message,false);
319
+    }
320
+    echo '<br /><br />';
321 321
     echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>';
322 322
     echo '<br /><br />';
323 323
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard)
7 7
  */
8 8
 // resetting the course id
9
-$cidReset=true;
9
+$cidReset = true;
10 10
 require_once __DIR__.'/../inc/global.inc.php';
11 11
 // setting the section (for the tabs)
12 12
 $this_section = SECTION_PLATFORM_ADMIN;
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 api_protect_admin_script();
16 16
 require('../auth/ldap/authldap.php');
17 17
 
18
-$annee_base=date('Y');
18
+$annee_base = date('Y');
19 19
 
20 20
 $tool_name = get_lang('LDAPImport');
21 21
 // setting breadcrumbs
22
-$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
22
+$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
23 23
 
24 24
 $htmlHeadXtra[] = '<script language="JavaScript" type="text/javascript">
25 25
 var buttoncheck = 1;
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 $annee = $_GET['annee'];
47 47
 $composante = $_GET['composante'];
48
-$etape =  $_GET['etape'];
48
+$etape = $_GET['etape'];
49 49
 $course = $_POST['course'];
50 50
 
51 51
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	echo '</div>';
196 196
 }
197 197
 */
198
-elseif(!empty($annee) && empty($course))
198
+elseif (!empty($annee) && empty($course))
199 199
 {
200 200
 	Display::display_header($tool_name);
201 201
 	echo '<div style="align:center">';
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />';
204 204
 	echo '<select name="course">';
205 205
 	$courses = CourseManager::get_courses_list();
206
-	foreach($courses as $row)
206
+	foreach ($courses as $row)
207 207
 	{
208 208
 		echo '<option value="'.$row['code'].'">'.api_htmlentities($row['title']).'</option>';
209 209
 	}
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
 		$info = ldap_get_entries($ds, $sr);
238 238
 
239
-		for ($key = 0; $key < $info["count"]; $key ++) {
239
+		for ($key = 0; $key < $info["count"]; $key++) {
240 240
 			$nom_form[] = $info[$key]["sn"][0];
241 241
 			$prenom_form[] = $info[$key]["givenname"][0];
242 242
 			$email_form[] = $info[$key]["mail"][0];
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 		asort($nom_form);
257 257
 		reset($nom_form);
258 258
 
259
-		$statut=5;
259
+		$statut = 5;
260 260
 		include ('ldap_form_add_users_group.php');
261 261
 	} else {
262 262
 		echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>';
@@ -267,25 +267,25 @@  discard block
 block discarded – undo
267 267
     echo '</div>';
268 268
 
269 269
 }
270
-elseif (!empty($annee) && !empty($course) && ($_POST['confirmed']=='yes'))
270
+elseif (!empty($annee) && !empty($course) && ($_POST['confirmed'] == 'yes'))
271 271
 {
272
-	$id=$_POST['username_form'];
273
-	$UserList=array();
272
+	$id = $_POST['username_form'];
273
+	$UserList = array();
274 274
 	$userid_match_login = array();
275 275
 	foreach ($id as $form_index=>$user_id)
276 276
 	{
277
-		if(is_array($_POST['checkboxes']) && in_array($form_index,array_values($_POST['checkboxes'])))
277
+		if (is_array($_POST['checkboxes']) && in_array($form_index, array_values($_POST['checkboxes'])))
278 278
 		{
279 279
 			$tmp = ldap_add_user($user_id);
280
-			$UserList[]= $tmp;
280
+			$UserList[] = $tmp;
281 281
 			$userid_match_login[$tmp] = $user_id;
282 282
 		}
283 283
 	}
284 284
 	if (!empty($_POST['course']))
285 285
 	{
286
-		foreach($UserList as $user_id)
286
+		foreach ($UserList as $user_id)
287 287
 		{
288
-			CourseManager::add_user_to_course($user_id,$_POST['course']);
288
+			CourseManager::add_user_to_course($user_id, $_POST['course']);
289 289
 		}
290 290
 		header('Location: course_information.php?code='.Security::remove_XSS($_POST['course']));
291 291
 	}
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
 	else
312 312
 	{
313 313
 		Display::display_header($tool_name);
314
-		$message=get_lang('NoUserAdded');
315
-		Display :: display_normal_message($message,false);
314
+		$message = get_lang('NoUserAdded');
315
+		Display :: display_normal_message($message, false);
316 316
 	}
317 317
 	echo '<br /><br />';
318 318
     echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>';
Please login to merge, or discard this patch.