forked from integral-learning/moodle-auth_mumie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.php
161 lines (140 loc) · 5.86 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
<?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/>.
/**
* This file defines the global auth_mumie settings page.
*
* @package auth_mumie
* @copyright 2017-2020 integral-learning GmbH (https://www.integral-learning.de/)
* @author Tobias Goltz ([email protected])
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
require_once($CFG->dirroot . '/auth/mumie/classes/mumie_server.php');
global $DB, $PAGE;
$mumieservers = auth_mumie\mumie_server::get_all_servers();
// Build html table containing all saved mumie servers.
$table = new html_table();
$table->attributes['class'] = 'generaltable auth_index mumie_server_list_container';
$table->head = array(get_string("mumie_table_header_name", "auth_mumie"), get_string("mumie_table_header_url", "auth_mumie"),
get_string("mumie_edit_button", "auth_mumie"), get_string("mumie_delete_button", "auth_mumie"));
foreach ($mumieservers as $server) {
$id = "<span class='mumie_list_entry_id' hidden>" . $server->get_id() . "</span>";
$name = "<span class='mumie_list_entry_name'>" . $server->get_name() . "</span>" . $id;
$url = "<span class='mumie_list_entry_url'>" . $server->get_urlprefix() . "</span>";
$edit = "<a class = 'mumie_list_edit_button' title='" . get_string("mumie_edit_button", "auth_mumie") . "'>"
. '<span class="icon fa fa-cog fa-fw " aria-hidden="true" aria-label=""></span>'
. "</a>";
$deleteurl = "{$CFG->wwwroot}/auth/mumie/deletemumieserver.php?id={$server->get_id()}&sesskey={$USER->sesskey}";
$delete = "<a class = 'mumie_list_delete_button' href='{$deleteurl}' title='"
. get_string("mumie_delete_button", "auth_mumie")
. "'>"
. '<span class="icon fa fa-trash fa-fw " aria-hidden="true"></span>'
. "</a>";
$table->data[] = array($name, $url, $edit, $delete);
}
$addbutton = "<button class='btn mumie_add_server_button btn-primary' id='mumie_add_server_button'>"
. '<span class="icon fa fa-plus fa-fw " aria-hidden="true" aria-label=""></span>'
. get_string("mumie_add_server_button", "auth_mumie")
. "</button>";
if ($ADMIN->fulltree) {
// Header for authentication settings.
$settings->add(new admin_setting_heading(
'authorization',
get_string('mumie_authentication_header', 'auth_mumie'),
get_string('mumie_authentication_header_desc', 'auth_mumie')
));
$settings->add(new admin_setting_configtext(
'auth_mumie/mumie_api_key',
get_string('mumie_api_key', 'auth_mumie'),
get_string('mumie_api_key_desc', 'auth_mumie'),
'',
PARAM_ALPHANUM
));
$settings->add(new admin_setting_configtext(
'auth_mumie/mumie_org',
get_string('mumie_org', 'auth_mumie'),
get_string('mumie_org_desc', 'auth_mumie'),
'',
PARAM_ALPHANUMEXT
));
// Header for shared user data.
$settings->add(new admin_setting_heading(
'userdata',
get_string('mumie_shared_user_data', 'auth_mumie'),
get_string('mumie_shared_user_data_desc', 'auth_mumie')
));
$settings->add(new admin_setting_configcheckbox(
'auth_mumie/userdata_firstname',
get_string('mumie_firstname', 'auth_mumie'),
'',
0
));
$settings->add(new admin_setting_configcheckbox(
'auth_mumie/userdata_lastname',
get_string('mumie_lastname', 'auth_mumie'),
'',
0
));
$settings->add(new admin_setting_configcheckbox(
'auth_mumie/userdata_mail',
get_string('mumie_mail', 'auth_mumie'),
'',
0
));
// Header for MumieTask settings.
$settings->add(new admin_setting_heading(
'mumietask',
get_string('mumie_task_admin_header', 'auth_mumie'),
get_string('mumie_task_admin_header_desc', 'auth_mumie')
));
$gradepooloptions = array(
-1 => get_string('admin_gradepool_free_choice_option', 'auth_mumie'),
1 => get_string('admin_gradepool_private_option', 'auth_mumie'),
0 => get_string('admin_gradepool_shared_option', 'auth_mumie')
);
$settings->add(
new admin_setting_configselect(
'auth_mumie/defaultgradepool',
get_string('admin_gradepool_selection', 'auth_mumie'),
get_string('admin_gradepool_description', 'auth_mumie'),
-1,
$gradepooloptions
)
);
$settings->add(
new admin_setting_heading(
'mumie_servers',
get_string("mumie_server_list_heading", "auth_mumie"),
html_writer::table($table) . $addbutton
)
);
$settings->add(
new admin_setting_heading(
'mumie_dev_options',
get_string("mumie_dev_options_heading", "auth_mumie"),
get_string("mumie_dev_options_description", "auth_mumie")
)
);
$settings->add(new admin_setting_configtext(
'auth_mumie/mumie_problem_selector_url',
get_string('mumie_problem_selector_url', 'auth_mumie'),
get_string('mumie_problem_selector_url_description', 'auth_mumie'),
'https://pool.mumie.net',
PARAM_URL
));
$context = context_system::instance();
$PAGE->requires->js_call_amd('auth_mumie/settings', 'init', array(json_encode($context->id)));
}