forked from Wunderbyte-GmbH/moodle-mod_mooduell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.php
executable file
·221 lines (193 loc) · 7.7 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?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/>.
/**
* Plugin administration pages are defined here.
*
* @package mod_mooduell
* @category admin
* @copyright 2020 David Bogner <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use mod_mooduell\utils\wb_payment;
defined('MOODLE_INTERNAL') || die();
global $ADMIN;
if ($ADMIN->fulltree) {
// Has PRO version been activated?
$proversion = wb_payment::pro_version_is_activated();
$settings->add(
new admin_setting_heading('licensekeycfgheading',
get_string('licensekeycfg', 'mod_mooduell'),
get_string('licensekeycfgdesc', 'mod_mooduell')));
// Dynamically change the license info text.
$licensekeydesc = get_string('licensekeydesc', 'mod_mooduell');
// Get license key which has been set in text field.
$pluginconfig = get_config('mooduell');
if (!empty($pluginconfig->licensekey)) {
$licensekey = $pluginconfig->licensekey;
$expirationdate = wb_payment::decryptlicensekey($licensekey);
if (!empty($expirationdate)) {
$licensekeydesc = "<p style='color: green; font-weight: bold'>"
.get_string('license_activated', 'mod_mooduell')
.$expirationdate
.")</p>";
} else {
$licensekeydesc = "<p style='color: red; font-weight: bold'>"
.get_string('license_invalid', 'mod_mooduell')
."</p>";
}
}
$settings->add(
new admin_setting_configtext('mooduell/licensekey',
get_string('licensekey', 'mod_mooduell'),
$licensekeydesc, ''));
$setting = new admin_setting_configcheckbox(
'mooduell/usefullnames',
get_string('usefullnames', 'mod_mooduell'),
"",
0
);
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
$settings->add($setting);
$settings->add(new admin_setting_configcheckbox(
'mooduell/showcontinuebutton',
get_string('showcontinuebutton', 'mod_mooduell'),
"",
0
));
$settings->add(new admin_setting_configcheckbox(
'mooduell/showcorrectanswer',
get_string('showcorrectanswer', 'mod_mooduell'),
"",
0
));
$settings->add(new admin_setting_configcheckbox(
'mooduell/showgeneralfeedback',
get_string('showgeneralfeedback', 'mod_mooduell'),
"",
0
));
$settings->add(new admin_setting_configcheckbox(
'mooduell/showanswersfeedback',
get_string('showanswersfeedback', 'mod_mooduell'),
"",
0
));
$name = new lang_string('countdown', 'mod_mooduell');
$options = [
"0" => get_string('nocountdown', 'mod_mooduell'),
"10" => get_string('xseconds', 'mod_mooduell', 10),
"20" => get_string('xseconds', 'mod_mooduell', 20),
"30" => get_string('xseconds', 'mod_mooduell', 30),
"60" => get_string('xseconds', 'mod_mooduell', 60),
"90" => get_string('xseconds', 'mod_mooduell', 90),
"120" => get_string('xseconds', 'mod_mooduell', 120),
];
$setting = new admin_setting_configselect(
'countdown',
$name,
"",
-1,
$options
);
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
$settings->add($setting);
$name = new lang_string('clicktomoveon', 'mod_mooduell');
$options = [
"0" => get_string('clicktomoveon', 'mod_mooduell'),
"2" => get_string('xseconds', 'mod_mooduell', 2),
"5" => get_string('xseconds', 'mod_mooduell', 5),
"10" => get_string('xseconds', 'mod_mooduell', 10),
"20" => get_string('xseconds', 'mod_mooduell', 20),
"30" => get_string('xseconds', 'mod_mooduell', 30),
];
$settings->add(new admin_setting_configselect(
'mooduell/waitfornextquestion',
$name,
"",
-1,
$options
));
$settings->add(new admin_setting_configtext(
'mooduell/cachetime',
get_string('cachetime', 'mod_mooduell'),
'',
300,
PARAM_INT
));
$settings->add(new admin_setting_configtext(
'mooduell/pushtoken',
get_string('pushtoken', 'mod_mooduell'),
'',
'',
PARAM_TEXT
));
$settings->add(new admin_setting_configtext(
'mooduell/supporturl',
get_string('supporturl', 'mod_mooduell'),
'',
'',
PARAM_URL
));
$settings->add(new admin_setting_configtext(
'mooduell/appstoreurl',
get_string('appstoreurl', 'mod_mooduell'),
'',
'https://apps.apple.com/at/app/mooduell/id1598911543',
PARAM_URL
));
$settings->add(new admin_setting_configtext(
'mooduell/playstoreurl',
get_string('playstoreurl', 'mod_mooduell'),
'',
'https://play.google.com/store/apps/details?id=at.wunderbyte.mooduellapp',
PARAM_URL
));
$settings->add(new admin_setting_configcheckbox(
'mooduell/enablepush',
get_string('enablepush', 'mod_mooduell'),
'',
0
));
$settings->add(new admin_setting_configcheckbox(
'mooduell/disablebadges',
get_string('disablesbadges', 'mod_mooduell'),
"",
0
));
if ($proversion) {
$settings->add(new admin_setting_configtextarea(
'mod_mooduell/themejsonarea',
get_string('theme', 'mod_mooduell'),
get_string('themedesc', 'mod_mooduell'),
'',
PARAM_TEXT
));
$settings->add(new admin_setting_configstoredfile(
'mod_mooduell/companylogo',
get_string('companylogo', 'mod_mooduell'),
get_string('companylogodesc', 'mod_mooduell'),
'themepicture',
0
));
$settings->add(new admin_setting_configstoredfile(
'mod_mooduell/companylogoalternative',
get_string('alternativelogo', 'mod_mooduell'),
get_string('alternativelogodesc', 'mod_mooduell'),
'themepicturealternative',
0
));
}
}