From ba93fe345a8d1bfa45c936ea891d30777288cd79 Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Thu, 17 Nov 2022 14:47:51 +0800 Subject: [PATCH] MDL-76138 gradereport_grader: Create basic action bar --- .../grader/classes/output/action_bar.php | 64 ++++++++++++++++ grade/report/grader/index.php | 4 +- .../grader/templates/action_bar.mustache | 73 +++++++++++++++++++ 3 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 grade/report/grader/classes/output/action_bar.php create mode 100644 grade/report/grader/templates/action_bar.mustache diff --git a/grade/report/grader/classes/output/action_bar.php b/grade/report/grader/classes/output/action_bar.php new file mode 100644 index 00000000000..dd100ecc87d --- /dev/null +++ b/grade/report/grader/classes/output/action_bar.php @@ -0,0 +1,64 @@ +. + +namespace gradereport_grader\output; + +use moodle_url; +use core_grades\output\general_action_bar; + +/** + * Renderable class for the action bar elements in the grader report. + * + * @package gradereport_grader + * @copyright 2022 Mihail Geshoski + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class action_bar extends \core_grades\output\action_bar { + + /** + * The class constructor. + * + * @param \context_course $context The context object. + */ + public function __construct(\context_course $context) { + parent::__construct($context); + } + + /** + * Returns the template for the action bar. + * + * @return string + */ + public function get_template(): string { + return 'gradereport_grader/action_bar'; + } + + /** + * Export the data for the mustache template. + * + * @param \renderer_base $output renderer to be used to render the action bar elements. + * @return array + */ + public function export_for_template(\renderer_base $output): array { + // If in the course context, we should display the general navigation selector in gradebook. + $courseid = $this->context->instanceid; + // Get the data used to output the general navigation selector. + $generalnavselector = new general_action_bar($this->context, + new moodle_url('/grade/report/grader/index.php', ['id' => $courseid]), 'gradereport', 'grader'); + + return $generalnavselector->export_for_template($output); + } +} diff --git a/grade/report/grader/index.php b/grade/report/grader/index.php index 5146f6b6301..82dd64ad9a7 100644 --- a/grade/report/grader/index.php +++ b/grade/report/grader/index.php @@ -112,8 +112,10 @@ $reportname = get_string('pluginname', 'gradereport_grader'); // Do this check just before printing the grade header (and only do it once). grade_regrade_final_grades_if_required($course); +$actionbar = new \gradereport_grader\output\action_bar($context); // Print header -print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons); +print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons, true, + null, null, null, $actionbar); //Initialise the grader report object that produces the table //the class grade_report_grader_ajax was removed as part of MDL-21562 diff --git a/grade/report/grader/templates/action_bar.mustache b/grade/report/grader/templates/action_bar.mustache new file mode 100644 index 00000000000..8697607e9be --- /dev/null +++ b/grade/report/grader/templates/action_bar.mustache @@ -0,0 +1,73 @@ +{{! + 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 . +}} +{{! + @template gradereport_grader/action_bar + + Actions bar for the grader report. + + Context variables required for this template: + * generalnavselector - The data object containing the required properties to render the general navigation selector. + + Example context (json): + { + "generalnavselector": { + "name": "Gradebook tertiary navigation selector", + "value": "opt2", + "baseid": "select-menu56789", + "selectedoption": "Gradebook setup", + "options": [ + { + "selected": false, + "isgroup": { + "name": "View", + "id": "select-menu-group1", + "options": [ + { + "name": "Grader report", + "value": "opt1", + "id": "select-menu-option1", + "selected": false + } + ] + } + }, + { + "selected": false, + "isgroup": { + "name": "Setup", + "id": "select-menu-group2", + "options": [ + { + "name": "Gradebook setup", + "value": "opt2", + "id": "select-menu-option2", + "selected": true + } + ] + } + } + ] + } + } +}} +
+
+ {{#generalnavselector}} + + + {{/generalnavselector}} +
+