Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 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 * UI element for a text input field. 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\ui; 26 27 use html_writer; 28 defined('MOODLE_INTERNAL') || die; 29 30 /** 31 * UI element for a text input field. 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 text_attribute extends element { 38 39 /** @var bool $isdisabled Is this input disabled? */ 40 private $isdisabled; 41 42 /** 43 * Constructor 44 * 45 * @param string $name The input name (the first bit) 46 * @param string $value The input initial value. 47 * @param string $label The label for this input field. 48 * @param bool $isdisabled Is this input disabled. 49 */ 50 public function __construct($name, $value, $label, $isdisabled = false) { 51 $this->isdisabled = $isdisabled; 52 parent::__construct($name, $value, $label); 53 } 54 55 /** 56 * Nasty function allowing custom textbox behaviour outside the class. 57 * @return bool Is this a textbox. 58 */ 59 public function is_textbox() { 60 return true; 61 } 62 63 /** 64 * Render the html for this field. 65 * @return string The HTML. 66 */ 67 public function html() { 68 global $OUTPUT; 69 70 $context = (object) [ 71 'id' => $this->name, 72 'name' => $this->name, 73 'value' => $this->value, 74 'disabled' => $this->isdisabled, 75 ]; 76 77 $context->label = ''; 78 if (preg_match("/^feedback/", $this->name)) { 79 $context->label = get_string('feedbackfor', 'gradereport_singleview', $this->label); 80 $context->tabindex = '2'; 81 } else if (preg_match("/^finalgrade/", $this->name)) { 82 $context->label = get_string('gradefor', 'gradereport_singleview', $this->label); 83 $context->tabindex = '1'; 84 } 85 86 return $OUTPUT->render_from_template('gradereport_singleview/text_attribute', $context); 87 } 88 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body