From 178b2763eae048bfc24d464b5ee5d76b7d56d75f Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 6 Feb 2015 11:36:32 +0100 Subject: [PATCH 1/5] Fixes user sorting see BT#9287 --- main/gradebook/lib/fe/flatviewtable.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main/gradebook/lib/fe/flatviewtable.class.php b/main/gradebook/lib/fe/flatviewtable.class.php index 5f4923197c..8e9e394904 100755 --- a/main/gradebook/lib/fe/flatviewtable.class.php +++ b/main/gradebook/lib/fe/flatviewtable.class.php @@ -541,10 +541,13 @@ class FlatViewTable extends SortableTable } // retrieve sorting type + if ($is_western_name_order) { - $users_sorting = ($this->column == 0 ? FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME : FlatViewDataGenerator :: FVDG_SORT_LASTNAME); + //$users_sorting = ($this->column == 0 ? FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME : FlatViewDataGenerator :: FVDG_SORT_LASTNAME); + $users_sorting = FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME; } else { - $users_sorting = ($this->column == 0 ? FlatViewDataGenerator :: FVDG_SORT_LASTNAME : FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME); + //$users_sorting = ($this->column == 0 ? FlatViewDataGenerator :: FVDG_SORT_LASTNAME : FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME); + $users_sorting = FlatViewDataGenerator :: FVDG_SORT_LASTNAME; } if ($this->direction == 'DESC') { $users_sorting |= FlatViewDataGenerator :: FVDG_SORT_DESC; From 9418d8da68d73ab0e9e7b014ddddc88af9c1af3c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 6 Feb 2015 13:58:19 +0100 Subject: [PATCH 2/5] Minor - format code. --- main/gradebook/lib/fe/flatviewtable.class.php | 12 +- .../lib/flatview_data_generator.class.php | 25 ++-- main/template/default/layout/footer.tpl | 134 +++++++++--------- 3 files changed, 89 insertions(+), 82 deletions(-) diff --git a/main/gradebook/lib/fe/flatviewtable.class.php b/main/gradebook/lib/fe/flatviewtable.class.php index 8e9e394904..f9f54f3f18 100755 --- a/main/gradebook/lib/fe/flatviewtable.class.php +++ b/main/gradebook/lib/fe/flatviewtable.class.php @@ -43,6 +43,7 @@ class FlatViewTable extends SortableTable $mainCourseCategory = null ) { parent :: __construct('flatviewlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 1 : 0); + $this->selectcat = $selectcat; $this->datagen = new FlatViewDataGenerator( @@ -558,16 +559,15 @@ class FlatViewTable extends SortableTable $header_names = $this->datagen->get_header_names($this->offset, $selectlimit); - $column = 0; - if ($is_western_name_order) { - $this->set_header($column++, $header_names[1]); - $this->set_header($column++, $header_names[0]); + $this->set_header(0, $header_names[1]); + $this->set_header(1, $header_names[0]); } else { - $this->set_header($column++, $header_names[0]); - $this->set_header($column++, $header_names[1]); + $this->set_header(0, $header_names[0]); + $this->set_header(1, $header_names[1]); } + $column = 2; while ($column < count($header_names)) { $this->set_header($column, $header_names[$column], false); $column++; diff --git a/main/gradebook/lib/flatview_data_generator.class.php b/main/gradebook/lib/flatview_data_generator.class.php index 736411a315..405d518b65 100755 --- a/main/gradebook/lib/flatview_data_generator.class.php +++ b/main/gradebook/lib/flatview_data_generator.class.php @@ -157,9 +157,11 @@ class FlatViewDataGenerator $session_id, 'ORDER BY id' ); + $evaluationsAdded = array(); if ($parent_id == 0 && !empty($allcat)) { // Means there are any subcategory + foreach ($allcat as $sub_cat) { $sub_cat_weight = round(100 * $sub_cat->get_weight() / $main_weight, 1); $add_weight = " $sub_cat_weight %"; @@ -216,7 +218,8 @@ class FlatViewDataGenerator $max = $score[0]; } } - return $max ; + + return $max; } /** @@ -389,7 +392,12 @@ class FlatViewDataGenerator $course_code = api_get_course_id(); $session_id = api_get_session_id(); - $allcat = $this->category->get_subcategories(null, $course_code, $session_id, 'ORDER BY id'); + $allcat = $this->category->get_subcategories( + null, + $course_code, + $session_id, + 'ORDER BY id' + ); $evaluationsAdded = array(); @@ -400,7 +408,7 @@ class FlatViewDataGenerator $real_score = $score; - $divide = ( ($score[1])==0 ) ? 1 : $score[1]; + $divide = $score[1] == 0 ? 1 : $score[1]; $sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()]; $item_value = $score[0]/$divide*$main_weight; @@ -410,10 +418,10 @@ class FlatViewDataGenerator $item_value = $percentage*$item_value; $item_total += $sub_cat->get_weight(); /* - if ($convert_using_the_global_weight) { - $score[0] = $score[0]/$main_weight*$sub_cat->get_weight(); - $score[1] = $main_weight ; - } + if ($convert_using_the_global_weight) { + $score[0] = $score[0]/$main_weight*$sub_cat->get_weight(); + $score[1] = $main_weight ; + } */ if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') { //if (true) @@ -427,8 +435,7 @@ class FlatViewDataGenerator } if (!isset($this->params['only_total_category']) || - (isset($this->params['only_total_category']) && - $this->params['only_total_category'] == false) + (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false) ) { if (!$show_all) { $row[] = $temp_score.' '; diff --git a/main/template/default/layout/footer.tpl b/main/template/default/layout/footer.tpl index 68d0da030f..d3fdb29c11 100755 --- a/main/template/default/layout/footer.tpl +++ b/main/template/default/layout/footer.tpl @@ -20,7 +20,7 @@ {{ plugin_footer_left }} {% endif %} -   +   {% endif %} -   +