1441 |
ariadna |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Adds settings links to admin tree.
|
|
|
19 |
*
|
|
|
20 |
* AI gets top billing in general because it's the future.
|
|
|
21 |
*
|
|
|
22 |
* @package core_admin
|
|
|
23 |
* @copyright 2024 Matt Porritt <matt.porritt@moodle.com>
|
|
|
24 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
25 |
*/
|
|
|
26 |
|
|
|
27 |
defined('MOODLE_INTERNAL') || die();
|
|
|
28 |
|
|
|
29 |
if ($hassiteconfig) {
|
|
|
30 |
// Add settings page for AI provider settings.
|
|
|
31 |
$providers = new admin_settingpage('aiprovider', new lang_string('aiproviders', 'ai'));
|
|
|
32 |
$providers->add(new admin_setting_heading('availableproviders',
|
|
|
33 |
get_string('availableproviders', 'core_ai'),
|
|
|
34 |
get_string('availableproviders_desc', 'core_ai')));
|
|
|
35 |
// Add call to action to add a new provider.
|
|
|
36 |
$providers->add(new \core_admin\admin\admin_setting_template_render(
|
|
|
37 |
name: 'addnewprovider',
|
|
|
38 |
templatename: 'core_ai/admin_add_provider',
|
|
|
39 |
context: ['addnewproviderurl' => new moodle_url('/ai/configure.php')]
|
|
|
40 |
));
|
|
|
41 |
|
|
|
42 |
$providers->add(new \core_ai\admin\admin_setting_provider_manager(
|
|
|
43 |
'aiprovider',
|
|
|
44 |
\core_ai\table\aiprovider_management_table::class,
|
|
|
45 |
'manageaiproviders',
|
|
|
46 |
new lang_string('manageaiproviders', 'core_ai'),
|
|
|
47 |
));
|
|
|
48 |
$ADMIN->add('ai', $providers);
|
|
|
49 |
|
|
|
50 |
// Add settings page for AI placement settings.
|
|
|
51 |
$placements = new admin_settingpage('aiplacement', new lang_string('aiplacements', 'ai'));
|
|
|
52 |
$placements->add(new admin_setting_heading('availableplacements',
|
|
|
53 |
get_string('availableplacements', 'core_ai'),
|
|
|
54 |
get_string('availableplacements_desc', 'core_ai')));
|
|
|
55 |
$placements->add(new \core_admin\admin\admin_setting_plugin_manager(
|
|
|
56 |
'aiplacement',
|
|
|
57 |
\core_ai\table\aiplacement_management_table::class,
|
|
|
58 |
'manageaiplacements',
|
|
|
59 |
new lang_string('manageaiplacements', 'core_ai'),
|
|
|
60 |
));
|
|
|
61 |
$ADMIN->add('ai', $placements);
|
|
|
62 |
|
|
|
63 |
// Load settings for all placements.
|
|
|
64 |
$plugins = core_plugin_manager::instance()->get_plugins_of_type('aiplacement');
|
|
|
65 |
foreach ($plugins as $plugin) {
|
|
|
66 |
/** @var \core\plugininfo\aiprovider $plugin */
|
|
|
67 |
$plugin->load_settings($ADMIN, 'ai', $hassiteconfig);
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
// AI reports category.
|
|
|
72 |
$ADMIN->add('reports', new admin_category('aireports', get_string('aireports', 'core_ai')));
|
|
|
73 |
// Add AI policy acceptance report.
|
|
|
74 |
$aipolicyacceptance = new admin_externalpage(
|
|
|
75 |
'aipolicyacceptancereport',
|
|
|
76 |
get_string('aipolicyacceptance', 'core_ai'),
|
|
|
77 |
new moodle_url('/ai/policy_acceptance_report.php'),
|
|
|
78 |
'moodle/ai:viewaipolicyacceptancereport'
|
|
|
79 |
);
|
|
|
80 |
$ADMIN->add('aireports', $aipolicyacceptance);
|
|
|
81 |
// Add AI usage report.
|
|
|
82 |
$aiusage = new admin_externalpage(
|
|
|
83 |
'aiusagereport',
|
|
|
84 |
get_string('aiusage', 'core_ai'),
|
|
|
85 |
new moodle_url('/ai/usage_report.php'),
|
|
|
86 |
'moodle/ai:viewaiusagereport',
|
|
|
87 |
);
|
|
|
88 |
$ADMIN->add('aireports', $aiusage);
|