Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402] [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 /** 18 * The gradebook simple view - initial view to select your search options 19 * 20 * @package gradereport_singleview 21 * @copyright 2014 Moodle Pty Ltd (http://moodle.com) 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace gradereport_singleview\local\screen; 26 27 use gradereport_singleview; 28 use moodle_url; 29 30 defined('MOODLE_INTERNAL') || die; 31 32 /** 33 * The gradebook simple view - initial view to select your search options 34 * 35 * @package gradereport_singleview 36 * @copyright 2014 Moodle Pty Ltd (http://moodle.com) 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class select extends screen { 40 41 /** @var \stdClass course data. */ 42 public $item; 43 44 /** 45 * Initialise this screen 46 * 47 * @param bool $selfitemisempty Has an item been selected (will be false) 48 */ 49 public function init($selfitemisempty = false) { 50 global $DB; 51 52 $roleids = explode(',', get_config('moodle', 'gradebookroles')); 53 54 $this->items = []; 55 foreach ($roleids as $roleid) { 56 // Keeping the first user appearance. 57 $this->items = $this->items + get_role_users( 58 $roleid, $this->context, false, '', 59 'u.id, u.lastname, u.firstname', null, $this->groupid, 60 $this->perpage * $this->page, $this->perpage 61 ); 62 } 63 $this->item = $DB->get_record('course', ['id' => $this->courseid]); 64 } 65 66 /** 67 * Get the type of items on this screen, not valid so return false. 68 * 69 * @return string|null 70 */ 71 public function item_type(): ?string { 72 return false; 73 } 74 75 /** 76 * Return the HTML for the page. 77 * 78 * @return string 79 */ 80 public function html(): string { 81 global $OUTPUT, $COURSE; 82 83 if ($this->itemid === null) { 84 $userlink = new \moodle_url('/grade/report/singleview/index.php', ['id' => $COURSE->id, 'item' => 'user_select']); 85 $gradelink = new \moodle_url('/grade/report/singleview/index.php', ['id' => $COURSE->id, 'item' => 'grade_select']); 86 $context = [ 87 'courseid' => $COURSE->id, 88 'imglink' => $OUTPUT->image_url('zero_state', 'gradereport_singleview'), 89 'userzerolink' => $userlink->out(false), 90 'userselectactive' => false, 91 'gradezerolink' => $gradelink->out(false), 92 'gradeselectactive' => false, 93 'displaylabel' => false 94 ]; 95 return $OUTPUT->render_from_template('gradereport_singleview/zero_state', $context); 96 } 97 98 $html = ''; 99 100 $types = gradereport_singleview\report\singleview::valid_screens(); 101 102 foreach ($types as $type) { 103 $classname = "gradereport_singleview\\local\\screen\\{$type}"; 104 105 $screen = new $classname($this->courseid, null, $this->groupid); 106 107 if (!$screen instanceof selectable_items) { 108 continue; 109 } 110 111 $options = $screen->options(); 112 113 if (empty($options)) { 114 continue; 115 } 116 117 $params = [ 118 'id' => $this->courseid, 119 'item' => $screen->item_type(), 120 'group' => $this->groupid 121 ]; 122 123 $url = new moodle_url('/grade/report/singleview/index.php', $params); 124 125 $select = new \single_select($url, 'itemid', $options, '', ['' => $screen->select_label()]); 126 $select->set_label($screen->select_label(), ['class' => 'accesshide']); 127 $html .= $OUTPUT->render($select); 128 } 129 $html = $OUTPUT->container($html, 'selectitems'); 130 131 if (empty($html)) { 132 $OUTPUT->notification(get_string('noscreens', 'gradereport_singleview')); 133 } 134 135 return $html; 136 } 137 138 /** 139 * Should we show the next prev selector? 140 * @return bool 141 */ 142 public function supports_next_prev(): bool { 143 return false; 144 } 145 146 /** 147 * Should we show the base singlereport group selector? 148 * @return bool 149 */ 150 public function display_group_selector(): bool { 151 if ($this->itemid === null) { 152 return false; 153 } 154 return true; 155 } 156 157 /** 158 * Get the heading for the screen. 159 * 160 * @return string 161 */ 162 public function heading(): string { 163 return ' '; 164 } 165 166 /** 167 * Does this screen support paging? 168 * 169 * @return bool 170 */ 171 public function supports_paging(): bool { 172 return false; 173 } 174 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body