New plugin! Advanced Config

I have started work on a new plugin for Moodle and it is now in alpha stages.

It allows for more advanced configuration management in Moodle (that sounds really boring). Despite how boring it sounds I am very excited about! It solves a problem that I have and hopefully it will solve some other people’s problems too.

Its main feature is that settings defined with it are inheritable and can be overridden in categories and the child categories in that category then inherit that new setting.

You can find out more at the github page for it: https://github.com/darrencocco/moodle-local_advancedconfig

Here is an image of those settings in one of my development instances:

Screenshot-2017-9-1 S1 Advanced Config Callista Grade Export

As you can see there is a little menu in the Administration block at the bottom of the Category menu that says Advanced Config. This leads to category context specific configuration page for one of our grade export tools.

Here is an example of a config file that defines those settings in particular:

<?php
namespace gradeexport_callista\settings;

use local_advancedconfig\model\basic_setting_definition;
use local_advancedconfig\model\setting_definition;
use local_advancedconfig\model\settings;
use local_advancedconfig\model\setting_definition\validate\param_generic;
use local_advancedconfig\model\setting_definition\input;
use local_advancedconfig\model\tree;

class basic_settings implements settings, tree {

    /** @var basic_settings */
    private static $instance = null;

    public static function get_instance() {
        if (is_null(self::$instance)) {
            self::$instance = new basic_settings();
        }
        return self::$instance;
    }

    /**
     * @return setting_definition[]
     */
    public function settings_defined() {
        return [
            'gradeexport_callista/adminnotificationemail' =&gt; new basic_setting_definition(
                'gradeexport_callista', 'adminnotificationemail',
                new param_generic(PARAM_TEXT),
                new input(input::TEXT), '',
                'gradeexport/callista:categoryadmin'),
            'gradeexport_callista/mainheader' =&gt; new basic_setting_definition(
                'gradeexport_callista', 'mainheader',
                new param_generic(PARAM_CLEANHTML),
                new input(input::HTML), '',
                'gradeexport/callista:categoryadmin'),
            'gradeexport_callista/confirmation' =&gt; new basic_setting_definition(
                'gradeexport_callista', 'confirmation',
                new param_generic(PARAM_CLEANHTML),
                new input(input::HTML), '',
                'gradeexport/callista:categoryadmin'),
        ];
    }

    /**
     * @return string
     */
    public function plugin_name() {
        return 'gradeexport_callista';
    }

    /**
     * @return branch[]
     */
    public function get_branches() {
        return [
            new tree\leaf\leaf_settings( 'gradeexports', 'gradeexportcallista',
                new \lang_string( 'pluginname', 'gradeexport_callista'),
                ['moodle/site:config', 'gradeexport/callista:categoryadmin'],[
                    new \admin_setting_configtext(
                        'gradeexport_callista/adminnotificationemail',
                        new \lang_string('adminnotificationemail', 'gradeexport_callista'),
                        new \lang_string( 'adminnotificationemail_help', 'gradeexport_callista'),
                        ''),
                    new \admin_setting_confightmleditor(
                        'gradeexport_callista/mainheader',
                        new \lang_string( 'mainheader', 'gradeexport_callista'),
                        new \lang_string( 'mainheader_desc', 'gradeexport_callista'),
                        ''),
                    new \admin_setting_confightmleditor(
                        'gradeexport_callista/confirmation',
                        new \lang_string( 'confirmation', 'gradeexport_callista'),
                        new \lang_string( 'confirmation_desc','gradeexport_callista'),
                        ''
                    ),
                ]),
        ];
    }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s