Skip to content

Commit

Permalink
MDL-70795 reportbuilder: add interface for creating reports.
Browse files Browse the repository at this point in the history
Implement elements for creating/editing reports, along with
new system report for listing and accompanying JS modules for
user interaction.

Create "Users" datasource as proof-of-concept.

Co-authored-By: Paul Holden <[email protected]>
  • Loading branch information
dravek and paulholden committed Oct 19, 2021
1 parent 95967d6 commit 22d896e
Show file tree
Hide file tree
Showing 33 changed files with 1,619 additions and 10 deletions.
44 changes: 44 additions & 0 deletions admin/settings/reportbuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Report builder related settings.
*
* @package core_reportbuilder
* @copyright 2021 David Matamoros <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

declare(strict_types=1);

use core_admin\local\externalpage\accesscallback;
use core_reportbuilder\permission;

defined('MOODLE_INTERNAL') || die;

/** @var admin_root $ADMIN */
$ADMIN->add('reports', new admin_category('reportbuilder', new lang_string('reportbuilder', 'core_reportbuilder')));

$ADMIN->add(
'reportbuilder', new accesscallback(
'customreports',
get_string('customreports', 'core_reportbuilder'),
(new moodle_url('/reportbuilder/index.php'))->out(),
static function(accesscallback $accesscallback): bool {
return permission::can_view_reports_list();
}
)
);
18 changes: 18 additions & 0 deletions lang/en/reportbuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
$string['courseidnumberewithlink'] = 'Course ID number with link';
$string['courseshortnamewithlink'] = 'Course short name with link';
$string['customfieldcolumn'] = '{$a}';
$string['deletereport'] = 'Delete report';
$string['deletereportconfirm'] = 'Are you sure you want to delete the report \'{$a}\' and all associated data?';
$string['editreportdetails'] = 'Edit report details';
$string['editreportname'] = 'Edit report name';
$string['customreports'] = 'Custom reports';
$string['entitycourse'] = 'Course';
$string['entityuser'] = 'User';
$string['errorreportaccess'] = 'You can not view this report';
Expand Down Expand Up @@ -66,6 +71,9 @@
$string['filtersappliedx'] = 'Filters ({$a})';
$string['filtersreset'] = 'Filters reset';
$string['filterstartswith'] = 'Starts with';
$string['includedefaultsetup'] = 'Include default setup';
$string['includedefaultsetup_help'] = 'Populate report with default layout as defined by the selected source. These include pre-defined columns, filters and conditions.';
$string['newreport'] = 'New report';
$string['privacy:metadata:column'] = 'Report column definitions';
$string['privacy:metadata:column:uniqueidentifier'] = 'Unique identifier of the column';
$string['privacy:metadata:column:usercreated'] = 'The ID of the user who created the column';
Expand All @@ -79,8 +87,18 @@
$string['privacy:metadata:report:name'] = 'The name of the report';
$string['privacy:metadata:report:usercreated'] = 'The ID of the user who created the report';
$string['privacy:metadata:report:usermodified'] = 'The ID of the user who last modified the report';
$string['reportbuilder'] = 'Report builder';
$string['reportcreated'] = 'Report created';
$string['reportdeleted'] = 'Report deleted';
$string['reportsource'] = 'Report source';
$string['reportsource_help'] = 'The report source defines where the data for the report will come from';
$string['reportupdated'] = 'Report updated';
$string['resetall'] = 'Reset all';
$string['selectareportsource'] = 'Select a report source';
$string['selectcourses'] = 'Select courses';
$string['timeadded'] = 'Time added';
$string['timecreated'] = 'Time created';
$string['timemodified'] = 'Time modified';
$string['userfullnamewithlink'] = 'Full name with link';
$string['userfullnamewithpicture'] = 'Full name with picture';
$string['userfullnamewithpicturelink'] = 'Full name with picture and link';
Expand Down
3 changes: 3 additions & 0 deletions lang/en/role.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@
$string['rating:view'] = 'View the total rating you received';
$string['rating:viewany'] = 'View total ratings that anyone received';
$string['rating:viewall'] = 'View all raw ratings given by individuals';
$string['reportbuilder:edit'] = 'Create/edit custom reports';
$string['reportbuilder:editall'] = 'Create/edit all custom reports';
$string['reportbuilder:view'] = 'View custom reports';
$string['resetrole'] = 'Reset';
$string['resettingrole'] = 'Resetting role \'{$a}\'';
$string['restore:configure'] = 'Configure restore options';
Expand Down
27 changes: 27 additions & 0 deletions lib/db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -2627,4 +2627,31 @@
'coursecreator' => CAP_ALLOW,
]
],

// Allow users to view custom reports.
'moodle/reportbuilder:view' => [
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => [
'user' => CAP_ALLOW,
],
],

// Allow users to create/edit their own custom reports.
'moodle/reportbuilder:edit' => [
'captype' => 'write',
'riskbitmap' => RISK_PERSONAL,
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => [
'manager' => CAP_ALLOW,
],
],

// Allow users to create/edit all custom reports.
'moodle/reportbuilder:editall' => [
'captype' => 'write',
'riskbitmap' => RISK_PERSONAL,
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => [],
],
);
6 changes: 6 additions & 0 deletions lib/db/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -2798,6 +2798,12 @@
'type' => 'write',
'ajax' => true,
],
'core_reportbuilder_reports_delete' => [
'classname' => 'core_reportbuilder\external\reports\delete',
'description' => 'Delete report',
'type' => 'write',
'ajax' => true,
],
);

$services = array(
Expand Down
2 changes: 2 additions & 0 deletions reportbuilder/amd/build/local/repository/modals.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions reportbuilder/amd/build/local/repository/modals.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions reportbuilder/amd/build/local/repository/reports.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion reportbuilder/amd/build/local/selectors.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion reportbuilder/amd/build/local/selectors.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 22d896e

Please sign in to comment.