Browse Source

Minor - format code

Julio 5 years ago
parent
commit
beab7fd1eb
2 changed files with 22 additions and 29 deletions
  1. 1 3
      main/gradebook/gradebook_edit_cat.php
  2. 21 26
      main/gradebook/lib/fe/catform.class.php

+ 1 - 3
main/gradebook/gradebook_edit_cat.php

@@ -66,12 +66,10 @@ if ($form->validate()) {
         $cat->set_certificate_min_score($values['certif_min_score']);
     }
 
+    $visible = 1;
     if (empty($values['visible'])) {
         $visible = 0;
-    } else {
-        $visible = 1;
     }
-
     $cat->set_visible($visible);
 
     if (isset($values['is_requirement'])) {

+ 21 - 26
main/gradebook/lib/fe/catform.class.php

@@ -39,26 +39,23 @@ class CatForm extends FormValidator
         if (isset($category_object)) {
             $this->category_object = $category_object;
         }
-        if ($this->form_type == self::TYPE_EDIT) {
-            $this->build_editing_form();
-        } elseif ($this->form_type == self::TYPE_ADD) {
-            $this->build_add_form();
-        } elseif ($this->form_type == self::TYPE_MOVE) {
-            $this->build_move_form();
-        } elseif ($this->form_type == self::TYPE_SELECT_COURSE) {
-            $this->build_select_course_form();
-        }
-        $this->setDefaults();
-    }
 
-    public function display()
-    {
-        parent::display();
-    }
+        switch ($this->form_type) {
+            case self::TYPE_EDIT:
+                $this->build_editing_form();
+                break;
+            case self::TYPE_ADD:
+                $this->build_add_form();
+                break;
+            case self::TYPE_MOVE:
+                $this->build_move_form();
+                break;
+            case self::TYPE_SELECT_COURSE:
+                $this->build_select_course_form();
+                break;
+        }
 
-    public function setDefaults($defaults = [], $filter = null)
-    {
-        parent::setDefaults($defaults, $filter);
+        $this->setDefaults();
     }
 
     /**
@@ -98,13 +95,12 @@ class CatForm extends FormValidator
      */
     protected function build_add_form()
     {
-        //check if we are a root category
-        //if so, you can only choose between courses
+        // check if we are a root category
+        // if so, you can only choose between courses
         if ($this->category_object->get_parent_id() == '0') {
             $this->setDefaults(
                 [
-                    'select_course' => $this->category_object->get_course_code(
-                    ),
+                    'select_course' => $this->category_object->get_course_code(),
                     'hid_user_id' => $this->category_object->get_user_id(),
                     'hid_parent_id' => $this->category_object->get_parent_id(),
                 ]
@@ -201,10 +197,9 @@ class CatForm extends FormValidator
             [get_lang('PickACourse'), 'test'],
             null
         );
-        $coursecat = Category::get_all_courses(api_get_user_id());
+        $courses = Category::get_all_courses(api_get_user_id());
         //only return courses that are not yet created by the teacher
-
-        foreach ($coursecat as $row) {
+        foreach ($courses as $row) {
             $select->addoption($row[1], $row[0]);
         }
         $this->setDefaults([
@@ -229,7 +224,7 @@ class CatForm extends FormValidator
         if (isset($this->category_object) &&
             $this->category_object->get_parent_id() == 0
         ) {
-            //we can't change the root category
+            // we can't change the root category
             $this->freeze('name');
         }