Should fix bugs in gradebook due recent see #4685

skala
Julio Montoya 13 years ago
parent 44c32c9e69
commit 9113ede12b
  1. 18
      main/gradebook/gradebook_edit_eval.php
  2. 15
      main/gradebook/gradebook_edit_link.php
  3. 15
      main/gradebook/lib/fe/evalform.class.php
  4. 16
      main/gradebook/lib/fe/gradebooktable.class.php
  5. 14
      main/gradebook/lib/fe/linkaddeditform.class.php
  6. 42
      main/gradebook/lib/gradebook_functions.inc.php

@ -27,13 +27,19 @@ if ($form->validate()) {
$eval->set_user_id($values['hid_user_id']);
$eval->set_course_code($values['hid_course_code']);
$eval->set_category_id($values['hid_category_id']);
$parent_cat = Category :: load($values['hid_category_id']);
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0] -> get_weight();
$values['weight'] = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
$eval->set_weight($values['weight']);
$parent_cat = Category :: load($values['hid_category_id']);
$final_weight = null;
if ($parent_cat[0]->get_parent_id() == 0) {
$final_weight = $values['weight_mask'];
} else {
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0]->get_weight();
$final_weight = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
}
$eval->set_weight($final_weight);
$eval->set_max($values['max']);
if (empty ($values['visible'])) {

@ -34,10 +34,17 @@ $form = new LinkAddEditForm(LinkAddEditForm :: TYPE_EDIT, $cats, null, $link, 'e
if ($form->validate()) {
$values = $form->exportValues();
$parent_cat = Category :: load($values['select_gradebook']);
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0]->get_weight();
$values['weight'] = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
$link->set_weight($values['weight']);
$final_weight = null;
if ($parent_cat[0]->get_parent_id() == 0) {
$final_weight = $values['weight_mask'];
} else {
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0]->get_weight();
$final_weight = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
}
$link->set_weight($final_weight);
if (!empty($values['select_gradebook'])) {
$link->set_category_id($values['select_gradebook']);

@ -172,7 +172,7 @@ class EvalForm extends FormValidator
}
usort($results_and_users, array ('EvalForm', 'sort_by_user'));
$defaults= array ();
$defaults = array();
foreach ($results_and_users as $result_and_user) {
$user = $result_and_user['user'];
@ -383,10 +383,13 @@ class EvalForm extends FormValidator
*/
protected function build_editing_form() {
$parent_cat = Category :: load($this->evaluation_object->get_category_id());
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0]->get_weight();
//$values['weight'] = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight();
$weight_mask = $global_weight*$this->evaluation_object->get_weight()/$parent_cat[0]->get_weight() ;
if ($parent_cat[0]->get_parent_id() == 0) {
$weight_mask = $this->evaluation_object->get_weight();
} else {
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0]->get_weight();
$weight_mask = $global_weight*$this->evaluation_object->get_weight()/$parent_cat[0]->get_weight() ;
}
$this->setDefaults(array ( 'hid_id' => $this->evaluation_object->get_id(),
'name' => $this->evaluation_object->get_name(),
@ -434,7 +437,7 @@ class EvalForm extends FormValidator
if (count($all_categories) == 1) {
$this->addElement('hidden', 'hid_category_id', $cat_id);
} else {
} else {
$select_gradebook = $this->addElement('select', 'hid_category_id', get_lang('SelectGradebook'), array(), array('id' => 'hid_category_id'));
$this->addRule('hid_category_id', get_lang('ThisFieldIsRequired'), 'nonzero');

@ -215,13 +215,17 @@ class GradebookTable extends SortableTable {
$row[] = $this->build_edit_column($item);
}
} else {
//students get the results and certificates columns
if (count($this->evals_links)>0 && $status_user!=1 ) {
$value_data = isset($data[4]) ? $data[4] : null;
if (!is_null($value_data)) {
//students get the results and certificates columns
if (count($this->evals_links) > 0 && $status_user != 1) {
$value_data = isset($data[4]) ? $data[4] : null;
if (!is_null($value_data)) {
$row[] = Display::tag('h4', $value_data);
}
}
} else {
$row[] = $this->build_edit_column($item);
}
} else {
$row[] = $this->build_edit_column($item);
}
}
//Category added

@ -112,12 +112,16 @@ class LinkAddEditForm extends FormValidator
$this->addRule('weight_mask',get_lang('OnlyNumbers'),'numeric');
$this->addRule(array ('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
if ($form_type == self :: TYPE_EDIT) {
$parent_cat = Category :: load($link->get_category_id());
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0]->get_weight();
$parent_cat = Category :: load($link->get_category_id());
$values['weight'] = $link->get_weight()/$parent_cat[0]->get_weight()*$global_weight;
//$defaults['weight'] = $link->get_weight();
if ($parent_cat[0]->get_parent_id() == 0) {
$values['weight'] = $link->get_weight();
} else {
$cat = Category :: load($parent_cat[0]->get_parent_id());
$global_weight = $cat[0]->get_weight();
$values['weight'] = $link->get_weight()/$parent_cat[0]->get_weight()*$global_weight;
}
$defaults['weight_mask'] = $values['weight'] ;
$defaults['select_gradebook'] = $link->get_category_id();

@ -207,26 +207,27 @@ function build_edit_icons_cat($cat, $selectcat) {
$modify_icons .= '<a class="view_children" data-cat-id="'.$cat->get_id().'" href="javascript:void(0);">'.Display::return_icon('view_more_stats.gif', get_lang('Show'),'',ICON_SIZE_SMALL).'</a>';
if (empty($grade_model_id) || $grade_model_id == -1) {
$modify_icons .= '<a href="gradebook_edit_cat.php?editcat='.$cat->get_id().'&amp;cidReq='.$cat->get_course_code().'">'.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'</a>';
if (api_is_allowed_to_edit(null, true)) {
if (empty($grade_model_id) || $grade_model_id == -1) {
$modify_icons .= '<a href="gradebook_edit_cat.php?editcat='.$cat->get_id().'&amp;cidReq='.$cat->get_course_code().'">'.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'</a>';
}
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?visiblecat=' . $cat->get_id() . '&amp;' . $visibility_command . '=&amp;selectcat=' . $selectcat . ' ">'.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_SMALL).'</a>';
//no move ability for root categories
if ($cat->is_movable()) {
/*$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?movecat=' . $cat->get_id() . '&amp;selectcat=' . $selectcat . ' &amp;cidReq='.$cat->get_course_code().'">
<img src="../img/icons/22/move.png" border="0" title="' . get_lang('Move') . '" alt="" /></a>';*/
} else {
//$modify_icons .= '&nbsp;<img src="../img/deplacer_fichier_na.gif" border="0" title="' . get_lang('Move') . '" alt="" />';
}
if (empty($grade_model_id) || $grade_model_id == -1) {
/*$modify_icons .= ' <a href="gradebook_edit_all.php?id_session='.api_get_session_id().'&amp;cidReq='.$cat->get_course_code().'&selectcat=' . $cat->get_id() . '"> '.
Display::return_icon('percentage.png', get_lang('EditAllWeights'),'',ICON_SIZE_SMALL).' </a>'; */
}
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deletecat=' . $cat->get_id() . '&amp;selectcat=' . $selectcat . '&amp;cidReq='.$cat->get_course_code().'" onclick="return confirmation();">'.Display::return_icon('delete.png', get_lang('DeleteAll'),'',ICON_SIZE_SMALL).'</a>';
}
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?visiblecat=' . $cat->get_id() . '&amp;' . $visibility_command . '=&amp;selectcat=' . $selectcat . ' ">'.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_SMALL).'</a>';
//no move ability for root categories
if ($cat->is_movable()) {
/*$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?movecat=' . $cat->get_id() . '&amp;selectcat=' . $selectcat . ' &amp;cidReq='.$cat->get_course_code().'">
<img src="../img/icons/22/move.png" border="0" title="' . get_lang('Move') . '" alt="" /></a>';*/
} else {
//$modify_icons .= '&nbsp;<img src="../img/deplacer_fichier_na.gif" border="0" title="' . get_lang('Move') . '" alt="" />';
}
if (empty($grade_model_id) || $grade_model_id == -1) {
/*$modify_icons .= ' <a href="gradebook_edit_all.php?id_session='.api_get_session_id().'&amp;cidReq='.$cat->get_course_code().'&selectcat=' . $cat->get_id() . '"> '.
Display::return_icon('percentage.png', get_lang('EditAllWeights'),'',ICON_SIZE_SMALL).' </a>'; */
}
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deletecat=' . $cat->get_id() . '&amp;selectcat=' . $selectcat . '&amp;cidReq='.$cat->get_course_code().'" onclick="return confirmation();">'.Display::return_icon('delete.png', get_lang('DeleteAll'),'',ICON_SIZE_SMALL).'</a>';
return $modify_icons;
}
@ -242,7 +243,8 @@ function build_edit_icons_eval($eval, $selectcat) {
$eval->get_course_code();
$cat=new Category();
$message_eval=$cat->show_message_resource_delete($eval->get_course_code());
if ($message_eval===false) {
if ($message_eval===false && api_is_allowed_to_edit(null, true)) {
$visibility_icon= ($eval->is_visible() == 0) ? 'invisible' : 'visible';
$visibility_command= ($eval->is_visible() == 0) ? 'set_visible' : 'set_invisible';
$modify_icons= '<a href="gradebook_edit_eval.php?editeval=' . $eval->get_id() . ' &amp;cidReq='.$eval->get_course_code().'">

Loading…
Cancel
Save