Fixing bug when adding a new gradebook dir see BT#2849

skala
Julio Montoya 14 years ago
parent 4d67a9f102
commit 4d48039ede
  1. 2
      main/gradebook/exercise_jump.php
  2. 2
      main/gradebook/gradebook_add_cat.php
  3. 17
      main/gradebook/index.php
  4. 17
      main/gradebook/lib/be/category.class.php
  5. 19
      main/gradebook/lib/fe/catform.class.php

@ -29,7 +29,7 @@ $_course['name'] = $course_title;
$_course['official_code'] = $course_code;
if (isset($_GET['doexercise'])) {
header('Location: ../exercice/exercise_submit.php?cidReq='.$cidReq.'&gradebook='.$gradebook.'&origin=&learnpath_id=&learnpath_item_id=&exerciseId='.Security::remove_XSS($_GET['doexercise']));
header('Location: ../exercice/overview.php?cidReq='.$cidReq.'&gradebook='.$gradebook.'&origin=&learnpath_id=&learnpath_item_id=&exerciseId='.intval($_GET['doexercise']));
exit;
} else {
if (isset($_GET['gradebook'])) {

@ -67,7 +67,7 @@ if ($form->validate()) {
$visible = 1;
}
$cat->set_visible($visible);
$cat->add();
$result = $cat->add();
header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?addcat=&selectcat=' . $cat->get_parent_id());
exit;
}

@ -310,8 +310,10 @@ if (isset ($_GET['visiblelink'])) {
$visibility_command= 0;
}
$link= LinkFactory :: load($_GET['visiblelink']);
$link[0]->set_visible($visibility_command);
$link[0]->save();
if (isset($link) && isset($link[0])) {
$link[0]->set_visible($visibility_command);
$link[0]->save();
}
unset ($link);
if ($visibility_command) {
$confirmation_message = get_lang('ViMod');
@ -793,11 +795,7 @@ if ($first_time==1 && api_is_allowed_to_edit(null,true)) {
$alllink = $cat->get_links($stud_id);
if ($cat->get_parent_id() != 0 ) {
/*echo Display::tag('h2', $cat->get_name().' ( '.$items[$i]['percentage'].') ');
DisplayGradebook::display_header_gradebook_per_gradebook($cat, 0, $cat->get_id(), $is_course_admin, $is_platform_admin, $simple_search_form, false, true);
$gradebooktable = new GradebookTable($cat, $allcat, $alleval,$alllink, $addparams);
$gradebooktable->display();*/
$i++;
} else {
//This is the father
@ -813,9 +811,8 @@ if ($first_time==1 && api_is_allowed_to_edit(null,true)) {
}
$gradebooktable = new GradebookTable($cat, $allcat, $alleval, $alllink, $addparams);
$gradebooktable->display();
//DisplayGradebook :: display_reduce_header_gradebook($cat,$is_course_admin, $is_platform_admin, $simple_search_form, false, false);
$gradebooktable->display();
//
}
}
}

@ -242,10 +242,12 @@ class Category implements GradebookItem
if ( isset($this->name) && '-1'==$this->name) {
return false;
}
if (isset($this->name) && isset($this->user_id) && isset($this->weight) && isset($this->visible)) {
if (isset($this->name) && isset($this->user_id)) {
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'INSERT INTO '.$tbl_grade_categories
.' (name,user_id,weight,visible';
$sql = 'INSERT INTO '.$tbl_grade_categories.' (name,user_id,weight,visible';
if (isset($this->description)) {
$sql .= ',description';
}
@ -274,12 +276,11 @@ class Category implements GradebookItem
if (!empty($this->session_id)) {
$sql .= ', '.intval($this->get_session_id());
}
$sql .= ')';
$sql .= ')';
Database::query($sql);
$this->set_id(Database::insert_id());
} else {
die('Error in Category add: required field empty');
$id = Database::insert_id();
$this->set_id($id);
return $id;
}
}
/**

@ -131,8 +131,8 @@ class CatForm extends FormValidator {
private function build_basic_form() {
$this->addElement('hidden', 'zero', 0);
$this->add_textfield('name', get_lang('CategoryName'),true,array('size'=>'54','maxlength'=>'50'));
$this->add_textfield('name', get_lang('CategoryName'), true,array('size'=>'54','maxlength'=>'50'));
$this->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
$models = api_get_settings_options('grading_model');
$course_grading_model_id = api_get_course_setting('course_grading_model');
$grading_model = '';
@ -145,6 +145,7 @@ class CatForm extends FormValidator {
}
$grading_contents = api_grading_model_functions($grading_model, 'to_array');
if (!empty($grading_contents)) {
$course_code = api_get_course_id();
@ -153,15 +154,23 @@ class CatForm extends FormValidator {
///direct access to one evaluation
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init
$count = count($cats) - 1;
$value = intval($grading_contents['items'][$count]['percentage']);
$this->add_textfield('weight', get_lang('TotalWeight'),true,array('value'=>$value,'size'=>'4','maxlength'=>'5'));
$value = intval($grading_contents['items'][$count]['percentage']);
$this->add_textfield('weight', get_lang('TotalWeight'),true,array('value'=>$value,'size'=>'4','maxlength'=>'5'));
//$this->addRule('weight',get_lang('ThisFieldIsRequired'),'required');
$this->freeze('weight');
}
} else {
$this->add_textfield('weight', get_lang('TotalWeight'),true,array('value'=>$value,'size'=>'4','maxlength'=>'5'));
$this->addRule('weight',get_lang('ThisFieldIsRequired'),'required');
}
$this->addElement('static', null, null, '<i>'.get_lang('TotalSumOfWeights').'</i>');
$this->add_textfield('certif_min_score', get_lang('CertificateMinScore'),false,array('size'=>'4','maxlength'=>'5'));
$this->addRule('certif_min_score', get_lang('ThisFieldIsRequired'), 'required');
$this->addElement('hidden','hid_user_id');
$this->addElement('hidden','hid_parent_id');
$this->addElement('textarea', 'description', get_lang('Description'),array('rows'=>'3','cols' => '34'));

Loading…
Cancel
Save