Can’t create a new XMLDB file

The Moodle XMLDB plugin does some checks of the db/ folder in your plugin to ensure it has read/write access before allowing certain permissions (e.g. create and load). If it doesn’t find this, the text will appear but it won’t be a hyperlink. Have a look in admin/tool/xmldb/actions/main_view/main_view.class.php For example for the create button it…

Scheduled Tasks: A lock was created but not released

Schedule tasks can use two types of locks: * Database locks — lock_db table * File locks — dirroot/lock The follow error can occur when running a cron through the CLI for example: !!! Coding error detected, it must be fixed by a programmer: A lock was created but not released at: [dirroot]/lib/classes/task/manager.php on line…

Replacing strings in the database through the CLI

There is a tool provided with Moodle to replace strings in your database with another value. This is very useful for things such as site address or domain name changes, and changes from non-SSL (http) to SSL (https). The tool can be accessed via the following relative URL as a site administrator. /admin/tool/replace/ While you…

Resetting a user’s password through the CLI

If you have access to the Moodle server, you can use the admin/cli/reset_password.php script to reset passwords for users with the manual authentication method. To run this script (from the moodle root code directory), note you may need to sudo as a user with write privileges to the $CFG->dataroot directory. php admin/cli/reset_password.php == Password reset…

Course file system space usage query

The following query provides a summary of the file space usage (in bytes) and number of files used by each course in the system from the mdl_files meta table for the data directory. This is just for the space used in the data directory (not the database). select f.contextid, x.instanceid, c.fullname as course_full_name, c.shortname as…

Overriding PHP Settings

There are a few ways to override global PHP (php.ini) settings with local settings. For example you can use a .htaccess file or local php.ini file depending on what options exist for your site hosting. Another way to do it, is to override the settings in config.php. This has the benefit of being part of…

Getting PHP Info for your Moodle Site

There is a handy link under Site adminstration > Server > PHP Info ( or browse to http://yoursite.com/admin/phpinfo.php ) that will return the standard PHP Info phpinfo() results for your server. Very handy for checking things like installed modules and core parameters if you are overriding them ( e.g. error_log, max_execution_time, post_max_size, upload_max_size etc )

Query blocks instances and positions through the database

The following query gives you an idea of all the moodle blocks that have been added to various pages on your site and where they are positioned: select bi.*, bp.*, x.* from mdl_block_instances bi inner join mdl_block_positions bp on bi.id = bp.blockinstanceid inner join mdl_context x on x.id = bp.contextid order by bi.blockname; Very handy…

Verify your Moodle Database Schema against XMLDB

There is a very handy CLI tool admin/cli/check_database_schema.php which compares the structure of your Moodle database against the XMLDB metadata and looks for any issues. These might includes issues such as: Missing tables – they exist in XMLDB but not in your DB (not good!) Unexpected tables – tables in your database not defined in…

CLI Maintenance Mode

Newer versions of Moodle now provide the ability to put a site into maintenance mode through the CLI: This can be found under the standard admin CLI location php admin/cli/maintenance.php Options include php admin/cli/maintenance.php –enable php admin/cli/maintenance.php –disable NOTE this disables all web access to the site and can only be restored by disabling maintenance…

Table formats from Antelope to Barracuda

On your environments page, as of around Moodle 2.6 you might see a message like this: unsupported_db_table_row_format if this test fails, it indicates a potential problem Your database has tables using Antelope as the file format. You are recommended to convert the tables to the Barracuda file format. See the documentation Administration via command line…

Moodle User Management URLs

Some handy user management and search URLs, particularly if the site admin block is hidden. User search Note a %20=means a blank space, encoded to work in a URL. user/index.php?id=1&search= http://yourmoodle.com/user/index.php?id=1&search=fred http://yourmoodle.com/user/index.php?id=1&search=Fred%20Jones Create a new user user/editadvanced.php?id=-1 http://yourmoodle.com/user/editadvanced.php?id=-1 Edit a user if you know their moodle internal id user/editadvanced.php?id={moodle_user_id} http://yourmoodle.com/user/editadvanced.php?id=16 Delete an existing user This…

Hide My Profile -> Forum Posts from Navigation

To hide the navigation: My Profile > Forum Posts for all users: 1. This is set by the configuration value navadduserpostslinks 2. You can either update the value of this in the database (config table) from 1 to 0 OR you can add an entry in config.php where you set $CFG->navadduserpostslinks = 0; 3. Clear…

Assign site admins through the database

The following steps can be used to add your user as a siteadmin in the database if required. Step 1: Find your moodle user ID select id from mdl_user where username = ‘{username}’; Step 2: Get the list of current siteadmin IDs select value from mdl_config where name = ‘siteadmins’; This gives you a list…