Merge branch 'MDL-76835-401' of https://github.com/aya-saad1/moodle into MOODLE_401_S...
[moodle.git] / course / format / README.txt
blob9be444ce8d0fb0d11bab1c66bb4e2586633a91ab
1 Course formats
2 ==============
4 To create a new course format, make another folder in here.
6 If you want a basic format, you only need to write the 'standard files' listed
7 below.
9 If you want to store information in the database for your format, or control
10 access to features of your format, you need some of the optional files too.
12 If you want to override some standard course output component (located in
13 coure/classes/output/{course|section|cm}_format/*) you need to create an
14 extend class inside your course/format/yourformat/classes/output.
16 All names below assume that your format is called 'yourformat'.
19 Standard files
20 --------------
22 * yourformat/format.php
24   Code that actually displays the course view page. See existing formats for
25   examples.
27 * yourformat/config.php
29   Configuration file, mainly controlling default blocks for the format.
30   See existing formats for examples.
32 * yourformat/lang/en/format_yourformat.php
34   Language file containing basic language strings for your format. Here
35   is a minimal language file:
37 <?php
38 $string['formatyourformat']='Your format'; // Name to display for format
39 $string['nameyourformat']='section'; // Name of a section within your format
42   The first string is used in the dropdown menu of course settings. The second
43   is used when editing an activity within a course of your format.
45   Note that existing formats store their language strings in the main
46   moodle.php, which you can also do, but this separate file is recommended
47   for contributed formats.
49   You can also store other strings in this file if you wish. They can be
50   accessed as follows, for example to get the section name:
52   get_string('nameyourformat','format_yourformat');
54   Of course you can have other folders as well as just English if you want
55   to provide multiple languages.
58 Optional files (database access)
59 --------------------------------
61 If these files exist, Moodle will use them to set up database tables when you
62 visit the admin page.
64 * yourformat/db/install.xml
66   Database table definitions. Use your format name at the start of the table
67   names to increase the chance that they are unique.
69 * yourformat/db/upgrade.php
71   Database upgrade instructions. Similar to other upgrade.php files, so look
72   at those for modules etc. if you want to see.
74   The function must look like:
76   function xmldb_format_yourformat_upgrade($oldversion) {
77   ...
79 * yourformat/version.php
81   Required if you use database tables.
83   <?php
84   $plugin->version  = 2006120100; // Plugin version (update when tables change)
85   $plugin->requires = 2006092801; // Required Moodle version
86   ?>
89 Optional files (backup)
90 -----------------------
92 If these files exist, backup and restore run automatically when backing up
93 the course. You can't back up the course format data independently.
95 * yourformat/backuplib.php
97   Similar to backup code for other plugins. Must have a function:
99   function yourformat_backup_format_data($bf,$preferences) {
100   ...
102 * yourformat/restorelib.php
104   Similar to restore code for other plugins. Must have a function:
106   function yourformat_restore_format_data($restore,$data) {
107   ...
109   ($data is the xmlized data underneath FORMATDATA in the backup XML file.
110   Do print_object($data); while testing to see how it looks.)
113 Optional file (capabilities)
114 ----------------------------
116 If this file exists, Moodle refreshes your format's capabilities
117 (checks that they are all included in the database) whenever you increase
118 the version in yourformat/version.php.
120 * yourformat/db/access.php
122   Contains capability entries similar to other access.php files.
124   The array definition must look like:
126   $format_yourformat_capabilities = array(
127   ...
129   Format names must look like:
131   format/yourformat:specialpower
133   Capability definitions in your language file must look like:
135   $string['yourformat:specialpower']='Revolutionise the world';
139 Optional file (styles)
140 ----------------------
142 * yourformat/styles.php
144   If this file exists it will be included in the CSS Moodle generates.
147 Optional files (outputs)
148 ----------------------
150 By default, the format renderer will use those output classes:
152 * core_courseformat\output\local\content: for the general course structure
153 * core_courseformat\output\local\content\*: to render specific course structure parts
155 * core_courseformat\output\local\content\section: for the complete section output
156 * core_courseformat\output\local\content\section\*: to render specific section parts
158 * core_courseformat\output\local\content\cm: for output an activity inside a section
159 * core_courseformat\output\local\content\cm\*: for speficis parts of the cm output
161   Your format can override any of this output classes just by creating class
162   inside your format_yourformat\output\courseformat\* namespace. We recommend to extend the
163   original class to ensure all element will work as expected.
165   For example: if you want to change the section header, you should create
166   format_yourformat\output\section\header, which will extend the original
167   core_courseformat\output\courseformat\content\section\header class.
169   By default, only a few format renderer methods are needed to render a course:
170   - render_content to render a full course content
171   - course_section_updated used by the course editor to refresh a specific section
172   - course_section_updated_cm_item used by the course editor to refresh a specific cm item
174   Formats can override those two methods to use different templates to render a course.