Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
92.59% covered (success)
92.59%
25 / 27
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
open_form
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 definition
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
1 / 1
1
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
17namespace local_integritycase\form;
18
19defined('MOODLE_INTERNAL') || die();
20
21require_once($CFG->libdir . '/formslib.php');
22
23/**
24 * Form to open a case.
25 *
26 * @package    local_integritycase
27 * @copyright  2026 DevLMS <contact@devlms.com>
28 * @license    https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29 */
30class open_form extends \moodleform {
31    /**
32     * Define the fields. Custom data: students, activities and handlers, each id => name.
33     */
34    protected function definition() {
35        $mform = $this->_form;
36        $data = $this->_customdata;
37        $mform->addElement('hidden', 'courseid');
38        $mform->setType('courseid', PARAM_INT);
39
40        $mform->addElement('autocomplete', 'studentid', get_string('student', 'local_integritycase'), $data['students']);
41        $mform->addRule('studentid', null, 'required', null, 'client');
42        $mform->addElement(
43            'select',
44            'cmid',
45            get_string('activity', 'local_integritycase'),
46            [0 => get_string('none')] + $data['activities']
47        );
48        $mform->addElement('select', 'handlerid', get_string('handler', 'local_integritycase'), $data['handlers']);
49        $mform->addElement('textarea', 'summary', get_string('summary', 'local_integritycase'), ['rows' => 6, 'cols' => 60]);
50        $mform->setType('summary', PARAM_TEXT);
51        $mform->addRule('summary', null, 'required', null, 'client');
52        $mform->addElement(
53            'filemanager',
54            'evidence',
55            get_string('evidence', 'local_integritycase'),
56            null,
57            ['subdirs' => 0, 'maxfiles' => 20]
58        );
59        $mform->addHelpButton('evidence', 'evidence', 'local_integritycase');
60        $this->add_action_buttons(true, get_string('newcase', 'local_integritycase'));
61    }
62}