Disable courses after a specified hour, everyday

Disable courses after a specified hour, everyday

by Leopoldo Spedalieri -
Number of replies: 6

Hi everybody

I'm setting up a Moodle 3.2.2 with several courses and a curious requirement: users can't use specific courses at night, in this case from 22:00 to 06:00 everyday.

I looked around in the system and course settings, checked the plugin library without success, maybe I just didn't use the right keywords.

I'm thinking about a workaround but like change user roles bound to the courses but I always need cron job and a cli script.

Is there another solution ?

Thanks

Average of ratings: -
In reply to Leopoldo Spedalieri

Re: Disable courses after a specified hour, everyday

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I am not the expert on this matter, but it seems that your need is incompatible with computer-bases and Internet-based education.  Why lock students out between certain times?  I have never seen this feature with any LMS.

However, as I ponder about how I might do this, I would probably write a (server) cron job that would put my moodle into "maintenance mode" at 22:00, and then take it out of maintenance mode at 6:00 the next day.  There is a command line for putting a moodle into maintenance mode (but I can't remember what it is off hand.) 

This is an all or nothing solution.  I cannot think of how to do this only for specific courses, or specific students.  But maybe someone else will know.

Average of ratings: Useful (1)
In reply to Rick Jerz

Re: Disable courses after a specified hour, everyday

by Leopoldo Spedalieri -

Hi Rick, thank you for your answer.

I know, this request is quite weird but, because some legal issue, the courses should be used just during the "work hours" like a "old fashion" class.

I had thought about the maintenance mode by cron, it is just a single db update and quite easy to implement. It will be the solution "if everything else fail" :D


In reply to Leopoldo Spedalieri

Re: Disable courses after a specified hour, everyday

by Ken Task -
Picture of Particularly helpful Moodlers

No plugin like that exist ... all though one might be able to develop a task - actually two of them - that one could schedule via the Moodle Admin UI.   One task for setting course to invisible. The other for setting course visiable.   That's a lot of trouble me thinks ... besides, maintainance mode is the entire site ... not just a single course.

The only other I could think of is a web services thang ... if there is a web services function that could do that.

So think two bash shell scripts that are really mysql queries to work with the courses table and the specific course ID setting that ID visible column to either a 1 or a 0 is the path of least resistance and really might be the safest thing as well. ;)   Think I'd also do a script to run admin/cli/backup.php on that course ID to a specific directory every day when the course was visible - just to be on the safe side.

'spirit of sharing', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Disable courses after a specified hour, everyday

by Leopoldo Spedalieri -

Thank you Ken

Yes, it is probably the safest solution. A simple update query of a single field for the specified courses should do the trick. I'm a bit puzzled about the lack of a plugin, but, as Rick wrote before, this type of request break the "spirit" of the LMS itself.

Probably i will try first a simple warning like "don't use the course at night or that activity won't be counted" smile


In reply to Leopoldo Spedalieri

Re: Disable courses after a specified hour, everyday

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Check out Moodle Moosh - https://moosh-online.com/

You could write a couple of commands in cron to hide and show the courses at the required times. I would imagine the 'course-config-set' command is the one you want...

To hide...

moosh course-config-set course 999 visible 0

To make visible again

moosh course-config-set course 999 visible 1


Average of ratings: Useful (1)
In reply to Howard Miller

Re: Disable courses after a specified hour, everyday

by Leopoldo Spedalieri -

It looks a really nice and useful tool. Thank you so much Howard!