-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexportresults_form.php
158 lines (142 loc) · 6.46 KB
/
exportresults_form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package quiz_exportresults
* @copyright 2022, Sven Waser <sven.waser@ksso.ch>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once("$CFG->libdir/formslib.php");
/**
* Form class where the form is placed together
*
* @package exportresults
* @category form
* @copyright 2022 Sven Waser
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quiz_exportresults_form extends moodleform {
public function definition() {
// Get global variables.
global $COURSE, $USER;
// Start Moodle form.
$mform = $this->_form; // Don't forget the underscore!
/******************************** General settings ********************************/
$mform->addElement('header',
'exportoptions',
get_string('exportresults_exportoptions_header', 'quiz_exportresults'),
'quiz_exportresults'
);
// Select export attempts.
$mform->addElement(
'select',
'attempts',
get_string('exportresults_exportoptions_select_info', 'quiz_exportresults'),
array(
'highest' => get_string('exportresults_exportoptions_option_highest_grade', 'quiz_exportresults'), // Add select-option.
'first' => get_string('exportresults_exportoptions_option_first_attempt', 'quiz_exportresults'), // Add select-option.
'last' => get_string('exportresults_exportoptions_option_last_attempt', 'quiz_exportresults'), // Add select-option.
'all' => get_string('exportresults_exportoptions_option_all_attempts', 'quiz_exportresults') // Add select-option.
)
);
// Check if group mode enabled.
if (groups_get_course_groupmode($COURSE) != 0) {
// Get all groups as option.
foreach (groups_get_user_groups($COURSE->id, $USER->id)[0] as $group) {
$options[$group] = groups_get_group_name($group);
}
// Add group selection to form.
$groupselect = $mform->addElement(
'select',
'groups',
get_string('exportresults_exportoptions_select_groups', 'quiz_exportresults'),
$options ?? null,
);
$groupselect->setMultiple(true);
}
// Checkbox to include questiontext.
$mform->addElement(
'advcheckbox',
'questions',
get_string('exportresults_exportoptions_checkbox_question', 'quiz_exportresults'),
get_string('exportresults_exportoptions_checkbox_question_label', 'quiz_exportresults')
);
$mform->setDefault('questions', 1);
/******************************** File Settings ********************************/
$mform->addElement(
'header',
'fileoptions',
get_string('exportresults_fileoptions_header', 'quiz_exportresults'),
'quiz_exportresults'
);
$mform->setExpanded('fileoptions', false);
// Includde margin-options.
$mform->addElement('text',
'margintop',
get_string('exportresults_fileoption_margintop', 'quiz_exportresults'),
"value='2cm'",
);
$mform->setTYpe('margintop', PARAM_RAW);
$mform->addElement('text',
'marginright',
get_string('exportresults_fileoption_marginright', 'quiz_exportresults'),
"value='2cm'",
);
$mform->setTYpe('marginright', PARAM_RAW);
$mform->addElement('text',
'marginbottom',
get_string('exportresults_fileoption_marginbottom', 'quiz_exportresults'),
"value='2cm'",
);
$mform->setTYpe('marginbottom', PARAM_RAW);
$mform->addElement('text',
'marginleft',
get_string('exportresults_fileoption_marginleft', 'quiz_exportresults'),
"value='2cm'",
);
$mform->setTYpe('marginleft', PARAM_RAW);
// Include font-size option.
$mform->addElement('text',
'fontsize',
get_string('exportresults_fileoption_fontsize', 'quiz_exportresults'),
"value='12pt'"
);
$mform->setTYpe('fontsize', PARAM_RAW);
// Include font-family option.
$options = array(
'Arial' => 'Arial',
'Times New Roman' => 'Times New Roman',
'Frutiger LT Com 55 Roman' => 'Frutiger LT Com 55 Roman',
);
$fontfamily = $mform->addElement('select',
'fontfamily',
get_string('exportresults_fileoption_fontfamily',
'quiz_exportresults'),
$options
);
$fontfamily->setSelected('Arial');
// Include line-height option.
$mform->addElement('text',
'lineheight',
get_string('exportresults_fileoption_lineheight', 'quiz_exportresults'),
"value='1.5'"
);
$mform->setTYpe('lineheight', PARAM_RAW);
// Include submit button.
$mform->closeHeaderBefore('submitbutton');
$mform->addElement('submit', 'submitbutton', get_string('exportresutls_submit', 'quiz_exportresults'));
}
}