Incorporating core moodle functionality into theme

Incorporating core moodle functionality into theme

by Marco Cigna -
Number of replies: 3

Hi,

I'm new to theming and was wondering if you could incorporate changes to core moodle functionality into the theme (like an override). I know you can override mustache templates and renderers, but what if the core functionality you want to edit isn't in either? would it still be possible to add to the theme? An example:

mod/assign/locallib.php


    protected function notify_student_submission_receipt(stdClass $submission) {

        global $DB, $USER;


        $adminconfig = $this->get_admin_config();

        if (empty($adminconfig->submissionreceipts)) {

            // No need to do anything.

            return;

        }

        if ($submission->userid) {

            $user = $DB->get_record('user', array('id'=>$submission->userid), '*', MUST_EXIST);

        } else {

            $user = $USER;

        }

        if ($submission->userid == $USER->id) {

            $this->send_notification(core_user::get_noreply_user(),

                                     $user,

                                     'submissionreceipt',

                                     'assign_notification',

                                     $submission->timemodified);

        } else {

            // $this->send_notification($USER,

            //                          $user,

            //                          'submissionreceiptother',

            //                          'assign_notification',

            //                          $submission->timemodified);
         }
}

All i want is to comment out these last few lines, but I heard its not good practice to edit core moodle functionality? so what do I do here?

Thanks in advance!

Average of ratings: -
In reply to Marco Cigna

Re: Incorporating core moodle functionality into theme

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
You can't. Anything in lib.php / locallib.php is not overridable by the theme. Moodle is OO in theory, but not completely in practice.
In reply to Gareth J Barnard

Re: Incorporating core moodle functionality into theme

by Marco Cigna -
So would the best approach for maintaining core moodle changes be setting up a github moodle repository? Forking the main base moodle repository, making those select changes to core moodle in my custom repo and when needing to update just merging the new changes from the main base moodle repository? Otherwise, how would we facilitate regular updates to a highly customised moodle site?

Thanks again!

Note: Locallib.php isn't the only file we need overriding. We also have files such as /question/format.php, /question/type/edit_question_form.php which need custom edits.
In reply to Marco Cigna

Re: Incorporating core moodle functionality into theme

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
This would probably be the way that has the least hands on code editing. Of course, you will have to test and review after each upgrade to make sure that your changes were not overwritten plus git will often make you reset your code before pulling an updated version if there is a conflict.