Ejemplo n.º 1
0
<script>
$(function() {
<?php 
// grid definition see the $career->display() function
echo Display::grid_js('gradebooks', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
?>
});
</script>
<?php 
$gradebook = new Gradebook();
switch ($action) {
    case 'display':
        $gradebook->display();
        break;
    case 'add_skill':
        $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
        $gradebook_info = $gradebook->get($id);
        $url = api_get_self() . '?action=' . $action . '&id=' . $id;
        $form = $gradebook->show_skill_form($id, $url, $gradebook_info['name']);
        if ($form->validate()) {
            $values = $form->exportValues();
            $res = $gradebook->update_skills_to_gradebook($values['id'], $values['skill']);
            if ($res) {
                Display::display_confirmation_message(get_lang('ItemAdded'));
            }
        }
        $form->display();
        //echo Display::tag('h2',$gradebook_info['name']);
        break;
}
Display::display_footer();
Ejemplo n.º 2
0
 /**
  * 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));
 }
Ejemplo n.º 3
0
 /**
  * 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);
 }