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 * Checkbox element used for bulk inserting values in the gradebook. 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 defined('MOODLE_INTERNAL') || die; 28 29 /** 30 * Checkbox element used for bulk inserting values in the gradebook. 31 * 32 * @package gradereport_singleview 33 * @copyright 2014 Moodle Pty Ltd (http://moodle.com) 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class bulk_insert extends element { 37 38 /** 39 * Constructor 40 * 41 * @param mixed $item The grade item or user. 42 */ 43 public function __construct($item) { 44 $this->name = 'bulk_' . $item->id; 45 $this->applyname = $this->name_for('apply'); 46 $this->selectname = $this->name_for('type'); 47 $this->insertname = $this->name_for('value'); 48 } 49 50 /** 51 * Is this checkbox checked? 52 * 53 * @param array|object $data The form data 54 * @return bool 55 */ 56 public function is_applied($data): bool { 57 return isset($data->{$this->applyname}); 58 } 59 60 /** 61 * Get the type of this input (user or grade) 62 * 63 * @param array|object $data The form data 64 * @return string 65 */ 66 public function get_type($data): string { 67 return $data->{$this->selectname}; 68 } 69 70 /** 71 * Get the value from either the user or grade. 72 * 73 * @param array|object $data The form data 74 * @return string 75 */ 76 public function get_insert_value($data): string { 77 return $data->{$this->insertname}; 78 } 79 80 /** 81 * Generate the html for this form element. 82 * 83 * @return string HTML 84 */ 85 public function html(): string { 86 global $OUTPUT; 87 88 $text = new text_attribute($this->insertname, "0", 'bulk'); 89 $context = (object) [ 90 'label' => get_string('bulklegend', 'gradereport_singleview'), 91 'applylabel' => get_string('bulkperform', 'gradereport_singleview'), 92 'applyname' => $this->applyname, 93 'menuname' => $this->selectname, 94 'menulabel' => get_string('bulkappliesto', 'gradereport_singleview'), 95 'menuoptions' => [ 96 ['value' => 'all', 'name' => get_string('all_grades', 'gradereport_singleview')], 97 ['value' => 'blanks', 'name' => get_string('blanks', 'gradereport_singleview'), 'selected' => true], 98 ], 99 'valuename' => $this->insertname, 100 'valuefield' => $text->html() 101 ]; 102 103 return $OUTPUT->render_from_template('gradereport_singleview/bulk_insert', $context); 104 } 105 106 /** 107 * This form element has 3 elements with different suffixes. 108 * Generate the name with the suffix. 109 * 110 * @param string $extend The suffix. 111 * @return string 112 */ 113 private function name_for($extend) { 114 return "{$this->name}_$extend"; 115 } 116 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body