-
Notifications
You must be signed in to change notification settings - Fork 3
/
settings.php
130 lines (115 loc) · 4.62 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
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
/**
* Plugin administration pages are defined here.
*
* @package local_catquiz
* @category admin
* @copyright 2024 Wunderbyte GmbH <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$componentname = 'local_catquiz';
// Default for users that have site config.
if ($hassiteconfig) {
$settings = new admin_settingpage($componentname . '_settings', get_string('pluginname', 'local_catquiz'));
$ADMIN->add('localplugins', $settings);
foreach (core_plugin_manager::instance()->get_plugins_of_type('catmodel') as $plugin) {
$plugin->load_settings($ADMIN, 'localplugins', $hassiteconfig);
}
$catscalelink = new moodle_url('/local/catquiz/manage_catscales.php');
$actionlink = new action_link($catscalelink, get_string('catquizsettings', 'local_catquiz'));
$settingslink = ['link' => $OUTPUT->render($actionlink)];
$settings->add(
new admin_setting_heading(
'local_catquiz/catscales',
get_string('catscales', 'local_catquiz'),
get_string('catscales:information', 'local_catquiz', $settingslink),
)
);
$settings->add(
new admin_setting_heading(
'local_catquiz/cattags',
get_string('cattags', 'local_catquiz'),
get_string('cattags:information', 'local_catquiz'),
)
);
$sql = "SELECT DISTINCT t.id, t.name
FROM {tag} t
LEFT JOIN {tag_instance} ti ON t.id=ti.tagid
WHERE ti.component=:component AND ti.itemtype=:itemtype AND t.isstandard=1";
$params = [
'component' => 'core',
'itemtype' => 'course',
];
$records = $DB->get_records_sql($sql, $params);
$options = [0 => 'notags'];
foreach ($records as $record) {
$options[$record->id] = $record->name;
}
$setting = new admin_setting_configmultiselect(
'local_catquiz/cattags',
get_string('choosetags', 'local_catquiz'),
'',
[],
$options,
);
$settings->add(new admin_setting_description('cattagdisclaimer', '', get_string('choosetags:disclaimer', 'local_catquiz')));
$settings->add($setting);
$settings->add(new admin_setting_configtext(
'local_catquiz/tr_sd_ratio',
get_string('tr_sd_ratio_name', 'local_catquiz'),
get_string('tr_sd_ratio_desc', 'local_catquiz'),
3.0,
PARAM_FLOAT)
);
$settings->add(new admin_setting_configtext(
'local_catquiz/minquestions_default',
get_string('minquestions_default_name', 'local_catquiz'),
get_string('minquestions_default_desc', 'local_catquiz'),
3,
'/^\d+$/'
)
);
$settings->add(
new admin_setting_configcheckbox(
'local_catquiz/automatic_reload_on_scale_selection',
get_string('automatic_reload_on_scale_selection', 'local_catquiz'),
get_string('automatic_reload_on_scale_selection_description', 'local_catquiz'),
1));
$settings->add(new admin_setting_configtext(
'local_catquiz/time_penalty_threshold',
get_string('time_penalty_threshold_name', 'local_catquiz'),
get_string('time_penalty_threshold_desc', 'local_catquiz'),
10,
'/^[1-9]\d*$/'
)
);
$settings->add(
new admin_setting_configcheckbox(
'local_catquiz/store_debug_info',
get_string('store_debug_info_name', 'local_catquiz'),
get_string('store_debug_info_desc', 'local_catquiz'),
0));
// Add a setting for the default maximum attempt duration.
$settings->add(new admin_setting_configtext(
'local_catquiz/maximum_attempt_duration_hours',
get_string('maxattemptduration', 'local_catquiz'),
get_string('maxattemptduration_desc', 'local_catquiz'),
24, // Default value.
PARAM_INT // Expect integer type.
));
}