Fix gradebook general view see BT#9428

1.10.x
Julio Montoya 10 years ago
parent 07dcafb2b0
commit a6e6160cbb
  1. 2
      main/gradebook/gradebook_flatview.php
  2. 44
      main/gradebook/lib/fe/flatviewtable.class.php
  3. 60
      main/gradebook/lib/flatview_data_generator.class.php
  4. 1
      main/inc/lib/pear/HTML/Table.php
  5. 87
      main/inc/lib/pear/HTML/Table/Storage.php

@ -121,6 +121,8 @@ $flatviewtable = new FlatViewTable(
$mainCourseCategory[0]
);
$flatviewtable->setAutoFill(false);
$parameters = array('selectcat' => intval($_GET['selectcat']));
$flatviewtable->set_additional_parameters($parameters);

@ -3,9 +3,9 @@
set_time_limit(0);
use CpChart\Classes\pCache as pCache;
use CpChart\Classes\pData as pData;
use CpChart\Classes\pImage as pImage;
use CpChart\Classes\pCache as pCache;
/**
* Class FlatViewTable
@ -395,12 +395,43 @@ class FlatViewTable extends SortableTable
// step 1: generate columns: evaluations and links
$header_names = $this->datagen->get_header_names($this->offset, $selectlimit);
$this->set_header(0, $header_names[0]);
$this->set_header(1, $header_names[1]);
$userRowSpan = false;
foreach ($header_names as $item) {
if (is_array($item)) {
$userRowSpan = true;
break;
}
}
$thAttributes = '';
if ($userRowSpan) {
$thAttributes = 'rowspan=2';
}
$this->set_header(0, $header_names[0], true, $thAttributes);
$this->set_header(1, $header_names[1], true, $thAttributes);
$column = 2;
$firstHeader = [];
while ($column < count($header_names)) {
$this->set_header($column, $header_names[$column], false);
$headerData = $header_names[$column];
if (is_array($headerData)) {
$countItems = count($headerData['items']);
$this->set_header(
$column,
$headerData['header'],
false,
'colspan="'.$countItems.'"'
);
foreach ($headerData['items'] as $item) {
$firstHeader[] = '<center>'.$item.'</center>';
}
} else {
$this->set_header($column, $headerData, false, $thAttributes);
}
$column++;
}
@ -413,6 +444,11 @@ class FlatViewTable extends SortableTable
);
$table_data = array();
if (!empty($firstHeader)) {
$table_data[] = $firstHeader;
}
foreach ($data_array as $user_row) {
$user_id = $user_row[0];
unset($user_row[0]);

@ -65,9 +65,9 @@ class FlatViewDataGenerator
}
/**
* Get total number of evaluations/links (columns) (the 2 users columns not included)
* @return int
*/
* Get total number of evaluations/links (columns) (the 2 users columns not included)
* @return int
*/
public function get_total_items_count()
{
return count($this->evals_links);
@ -164,7 +164,14 @@ class FlatViewDataGenerator
// Means there are any subcategory
foreach ($allcat as $sub_cat) {
$extra = '';
$sub_cat_weight = round(100 * $sub_cat->get_weight() / $main_weight, 1);
$add_weight = " $sub_cat_weight %";
$mainHeader = Display::url(
$sub_cat->get_name(),
api_get_self().'?selectcat='.$sub_cat->get_id().'&'.api_get_cidreq()
).$add_weight;
if (api_get_configuration_value('gradebook_detailed_admin_view') == true) {
@ -183,20 +190,18 @@ class FlatViewDataGenerator
}
$finalList = array_merge($linkNameList, $evalNameList);
$extra = '';
if (!empty($finalList)) {
$finalList[] = get_lang('Average');
$extra = '<br />'.implode(' / ', $finalList);
}
}
$sub_cat_weight = round(100 * $sub_cat->get_weight() / $main_weight, 1);
$add_weight = " $sub_cat_weight %";
$headers[] = Display::url(
$sub_cat->get_name(),
api_get_self().'?selectcat='.$sub_cat->get_id().'&'.api_get_cidreq()
).$add_weight.$extra;
$list = [];
$list['items'] = $finalList;
$list['header'] = $mainHeader;
$headers[]= $list;
} else {
$headers[] = $mainHeader;
}
}
} else {
if (!isset($this->params['only_total_category']) ||
@ -462,7 +467,6 @@ class FlatViewDataGenerator
}
$real_score = $score;
$divide = $score[1] == 0 ? 1 : $score[1];
$sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()];
@ -479,7 +483,6 @@ class FlatViewDataGenerator
}
*/
if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') {
//if (true)
$real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE);
$temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM);
$temp_score = Display::tip($real_score, $temp_score);
@ -491,15 +494,16 @@ class FlatViewDataGenerator
if (!isset($this->params['only_total_category']) ||
(isset($this->params['only_total_category']) &&
$this->params['only_total_category'] == false)
$this->params['only_total_category'] == false)
) {
if (!$show_all) {
if (api_get_configuration_value('gradebook_detailed_admin_view')) {
$finalList = array_merge($linkScoreList, $evalScoreList);
$average = array_sum($finalList) / count($finalList);
$finalList[] = round($average, 2);
$extra = implode(' / ', $finalList);
$row[] = $extra;
foreach ($finalList as $finalValue) {
$row[] = '<center>'.$finalValue.'</center>';
}
} else {
$row[] = $temp_score.' ';
}
@ -507,7 +511,7 @@ class FlatViewDataGenerator
$row[] = $temp_score;
}
}
$item_value_total +=$item_value;
$item_value_total += $item_value;
}
if ($convert_using_the_global_weight) {
//$item_total = $main_weight;
@ -652,14 +656,14 @@ class FlatViewDataGenerator
) {
if (!$show_all) {
if (in_array($item->get_type(), array(
LINK_EXERCISE,
LINK_DROPBOX,
LINK_STUDENTPUBLICATION,
LINK_LEARNPATH,
LINK_FORUM_THREAD,
LINK_ATTENDANCE,
LINK_SURVEY,
LINK_HOTPOTATOES)
LINK_EXERCISE,
LINK_DROPBOX,
LINK_STUDENTPUBLICATION,
LINK_LEARNPATH,
LINK_FORUM_THREAD,
LINK_ATTENDANCE,
LINK_SURVEY,
LINK_HOTPOTATOES)
)
) {
if (!empty($score[0])) {
@ -689,7 +693,7 @@ class FlatViewDataGenerator
* @param int $session_id
* @return array
*/
public function get_evaluation_sumary_results ($session_id = null)
public function get_evaluation_sumary_results($session_id = null)
{
$usertable = array();
foreach ($this->users as $user) {

@ -1015,6 +1015,7 @@ class HTML_Table extends HTML_Common {
}
} else {
for ($i = 0; $i < $this->_tbodyCount; $i++) {
$this->_tbodies[$i]->setAutoFill($this->_autoFill);
$strHtml .= $this->_tbodies[$i]->toHtml($tabs, $tab);
}
}

@ -290,8 +290,8 @@ class HTML_Table_Storage extends HTML_Common {
{
if ( isset($this->_structure[$row][$col])
&& $this->_structure[$row][$col] == '__SPANNED__'
) {
return;
) {
return;
}
$attributes = $this->_parseAttributes($attributes);
$err = $this->_adjustEnds($row, $col, 'setCellAttributes', $attributes);
@ -299,7 +299,8 @@ class HTML_Table_Storage extends HTML_Common {
return $err;
}
$this->_structure[$row][$col]['attr'] = $attributes;
$this->_updateSpanGrid($row, $col);
// Fix use of rowspan/colspan
//$this->_updateSpanGrid($row, $col);
}
/**
@ -315,7 +316,7 @@ class HTML_Table_Storage extends HTML_Common {
{
if ( isset($this->_structure[$row][$col])
&& $this->_structure[$row][$col] == '__SPANNED__'
) {
) {
return;
}
$attributes = $this->_parseAttributes($attributes);
@ -324,7 +325,7 @@ class HTML_Table_Storage extends HTML_Common {
return $err;
}
$this->_updateAttrArray($this->_structure[$row][$col]['attr'], $attributes);
$this->_updateSpanGrid($row, $col);
//$this->_updateSpanGrid($row, $col);
}
/**
@ -338,7 +339,7 @@ class HTML_Table_Storage extends HTML_Common {
{
if ( isset($this->_structure[$row][$col])
&& $this->_structure[$row][$col] != '__SPANNED__'
) {
) {
return $this->_structure[$row][$col]['attr'];
} elseif (!isset($this->_structure[$row][$col])) {
return PEAR::raiseError('Invalid table cell reference[' .
@ -370,7 +371,7 @@ class HTML_Table_Storage extends HTML_Common {
if (is_array($contents)) {
foreach ($contents as $singleContent) {
$ret = $this->_setSingleCellContents($row, $col, $singleContent,
$type);
$type);
if (PEAR::isError($ret)) {
return $ret;
}
@ -406,7 +407,7 @@ class HTML_Table_Storage extends HTML_Common {
{
if ( isset($this->_structure[$row][$col])
&& $this->_structure[$row][$col] == '__SPANNED__'
) {
) {
return;
}
$err = $this->_adjustEnds($row, $col, 'setCellContents');
@ -428,7 +429,7 @@ class HTML_Table_Storage extends HTML_Common {
{
if ( isset($this->_structure[$row][$col])
&& $this->_structure[$row][$col] == '__SPANNED__'
) {
) {
return;
}
if (!isset($this->_structure[$row][$col])) {
@ -477,10 +478,10 @@ class HTML_Table_Storage extends HTML_Common {
{
if (isset($contents) && !is_array($contents)) {
return PEAR::raiseError('First parameter to HTML_Table::addRow ' .
'must be an array');
'must be an array');
}
if (is_null($contents)) {
$contents = array();
$contents = array();
}
$type = strtolower($type);
@ -620,10 +621,10 @@ class HTML_Table_Storage extends HTML_Common {
{
if (isset($contents) && !is_array($contents)) {
return PEAR::raiseError('First parameter to HTML_Table::addCol ' .
'must be an array');
'must be an array');
}
if (is_null($contents)) {
$contents = array();
$contents = array();
}
$type = strtolower($type);
@ -748,7 +749,7 @@ class HTML_Table_Storage extends HTML_Common {
if (isset($this->_structure[$i][$j]['contents'])) {
$contents = $this->_structure[$i][$j]['contents'];
}
$strHtml .= $tabs . $tab . $tab . $extraTab . "<$type" . $this->_getAttrString($attr) . '>';
if (is_object($contents)) {
// changes indent and line end settings on nested tables
if (is_subclass_of($contents, 'html_common')) {
@ -766,11 +767,22 @@ class HTML_Table_Storage extends HTML_Common {
if (is_array($contents)) {
$contents = implode(', ', $contents);
}
if (isset($this->_autoFill) && $contents === '') {
$contents = $this->_autoFill;
$typeContent = $tabs . $tab . $tab . $extraTab . "<$type" . $this->_getAttrString($attr) . '>';
if (empty($contents)) {
if (isset($this->_autoFill) && $this->_autoFill) {
$contents = $this->_autoFill;
}
} else {
$typeContent .= $contents;
}
$typeContent .= "</$type>" . $lnEnd;
if (!empty($contents)) {
$strHtml .= $typeContent;
}
$strHtml .= $contents;
$strHtml .= "</$type>" . $lnEnd;
}
$strHtml .= $tabs . $tab . $extraTab . '</tr>' . $lnEnd;
}
@ -816,16 +828,16 @@ class HTML_Table_Storage extends HTML_Common {
}
/**
* Adjusts ends (total number of rows and columns)
* @param int $row Row index
* @param int $col Column index
* @param string $method Method name of caller
* Used to populate PEAR_Error if thrown.
* @param array $attributes Assoc array of attributes
* Default is an empty array.
* @access private
* @throws PEAR_Error
*/
* Adjusts ends (total number of rows and columns)
* @param int $row Row index
* @param int $col Column index
* @param string $method Method name of caller
* Used to populate PEAR_Error if thrown.
* @param array $attributes Assoc array of attributes
* Default is an empty array.
* @access private
* @throws PEAR_Error
*/
function _adjustEnds($row, $col, $method, $attributes = array())
{
$colspan = isset($attributes['colspan']) ? $attributes['colspan'] : 1;
@ -833,9 +845,10 @@ class HTML_Table_Storage extends HTML_Common {
if (($row + $rowspan - 1) >= $this->_rows) {
if ($this->_autoGrow) {
$this->_rows = $row + $rowspan;
} else {
return PEAR::raiseError('Invalid table row reference[' .
$row . '] in HTML_Table::' . $method);
/*return PEAR::raiseError('Invalid table row reference[' .
$row . '] in HTML_Table::' . $method);*/
}
}
@ -843,18 +856,18 @@ class HTML_Table_Storage extends HTML_Common {
if ($this->_autoGrow) {
$this->_cols = $col + $colspan;
} else {
return PEAR::raiseError('Invalid table column reference[' .
$col . '] in HTML_Table::' . $method);
/*return PEAR::raiseError('Invalid table column reference[' .
$col . '] in HTML_Table::' . $method);*/
}
}
}
/**
* Tells if the parameter is an array of attribute arrays/strings
* @param mixed $attributes Variable to test
* @access private
* @return bool
*/
* Tells if the parameter is an array of attribute arrays/strings
* @param mixed $attributes Variable to test
* @access private
* @return bool
*/
function _isAttributesArray($attributes)
{
if (is_array($attributes) && isset($attributes[0])) {

Loading…
Cancel
Save