HowTo

Configuration Settings

  • Most configuration settings are stored in mdl_config (id, name, value).  So, if a configuration change breaks Moodle can correct it by adjusting this table.
    • Debug settings: select id,name,value from mdl_config where name like '%debug%';
      • name=debug (setting for the amount of messages to see)
      • name=debugdisplay (setting as to whether debug messages should be shown at all)
    • Site Administrators
      • name=siteadmins
      • value = list of userids of the Site Administrators
  • mdl_config_plugins contains additional configuration settings for plugins (e.g., CAS)

Clone existing site

  • Copy web files to new location
  • Copy moodledata directory to new location
  • mysqldump of database to SQL file
  • Create new database
  • Grant full access to new database to cehdmoodle
  • Run alter database NEWDBNAME default character set utf8 collate utf8_general_ci; (this sets the default character set to utf8)
  • Load SQL file into new database
  • Adjust config.php file for new web directory, moodle data directory, database

Reset User Password Via Database

UPDATE mdl_user SET password=md5('NEWPASSWORD') where username='myusername';

Creating New Assignment Types

  • within mod/assignments/type, create a new directory with new type name (or copy existing one)
  • the name cannot have any numerals

Grabbing Enrollment Data

  • Use courseid to look up context within mdl_context
    • SELECT id from mdl_context where instanceid=[courseid]
  • Use contextid to find students in course
    • SELECT userid FROM mdl_role_assignments WHERE contextid=[contextid]

Download old version

Moodle download page does not show old downloads. For example, 1.9.12 can be downloaded from here: http://download.moodle.org/stable19/

Tar'ring new files

Command to tar up new files: tar cf newdata.tar `find moodledata -mtime -2 -a -type f | xargs echo` (replace the -2 with the number of days to go back)

Unlock User

Moodle locks a user account if there are too many incorrect attempts (which is 10 times by default).

There is no way to "unlock" the user through moodle itself, or through the database. Restarting the browser may work. If it does not, we have to change the $max_logins variable in the source code.  (This is hard to believe, the lockout status has be to determined by the database somewhere.  OIherwise, there is no way to enforce it.)

In lib/moodlelib.php, under function update_login_count(), there is $max_logins = 10;

If a user is locked out, we need to change this value to something (well?) over 10 temporarily to prevent moodle from refusing the user. For example, $max_logins = 30;

Later, change it back to 10.

This problem is documented here.

Changing hard coded URLs during Migration

  • http://docs.moodle.org/20/en/Moodle_migration
  • ÍIf you have a new URL, you'll need to change this in the Moodle database to the new server. This is needed as links to pictures, files, etc are stored as absolute links and will reference the old $CFG->wwwroot value.
  • There are two methods
    1. Moodle script replace.php
    2. dump and replace then restore

Moodle Contexts

All context levels are defined in lib/accesslib.php:

define('CONTEXT_SYSTEM', 10);
define('CONTEXT_USER', 30);
define('CONTEXT_COURSECAT', 40);
define('CONTEXT_COURSE', 50);
define('CONTEXT_MODULE', 70);
define('CONTEXT_BLOCK', 80);
Taxonomy: