Implement data privacy provider.
[moodle-mod_attendance.git] / duration_form.php
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 * This file contains the forms for duration
19 *
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
23 */
24
25 defined('MOODLE_INTERNAL') || die();
26 require_once($CFG->libdir.'/formslib.php');
27
28 /**
29 * class for displaying duration form.
30 *
31 * @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33 */
34 class mod_attendance_duration_form extends moodleform {
35
36 /**
37 * Called to define this moodle form
38 *
39 * @return void
40 */
41 public function definition() {
42
43 $mform =& $this->_form;
44
45 $cm = $this->_customdata['cm'];
46 $ids = $this->_customdata['ids'];
47
48 $mform->addElement('header', 'general', get_string('changeduration', 'attendance'));
49 $mform->addElement('static', 'count', get_string('countofselected', 'attendance'), count(explode('_', $ids)));
50
51 for ($i = 0; $i <= 23; $i++) {
52 $hours[$i] = sprintf("%02d", $i);
53 }
54 for ($i = 0; $i < 60; $i += 5) {
55 $minutes[$i] = sprintf("%02d", $i);
56 }
57 $durselect[] =& $mform->createElement('select', 'hours', '', $hours);
58 $durselect[] =& $mform->createElement('select', 'minutes', '', $minutes, false, true);
59 $mform->addGroup($durselect, 'durtime', get_string('newduration', 'attendance'), array(' '), true);
60
61 $mform->addElement('hidden', 'ids', $ids);
62 $mform->setType('ids', PARAM_ALPHANUMEXT);
63 $mform->addElement('hidden', 'id', $cm->id);
64 $mform->setType('id', PARAM_INT);
65 $mform->addElement('hidden', 'action', mod_attendance_sessions_page_params::ACTION_CHANGE_DURATION);
66 $mform->setType('action', PARAM_INT);
67
68 $mform->setDefaults(array('durtime' => array('hours' => 0, 'minutes' => 0)));
69
70 $submitstring = get_string('update', 'attendance');
71 $this->add_action_buttons(true, $submitstring);
72 }
73
74 }