General plugins

Picture of Toshihiro KITA
CLI script for hiding/showing an activity or resource
Group Particularly helpful MoodlersGroup Translators
This simple standalone command is for hiding/showing a module (activity or resource) in a Moodle course.
If the URI of the module (assignment, chat, forum, quiz, page, ...) you want to hide/show is like, you can hide it by
  php set_coursemodule_visible.php 34 0
and show it by
  php set_coursemodule_visible.php 34 1

You can set the commands in crontab for time-dependent frequent access control of an activity or resource.

//---------------- set_coursemodule_visible.php --------------------
  // license: GNU GPL v3 or later
define('CLI_SCRIPT', true);
require('/var/www/html/moodle/config.php'); // you may need to modify
if ($argc>2){ $id= $argv[1]; $visible= $argv[2]; }
if ($argc<3 or ($visible!=0 and $visible!=1) ){
  echo "Invalid arguments!\nValid examples:\n php $argv[0] mod_id 1\n php $argv[0] mod_id 0\n";
  echo "(mod_id is the number at the tail of the course module URI.)\n";
set_coursemodule_visible($id, $visible);
Average of ratings:Useful (2)