-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathsettings.php
185 lines (157 loc) · 8.17 KB
/
settings.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
// This file is part of mod_offlinequiz for 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/>.
/**
* Administration settings definitions for the offlinequiz module.
*
* @package mod
* @subpackage offlinequiz
* @author Juergen Zimmer <zimmerj7@univie.ac.at>
* @copyright 2015 Academic Moodle Cooperation {@link http://www.academic-moodle-cooperation.org}
* @since Moodle 2.2+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
global $DB;
require_once($CFG->dirroot.'/mod/offlinequiz/lib.php');
require_once($CFG->dirroot.'/mod/offlinequiz/settingslib.php');
// Introductory explanation that all the settings are defaults for the add offlinequiz form.
$settings->add(new admin_setting_heading('offlinequizintro', '', get_string('configintro', 'offlinequiz')));
// User identification.
$settings->add(new admin_setting_configtext_user_formula('offlinequiz/useridentification',
get_string('useridentification', 'offlinequiz'), get_string('configuseridentification', 'offlinequiz'),
'[7]=idnumber' , PARAM_RAW, 30));
// Print study code field.
$settings->add(new admin_setting_configcheckbox('offlinequiz/printstudycodefield',
get_string('printstudycodefield', 'offlinequiz'), get_string('printstudycodefield_help', 'offlinequiz'),
1));
// Fontfamily.
require_once($CFG->dirroot . '/lib/pdflib.php');
$pdf = new pdf();
if($pdf) {
$fontfamilies = $pdf->get_font_families();
} else {
$fontfamilies = [];
$fontfamilies['fontfamilyfreserif'] = get_string('fontfamilyfreeserif', 'offlinequiz');
}
$options = [];
foreach ($fontfamilies as $name => $values) {
if(get_string_manager()->string_exists('fontfamily' . $name, 'offlinequiz') ) {
$options[$name] = get_string('fontfamily' . $name, 'offlinequiz');
} else {
$options[$name] = $name;
}
}
$settings->add(new admin_setting_configselect('offlinequiz/defaultpdffont',
get_string('defaultpdffont', 'offlinequiz'), get_string('defaultpdffont_help', 'offlinequiz'),
'freeserif', $options));
// PDF default fontsize.
$options = [
8 => 8,
9 => 9,
10 => 10,
11 => 11,
12 => 12,
14 => 14
];
$settings->add(new admin_setting_configselect('offlinequiz/defaultpdffontsize',
get_string('defaultpdffontsize', 'offlinequiz'), get_string('defaultpdffontsize_help', 'offlinequiz'),
10, $options));
// Shuffle questions.
$settings->add(new admin_setting_configcheckbox('offlinequiz/shufflequestions',
get_string('shufflequestions', 'offlinequiz'), get_string('configshufflequestions', 'offlinequiz'),
0));
// Shuffle within questions.
$settings->add(new admin_setting_configcheckbox('offlinequiz/shuffleanswers',
get_string('shufflewithin', 'offlinequiz'), get_string('configshufflewithin', 'offlinequiz'),
1));
// Logo image URL setting.
$settings->add(new admin_setting_configtext('offlinequiz/logourl', get_string('logourl', 'offlinequiz'),
get_string('logourldesc', 'offlinequiz'), '', PARAM_URL));
// Admin setting to disable display of copyright statement.
$settings->add(new admin_setting_configcheckbox('offlinequiz/showcopyright', get_string('showcopyright', 'offlinequiz'),
get_string('showcopyrightdesc', 'offlinequiz'), 1));
// Admin setting to set if participant usage is possible.
$settings->add(new admin_setting_configcheckbox('offlinequiz/defaultparticipantsusage', get_string('defaultparticipantsusage', 'offlinequiz'),
get_string('defaultparticipantsusagedesc', 'offlinequiz'), 1));
// Disable newlines around images.
$settings->add(new admin_setting_configcheckbox('offlinequiz/disableimgnewlines',
get_string('disableimgnewlines', 'offlinequiz'), get_string('configdisableimgnewlines', 'offlinequiz'),
0));
// Review options.
$settings->add(new admin_setting_heading('reviewheading',
get_string('reviewoptionsheading', 'offlinequiz'), ''));
foreach (mod_offlinequiz_admin_review_setting::fields() as $field => $name) {
$default = mod_offlinequiz_admin_review_setting::all_on();
$forceduring = null;
if ($field == 'attempt') {
$forceduring = true;
} else if ($field == 'overallfeedback') {
$default = $default ^ mod_offlinequiz_admin_review_setting::DURING;
$forceduring = false;
}
$settings->add(new mod_offlinequiz_admin_review_setting('offlinequiz/review' . $field,
$name, '', $default, $forceduring));
}
// Decimal places for overall grades.
$settings->add(new admin_setting_heading('gradingheading',
get_string('gradingoptionsheading', 'offlinequiz'), ''));
$options = array();
for ($i = 0; $i <= 3; $i++) {
$options[$i] = $i;
}
$settings->add(new admin_setting_configselect('offlinequiz/decimalpoints',
get_string('decimalplaces', 'offlinequiz'), get_string('configdecimalplaces', 'offlinequiz'),
2, $options));
$settings->add(new admin_setting_heading('scanningheading',
get_string('scanningoptionsheading', 'offlinequiz'), ''));
$options = array();
$options[610] = get_string("darkgray", "offlinequiz");
$options[640] = get_string("lightgray", "offlinequiz");
$options[670] = get_string("standard", "offlinequiz");
$options[680] = get_string("white", "offlinequiz");
$options[700] = get_string("pearlywhite", "offlinequiz");
$settings->add(new admin_setting_configselect('offlinequiz/papergray', get_string('papergray', 'offlinequiz'),
get_string('configpapergray', 'offlinequiz'), 670, $options));
$settings->add(new admin_setting_configtext('offlinequiz/blackwhitethreshold', get_string('blackwhitethreshold', 'offlinequiz'),
get_string('configblackwhitethreshold', 'offlinequiz'), '75', PARAM_INT));
$settings->add(new admin_setting_heading('correctionheading',
get_string('correctionoptionsheading', 'offlinequiz'), ''));
// Admin setting to allow teachers to enrol users with one click while correcting answer forms.
$settings->add(new admin_setting_configcheckbox('offlinequiz/oneclickenrol', get_string('oneclickenrol', 'offlinequiz'),
get_string('oneclickenroldesc', 'offlinequiz'), 0));
$studentroles = $DB->get_records('role', array('archetype' => 'student'), 'sortorder');
$options = array();
$default = null;
foreach ($studentroles as $role) {
if ($role->name) {
$name = $role->name;
} else {
$name = $role->shortname;
}
$options[$role->id] = $name;
if (!$default) {
$default = $role->id;
}
}
$settings->add(new admin_setting_configselect('offlinequiz/oneclickrole', get_string('oneclickrole', 'offlinequiz'),
get_string('oneclickroledesc', 'offlinequiz'), $default, $options));
$settings->add(new admin_setting_configtext('offlinequiz/keepfilesfordays', get_string('keepfilesfordays', 'offlinequiz'),
get_string('configkeepfilesfordays', 'offlinequiz'), 8, PARAM_INT));
$settings->add(new admin_setting_configcheckbox('offlinequiz/experimentalevaluation',
get_string('configexperimentalevaluation', 'offlinequiz'),
get_string('configexperimentalevaluationdesc', 'offlinequiz'), 0));
}