2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Forms for updating/adding attendance
20 * @package mod_attendance
21 * @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die();
26 require_once($CFG->dirroot
.'/course/moodleform_mod.php');
29 * class for displaying add/update form.
31 * @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34 class mod_attendance_mod_form
extends moodleform_mod
{
37 * Called to define this moodle form
41 public function definition() {
42 $attendanceconfig = get_config('attendance');
43 if (!isset($attendanceconfig->subnet
)) {
44 $attendanceconfig->subnet
= '';
46 $mform =& $this->_form
;
48 $mform->addElement('header', 'general', get_string('general', 'form'));
50 $mform->addElement('text', 'name', get_string('name'), array('size' => '64'));
51 $mform->setType('name', PARAM_TEXT
);
52 $mform->addRule('name', null
, 'required', null
, 'client');
53 $mform->setDefault('name', get_string('modulename', 'attendance'));
55 $this->standard_intro_elements();
58 $this->standard_grading_coursemodule_elements();
60 $this->standard_coursemodule_elements(true
);
63 if (get_config('attendance', 'subnetactivitylevel')) {
64 $mform->addElement('header', 'security', get_string('extrarestrictions', 'attendance'));
65 $mform->addElement('text', 'subnet', get_string('defaultsubnet', 'attendance'), array('size' => '164'));
66 $mform->setType('subnet', PARAM_TEXT
);
67 $mform->addHelpButton('subnet', 'defaultsubnet', 'attendance');
68 $mform->setDefault('subnet', $attendanceconfig->subnet
);
70 $mform->addElement('hidden', 'subnet', '');
71 $mform->setType('subnet', PARAM_TEXT
);
74 $this->add_action_buttons();