moodle_local_treestudyplan/settings.php

395 lines
16 KiB
PHP
Raw Permalink Normal View History

<?php
2023-08-24 23:02:41 +02:00
// This file is part of Moodle - http://moodle.org/.
//
2023-08-24 23:02:41 +02:00
// 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.
//
2024-06-02 19:23:40 +02:00
// Moodle is distributed in the hope that it will be useful, .
2023-08-24 23:02:41 +02:00
// 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.
//
2023-08-24 23:02:41 +02:00
// You should have received a copy of the GNU General Public License.
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
2023-08-27 15:12:54 +02:00
* Local plugin Settings
*
2023-08-27 15:12:54 +02:00
* @package local_treestudyplan
* @copyright 2023 P.M. Kuipers
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
use local_treestudyplan\aggregator;
if ($hassiteconfig) {
2023-08-25 09:44:34 +02:00
/**************************************
*
* Main studyplan settings
*
*************************************/
// Create admin settings category.
$ADMIN->add('courses', new admin_category('local_treestudyplan',
get_string('pluginname', 'local_treestudyplan', null, true)));
// Settings page: Root nodes.
$page = new admin_settingpage('local_treestudyplan_settings',
get_string('settingspage', 'local_treestudyplan', null, true));
2023-09-08 12:47:29 +02:00
// NAVIGATION.
$page->add(new admin_setting_heading('local_treestudyplan/navigation_heading',
get_string('setting_navigation_heading', 'local_treestudyplan'),
get_string('settingdesc_navigation_heading', 'local_treestudyplan')
));
2023-09-08 12:47:29 +02:00
$page->add(new admin_setting_configcheckbox('local_treestudyplan/primary_nav_autofill',
get_string('setting_primary_nav_autofill', 'local_treestudyplan'),
get_string('settingdesc_primary_nav_autofill', 'local_treestudyplan'),
true,
));
2024-06-02 23:23:32 +02:00
// Default image for study plans.
2024-06-02 19:23:40 +02:00
$page->add(new admin_setting_configstoredfile('local_treestudyplan/defaulticon',
get_string('setting_defaulticon', 'local_treestudyplan'),
get_string('settingdesc_defaulticon', 'local_treestudyplan'),
'defaulticon', 0,
[
2024-06-02 19:23:40 +02:00
'maxfiles' => 1,
'accepted_types' => ['.jpg', '.png']]
));
// OUTCOME AGGREGATION SETTINGS.
2023-08-25 09:44:34 +02:00
$page->add(new admin_setting_heading('local_treestudyplan/aggregation_heading',
get_string('setting_aggregation_heading', 'local_treestudyplan'),
get_string('settingdesc_aggregation_heading', 'local_treestudyplan')
));
$aggregators = [];
foreach (aggregator::list() as $a) {
$aggregators[$a] = get_string("{$a}_aggregator_title", 'local_treestudyplan', null, true);
}
$page->add(new admin_setting_configselect('local_treestudyplan/aggregation_mode',
get_string('setting_aggregation_mode', 'local_treestudyplan'),
get_string('settingdesc_aggregation_mode', 'local_treestudyplan'),
"core",
$aggregators
));
// DISPLAY COURSE INFO SETTINGS.
$page->add(new admin_setting_heading('local_treestudyplan/display_heading',
get_string('setting_display_heading', 'local_treestudyplan'),
get_string('settingdesc_display_heading', 'local_treestudyplan')
));
2024-06-02 23:23:32 +02:00
$displayfields = [
"shortname" => get_string("shortname"),
"idnumber" => get_string("idnumber"),
"fullname" => get_string("fullname"),
];
$infofields = [
"" => get_string('none'),
"description" => get_string("description"),
"contacts" => get_string("teachers"),
"idnumber" => get_string("idnumber"),
];
2023-08-25 09:44:34 +02:00
$handler = \core_customfield\handler::get_handler('core_course', 'course');
foreach ($handler->get_categories_with_fields() as $cat) {
$catname = $cat->get_formatted_name();
foreach ($cat->get_fields() as $field) {
$visibility = $field->get_configdata_property("visibility");
if ($visibility > 0) {
// Only include fields that are visible to Teachers, or Everyone.
$fieldname = $field->get_formatted_name();
$fieldid = $field->get("shortname");
$displayfields["customfield_".$fieldid] = $catname.": ".$fieldname;
$infofields["customfield_".$fieldid] = $catname.": ".$fieldname;
}
2023-08-25 09:44:34 +02:00
}
}
2024-06-02 23:23:32 +02:00
2023-12-11 23:41:03 +01:00
$page->add(new admin_setting_configcheckbox('local_treestudyplan/enableplansharing',
get_string('setting_enableplansharing', 'local_treestudyplan'),
get_string('settingdesc_enableplansharing', 'local_treestudyplan'),
true,
));
2023-08-25 09:44:34 +02:00
$page->add(new admin_setting_configcheckbox('local_treestudyplan/timelessperiods',
get_string('setting_timelessperiods', 'local_treestudyplan'),
get_string('settingdesc_timelessperiods', 'local_treestudyplan'),
false,
));
$page->add(new admin_setting_configcheckbox('local_treestudyplan/limitcourselist',
get_string('setting_limitcourselist', 'local_treestudyplan'),
get_string('settingdesc_limitcourselist', 'local_treestudyplan'),
false,
));
2024-04-21 23:08:03 +02:00
$page->add(new admin_setting_configcheckbox('local_treestudyplan/hivizdropslots',
get_string('setting_hivizdropslots', 'local_treestudyplan'),
get_string('settingdesc_hivizdropslots', 'local_treestudyplan'),
false,
));
$page->add(new admin_setting_configcheckbox('local_treestudyplan/toolboxleft',
get_string('setting_toolboxleft', 'local_treestudyplan'),
get_string('settingdesc_toolboxleft', 'local_treestudyplan'),
2024-06-01 14:00:32 +02:00
true,
2024-04-21 23:08:03 +02:00
));
2024-08-08 12:24:19 +02:00
$page->add(new admin_setting_configcheckbox('local_treestudyplan/toolboxcoursesonly',
get_string('setting_toolboxcoursesonly', 'local_treestudyplan'),
get_string('settingdesc_toolboxcoursesonly', 'local_treestudyplan'),
false,
));
2024-06-02 19:23:40 +02:00
2024-08-08 19:27:51 +02:00
$page->add(new admin_setting_configcheckbox('local_treestudyplan/showprevnextarrows',
get_string('setting_showprevnextarrows', 'local_treestudyplan'),
get_string('settingdesc_showprevnextarrows', 'local_treestudyplan'),
true,
));
2024-06-01 14:00:32 +02:00
$page->add(new admin_setting_configcheckbox('local_treestudyplan/copystudylinesnewpage',
get_string('setting_copystudylinesnewpage', 'local_treestudyplan'),
get_string('settingdesc_copystudylinesnewpage', 'local_treestudyplan'),
false,
));
$page->add(new admin_setting_configcheckbox('local_treestudyplan/continueperiodnumberingnewpage',
get_string('setting_continueperiodnumberingnewpage', 'local_treestudyplan'),
get_string('settingdesc_continueperiodnumberingnewpage', 'local_treestudyplan'),
false,
));
$page->add(new admin_setting_configcheckbox('local_treestudyplan/enablecoach',
get_string('setting_enablecoach', 'local_treestudyplan'),
get_string('settingdesc_enablecoach', 'local_treestudyplan'),
false,
));
2023-08-25 09:44:34 +02:00
$page->add(new admin_setting_configselect('local_treestudyplan/display_field',
get_string('setting_display_field', 'local_treestudyplan'),
get_string('settingdesc_display_field', 'local_treestudyplan'),
"shortname",
$displayfields
));
2023-12-11 09:30:55 +01:00
$page->add(new admin_setting_configcheckbox('local_treestudyplan/courseprogressbar',
get_string('setting_courseprogressbar', 'local_treestudyplan'),
get_string('settingdesc_courseprogressbar', 'local_treestudyplan'),
false,
));
$page->add(new admin_setting_heading('local_treestudyplan/infofields_heading',
get_string('setting_infofields_heading', 'local_treestudyplan'),
get_string('settingdesc_infofields_heading', 'local_treestudyplan')
));
2024-06-02 19:23:40 +02:00
$positions = [ "above" => get_string('infofield_position_above', 'local_treestudyplan'),
"below" => get_string("infofield_position_below", 'local_treestudyplan'),
2023-12-11 09:30:55 +01:00
];
2024-06-02 23:23:32 +02:00
for ($i = 1; $i <= 5; $i++) {
2023-12-11 09:30:55 +01:00
$page->add(new admin_setting_configselect('local_treestudyplan/courseinfo'.$i.'_field',
get_string('setting_infofield'.$i.'_field', 'local_treestudyplan'),
get_string('settingdesc_infofield'.$i.'_field', 'local_treestudyplan'),
"",
$infofields
));
$page->add(new admin_setting_configselect('local_treestudyplan/courseinfo'.$i.'_position',
get_string('setting_infofield'.$i.'_position', 'local_treestudyplan'),
get_string('settingdesc_infofield'.$i.'_position', 'local_treestudyplan'),
"below",
$positions
));
$page->add(new admin_setting_configtextarea('local_treestudyplan/courseinfo'.$i.'_title',
get_string('setting_infofield'.$i.'_title', 'local_treestudyplan'),
get_string('settingdesc_infofield'.$i.'_title', 'local_treestudyplan'),
"Information $i|en\nInformatie $i|nl"
));
}
2023-12-11 09:30:55 +01:00
// COMPETENCY AGGREGATON DEFAULTS.
$page->add(new admin_setting_configselect('local_treestudyplan/competency_displayname',
get_string('setting_competency_displayname', 'local_treestudyplan'),
get_string('settingdesc_competency_displayname', 'local_treestudyplan'),
"idnumber",
2024-06-02 19:23:40 +02:00
["shortname" => get_string("name", "core", ),
"idnumber" => get_string("idnumber", "core", ),
"description" => get_string("description", "core", )]
));
2024-06-02 19:23:40 +02:00
$page->add(new admin_setting_configselect('local_treestudyplan/competency_detailfield',
get_string('setting_competency_detailfield', 'local_treestudyplan'),
get_string('settingdesc_competency_detailfield', 'local_treestudyplan'),
"shortname",
2024-06-02 23:23:32 +02:00
["" => get_string("none", "core", ),
2024-06-02 19:23:40 +02:00
"shortname" => get_string("name", "core", ),
"idnumber" => get_string("idnumber", "core", ),
"description" => get_string("description", "core", )]
));
2023-11-23 07:44:04 +01:00
$page->add(new admin_setting_heading('local_treestudyplan/competency_aggregation_heading',
get_string('setting_competency_heading', 'local_treestudyplan'),
get_string('settingdesc_competency_heading', 'local_treestudyplan')
));
2024-08-30 12:42:52 +02:00
2023-11-23 07:44:04 +01:00
$page->add(new admin_setting_configtext('local_treestudyplan/competency_thresh_completed',
get_string('setting_competency_thresh_completed', 'local_treestudyplan'),
get_string('settingdesc_competency_thresh_completed', 'local_treestudyplan'),
"66",
PARAM_INT
));
$page->add(new admin_setting_configcheckbox('local_treestudyplan/competency_support_failed',
get_string('setting_competency_support_failed', 'local_treestudyplan'),
get_string('settingdesc_competency_support_failed', 'local_treestudyplan'),
true,
));
2023-08-25 09:44:34 +02:00
// BISTATE AGGREGATON DEFAULTS.
$page->add(new admin_setting_heading('local_treestudyplan/bistate_aggregation_heading',
get_string('setting_bistate_heading', 'local_treestudyplan'),
get_string('settingdesc_bistate_heading', 'local_treestudyplan')
));
$page->add(new admin_setting_configtext('local_treestudyplan/bistate_thresh_excellent',
get_string('setting_bistate_thresh_excellent', 'local_treestudyplan'),
get_string('settingdesc_bistate_thresh_excellent', 'local_treestudyplan'),
"100",
PARAM_INT
));
$page->add(new admin_setting_configtext('local_treestudyplan/bistate_thresh_good',
get_string('setting_bistate_thresh_good', 'local_treestudyplan'),
get_string('settingdesc_bistate_thresh_good', 'local_treestudyplan'),
"80",
PARAM_INT
));
$page->add(new admin_setting_configtext('local_treestudyplan/bistate_thresh_completed',
get_string('setting_bistate_thresh_completed', 'local_treestudyplan'),
get_string('settingdesc_bistate_thresh_completed', 'local_treestudyplan'),
"66",
PARAM_INT
));
$page->add(new admin_setting_configcheckbox('local_treestudyplan/bistate_support_failed',
get_string('setting_bistate_support_failed', 'local_treestudyplan'),
get_string('settingdesc_bistate_support_failed', 'local_treestudyplan'),
2023-08-25 12:16:51 +02:00
true,
2023-08-25 09:44:34 +02:00
));
$page->add(new admin_setting_configcheckbox('local_treestudyplan/bistate_accept_pending_submitted',
get_string('setting_bistate_accept_pending_submitted', 'local_treestudyplan'),
get_string('settingdesc_bistate_accept_pending_submitted', 'local_treestudyplan'),
2023-08-25 12:16:51 +02:00
false,
2023-08-25 09:44:34 +02:00
));
// Add settings page to the admin settings category.
$ADMIN->add('local_treestudyplan', $page);
/**************************************
*
* Manage plans link (systemwide)
*
*************************************/
$ADMIN->add('local_treestudyplan', new admin_externalpage(
'local_treestudyplan_editplans',
get_string('cfg_plans', 'local_treestudyplan', null, true),
$CFG->wwwroot . '/local/treestudyplan/edit-plan.php'));
/**************************************
*
* Settings page: Cohort sync
*
*************************************/
2023-08-25 10:41:56 +02:00
2023-08-25 09:44:34 +02:00
$pagecsync = new admin_settingpage('local_treestudyplan_settings_cohortsync',
get_string('settingspage_csync', 'local_treestudyplan', null, true));
// Description heading.
$pagecsync->add(new admin_setting_heading('local_treestudyplan/csync_heading',
get_string('setting_csync_heading', 'local_treestudyplan'),
get_string('settingdesc_csync_heading', 'local_treestudyplan')
));
// Enable/disable cohort sync.
$pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_enable',
get_string('setting_csync_enable_field', 'local_treestudyplan'),
get_string('settingdesc_csync_enable_field', 'local_treestudyplan'),
false
));
// Enable/disable autoremove.
$pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_autoremove',
get_string('setting_csync_autoremove_field', 'local_treestudyplan'),
get_string('settingdesc_csync_autoremove_field', 'local_treestudyplan'),
true
));
// Enable/disable remembering previously added cohort syncs so they're not automatically deleted.
$pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_remember_manual_csync',
get_string('setting_csync_remember_manual_csync_field', 'local_treestudyplan'),
get_string('settingdesc_csync_remember_manual_csync_field', 'local_treestudyplan'),
true
));
// Enable/disable group creation.
$pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_creategroup',
get_string('setting_csync_creategroup_field', 'local_treestudyplan'),
get_string('settingdesc_csync_creategroup_field', 'local_treestudyplan'),
true
));
// Sync users too yes/no?.
$pagecsync->add(new admin_setting_configcheckbox('local_treestudyplan/csync_users',
get_string('setting_csync_users_field', 'local_treestudyplan'),
get_string('settingdesc_csync_users_field', 'local_treestudyplan'),
true
));
// Select csync enrol role.
if (!during_initial_install()) {
$options = get_default_enrol_roles(context_system::instance());
$student = get_archetype_roles('student');
$student = reset($student);
$pagecsync->add(new admin_setting_configselect('local_treestudyplan/csync_roleid',
get_string('setting_csync_role_field', 'local_treestudyplan'),
get_string('settingdesc_csync_role_field', 'local_treestudyplan'),
$student->id ?? null, $options));
}
// Add settings page2 to the admin settings category.
$ADMIN->add('local_treestudyplan', $pagecsync);
/**************************************
*
* Grade and scale interpretation
*
*************************************/
$ADMIN->add('local_treestudyplan', new admin_externalpage(
'local_treestudyplan_gradeconfig',
get_string('cfg_grades', 'local_treestudyplan', null, true),
$CFG->wwwroot . '/local/treestudyplan/cfg_grades.php'));
/**************************************
*
* Add the help link (Temporary until a better place is found)
*
**************************************/
$ADMIN->add('local_treestudyplan', new admin_externalpage(
'local_treestudyplan_doc',
get_string('cfg_help', 'local_treestudyplan', null, true),
$CFG->wwwroot . '/local/treestudyplan/doc.php/index.htm'));
}