[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 Course formats 2 ============== 3 4 To create a new course format, make another folder in here. 5 6 If you want a basic format, you only need to write the 'standard files' listed 7 below. 8 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. 11 12 All names below assume that your format is called 'yourformat'. 13 14 15 Standard files 16 -------------- 17 18 * yourformat/format.php 19 20 Code that actually displays the course view page. See existing formats for 21 examples. 22 23 * yourformat/config.php 24 25 Configuration file, mainly controlling default blocks for the format. 26 See existing formats for examples. 27 28 * yourformat/lang/en/format_yourformat.php 29 30 Language file containing basic language strings for your format. Here 31 is a minimal language file: 32 33 <?php 34 $string['formatyourformat']='Your format'; // Name to display for format 35 $string['nameyourformat']='section'; // Name of a section within your format 36 ?> 37 38 The first string is used in the dropdown menu of course settings. The second 39 is used when editing an activity within a course of your format. 40 41 Note that existing formats store their language strings in the main 42 moodle.php, which you can also do, but this separate file is recommended 43 for contributed formats. 44 45 You can also store other strings in this file if you wish. They can be 46 accessed as follows, for example to get the section name: 47 48 get_string('nameyourformat','format_yourformat'); 49 50 Of course you can have other folders as well as just English if you want 51 to provide multiple languages. 52 53 54 Optional files (database access) 55 -------------------------------- 56 57 If these files exist, Moodle will use them to set up database tables when you 58 visit the admin page. 59 60 * yourformat/db/install.xml 61 62 Database table definitions. Use your format name at the start of the table 63 names to increase the chance that they are unique. 64 65 * yourformat/db/upgrade.php 66 67 Database upgrade instructions. Similar to other upgrade.php files, so look 68 at those for modules etc. if you want to see. 69 70 The function must look like: 71 72 function xmldb_format_yourformat_upgrade($oldversion) { 73 ... 74 75 * yourformat/version.php 76 77 Required if you use database tables. 78 79 <?php 80 $plugin->version = 2006120100; // Plugin version (update when tables change) 81 $plugin->requires = 2006092801; // Required Moodle version 82 ?> 83 84 85 Optional files (backup) 86 ----------------------- 87 88 If these files exist, backup and restore run automatically when backing up 89 the course. You can't back up the course format data independently. 90 91 * yourformat/backuplib.php 92 93 Similar to backup code for other plugins. Must have a function: 94 95 function yourformat_backup_format_data($bf,$preferences) { 96 ... 97 98 * yourformat/restorelib.php 99 100 Similar to restore code for other plugins. Must have a function: 101 102 function yourformat_restore_format_data($restore,$data) { 103 ... 104 105 ($data is the xmlized data underneath FORMATDATA in the backup XML file. 106 Do print_object($data); while testing to see how it looks.) 107 108 109 Optional file (capabilities) 110 ---------------------------- 111 112 If this file exists, Moodle refreshes your format's capabilities 113 (checks that they are all included in the database) whenever you increase 114 the version in yourformat/version.php. 115 116 * yourformat/db/access.php 117 118 Contains capability entries similar to other access.php files. 119 120 The array definition must look like: 121 122 $format_yourformat_capabilities = array( 123 ... 124 125 Format names must look like: 126 127 format/yourformat:specialpower 128 129 Capability definitions in your language file must look like: 130 131 $string['yourformat:specialpower']='Revolutionise the world'; 132 133 134 135 Optional file (styles) 136 ---------------------- 137 138 * yourformat/styles.php 139 140 If this file exists it will be included in the CSS Moodle generates. 141
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |