Beispiel #1
0
                 $gradebook->update(array('id' => $cats[0]->get_id(), 'grade_model_id' => $value), true);
                 //do something
                 $obj = new GradeModel();
                 $components = $obj->get_components($value);
                 foreach ($components as $component) {
                     $gradebook = new Gradebook();
                     $params = array();
                     $params['name'] = $component['acronym'];
                     $params['description'] = $component['title'];
                     $params['user_id'] = api_get_user_id();
                     $params['parent_id'] = $cats[0]->get_id();
                     $params['weight'] = $component['percentage'];
                     $params['session_id'] = api_get_session_id();
                     $params['course_code'] = api_get_course_id();
                     $params['grade_model_id'] = api_get_session_id();
                     $gradebook->save($params);
                 }
                 // Reloading cats
                 $cats = Category::load(null, null, $course_code, null, null, $session_id, false);
             } else {
                 $form_grade->display();
             }
         }
     }
 }
 $i = 0;
 $allcat = array();
 /** @var Category $cat */
 foreach ($cats as $cat) {
     $allcat = $cat->get_subcategories($stud_id, $course_code, $session_id);
     $alleval = $cat->get_evaluations($stud_id);
 /**
  * Update the properties of this category in the database
  * @todo fix me
  */
 public function save()
 {
     $tbl_grade_categories = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
     $sql = 'UPDATE ' . $tbl_grade_categories . " SET name = '" . Database::escape_string($this->get_name()) . "'" . ', description = ';
     if (isset($this->description)) {
         $sql .= "'" . Database::escape_string($this->get_description()) . "'";
     } else {
         $sql .= 'null';
     }
     $sql .= ', user_id = ' . intval($this->get_user_id()) . ', course_code = ';
     if (isset($this->course_code)) {
         $sql .= "'" . Database::escape_string($this->get_course_code()) . "'";
     } else {
         $sql .= 'null';
     }
     $sql .= ', parent_id = ';
     if (isset($this->parent)) {
         $sql .= intval($this->get_parent_id());
     } else {
         $sql .= 'null';
     }
     $sql .= ', certif_min_score = ';
     if (isset($this->certificate_min_score) && !empty($this->certificate_min_score)) {
         $sql .= Database::escape_string($this->get_certificate_min_score());
     } else {
         $sql .= 'null';
     }
     if (isset($this->grade_model_id)) {
         $sql .= ', grade_model_id = ' . intval($this->get_grade_model_id());
     }
     $sql .= ', weight = ' . Database::escape_string($this->get_weight()) . ', visible = ' . intval($this->is_visible()) . ' WHERE id = ' . intval($this->id);
     Database::query($sql);
     if (!empty($this->id)) {
         $parent_id = $this->get_parent_id();
         $grade_model_id = $this->get_grade_model_id();
         if ($parent_id == 0) {
             if (isset($grade_model_id) && !empty($grade_model_id) && $grade_model_id != '-1') {
                 $obj = new GradeModel();
                 $components = $obj->get_components($grade_model_id);
                 $default_weight_setting = api_get_setting('gradebook_default_weight');
                 $default_weight = 100;
                 if (isset($default_weight_setting)) {
                     $default_weight = $default_weight_setting;
                 }
                 $final_weight = $this->get_weight();
                 if (!empty($final_weight)) {
                     $default_weight = $this->get_weight();
                 }
                 foreach ($components as $component) {
                     $gradebook = new Gradebook();
                     $params = array();
                     $params['name'] = $component['acronym'];
                     $params['description'] = $component['title'];
                     $params['user_id'] = api_get_user_id();
                     $params['parent_id'] = $this->id;
                     $params['weight'] = $component['percentage'] / 100 * $default_weight;
                     $params['session_id'] = api_get_session_id();
                     $params['course_code'] = $this->get_course_code();
                     $gradebook->save($params);
                 }
             }
         }
     }
     $gradebook = new Gradebook();
     $gradebook->update_skills_to_gradebook($this->id, $this->get_skills(false));
 }
 /**
  * Update the properties of this category in the database
  * @todo fix me
  */
 public function save()
 {
     $em = Database::getManager();
     $gradebookCategory = $em->getRepository('ChamiloCoreBundle:GradebookCategory')->find($this->id);
     if (empty($gradebookCategory)) {
         return false;
     }
     $gradebookCategory->setName($this->name);
     $gradebookCategory->setDescription($this->description);
     $gradebookCategory->setUserId($this->user_id);
     $gradebookCategory->setCourseCode($this->course_code);
     $gradebookCategory->setParentId($this->parent);
     $gradebookCategory->setWeight($this->weight);
     $gradebookCategory->setVisible($this->visible);
     $gradebookCategory->setCertifMinScore($this->certificate_min_score);
     $gradebookCategory->setGenerateCertificates($this->generateCertificates);
     $gradebookCategory->setGradeModelId($this->grade_model_id);
     $gradebookCategory->setIsRequirement($this->isRequirement);
     $em->merge($gradebookCategory);
     $em->flush();
     if (!empty($this->id)) {
         $parent_id = $this->get_parent_id();
         $grade_model_id = $this->get_grade_model_id();
         if ($parent_id == 0) {
             if (isset($grade_model_id) && !empty($grade_model_id) && $grade_model_id != '-1') {
                 $obj = new GradeModel();
                 $components = $obj->get_components($grade_model_id);
                 $default_weight_setting = api_get_setting('gradebook.gradebook_default_weight');
                 $default_weight = 100;
                 if (isset($default_weight_setting)) {
                     $default_weight = $default_weight_setting;
                 }
                 $final_weight = $this->get_weight();
                 if (!empty($final_weight)) {
                     $default_weight = $this->get_weight();
                 }
                 foreach ($components as $component) {
                     $gradebook = new Gradebook();
                     $params = array();
                     $params['name'] = $component['acronym'];
                     $params['description'] = $component['title'];
                     $params['user_id'] = api_get_user_id();
                     $params['parent_id'] = $this->id;
                     $params['weight'] = $component['percentage'] / 100 * $default_weight;
                     $params['session_id'] = api_get_session_id();
                     $params['course_code'] = $this->get_course_code();
                     $gradebook->save($params);
                 }
             }
         }
     }
     $gradebook = new Gradebook();
     $gradebook->update_skills_to_gradebook($this->id, $this->get_skills(false), true);
 }