Fix coloring and graph see BT#12812

pull/2487/head
jmontoyaa 8 years ago
parent b882339875
commit 831b496e71
  1. 2
      main/gradebook/lib/fe/flatviewtable.class.php
  2. 47
      main/gradebook/lib/flatview_data_generator.class.php
  3. 6
      main/gradebook/lib/scoredisplay.class.php

@ -106,7 +106,6 @@ class FlatViewTable extends SortableTable
$user_results = $this->datagen->get_data_to_graph2(false);
//if (empty($this->datagen->get_total_items_count()) || empty($total_users)) {
if (empty($user_results) || empty($total_users)) {
echo get_lang('NoResults');
return '';
@ -160,6 +159,7 @@ class FlatViewTable extends SortableTable
}
}
//fixing $resource_list
$max = 0;
$new_list = array();

@ -356,8 +356,7 @@ class FlatViewDataGenerator
$parent_id = $this->category->get_parent_id();
if (
$parent_id == 0 ||
if ($parent_id == 0 ||
(isset($this->params['only_subcat']) && $this->params['only_subcat'] == $this->category->get_id())
) {
$main_weight = $this->category->get_weight();
@ -388,7 +387,9 @@ class FlatViewDataGenerator
}
// Official code
if (isset($this->params['show_official_code']) && $this->params['show_official_code']) {
if (isset($this->params['show_official_code']) &&
$this->params['show_official_code']
) {
if ($export_to_pdf) {
$row['official_code'] = $user[4];
} else {
@ -430,9 +431,7 @@ class FlatViewDataGenerator
$item_value = 0;
$item_value_total = 0;
$item_total = 0;
$convert_using_the_global_weight = true;
$course_code = api_get_course_id();
$session_id = api_get_session_id();
$allcat = $this->category->get_subcategories(
@ -443,7 +442,6 @@ class FlatViewDataGenerator
);
$evaluationsAdded = array();
if ($parent_id == 0 && !empty($allcat)) {
/** @var Category $sub_cat */
foreach ($allcat as $sub_cat) {
@ -489,13 +487,13 @@ class FlatViewDataGenerator
$score[1] = $main_weight ;
}
*/
if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') {
$real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE);
$temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM);
if (api_get_setting('gradebook_show_percentage_in_reports') === 'false') {
$real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE, true);
$temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM, null);
$temp_score = Display::tip($real_score, $temp_score);
} else {
$real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
$temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM);
$temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM, null);
$temp_score = Display::tip($temp_score, $real_score);
}
@ -559,7 +557,6 @@ class FlatViewDataGenerator
$item_total += $result['item_total'];
$item_value_total += $result['item_value_total'];
$total_score = array($item_value_total, $item_total);
if (!$show_all) {
@ -570,9 +567,15 @@ class FlatViewDataGenerator
}
} else {
if ($export_to_pdf) {
$row['total'] = $scoredisplay->display_score($total_score, SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS);
$row['total'] = $scoredisplay->display_score(
$total_score,
SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS
);
} else {
$row[] = $scoredisplay->display_score($total_score, SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS);
$row[] = $scoredisplay->display_score(
$total_score,
SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS
);
}
}
unset($score);
@ -634,7 +637,6 @@ class FlatViewDataGenerator
// Sub cat weight
//$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
$item_value = isset($score[0]) ? $score[0] / $divide : 0;
// Fixing total when using one or multiple gradebooks.
@ -653,11 +655,7 @@ class FlatViewDataGenerator
}
$item_total += $item->get_weight();
$complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
//$temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);
//$temp_score = Display::tip($temp_score, $complete_score);
if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') {
$real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE);
$temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM);
@ -823,6 +821,8 @@ class FlatViewDataGenerator
*/
public function get_data_to_graph2($displayWarning = true)
{
$course_code = api_get_course_id();
$session_id = api_get_session_id();
// do some checks on users/items counts, redefine if invalid values
$usertable = array();
foreach ($this->users as $user) {
@ -843,12 +843,13 @@ class FlatViewDataGenerator
$final_score = 0;
$item_value_total = 0;
$convert_using_the_global_weight = true;
$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'
);
$parent_id = $this->category->get_parent_id();
if ($parent_id == 0 && !empty($allcat)) {
foreach ($allcat as $sub_cat) {
$score = $sub_cat->calc_score($user[0]);

@ -293,6 +293,7 @@ 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)
* @param bool $disableColor
*
* @return string
*/
@ -300,7 +301,7 @@ class ScoreDisplay
$score,
$type = SCORE_DIV_PERCENT,
$what = SCORE_BOTH,
$no_color = false
$disableColor = false
) {
$my_score = $score == 0 ? 1 : $score;
@ -321,10 +322,9 @@ class ScoreDisplay
// if no custom display set, use default display
$display = $this->display_default($my_score, $type);
}
if ($this->coloring_enabled && $no_color != false) {
if ($this->coloring_enabled && $disableColor == false) {
$my_score_denom = isset($score[1]) && !empty($score[1]) && $score[1] > 0 ? $score[1] : 1;
$scoreCleaned = isset($score[0]) ? $score[0] : 0;
if (($scoreCleaned / $my_score_denom) < ($this->color_split_value / 100)) {
$display = Display::tag(
'font',

Loading…
Cancel
Save