diff --git a/main/gradebook/gradebook_flatview.php b/main/gradebook/gradebook_flatview.php index ff6eb46d43..2ea1e7e23a 100755 --- a/main/gradebook/gradebook_flatview.php +++ b/main/gradebook/gradebook_flatview.php @@ -262,6 +262,8 @@ if (!empty($_POST['export_report']) && $_POST['export_report'] == 'export_report require_once 'gradebook_result.class.php'; $printable_data = get_printable_data($users, $alleval, $alllinks); + + //exit; switch($_POST['export_format']) { case 'xls': diff --git a/main/gradebook/lib/fe/flatviewtable.class.php b/main/gradebook/lib/fe/flatviewtable.class.php index c2bfb24a26..1793d67242 100755 --- a/main/gradebook/lib/fe/flatviewtable.class.php +++ b/main/gradebook/lib/fe/flatviewtable.class.php @@ -24,6 +24,7 @@ class FlatViewTable extends SortableTable function FlatViewTable ($selectcat, $users= array (), $evals= array (), $links= array (), $limit_enabled = false, $offset = 0, $addparams = null) { parent :: __construct ('flatviewlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 1 : 0); $this->datagen = new FlatViewDataGenerator($users, $evals, $links); + $this->selectcat = $selectcat; $this->limit_enabled = $limit_enabled; $this->offset = $offset; diff --git a/main/gradebook/lib/flatview_data_generator.class.php b/main/gradebook/lib/flatview_data_generator.class.php index 5188606cab..5314c4eba3 100755 --- a/main/gradebook/lib/flatview_data_generator.class.php +++ b/main/gradebook/lib/flatview_data_generator.class.php @@ -48,20 +48,25 @@ class FlatViewDataGenerator /** * Get array containing column header names (incl user columns) */ - public function get_header_names ($items_start = 0, $items_count = null) { + public function get_header_names ($items_start = 0, $items_count = null , $show_detail = false) { $headers = array(); $headers[] = get_lang('LastName'); $headers[] = get_lang('FirstName'); if (!isset($items_count)) { $items_count = count($this->evals_links) - $items_start; } - for ($count=0; - ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); - $count++) { + for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) { $item = $this->evals_links [$count + $items_start]; $headers[] = $item->get_name(); + if ($show_detail == true) { + $headers[] = $item->get_name().' ('.get_lang('Detail').')'; + } } + $headers[] = get_lang('GradebookQualificationTotal'); + if ($show_detail == true) { + $headers[] = get_lang('GradebookQualificationTotal').' ('.get_lang('Detail').')'; + } return $headers; } @@ -91,10 +96,9 @@ class FlatViewDataGenerator * 2: user firstname * 3+: evaluation/link scores */ - public function get_data ($users_sorting = 0, - $users_start = 0, $users_count = null, + public function get_data ($users_sorting = 0, $users_start = 0, $users_count = null, $items_start = 0, $items_count = null, - $ignore_score_color = false) { + $ignore_score_color = false, $show_all = false) { // do some checks on users/items counts, redefine if invalid values if (!isset($users_count)) { $users_count = count ($this->users) - $users_start; @@ -120,9 +124,11 @@ class FlatViewDataGenerator } elseif ($users_sorting & self :: FVDG_SORT_FIRSTNAME) { usort($usertable, array ('FlatViewDataGenerator','sort_by_first_name')); } + if ($users_sorting & self :: FVDG_SORT_DESC) { $usertable = array_reverse($usertable); } + // select the requested users $selected_users = array_slice($usertable, $users_start, $users_count); // generate actual data array @@ -144,22 +150,30 @@ class FlatViewDataGenerator $item_value=0; $item_total=0; - for ($count=0; - ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); - $count++) { + for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) { $item = $this->evals_links [$count + $items_start]; $score = $item->calc_score($user[0]); $divide=( ($score[1])==0 ) ? 1 : $score[1]; $item_value+=round($score[0]/$divide*$item->get_weight(),2); $item_total+=$item->get_weight(); - $row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT); + if ($show_all == false) { + $row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT); + } else { + $row[] = $scoredisplay->display_score($score, SCORE_DECIMAL); + $row[] = $scoredisplay->display_score($score, SCORE_DIV_PERCENT); + } } + $total_score=array($item_value,$item_total); - $row[] = $scoredisplay->display_score($total_score,SCORE_DIV_PERCENT); - + if ($show_all == false) { + $row[] = $scoredisplay->display_score($total_score,SCORE_DIV_PERCENT); + } else { + $row[] = $scoredisplay->display_score($total_score,SCORE_DECIMAL); + $row[] = $scoredisplay->display_score($total_score,SCORE_DIV_PERCENT); + } unset($score); - $data[] = $row; - } + $data[] = $row; + } return $data; } diff --git a/main/gradebook/lib/gradebook_functions.inc.php b/main/gradebook/lib/gradebook_functions.inc.php index c9d31a0416..15cecc950a 100755 --- a/main/gradebook/lib/gradebook_functions.inc.php +++ b/main/gradebook/lib/gradebook_functions.inc.php @@ -302,8 +302,9 @@ function get_printable_data($users,$alleval, $alllinks) { $datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks); $offset = isset($_GET['offset']) ? $_GET['offset'] : '0'; $count = (($offset + 10) > $datagen->get_total_items_count()) ? ($datagen->get_total_items_count() - $offset) : 10; - $header_names = $datagen->get_header_names($offset, $count); - $data_array = $datagen->get_data(FlatViewDataGenerator :: FVDG_SORT_LASTNAME, 0, null, $offset, $count, true); + $header_names = $datagen->get_header_names($offset, $count, true); + $data_array = $datagen->get_data(FlatViewDataGenerator :: FVDG_SORT_LASTNAME, 0, null, $offset, $count, true,true); + $newarray = array(); foreach ($data_array as $data) { $newarray[] = array_slice($data, 1); diff --git a/main/gradebook/lib/scoredisplay.class.php b/main/gradebook/lib/scoredisplay.class.php index 6934a481c1..d4dca8a46d 100755 --- a/main/gradebook/lib/scoredisplay.class.php +++ b/main/gradebook/lib/scoredisplay.class.php @@ -5,6 +5,8 @@ define('SCORE_DIV',1); define('SCORE_PERCENT',2); define('SCORE_DIV_PERCENT',3); define('SCORE_AVERAGE',4); + +define('SCORE_DECIMAL',5); define('SCORE_IGNORE_SPLIT', 8); define('SCORE_BOTH',1); define('SCORE_ONLY_DEFAULT',2); @@ -233,11 +235,14 @@ class ScoreDisplay * @param int $what one of the following constants: SCORE_BOTH, SCORE_ONLY_DEFAULT, SCORE_ONLY_CUSTOM (default: SCORE_BOTH) * (only taken into account if custom score display is enabled and for course/platform admin) */ - public function display_score($score,$type,$what = SCORE_BOTH) { - $type2 = $type & 7; // removes the 'SCORE_IGNORE_SPLIT' bit + public function display_score($score,$type, $what = SCORE_BOTH) { + + $type2 = $type & 7; // removes the 'SCORE_IGNORE_SPLIT' bit $split_enabled = ($type2 == $type); + $my_score=($score==0) ? 1 : $score; - if ($this->custom_enabled && isset($this->custom_display_conv)) { + + if ($this->custom_enabled && isset($this->custom_display_conv)) { // students only see the custom display if (!api_is_allowed_to_create_course()) { $display = $this->display_custom($my_score); @@ -254,8 +259,8 @@ class ScoreDisplay $display.= ' ('.$this->display_custom ($my_score).')'; } - } else { - // if no custom display set, use default display + } else { + // if no custom display set, use default display $display = $this->display_default ($my_score, $type2); } return (($split_enabled ? $this->get_color_display_start_tag($my_score) : '') @@ -278,9 +283,17 @@ class ScoreDisplay case SCORE_AVERAGE : // XX % return $this->display_as_percent($score); + + case SCORE_DECIMAL : // 0.50 (X/Y) + return $this->display_as_decimal($score); + } } - + + private function display_as_decimal($score) { + $score_denom=($score[1]==0) ? 1 : $score[1]; + return round(($score[0]/ $score_denom),2); + } private function display_as_percent ($score) { $score_denom=($score[1]==0) ? 1 : $score[1]; return round(($score[0] / $score_denom) * 100,2) . ' %';