forked from jsxgraph/moodle-filter_jsxgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.php
265 lines (233 loc) · 10.9 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<?php
// This file is part of JSXGraph Moodle Filter.
//
// 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/>.
/**
* This is a plugin to enable function plotting and dynamic geometry constructions with JSXGraph within a Moodle platform.
*
* JSXGraph is a cross-browser JavaScript library for interactive geometry,
* function plotting, charting, and data visualization in the web browser.
* JSXGraph is implemented in pure JavaScript and does not rely on any other
* library. Special care has been taken to optimize the performance.
*
* @package filter_jsxgraph
* @copyright 2023 JSXGraph team - Center for Mobile Learning with Digital Technology – Universität Bayreuth
* Matthias Ehmann,
* Michael Gerhaeuser,
* Carsten Miller,
* Andreas Walter <[email protected]>,
* Alfred Wassermann <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
// Add the placeholder to the description of a setting that should be separated from the following setting.
// Deprecated.
$styles = '<style type="text/css">' .
' code { ' .
' padding: .2em .4em;' .
' margin: 0;' .
' font-size: 85%;' .
' background-color: rgba(175,184,193,0.2);' .
' color: #212529;' .
' border-radius: 6px;' .
' }' .
'</style>';
$versionsconfig = json_decode(get_config('filter_jsxgraph', 'versions'), true);
if (!$versionsconfig) {
$versionsconfig = [["label" => "auto"]];
}
$versions = [];
foreach ($versionsconfig as $v) {
$versions[$v["id"]] = $v["id"] === "auto" ? get_string('versionJSXGraph_auto', 'filter_jsxgraph') : $v["label"];
}
if (!function_exists('get_jsxfilter_version')) {
/**
* Get the filter version as a HTML-String.
*
* @return string
*/
function get_jsxfilter_version() {
$release = get_config('filter_jsxgraph', 'release');
$version = get_config('filter_jsxgraph', 'version');
if (substr($version, 8, 2) === '00') {
$version = substr($version, 0, 8);
} else {
$version = substr_replace($version, ' (', 8, 0) . ')';
}
$version = substr_replace($version, '-', 6, 0);
$version = substr_replace($version, '-', 4, 0);
return '<div style="text-align: center;margin-top: -0.75rem;margin-bottom: 1rem;">' .
($release !== "" ?
'<i><b>' . $release . '</b><br><small>' . $version . '</small></i>' :
'<b><i>' . $version . '</i></b>'
) .
'</div>';
}
}
if (!function_exists('get_recommended_version_with_prefix')) {
/**
* Get the recommended JSXGraph version as a HTML-String.
*
* @return string
*/
function get_recommended_version_with_prefix() {
$recommended = get_config('filter_jsxgraph', 'recommendedJSX');
if (!$recommended) {
return '';
} else {
return get_string('recommendedversion_pre', 'filter_jsxgraph') .
$recommended .
get_string('recommendedversion_post', 'filter_jsxgraph');
}
}
}
$settings->add(new admin_setting_heading('filter_jsxgraph/styles', '', $styles));
$settings->add(new admin_setting_heading(
'filter_jsxgraph/docs',
get_string('header_docs', 'filter_jsxgraph'),
get_string('docs', 'filter_jsxgraph')
));
$settings->add(new admin_setting_heading(
'filter_jsxgraph/versions_info',
get_string('header_versions', 'filter_jsxgraph'),
get_string('filterversion', 'filter_jsxgraph') .
get_jsxfilter_version() .
get_recommended_version_with_prefix()
));
$settings->add(new admin_setting_heading(
'filter_jsxgraph/version_header',
get_string('header_jsxversion', 'filter_jsxgraph'),
''
));
$settings->add(new admin_setting_configselect(
'filter_jsxgraph/versionJSXGraph',
get_string('versionJSXGraph', 'filter_jsxgraph'),
get_string('versionJSXGraph_desc', 'filter_jsxgraph'),
"auto",
$versions
));
$settings->add(new admin_setting_heading(
'filter_jsxgraph/libs',
get_string('header_libs', 'filter_jsxgraph'),
''
));
$settings->add(new admin_setting_configselect(
'filter_jsxgraph/formulasextension',
get_string('formulasextension', 'filter_jsxgraph'),
get_string('formulasextension_desc', 'filter_jsxgraph'),
'1',
[get_string('off', 'filter_jsxgraph'), get_string('on', 'filter_jsxgraph')]
));
$settings->add(new admin_setting_heading(
'filter_jsxgraph/codingbetweentags',
get_string('header_codingbetweentags', 'filter_jsxgraph'),
''
));
$settings->add(new admin_setting_configselect(
'filter_jsxgraph/html_entities',
get_string('html_entities', 'filter_jsxgraph'),
get_string('html_entities_desc', 'filter_jsxgraph'),
'1',
[get_string('no', 'filter_jsxgraph'), get_string('yes', 'filter_jsxgraph')]
));
$settings->add(new admin_setting_configselect(
'filter_jsxgraph/convertencoding',
get_string('convertencoding', 'filter_jsxgraph'),
get_string('convertencoding_desc', 'filter_jsxgraph'),
'1',
[get_string('no', 'filter_jsxgraph'), get_string('yes', 'filter_jsxgraph')]
));
$settings->add(new admin_setting_heading(
'filter_jsxgraph/globaljs',
get_string('header_globaljs', 'filter_jsxgraph'),
''
));
$settings->add(new admin_setting_configtextarea(
'filter_jsxgraph/globalJS',
get_string('globalJS', 'filter_jsxgraph'),
get_string('globalJS_desc', 'filter_jsxgraph'),
'', PARAM_RAW, 60, 20
));
$settings->add(new admin_setting_heading(
'filter_jsxgraph/dimensions',
get_string('header_dimensions', 'filter_jsxgraph'),
get_string('dimensions', 'filter_jsxgraph')
));
$settings->add(new admin_setting_configtext(
'filter_jsxgraph/aspectratio',
get_string('aspectratio', 'filter_jsxgraph'),
get_string('aspectratio_desc', 'filter_jsxgraph'),
'', PARAM_TEXT
));
$settings->add(new admin_setting_configtext(
'filter_jsxgraph/fixwidth',
get_string('fixwidth', 'filter_jsxgraph'),
get_string('fixwidth_desc', 'filter_jsxgraph'),
get_config('filter_jsxgraph', 'width') ?? '', PARAM_TEXT
));
$settings->add(new admin_setting_configtext(
'filter_jsxgraph/fixheight',
get_string('fixheight', 'filter_jsxgraph'),
get_string('fixheight_desc', 'filter_jsxgraph'),
get_config('filter_jsxgraph', 'height') ?? '', PARAM_TEXT
));
$settings->add(new admin_setting_configtext(
'filter_jsxgraph/maxwidth',
get_string('maxwidth', 'filter_jsxgraph'),
get_string('maxwidth_desc', 'filter_jsxgraph'),
'', PARAM_TEXT
));
$settings->add(new admin_setting_configtext(
'filter_jsxgraph/maxheight',
get_string('maxheight', 'filter_jsxgraph'),
get_string('maxheight_desc', 'filter_jsxgraph'),
'', PARAM_TEXT
));
$settings->add(new admin_setting_configtext(
'filter_jsxgraph/fallbackaspectratio',
get_string('fallbackaspectratio', 'filter_jsxgraph'),
get_string('fallbackaspectratio_desc', 'filter_jsxgraph'),
'1 / 1', PARAM_TEXT
));
$settings->add(new admin_setting_configtext(
'filter_jsxgraph/fallbackwidth',
get_string('fallbackwidth', 'filter_jsxgraph'),
get_string('fallbackwidth_desc', 'filter_jsxgraph'),
'100%', PARAM_TEXT
));
$settings->add(new admin_setting_heading(
'filter_jsxgraph/deprecated',
get_string('header_deprecated', 'filter_jsxgraph'),
''
));
$settings->add(new admin_setting_configselect(
'filter_jsxgraph/usedivid',
get_string('usedivid', 'filter_jsxgraph'),
get_string('usedivid_desc', 'filter_jsxgraph'),
'0',
[get_string('no', 'filter_jsxgraph'), get_string('yes', 'filter_jsxgraph')]
));
$settings->add(new admin_setting_configtext(
'filter_jsxgraph/divid',
get_string('divid', 'filter_jsxgraph'),
get_string('divid_desc', 'filter_jsxgraph'),
'box'
));
$settings->add(new admin_setting_heading(
'filter_jsxgraph/last',
'',
'<br><br>'
));
}