From e858c2e7476cb70f654713ce55ce03d8055533a2 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Thu, 20 Jul 2023 21:42:07 +0100 Subject: [PATCH] MDL-78773 report_stats: improve display of mode selection element. Make use of existing theme selectors for navigation elements to style. --- lib/classes/report_helper.php | 26 +++++++++++++------------- report/stats/index.php | 9 ++++++--- report/upgrade.txt | 5 +++++ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/lib/classes/report_helper.php b/lib/classes/report_helper.php index 05a0b26a9a5..652456549e8 100644 --- a/lib/classes/report_helper.php +++ b/lib/classes/report_helper.php @@ -14,16 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Report plugins helper class - * - * @package core - * @subpackage report - * @copyright 2021 Sujith Haridasan - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core; + use context_course; use moodle_url; use stdClass; @@ -32,17 +24,19 @@ use stdClass; * A helper class with static methods to help report plugins * * @package core + * @subpackage report * @copyright 2021 Sujith Haridasan * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class report_helper { + /** * Print the selector dropdown * * @param string $pluginname The report plugin where the header is modified - * @return void + * @param string $additional Additional content to display aligned with the selector */ - public static function print_report_selector(string $pluginname): void { + public static function print_report_selector(string $pluginname, string $additional = ''): void { global $OUTPUT, $PAGE; if ($reportnode = $PAGE->settingsnav->find('coursereports', \navigation_node::TYPE_CONTAINER)) { @@ -81,12 +75,18 @@ class report_helper { $options = \html_writer::tag( 'div', $OUTPUT->render_from_template('core/tertiary_navigation_selector', $selectmenu->export_for_template($OUTPUT)), - ['class' => 'row pb-3'] + ['class' => 'navitem'] ); + + if ($additional) { + $options .= \html_writer::div('', 'navitem-divider') . + \html_writer::div($additional, 'navitem'); + } + echo \html_writer::tag( 'div', $options, - ['class' => 'tertiary-navigation full-width-bottom-border ml-0', 'id' => 'tertiary-navigation']); + ['class' => 'tertiary-navigation full-width-bottom-border ml-0 d-flex', 'id' => 'tertiary-navigation']); } else { echo $OUTPUT->heading($pluginname, 2, 'mb-3'); } diff --git a/report/stats/index.php b/report/stats/index.php index 6b4241b9bd0..94a19141287 100644 --- a/report/stats/index.php +++ b/report/stats/index.php @@ -86,12 +86,15 @@ if ($course->id == SITEID) { $PAGE->set_title("$course->shortname: $strstats"); $PAGE->set_heading($course->fullname); $PAGE->set_pagelayout('report'); - $PAGE->set_headingmenu(report_stats_mode_menu($course, $mode, $time, "$CFG->wwwroot/report/stats/index.php")); + echo $OUTPUT->header(); // Print the selected dropdown. - $pluginname = get_string('pluginname', 'report_stats'); - report_helper::print_report_selector($pluginname); + report_helper::print_report_selector( + get_string('pluginname', 'report_stats'), + report_stats_mode_menu($course, $mode, $time, $PAGE->url->out_omit_querystring()) + ); + } report_stats_report($course, $report, $mode, $user, $roleid, $time); diff --git a/report/upgrade.txt b/report/upgrade.txt index 824ae418aba..b9f01512e2f 100644 --- a/report/upgrade.txt +++ b/report/upgrade.txt @@ -1,6 +1,11 @@ This files describes API changes in /report/* - plugins, information provided here is intended especially for developers. +=== 4.4.2 === + +* The `report_helper::print_report_selector` method accepts an additional argument for adding content to the + tertiary navigation to align with the report selector + === 4.2 === * The method report_progress\local\helper::get_activities_to_show() has an additional parameter $activitysection