Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
357ddcaf
Commit
357ddcaf
authored
Nov 19, 2021
by
jun
Browse files
Merge branch 'MDL-72826' of
git://github.com/paulholden/moodle
parents
2db434ea
be11216d
Changes
9
Hide whitespace changes
Inline
Side-by-side
lang/en/reportbuilder.php
View file @
357ddcaf
...
...
@@ -189,6 +189,8 @@ $string['switchpreview'] = 'Switch to preview mode';
$string
[
'timeadded'
]
=
'Time added'
;
$string
[
'timecreated'
]
=
'Time created'
;
$string
[
'timemodified'
]
=
'Time modified'
;
$string
[
'uniquerows'
]
=
'Show unique rows'
;
$string
[
'uniquerows_help'
]
=
'Show only unique rows in the report. Note this setting has no effect if any report columns are being aggregated'
;
$string
[
'userfullnamewithlink'
]
=
'Full name with link'
;
$string
[
'userfullnamewithpicture'
]
=
'Full name with picture'
;
$string
[
'userfullnamewithpicturelink'
]
=
'Full name with picture and link'
;
...
...
lib/db/install.xml
View file @
357ddcaf
...
...
@@ -4386,6 +4386,7 @@
<FIELD
NAME=
"name"
TYPE=
"char"
LENGTH=
"255"
NOTNULL=
"false"
SEQUENCE=
"false"
/>
<FIELD
NAME=
"source"
TYPE=
"char"
LENGTH=
"255"
NOTNULL=
"true"
SEQUENCE=
"false"
/>
<FIELD
NAME=
"type"
TYPE=
"int"
LENGTH=
"2"
NOTNULL=
"true"
DEFAULT=
"0"
SEQUENCE=
"false"
/>
<FIELD
NAME=
"uniquerows"
TYPE=
"int"
LENGTH=
"1"
NOTNULL=
"true"
DEFAULT=
"0"
SEQUENCE=
"false"
/>
<FIELD
NAME=
"conditiondata"
TYPE=
"text"
NOTNULL=
"false"
SEQUENCE=
"false"
/>
<FIELD
NAME=
"settingsdata"
TYPE=
"text"
NOTNULL=
"false"
SEQUENCE=
"false"
/>
<FIELD
NAME=
"contextid"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
SEQUENCE=
"false"
/>
...
...
lib/db/upgrade.php
View file @
357ddcaf
...
...
@@ -3156,5 +3156,20 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint
(
true
,
2021111700.00
);
}
if
(
$oldversion
<
2021111700.01
)
{
// Define field uniquerows to be added to reportbuilder_report.
$table
=
new
xmldb_table
(
'reportbuilder_report'
);
$field
=
new
xmldb_field
(
'uniquerows'
,
XMLDB_TYPE_INTEGER
,
'1'
,
null
,
XMLDB_NOTNULL
,
null
,
'0'
,
'type'
);
// Conditionally launch add field uniquerows.
if
(
!
$dbman
->
field_exists
(
$table
,
$field
))
{
$dbman
->
add_field
(
$table
,
$field
);
}
// Main savepoint reached.
upgrade_main_savepoint
(
true
,
2021111700.01
);
}
return
true
;
}
reportbuilder/classes/form/report.php
View file @
357ddcaf
...
...
@@ -111,6 +111,9 @@ class report extends dynamic_form {
$mform
->
setDefault
(
'includedefaultsetup'
,
1
);
$mform
->
addHelpButton
(
'includedefaultsetup'
,
'includedefaultsetup'
,
'core_reportbuilder'
);
}
$mform
->
addElement
(
'advcheckbox'
,
'uniquerows'
,
get_string
(
'uniquerows'
,
'core_reportbuilder'
));
$mform
->
addHelpButton
(
'uniquerows'
,
'uniquerows'
,
'core_reportbuilder'
);
}
/**
...
...
reportbuilder/classes/local/helpers/report.php
View file @
357ddcaf
...
...
@@ -75,8 +75,10 @@ class report {
throw
new
invalid_parameter_exception
(
'Invalid report'
);
}
$report
->
set
(
'name'
,
trim
(
$data
->
name
))
->
update
();
$report
->
set_many
([
'name'
=>
trim
(
$data
->
name
),
'uniquerows'
=>
$data
->
uniquerows
,
])
->
update
();
return
$report
;
}
...
...
reportbuilder/classes/local/models/report.php
View file @
357ddcaf
...
...
@@ -60,6 +60,10 @@ class report extends persistent {
base
::
TYPE_SYSTEM_REPORT
,
],
],
'uniquerows'
=>
[
'type'
=>
PARAM_BOOL
,
'default'
=>
false
,
],
'conditiondata'
=>
[
'type'
=>
PARAM_RAW
,
'null'
=>
NULL_ALLOWED
,
...
...
reportbuilder/classes/table/custom_report_table.php
View file @
357ddcaf
...
...
@@ -62,7 +62,7 @@ class custom_report_table extends base_report_table {
$this
->
define_baseurl
(
new
moodle_url
(
'/reportbuilder/edit.php'
,
[
'id'
=>
$matches
[
'id'
]]));
// Load the report persistent, and accompanying
system
report instance.
// Load the report persistent, and accompanying report instance.
$this
->
persistent
=
new
report
(
$matches
[
'id'
]);
$this
->
report
=
manager
::
get_report_from_persistent
(
$this
->
persistent
);
...
...
@@ -90,7 +90,10 @@ class custom_report_table extends base_report_table {
$aggregatedcolumns
=
array_filter
(
$columns
,
static
function
(
column
$column
):
bool
{
return
!
empty
(
$column
->
get_aggregation
());
});
// Also take account of the report setting to show unique rows (only if no columns are being aggregated).
$hasaggregatedcolumns
=
!
empty
(
$aggregatedcolumns
);
$showuniquerows
=
!
$hasaggregatedcolumns
&&
$this
->
persistent
->
get
(
'uniquerows'
);
$columnheaders
=
[];
$columnsattributes
=
[];
...
...
@@ -98,8 +101,9 @@ class custom_report_table extends base_report_table {
$columnheading
=
$column
->
get_persistent
()
->
get_formatted_heading
(
$this
->
report
->
get_context
());
$columnheaders
[
$column
->
get_column_alias
()]
=
$columnheading
!==
''
?
$columnheading
:
$column
->
get_title
();
// We need to determine for each column whether we should group by it's fields, to support aggregation.
$columnaggregation
=
$column
->
get_aggregation
();
if
(
$hasaggregatedcolumns
&&
empty
(
$columnaggregation
))
{
if
(
$showuniquerows
||
(
$hasaggregatedcolumns
&&
empty
(
$columnaggregation
))
)
{
$groupby
=
array_merge
(
$groupby
,
$column
->
get_groupby_sql
());
}
...
...
reportbuilder/tests/behat/columnaggregationeditor.feature
View file @
357ddcaf
...
...
@@ -65,9 +65,9 @@ Feature: Manage custom report columns aggregation
Then
I should see
"Aggregated column 'Last access'"
And
I should see
"<output>"
in the
"Richie"
"table_row"
Examples
:
|
aggregation
|
output
|
|
Count
|
3
|
|
Count
distinct
|
2
|
|
aggregation
|
output
|
|
Count
|
3
|
|
Count
distinct
|
2
|
|
Maximum
|
##2 days ago##%A, %d %B %Y## |
|
Minimum
|
##3 days ago##%A, %d %B %Y## |
...
...
@@ -94,3 +94,25 @@ Feature: Manage custom report columns aggregation
|
Minimum
|
No
|
|
Percentage
|
66.7%
|
|
Sum
|
2
|
Scenario
:
Show unique report rows
Given the following "core_reportbuilder > Reports" exist
:
|
name
|
source
|
default
|
uniquerows
|
|
My
report
|
core_user\reportbuilder\datasource\users
|
0
|
1
|
And the following "core_reportbuilder > Columns" exist
:
|
report
|
uniqueidentifier
|
|
My
report
|
user:firstname
|
|
My
report
|
user:lastname
|
When
I am on the
"My report"
"reportbuilder > Editor"
page logged in as
"admin"
Then the following should exist in the "reportbuilder-table" table
:
|
-1-
|
-2-
|
|
Admin
|
User
|
|
Ben
|
Richie
|
|
Bill
|
Richie
|
# Assert there is no 4th row (duplicate Bill Richie) because we're showing unique rows.
And
"//table[@data-region='reportbuilder-table']/tbody/tr[not(@class = 'emptyrow')][4]"
"xpath_element"
should not exist
And
I set the
"First name"
column aggregation to
"Comma separated values"
And the following should exist in the "reportbuilder-table" table
:
|
-1-
|
-2-
|
|
Admin
|
User
|
|
Ben,
Bill,
Bill
|
Richie
|
version.php
View file @
357ddcaf
...
...
@@ -29,7 +29,7 @@
defined
(
'MOODLE_INTERNAL'
)
||
die
();
$version
=
2021111700.0
0
;
// YYYYMMDD = weekly release date of this DEV branch.
$version
=
2021111700.0
1
;
// YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release
=
'4.0dev+ (Build: 20211116)'
;
// Human-friendly version name
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment