Avoid the warnings and when the max is integer show in the axis only integer values - refs #6876

1.9.x
Francis Gonzales 11 years ago
parent 8e905670c4
commit 8d5db145e3
  1. 18
      main/gradebook/lib/fe/flatviewtable.class.php
  2. 11
      main/gradebook/lib/flatview_data_generator.class.php

@ -184,9 +184,9 @@ class FlatViewTable extends SortableTable
if (is_array($customdisplays) && count(($customdisplays))) {
$user_results = $this->datagen->get_data_to_graph2();
$user_results = $this->datagen->get_data_to_graph2(false);
$pre_result = $new_result = array();
$DataSet = new pData();
$DataSet = new pData();
//filling the Dataset
foreach ($user_results as $result) {
//print_r($result);
@ -266,7 +266,7 @@ class FlatViewTable extends SortableTable
// the graph id
$gradebook_id = intval($_GET['selectcat']);
$graph_id = api_get_user_id() . 'ByResource' . $gradebook_id . api_get_course_id() . api_get_session_id();
if ($show_draw) {
//if ($Cache->IsInCache($graph_id, $DataSet->GetData())) {
if (0) {
@ -283,12 +283,12 @@ class FlatViewTable extends SortableTable
// Adding the color schemma
$Test->loadColorPalette(api_get_path(LIBRARY_PATH) . "pchart/palette/pastel.txt");
// set font of the axes
$Test->setFontProperties(api_get_path(LIBRARY_PATH) . "pchart/fonts/tahoma.ttf", 8);
$area_graph_w = $chart_size_w - 130;
$Test->setGraphArea(50, 30, $area_graph_w, $chart_size_h - 50);
$Test->drawFilledRoundedRectangle(5, 5, $chart_size_w - 1, $chart_size_h - 20, 5, 240, 240, 240);
//$Test->drawRoundedRectangle(5,5,790,330,5,230,230,230);
//background color area & stripe or not
@ -296,9 +296,13 @@ class FlatViewTable extends SortableTable
//Setting max height by default see #3296
if (!empty($max)) {
$Test->setFixedScale(0, $max);
if (is_int($max)) {
$Test->setFixedScale(0, $max + 1, $max + 1);
} else {
$Test->setFixedScale(0, $max);
}
}
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALLSTART0, 150, 150, 150, TRUE, 0, 1, FALSE);
//background grid

@ -524,7 +524,12 @@ class FlatViewDataGenerator
return $data;
}
public function get_data_to_graph2 () {
/**
* This is a function to show the generated data
* @param type $displayWarning
* @return array
*/
public function get_data_to_graph2 ($displayWarning = true) {
// do some checks on users/items counts, redefine if invalid values
$usertable = array ();
foreach ($this->users as $user) {
@ -593,7 +598,9 @@ class FlatViewDataGenerator
}
$total_score=array($item_value,$item_total);
$score_final = ($item_value / $item_total) * 100;
Display::display_warning_message( Display::display_warning_message($total_score[1]));
if ($displayWarning) {
Display::display_warning_message( Display::display_warning_message($total_score[1]));
}
$row[] =array ($score_final, trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true)));
}

Loading…
Cancel
Save