This action might not be possible to undo. Are you sure you want to continue?
Introduction to Moodle Programming
Moodle Dev Courses ► Moodle Programming ► Resources ► Unit 5 Part A - Moodle's Directory Structure
Unit 5 Part A: Moodle Directory Structure
Overview | Unit 5 "To Do" List External resources open in new browser windows. This Unit refers to the directory structure in Moodle version 1.8.
The /admin directory
Files under this directory handle all the features under the "Site Administration" block. As of November 2007, there are 635 files spread out in 137 directories under this /admin directory (in Moodle 1.8.3+ version). For purposes of this course, we will just focus on the most important file: /admin/cron.php Some of Moodle's modules require continual checks to perform tasks. For example, Moodle needs to check the discussion forums so it can mail out copies of posts to people who have subscribed. The script that performs these continual checks is located in the admin directory and is called cron.php. Usually we set up a mechanism where this script runs regularly by itself, although you could also manually run it directly from a Web browser, or from a command line. Cron.php provides a "heartbeat" to perform functions at intervals defined by each module. This kind of regular mechanism is typically implemented using a cron daemon/service via cron jobs. The cron.php script: 1. Searches the mdl_modules table (assuming the default table prefix, of course) in the Moodle database for modules scheduled to have their cron functions run 2. In each such module directory locates any function called module-name_cron in the lib.php file and runs it 3. Searches the mdl_block table for blocks scheduled for their cron methods (object functions) to be run 4. for each such block, runs the cron method for a new object associated with that block These files (the lib.php files and the files where the block classes are defined) can contain cleanup
1 of 6
9/23/2009 6:12 PM
For example. It's best not to make the time period too long. so 5 minutes is usually reasonable.php?id=34 functions. All that matters is that the cron. Remember that mail-outs also wait for the editing time to expire before being queued for sending. However.php file has a section which will randomly call these core tasks approximately 1 in 5 times the cron runs. top The /blocks directory By now you probably already know about 'blocks' in moodle. if you have a limited web hosting service that does not have a cron service. as delaying mail-outs can slow down activity within the course. Note that the machine performing the cron does not need to be the same machine that is running Moodle.moodle. the load is not very high. cron will trigger the system to create the backups of courses at the time specified in the administration settings. 2 of 6 9/23/2009 6:12 PM . It also triggers any messaging module or forum email notifications. if it hasn't been run in a long time or the proceessing frequency is too far apart the loads can be considerable depending on site activity and any background batch processes such as enrolling or un-enrolling that may need to occur. are only run occasionally. They typically contain a function and differ from the "sections" that appear down the center column of a course's main page that contain the content and Activities or Resources added by the instructor. Moodle blocks typically appear in the left and right margins of a course's main page. but you can reduce the time period to 15 minutes or even 30 minutes. then you might choose to run cron on another server or on your home computer. As long as cron is run regularly and fairly frequently. For example. but not all functions are called each time the cron runs.org/mod/resource/view. The load of this script is not very high.Moodle's Directory Structure http://dev. The cron.php file is called regularly. such as unenrolling students who have not logged in or deleting old copies of log files. email functions or anything that needs to be run on a regular basis. Some functions.Moodle Programming: Unit 5 Part A .
3 of 6 9/23/2009 6:12 PM .php?id=34 When a Moodle course is created it automatically generates several 'blocks' that allow you to control how you navigate or find information in Moodle (examples of these include the "Site Administration" block for administrator. Similarly. you will find a matching directory for each block. you will see a set of standard blocks available for each course creator.moodle. the "Blog" block. the "Search Forums" block or the "Calendar" block for all users. you will notice that you have several options for further blocks of tools (from the Blocks drop down menu when editing is turned on) to add to your course. Examples include the "Remote RSS Feeds" block.8 installation.org/mod/resource/view. etc.). If you look into your local Moodle installation and navigate to /blocks directory.Moodle's Directory Structure http://dev.Moodle Programming: Unit 5 Part A . In a typical Moodle 1. etc. you can delete any of the existing blocks if you feel they are unnecessary to your course and you can also move the blocks so that they appear on a single side rather than on both sides of the middle content (this can only be achieved using the move or delete buttons with editing turned on).). In addition to the blocks that automatically appear.
you go to the "blog_menu' directory. Under this directory you will be able to understand how Moodle defines all the strings in different modules or blocks.php. Additional details about "Blocks administration" (usually from a system administrator's perspective). Later in this course we will introduce more about how to write a Moodle block from a programmer's perspective. for example. all the strings that are related to the admin module defined in admin.moodle. Important Tip: Localized strings should be in a separate language The /lib directory 4 of 6 9/23/2009 6:12 PM . including their related help button content. The one to pay most attention to is the "en_utf8" directory.php?id=34 If you need to debug the "Blog Menu" block. etc. If you need to debug the "Search Forums" block. For example.Moodle's Directory Structure http://dev.org/mod/resource/view. The /lang directory This directory contains all the different language files. begin with the "search_forums" directory.Moodle Programming: Unit 5 Part A .
top 5 of 6 9/23/2009 6:12 PM . weblib. The most important three library files are probably moodlelib.Moodle's Directory Structure http://dev. and accesslib. The default is if a string is not found in one language it falls back to en_utf8. print_header().php.8 there are 18 key modules under /mod directory.moodle. These three library files will be discussed in more depth in Part B of this Unit.php?id=34 directory such as For a Moodle developer.8. The /mod directory This directory contains most of the Moodle key modules. such as load_defaultuser_role().php contains functions that help Moodle produce web output. but you do not have to include every string or manage changing core language strings. it also has functions that deal with the role capabilities. Currently in moodle 1. You just have to manage your localized settings. This file contains of miscellaneous general-purpose Moodle functions (such as set_user_preferences(). it has functions such as format_text_email().php contains functions that alllow moodle to access the database. and so on). as of Moodle 1.php. get_guest_role(). However. to xmldb and yui (Yahoo User Interface) libraries. The /lib directory contains many library files (275 directories and 2179 files. etc. print_group_menu().Moodle Programming: Unit 5 Part A . datalib. This way.php. weblib.org/mod/resource/view. en_custom. your changes override the default. get_user_timezone(). etc.php is the Moodle "main" library.3+) ranging from ajax and adodb libraries. this is probably one of the most important directories that you will use. this is a brief summary of these three library files: moodlelib. For example.
If cron is called from the command line by any user logged in to your Moodle it will create a temporary admin environment in order to run and then log the user out. Run admin/auth. See more details about how to set up automated execution of this script (cron.php file. 09:46 AM You are logged in as Anguillo Gulianni from Moodle. or (3) Using the crontab program on Unix. 2008. top Overview | Unit 5 "To Do" List Last modified: Wednesday.Moodle Programming: Unit 5 Part A . 2.php) to see what it does.Moodle's Directory Structure http://dev.php?id=34 "To Do" List 1.php) on (1) Windows.php). February 20.org/mod/resource/view. (2) Web hosting services. Experiment with the cron script by running it directly from your browser (http://localhost/moodle/admin/cron.moodle. Usually this is a system administrator's job to set up so it is beyond the scope of this introductory Moodle programmer's course. You can disable command line running of cron by disabling the appropriate section in the cron.org (Logout) Moodle Programming 6 of 6 9/23/2009 6:12 PM .php from your Web browser (http://localhost/moodle18/moodle/admin/auth. You could also access this file through the "Site Administration" menu (under Users -> Authentication).
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.