Differences Between: [Versions 402 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace gradereport_grader\output; 18 19 use moodle_url; 20 use core_grades\output\general_action_bar; 21 use core_grades\output\gradebook_dropdown; 22 23 /** 24 * Renderable class for the action bar elements in the grader report. 25 * 26 * @package gradereport_grader 27 * @copyright 2022 Mihail Geshoski <mihail@moodle.com> 28 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 29 */ 30 class action_bar extends \core_grades\output\action_bar { 31 32 /** @var string $usersearch The content that the current user is looking for. */ 33 protected string $usersearch = ''; 34 35 /** 36 * The class constructor. 37 * 38 * @param \context_course $context The context object. 39 */ 40 public function __construct(\context_course $context) { 41 parent::__construct($context); 42 43 $this->usersearch = optional_param('gpr_search', '', PARAM_NOTAGS); 44 } 45 46 /** 47 * Returns the template for the action bar. 48 * 49 * @return string 50 */ 51 public function get_template(): string { 52 return 'gradereport_grader/action_bar'; 53 } 54 55 /** 56 * Export the data for the mustache template. 57 * 58 * @param \renderer_base $output renderer to be used to render the action bar elements. 59 * @return array 60 * @throws \moodle_exception 61 */ 62 public function export_for_template(\renderer_base $output): array { 63 global $PAGE, $OUTPUT; 64 // If in the course context, we should display the general navigation selector in gradebook. 65 $courseid = $this->context->instanceid; 66 // Get the data used to output the general navigation selector. 67 $generalnavselector = new general_action_bar($this->context, 68 new moodle_url('/grade/report/grader/index.php', ['id' => $courseid]), 'gradereport', 'grader'); 69 70 $data = $generalnavselector->export_for_template($output); 71 72 // If the user has the capability to view all grades, display the group selector (if applicable), the user selector 73 // and the view mode selector (if applicable). 74 if (has_capability('moodle/grade:viewall', $this->context)) { 75 $course = get_course($courseid); 76 $gradesrenderer = $PAGE->get_renderer('core_grades'); 77 78 $initialscontent = $gradesrenderer->initials_selector( 79 $course, 80 $this->context, 81 '/grade/report/grader/index.php' 82 ); 83 $initialselector = new gradebook_dropdown( 84 false, 85 $initialscontent->buttoncontent, 86 $initialscontent->dropdowncontent, 87 'initials-selector', 88 'initialswidget', 89 'initialsdropdown', 90 $initialscontent->buttonheader, 91 ); 92 $data['initialselector'] = $initialselector->export_for_template($output); 93 $data['groupselector'] = $gradesrenderer->group_selector($course); 94 95 $resetlink = new moodle_url('/grade/report/grader/index.php', ['id' => $courseid]); 96 $searchinput = $OUTPUT->render_from_template('gradereport_grader/search/searchinput', [ 97 'currentvalue' => $this->usersearch, 98 'courseid' => $courseid, 99 'resetlink' => $resetlink->out(false), 100 ]); 101 $searchdropdown = new gradebook_dropdown( 102 true, 103 $searchinput, 104 null, 105 'user-search', 106 'usersearchwidget', 107 'usersearchdropdown overflow-auto', 108 null, 109 false, 110 ); 111 $data['searchdropdown'] = $searchdropdown->export_for_template($output); 112 113 $collapse = new gradebook_dropdown( 114 true, 115 get_string('collapsedcolumns', 'gradereport_grader', 0), 116 null, 117 'collapse-columns', 118 'collapsecolumn', 119 'collapsecolumndropdown p-3 flex-column', 120 null, 121 true, 122 ); 123 $data['collapsedcolumns'] = [ 124 'classes' => 'd-none', 125 'content' => $collapse->export_for_template($output) 126 ]; 127 } 128 129 return $data; 130 } 131 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body