diff --git a/main/gradebook/lib/fe/displaygradebook.php b/main/gradebook/lib/fe/displaygradebook.php index 70081f5f84..65ca962ca7 100644 --- a/main/gradebook/lib/fe/displaygradebook.php +++ b/main/gradebook/lib/fe/displaygradebook.php @@ -175,25 +175,12 @@ class DisplayGradebook $header .= ''.Display::return_icon('export_doc.png', get_lang('ExportAsDOC'),'',ICON_SIZE_MEDIUM).''; $header .= ''.Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).''; $header .= ''.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).''; - - //exportpdf - //
- $header .= '
'; - if (!$catobj->get_id() == '0') { - //this is necessary? - //$header .= '
Show Evaluations  '; - //$header .= ''.get_lang('ShowLinks').'
'; - } - /* - if (isset ($_GET['search'])) { - $header .= ''.get_lang('SearchResults').' :'; - }*/ + $header .= ''; echo $header; } function display_header_gradebook_per_gradebook($catobj, $showtree, $selectcat, $is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true) { - - //student + // Student $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); $objcat = new Category(); $course_id = Database::get_course_by_category($selectcat); @@ -218,8 +205,7 @@ class DisplayGradebook $score = $item->calc_score($user_id); $my_score_denom=($score[1]==0) ? 1 : $score[1]; $item_value+=$score[0]/$my_score_denom*$item->get_weight(); - $item_total+=$item->get_weight(); - //$row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT); + $item_total+=$item->get_weight(); } $item_value = number_format($item_value, 2, '.', ' '); $total_score=array($item_value,$item_total); @@ -234,8 +220,8 @@ class DisplayGradebook } Display :: display_normal_message($scoreinfo, false); } - // show navigation tree and buttons? - + + // show navigation tree and buttons? $header = '
'; if (($showtree == '1') || (isset ($_GET['studentoverview']))) { $header .= ''; diff --git a/main/gradebook/lib/fe/evalform.class.php b/main/gradebook/lib/fe/evalform.class.php index c053a89672..c05e59ec91 100644 --- a/main/gradebook/lib/fe/evalform.class.php +++ b/main/gradebook/lib/fe/evalform.class.php @@ -463,9 +463,7 @@ class EvalForm extends FormValidator } } - $global_weight = api_get_setting('gradebook_default_weight'); - - $this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$global_weight.'] '), true, array ( + $this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$all_categories[0]->get_weight().'] '), true, array ( 'size' => '4', 'maxlength' => '5', 'class' => 'span1' diff --git a/main/gradebook/lib/fe/flatviewtable.class.php b/main/gradebook/lib/fe/flatviewtable.class.php index 48af4d8bf0..d36e319eea 100644 --- a/main/gradebook/lib/fe/flatviewtable.class.php +++ b/main/gradebook/lib/fe/flatviewtable.class.php @@ -78,8 +78,7 @@ class FlatViewTable extends SortableTable $show_draw = false; if ($total_users >0 ) { foreach($pre_result as $res) { - $total = $res / ($total_users); - + $total = $res / ($total_users); if ($total != 0) { $show_draw = true; } diff --git a/main/gradebook/lib/fe/linkaddeditform.class.php b/main/gradebook/lib/fe/linkaddeditform.class.php index 6089e57596..2b789290c6 100644 --- a/main/gradebook/lib/fe/linkaddeditform.class.php +++ b/main/gradebook/lib/fe/linkaddeditform.class.php @@ -87,17 +87,12 @@ class LinkAddEditForm extends FormValidator if ($link->get_category_id() == $my_cat->get_id()) { $default_weight = $my_cat->get_weight(); } - } + } } } - - - } - $global_weight = api_get_setting('gradebook_default_weight'); - - $this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$global_weight.'] '), true, array ( + $this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$category_object[0]->get_weight().'] '), true, array ( 'size' => '4', 'maxlength' => '5', 'class' => 'span1' diff --git a/main/gradebook/lib/flatview_data_generator.class.php b/main/gradebook/lib/flatview_data_generator.class.php index 4f0a8fecea..042ab53a67 100644 --- a/main/gradebook/lib/flatview_data_generator.class.php +++ b/main/gradebook/lib/flatview_data_generator.class.php @@ -87,7 +87,7 @@ class FlatViewDataGenerator $session_id = api_get_session_id(); $allcat = $this->category->get_subcategories(null, $course_code, $session_id); foreach ($allcat as $sub_cat) { - $headers[] = Display::url($sub_cat->get_name(), api_get_self().'?selectcat='.$sub_cat->get_id()).'
'.$sub_cat->get_weight().' % '; + $headers[] = Display::url($sub_cat->get_name(), api_get_self().'?selectcat='.$sub_cat->get_id()).' '.$sub_cat->get_weight().' % '; } } else { for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) { @@ -97,18 +97,13 @@ class FlatViewDataGenerator $sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()]; $weight = round($item->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$this->category->get_weight() *100, 2); - $headers[] = $item->get_name().'
'.$weight.' % '; + $headers[] = $item->get_name().' '.$weight.' % '; if ($show_detail) { //$headers[] = $item->get_name().' ('.get_lang('Detail').')'; } } } - - - $headers[] = get_lang('GradebookQualificationTotal').' 100%'; - if ($show_detail) { - //$headers[] = get_lang('GradebookQualificationTotal').' ('.get_lang('Detail').')'; - } + $headers[] = get_lang('GradebookQualificationTotal').' 100%'; return $headers; } @@ -145,8 +140,7 @@ class FlatViewDataGenerator $headers[] = $item->get_name(); } return $headers; - } - + } /** * Get actual array data @@ -217,8 +211,12 @@ class FlatViewDataGenerator $grade_model_id = $this->category->get_grade_model_id(); $parent_id = $this->category->get_parent_id(); - $main_cat = Category::load($parent_id, null, null); - $main_weight = $main_cat[0]->get_weight(); + if ($parent_id == 0) { + $main_weight = $this->category->get_weight(); + } else { + $main_cat = Category::load($parent_id, null, null); + $main_weight = $main_cat[0]->get_weight(); + } $use_grade_model = true; if (empty($grade_model_id) || $grade_model_id == -1) { @@ -233,7 +231,9 @@ class FlatViewDataGenerator $item_value = 0; $item_value_total = 0; - $item_total = 0; + $item_total = 0; + + $convert_using_the_global_weight = false; if ($use_grade_model) { $course_code = api_get_course_id(); @@ -244,26 +244,31 @@ class FlatViewDataGenerator $divide = ( ($score[1])==0 ) ? 1 : $score[1]; $sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()]; - - $item_value = round($score[0]/$divide,2) * 100; + $item_value = round($score[0]/$divide,2) * $main_weight; //Fixing total when using one or multiple gradebooks $percentage = round($sub_cat->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$this->category->get_weight(), 2); $item_value = $percentage*$item_value; $item_total += $sub_cat->get_weight(); - + + if ($convert_using_the_global_weight) { + $score[0] = $main_weight*$score[0]/$sub_cat->get_weight(); + $score[1] = $main_weight ; + } + $temp_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE); - $temp_score = $temp_score; - if (!$show_all) { $row[] = $temp_score.' '; } else { $row[] = $temp_score; - } + } $item_value_total +=$item_value; - } + } + if ($convert_using_the_global_weight) { + //$item_total = $main_weight; + } } else { for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) { $item = $this->evals_links[$count + $items_start]; @@ -287,7 +292,7 @@ class FlatViewDataGenerator //$percentage = round($item->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$this->category->get_weight(), 2); //if ($debug) var_dump($item->get_weight().' '.$item_value .' -'.$sub_cat_percentage); $item_value = $item_value*$item->get_weight(); - $item_value = 100*$item_value/$item->get_weight(); + $item_value = $main_weight*$item_value/$item->get_weight(); } //if ($debug) var_dump($item_value); $item_total += $item->get_weight(); diff --git a/main/gradebook/lib/scoredisplay.class.php b/main/gradebook/lib/scoredisplay.class.php index 7e6a9a41af..dc19a0e607 100644 --- a/main/gradebook/lib/scoredisplay.class.php +++ b/main/gradebook/lib/scoredisplay.class.php @@ -251,8 +251,7 @@ class ScoreDisplay * (only taken into account if custom score display is enabled and for course/platform admin) */ public function display_score($score, $type = SCORE_DIV_PERCENT, $what = SCORE_BOTH, $no_color = false) { - $my_score = ($score==0) ? 1 : $score; - + $my_score = ($score==0) ? 1 : $score; if ($this->custom_enabled && isset($this->custom_display_conv)) { $display = $this->display_default($my_score, $type); } else { @@ -317,8 +316,16 @@ class ScoreDisplay * Returns "100 %" for array("100", "100"); */ private function display_as_percent($score) { - $score_denom=($score[1]==0) ? 1 : $score[1]; - return round(($score[0] / $score_denom) * 100,2) . ' %'; + //Add real weight ugly hack + /*$course_code = api_get_course_id(); + $session_id = api_get_session_id(); + $main_cat = Category :: load(null, null, $course_code, null, null, $session_id, false); + $global_weight = $main_cat[0]->get_weight(); + $extra = $score[0] / $score_denom*$global_weight; + */ + + $score_denom=($score[1]==0) ? 1 : $score[1]; + return round(($score[0] / $score_denom) * 100,2) . ' %'.$extra; } /**