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 * This file contains the forms for duration
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->libdir
.'/formslib.php');
29 * class for displaying duration 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_duration_form
extends moodleform
{
37 * Called to define this moodle form
41 public function definition() {
43 $mform =& $this->_form
;
45 $cm = $this->_customdata
['cm'];
46 $ids = $this->_customdata
['ids'];
48 $mform->addElement('header', 'general', get_string('changeduration', 'attendance'));
49 $mform->addElement('static', 'count', get_string('countofselected', 'attendance'), count(explode('_', $ids)));
51 for ($i = 0; $i <= 23; $i++
) {
52 $hours[$i] = sprintf("%02d", $i);
54 for ($i = 0; $i < 60; $i +
= 5) {
55 $minutes[$i] = sprintf("%02d", $i);
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
);
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
);
68 $mform->setDefaults(array('durtime' => array('hours' => 0, 'minutes' => 0)));
70 $submitstring = get_string('update', 'attendance');
71 $this->add_action_buttons(true
, $submitstring);