Merge pull request #83 from barrysspace/expired_self_enrolments_MDL26
[moodle-mod_attendance.git] / export_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 * Export attendance sessions forms
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 require_once($CFG->libdir.'/formslib.php');
26
27 /**
28 * class for displaying export form.
29 *
30 * @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32 */
33 class mod_attendance_export_form extends moodleform {
34
35 /**
36 * Called to define this moodle form
37 *
38 * @return void
39 */
40 public function definition() {
41
42 global $USER;
43 $mform =& $this->_form;
44
45 $course = $this->_customdata['course'];
46 $cm = $this->_customdata['cm'];
47 $modcontext = $this->_customdata['modcontext'];
48
49 $mform->addElement('header', 'general', get_string('export', 'quiz'));
50
51 $groupmode=groups_get_activity_groupmode($cm, $course);
52 $groups = groups_get_activity_allowed_groups($cm, $USER->id);
53 if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) {
54 $grouplist[0] = get_string('allparticipants');
55 }
56 if ($groups) {
57 foreach ($groups as $group) {
58 $grouplist[$group->id] = $group->name;
59 }
60 }
61 $mform->addElement('select', 'group', get_string('group'), $grouplist);
62
63 $ident = array();
64 $ident[] =& $mform->createElement('checkbox', 'id', '', get_string('studentid', 'attendance'));
65 $ident[] =& $mform->createElement('checkbox', 'uname', '', get_string('username'));
66
67 $optional = array('idnumber', 'institution', 'department');
68 foreach ($optional as $opt) {
69 $ident[] =& $mform->createElement('checkbox', $opt, '', get_string($opt));
70 $mform->setType($opt, PARAM_NOTAGS);
71 }
72
73 $mform->addGroup($ident, 'ident', get_string('identifyby', 'attendance'), array('<br />'), true);
74 $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true));
75 $mform->setType('id', PARAM_INT);
76 $mform->setType('uname', PARAM_INT);
77
78 $mform->addElement('checkbox', 'includeallsessions', get_string('includeall', 'attendance'), get_string('yes'));
79 $mform->setDefault('includeallsessions', true);
80 $mform->addElement('checkbox', 'includenottaken', get_string('includenottaken', 'attendance'), get_string('yes'));
81 $mform->addElement('checkbox', 'includeremarks', get_string('includeremarks', 'attendance'), get_string('yes'));
82 $mform->addElement('date_selector', 'sessionstartdate', get_string('startofperiod', 'attendance'));
83 $mform->setDefault('sessionstartdate', $course->startdate);
84 $mform->disabledIf('sessionstartdate', 'includeallsessions', 'checked');
85 $mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod', 'attendance'));
86 $mform->disabledIf('sessionenddate', 'includeallsessions', 'checked');
87
88 $mform->addElement('select', 'format', get_string('format'),
89 array('excel' => get_string('downloadexcel', 'attendance'),
90 'ooo' => get_string('downloadooo', 'attendance'),
91 'text' => get_string('downloadtext', 'attendance')
92 ));
93
94 $submit_string = get_string('ok');
95 $this->add_action_buttons(false, $submit_string);
96
97 $mform->addElement('hidden', 'id', $cm->id);
98 }
99 }
100