Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Student projects/Admin page cleanup/XML file format.

Student projects/Admin page cleanup/XML file format

From MoodleDocs
Revision as of 03:57, 23 June 2006 by Vincenzo K. Marcovecchio (talk | contribs) (starting the page content)

Part of the Admin page cleanup project involves coming up with a format for storing the hierarchy of admin settings and general information about the settings. To that end, I've put together the following XML DTD

(N.B. this format is for storing how the settings are organized, not the setting themselves -- those are still stored in the database for reasons of efficiency.)

<!DOCTYPE moodleadmin [
  <!ELEMENT moodleadmin (category|settinggroup|settingpage)*>
  <!ELEMENT category (category|settinggroup|settingpage)*>
    <!ATTLIST category name CDATA #REQUIRED 
                       auth CDATA #REQUIRED>
  <!ELEMENT settinggroup (setting*)>
    <!ATTLIST settinggroup name CDATA #REQUIRED 
                           auth CDATA #REQUIRED>
    <!ELEMENT setting EMPTY>
      <!ATTLIST setting name CDATA #REQUIRED 
                        type (text|select|htmledit|checkbox) #REQUIRED 
                        selectoptions CDATA #IMPLIED 
                        description CDATA #REQUIRED 
                        setoninstall (true|false) "false" 
                        writeproc CDATA #REQUIRED 
                        readproc CDATA #REQUIRED>
  <!ELEMENT settingpage EMPTY>
    <!ATTLIST settingpage name CDATA #REQUIRED 
                          auth CDATA #REQUIRED 
                          hardcoded CDATA #REQUIRED>
]>

Here's a short sample XML file

<moodleadmin>
  <category name="php_code_must_return_string" 
            auth="php_code_must_return_boolean">
    <settinggroup name="php_code_must_return_string" 
                  auth="php_code_that_must_return_boolean">
      <setting name="php_code_must_return_string" 
               type="(text|select|htmledit|checkbox)" 
               selectoptions="option1,option2,option3" 
               description="php_code_must_return_string" 
               setoninstall="(true|false)" 
               writeproc="php_code_must_return_boolean"
               readproc="php_code_must_return_string" />
    </settinggroup>
    <settingpage name="php_code_must_return_string" 
                 hardcoded="filename.php" 
                 auth="php_code_must_return_boolean" />
  </category>
</moodleadmin>

And now the explanations.

Categories appear in the hierarchical menu as folders, while settinggroups and settingpages appear as actual clickable items. Thus, categories can be nested, while settinggroups and settingpages must appear either within a category or at the moodleadmin root level.