mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-75358 reportbuilder: display nulls as empty cells in aggregation
This commit is contained in:
parent
dcc44ae4c0
commit
4bb042c352
@ -76,6 +76,9 @@ class avg extends base {
|
||||
* @return mixed
|
||||
*/
|
||||
public static function format_value($value, array $values, array $callbacks, int $columntype) {
|
||||
if (reset($values) === null) {
|
||||
return null;
|
||||
}
|
||||
if ($columntype === column::TYPE_BOOLEAN || empty($callbacks)) {
|
||||
return format_float((float) reset($values), 1);
|
||||
}
|
||||
|
@ -111,6 +111,11 @@ class groupconcat extends base {
|
||||
* @return mixed
|
||||
*/
|
||||
public static function format_value($value, array $values, array $callbacks, int $columntype) {
|
||||
$firstvalue = reset($values);
|
||||
if ($firstvalue === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$formattedvalues = [];
|
||||
|
||||
// Store original names of all values that would be present without aggregation.
|
||||
@ -118,7 +123,7 @@ class groupconcat extends base {
|
||||
$valuenamescount = count($valuenames);
|
||||
|
||||
// Loop over each extracted value from the concatenated string.
|
||||
$values = explode(self::FIELD_VALUE_DELIMETER, (string) reset($values));
|
||||
$values = explode(self::FIELD_VALUE_DELIMETER, (string)$firstvalue);
|
||||
foreach ($values as $value) {
|
||||
|
||||
// Ensure we have equal number of value names/data, account for truncation by DB.
|
||||
|
@ -73,6 +73,9 @@ class percent extends base {
|
||||
* @return string
|
||||
*/
|
||||
public static function format_value($value, array $values, array $callbacks, int $columntype): string {
|
||||
if (reset($values) === null) {
|
||||
return '';
|
||||
}
|
||||
return format::percent((float) reset($values));
|
||||
}
|
||||
}
|
||||
|
@ -76,9 +76,13 @@ class sum extends base {
|
||||
* @return mixed
|
||||
*/
|
||||
public static function format_value($value, array $values, array $callbacks, int $columntype) {
|
||||
$firstvalue = reset($values);
|
||||
if ($firstvalue === null) {
|
||||
return null;
|
||||
}
|
||||
if ($columntype === column::TYPE_BOOLEAN || empty($callbacks)) {
|
||||
$decimalpoints = (int) ($columntype === column::TYPE_FLOAT);
|
||||
return format_float((float) reset($values), $decimalpoints);
|
||||
return format_float((float) $firstvalue, $decimalpoints);
|
||||
}
|
||||
|
||||
return parent::format_value($value, $values, $callbacks, $columntype);
|
||||
|
@ -206,7 +206,7 @@ class user_profile_fields_test extends core_reportbuilder_testcase {
|
||||
$this->assertEquals([
|
||||
[
|
||||
'c0_firstname' => 'Admin',
|
||||
'c1_data' => 'No',
|
||||
'c1_data' => '',
|
||||
'c2_data' => 'Not set',
|
||||
'c3_data' => '',
|
||||
'c4_data' => '',
|
||||
|
Loading…
x
Reference in New Issue
Block a user