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 core\output\comboboxsearch; 20 use core_grades\output\general_action_bar; 21 use moodle_url; 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, $SESSION, $USER; 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 comboboxsearch( 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('core_user/comboboxsearch/user_selector', [ 97 'currentvalue' => $this->usersearch, 98 'courseid' => $courseid, 99 'resetlink' => $resetlink->out(false), 100 'group' => 0, 101 ]); 102 $searchdropdown = new comboboxsearch( 103 true, 104 $searchinput, 105 null, 106 'user-search dropdown d-flex', 107 null, 108 'usersearchdropdown overflow-auto', 109 null, 110 false, 111 ); 112 $data['searchdropdown'] = $searchdropdown->export_for_template($output); 113 114 // The collapsed column dialog is aligned to the edge of the screen, we need to place it such that it also aligns. 115 $collapsemenudirection = right_to_left() ? 'dropdown-menu-left' : 'dropdown-menu-right'; 116 117 $collapse = new comboboxsearch( 118 true, 119 get_string('collapsedcolumns', 'gradereport_grader', 0), 120 null, 121 'collapse-columns', 122 'collapsecolumn', 123 'collapsecolumndropdown p-3 flex-column ' . $collapsemenudirection, 124 null, 125 true, 126 ); 127 $data['collapsedcolumns'] = [ 128 'classes' => 'd-none', 129 'content' => $collapse->export_for_template($output) 130 ]; 131 132 if ($course->groupmode == VISIBLEGROUPS || has_capability('moodle/site:accessallgroups', $this->context)) { 133 $allowedgroups = groups_get_all_groups($course->id, 0, $course->defaultgroupingid); 134 } else { 135 $allowedgroups = groups_get_all_groups($course->id, $USER->id, $course->defaultgroupingid); 136 } 137 138 if (!empty($SESSION->gradereport["filterfirstname-{$this->context->id}"]) || 139 !empty($SESSION->gradereport["filterlastname-{$this->context->id}"]) || 140 groups_get_course_group($course, true, $allowedgroups) || 141 $this->usersearch) { 142 $reset = new moodle_url('/grade/report/grader/index.php', [ 143 'id' => $courseid, 144 'group' => 0, 145 'sifirst' => '', 146 'silast' => '' 147 ]); 148 $data['pagereset'] = $reset->out(false); 149 } 150 } 151 152 return $data; 153 } 154 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body