From 674114ce9762101fe07571fbc1bcfd31a22934a4 Mon Sep 17 00:00:00 2001 From: Alex Yeung Date: Mon, 16 Sep 2024 10:59:28 +0100 Subject: [PATCH] Add site level setting to enable/disable the plugin --- lang/en/local_assess_type.php | 3 +++ lib.php | 5 ++++ settings.php | 45 +++++++++++++++++++++++++++++++++++ version.php | 2 +- 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 settings.php diff --git a/lang/en/local_assess_type.php b/lang/en/local_assess_type.php index f1ec374..26f22a0 100644 --- a/lang/en/local_assess_type.php +++ b/lang/en/local_assess_type.php @@ -35,6 +35,9 @@ $string['info'] = 'Summative activities count towards the course mark in SITS and are flagged to learners as mandatory.'; $string['pluginname'] = 'Assessment type'; $string['privacy:metadata'] = 'Assessment type does not store any personal data.'; +$string['settings:enable'] = 'Enable assessment type plugin'; +$string['settings:enable:desc'] = 'Enable the assessment type plugin for course activities.'; +$string['settings:pagename'] = 'Assessment type settings'; $string['summative'] = 'Summative'; $string['summativeoption'] = 'Summative - counts towards course mark and is mapped in SITS'; $string['warning'] = 'This activity must be marked as Formative or Summative.'; diff --git a/lib.php b/lib.php index 92fe375..445cb54 100644 --- a/lib.php +++ b/lib.php @@ -35,6 +35,11 @@ function local_assess_type_coursemodule_standard_elements($formwrapper, $mform) { global $DB; + // Do not show assessment type options in activity's editing page if not enabled. + if (!get_config('local_assess_type', 'enabled')) { + return; + } + $cm = $formwrapper->get_current(); // Check list of mods where this is enabled. diff --git a/settings.php b/settings.php new file mode 100644 index 0000000..4455def --- /dev/null +++ b/settings.php @@ -0,0 +1,45 @@ +. + +/** + * Plugin administration pages are defined here. + * + * @package local_assess_type + * @category admin + * @copyright 2024 onwards University College London {@link https://www.ucl.ac.uk/} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @author Alex Yeung + */ + +defined('MOODLE_INTERNAL') || die(); + +if ($hassiteconfig) { + $ADMIN->add( + 'localplugins', + new admin_category('local_assess_type_settings', new lang_string('pluginname', 'local_assess_type')) + ); + $settings = new admin_settingpage('managelocalassesstype', new lang_string('settings:pagename', 'local_assess_type')); + + // Setting to enable/disable the plugin. + $settings->add(new admin_setting_configcheckbox( + 'local_assess_type/enabled', + get_string('settings:enable', 'local_assess_type'), + get_string('settings:enable:desc', 'local_assess_type'), + '1' + )); + + $ADMIN->add('localplugins', $settings); +} diff --git a/version.php b/version.php index dae8b9b..e803425 100644 --- a/version.php +++ b/version.php @@ -27,6 +27,6 @@ $plugin->component = 'local_assess_type'; $plugin->release = '1.0'; -$plugin->version = 2024091300; // YYYYMMDD. +$plugin->version = 2024091400; // YYYYMMDD. $plugin->requires = 2023100900; $plugin->maturity = MATURITY_STABLE;