Updating the Moodle Frontpage Summary through the database

You might have the need to update the Moodle front page summary through the database rather than through the UI. For example you might get an error editing the summary after a clone, or you might want to script the cloning process and change the frontpage text through the database. Here are the steps: Update…

Upgrading database schema using upgrade.php

If you need to upgrade your database schema for a custom plugin, e.g. adding a new table or changing the properties of an existing table, you should do it through db/upgrade.php per the suggestions in the MoodleDocs UpgradeAPI. This isn’t a bad idea to do even when iterating through development as it isn’t a lot…

$DB->get_record_sql only returning a single row

So you’ve written a query, passed it to $DB->get_records_sql() and, what’s this – only one row? What’s going on, where’s the rest of the query data? First off, make sure you are using the plural form (get_records_sql() and not get_record_sql()). If that’s not the issue then read on. The reason this can happen is that…

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…

Uninstalling a Moodle Plugin and forcing reinstallation

The easiest way to get moodle to re-run installation is to update the version in version.php. However, if you want to be sure it makes any schema changes etc then remove the plugin version from the mdl_config_plugins table. Note you can leave the other configuration there if required to save re-setting up the plugin. The…

Moodle and Timezones

Moodle timezone information in the first instance is loaded from: http://download.moodle.org/timezone/ This returns a text file which is stored in the lib directory as timezone.txt The data is stored in the table mdl_timezone (adjust to suit your db prefix).

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…