I'm trying to implement a proof of concept for adding course settings that will set the course in maintenance mode. In other words a maintenance mode at the course level. This had been in my mind for years now and it is only now that I can articulate it but I just can't figure out the code. If anyone has done this already I'd appreciate any info.
The problem I'm trying to solve is this. When students are enrolled two weeks before the start of classes, course sites are hidden so students get frustrated and send support request that basically just asks where their courses are. As far as I know visibility has only two settings, hide and show, so students have no idea where the course site is until it is shown by the teacher. This is a situation wherein the control of the visibility of the course site is with the teacher.
Anyways I've been using meta linked courses as workaround (the topic for my proposed paper in MoodleMoot Philippines on April 2018) but I think a simple setting for maintenance mode at the course level is what is really needed. What I've done so far is to mock up what I mean by course maintenance mode as shown in the screenshot that was done by hacking moodle/course/view.php with:
21 //course maintenance mode test start
22 $maintenance_mode = 1;
23 //course maintenance mode test end
...
268 //maintenance test start 2
269 if ($USER->editing == 0 && $maintenance_mode == 1) {
270 echo "<h1>This course site is in maintenance mode.</h1>";
271 } else {
272 //maintenance test end 2
The problems that I need help are:
1. How to display the maintenance text only for users without editing capabilities. Those with editing capabilites should see the normal course page.
2. How to get rid of nav block menu items except for participants, for users without editing capabilities. Those with editing capabilities should see the normal nav block.
3. and how to add custom message text box in the settings.
The settings would simply add a select yes/no setting in the course editing page like so:
I guess I should add a db field for this but I don't know where to put it.
Any hints would be appreciated. I've attached some of the files in /moodle/course I've been trying to hack.