See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 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 * A checkbox ui element. 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 namespace gradereport_singleview\local\ui; 25 26 use html_writer; 27 28 defined('MOODLE_INTERNAL') || die; 29 30 /** 31 * A checkbox ui element. 32 * 33 * @package gradereport_singleview 34 * @copyright 2014 Moodle Pty Ltd (http://moodle.com) 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class checkbox_attribute extends element { 38 39 /** @var bool $ischecked Is it checked? */ 40 private $ischecked; 41 42 /** @var bool If this is a read-only input. */ 43 private bool $isreadonly; 44 45 /** 46 * Constructor 47 * 48 * @param string $name The element name 49 * @param string $label The label for the form element 50 * @param bool $ischecked Is this thing on? 51 * @param int $locked Is this element locked either 0 or a time. 52 * @param bool $isreadonly If this is a read-only input. 53 */ 54 public function __construct(string $name, string $label, bool $ischecked = false, int $locked=0, bool $isreadonly = false) { 55 $this->ischecked = $ischecked; 56 $this->locked = $locked; 57 $this->isreadonly = $isreadonly; 58 parent::__construct($name, 1, $label); 59 } 60 61 /** 62 * Nasty function allowing checkbox logic to escape the class. 63 * @return bool 64 */ 65 public function is_checkbox(): bool { 66 return true; 67 } 68 69 /** 70 * Generate the HTML 71 * 72 * @return string 73 */ 74 public function html(): string { 75 global $OUTPUT; 76 77 $attributes = [ 78 'type' => 'checkbox', 79 'name' => $this->name, 80 'value' => 1, 81 'id' => $this->name 82 ]; 83 84 // UCSB fixed user should not be able to override locked grade. 85 if ( $this->locked) { 86 $attributes['disabled'] = 'DISABLED'; 87 } 88 89 $hidden = [ 90 'type' => 'hidden', 91 'name' => 'old' . $this->name 92 ]; 93 94 if ($this->ischecked) { 95 $attributes['checked'] = 'CHECKED'; 96 $hidden['value'] = 1; 97 } 98 99 $type = "override"; 100 if (preg_match("/^exclude/", $this->name)) { 101 $type = "exclude"; 102 } 103 104 if (!$this->isreadonly) { 105 return ( 106 html_writer::tag('label', 107 get_string($type . 'for', 'gradereport_singleview', $this->label), 108 ['for' => $this->name, 'class' => 'accesshide']) . 109 html_writer::empty_tag('input', $attributes) . 110 html_writer::empty_tag('input', $hidden) 111 ); 112 } else if ($this->ischecked) { 113 return $OUTPUT->pix_icon('i/checked', get_string('selected', 'core_form'), 114 'moodle', ['class' => 'overrideexcludecheck']); 115 } else { 116 return ''; 117 } 118 } 119 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body