Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| agree_form | |
0.00% |
0 / 18 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
| definition | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
6 | |||
| validation | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | // This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>. |
| 16 | |
| 17 | namespace local_doublemark\form; |
| 18 | |
| 19 | defined('MOODLE_INTERNAL') || die(); |
| 20 | |
| 21 | require_once($CFG->libdir . '/formslib.php'); |
| 22 | |
| 23 | /** |
| 24 | * The lead's agreed mark, feedback for the student and a note for staff. |
| 25 | * |
| 26 | * Custom data: maxgrade (float). |
| 27 | * |
| 28 | * @package local_doublemark |
| 29 | * @copyright 2026 DevLMS <contact@devlms.com> |
| 30 | * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| 31 | */ |
| 32 | class agree_form extends \moodleform { |
| 33 | /** |
| 34 | * Fields. |
| 35 | */ |
| 36 | protected function definition() { |
| 37 | $mform = $this->_form; |
| 38 | foreach (['cmid', 'userid'] as $name) { |
| 39 | $mform->addElement('hidden', $name); |
| 40 | $mform->setType($name, PARAM_INT); |
| 41 | } |
| 42 | $mform->addElement('float', 'grade', get_string('agreedmark', 'local_doublemark', $this->_customdata['maxgrade'])); |
| 43 | $mform->addRule('grade', null, 'required', null, 'client'); |
| 44 | $mform->addElement('textarea', 'feedback', get_string('feedback', 'local_doublemark'), ['rows' => 5]); |
| 45 | $mform->setType('feedback', PARAM_TEXT); |
| 46 | $mform->addHelpButton('feedback', 'feedback', 'local_doublemark'); |
| 47 | $mform->addElement('textarea', 'note', get_string('note', 'local_doublemark'), ['rows' => 3]); |
| 48 | $mform->setType('note', PARAM_TEXT); |
| 49 | $mform->addHelpButton('note', 'note', 'local_doublemark'); |
| 50 | $this->add_action_buttons(true, get_string('saveagreed', 'local_doublemark')); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Grade within range. |
| 55 | * |
| 56 | * @param array $data |
| 57 | * @param array $files |
| 58 | * @return array |
| 59 | */ |
| 60 | public function validation($data, $files) { |
| 61 | $errors = parent::validation($data, $files); |
| 62 | $max = (float) $this->_customdata['maxgrade']; |
| 63 | if ($data['grade'] < 0 || $data['grade'] > $max) { |
| 64 | $errors['grade'] = get_string('error:range', 'local_doublemark', format_float($max, -1)); |
| 65 | } |
| 66 | return $errors; |
| 67 | } |
| 68 | } |