]> git.mjollnir.org Git - moodle.git/commitdiff
Made a small start on the coding guidelines
authormoodler <moodler>
Fri, 4 Jul 2003 13:24:10 +0000 (13:24 +0000)
committermoodler <moodler>
Fri, 4 Jul 2003 13:24:10 +0000 (13:24 +0000)
lang/en/docs/coding.html [new file with mode: 0755]

diff --git a/lang/en/docs/coding.html b/lang/en/docs/coding.html
new file mode 100755 (executable)
index 0000000..2df9540
--- /dev/null
@@ -0,0 +1,164 @@
+<html>\r
+\r
+<head>\r
+<title>Moodle Docs: Coding Guidelines</title>\r
+<link rel="stylesheet" href="../theme/standard/styles.php" type="TEXT/CSS">\r
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\r
+<style type="text/css">\r
+\r
+<!--\r
+li {\r
+       padding-top: 10px;\r
+}\r
+\r
+.question {\r
+\r
+    font-size: medium;\r
+\r
+    font-weight: bold;\r
+\r
+    font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;\r
+\r
+    border: 1px dotted;\r
+\r
+    padding: 10px;\r
+\r
+    background-color: #EEEEEE;\r
+\r
+}\r
+\r
+.answer {\r
+\r
+    font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;\r
+\r
+    font-size: medium;\r
+\r
+    border: none;\r
+\r
+    padding-left: 40px;\r
+\r
+}\r
+\r
+-->\r
+\r
+</style>\r
+<style type="text/css">\r
+\r
+<!--\r
+\r
+.normaltext {\r
+\r
+    font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;\r
+\r
+    font-size: medium;\r
+\r
+    border: none;\r
+\r
+    padding-left: 10px;\r
+\r
+}\r
+\r
+.answercode {\r
+\r
+    font-family: "Courier New", Courier, mono;\r
+\r
+    font-size: small;\r
+\r
+    border: none;\r
+\r
+    padding-left: 60px;\r
+\r
+}\r
+\r
+.questionlink {\r
+\r
+    font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;\r
+\r
+    font-size: medium;\r
+\r
+    border: none;\r
+\r
+    padding-left: 40px;\r
+\r
+}\r
+\r
+-->\r
+\r
+</style>\r
+<style type="text/css">\r
+<!--\r
+.examplecode {\r
+       font-family: "Courier New", Courier, mono;\r
+       font-size: small;\r
+       border: thin dashed #999999;\r
+       background-color: #FBFBFB;\r
+       margin: auto;\r
+       padding: 30px;\r
+       height: auto;\r
+       width: auto;\r
+}\r
+-->\r
+</style>\r
+</head>\r
+\r
+\r
+\r
+<body bgcolor="#FFFFFF">\r
+\r
+<h2>Moodle Coding Guidelines</h2>\r
+\r
+<h2 class="normaltext">General Rules</h2>\r
+  \r
+<ol class="normaltext">\r
+  <li>All files should use the .php extension.</li>\r
+  <li>All copyright notices should be retained. You can add your own if necessary.</li>\r
+  <li>Each file should include the main config.php file.</li>\r
+  <li>Each file should check that the user is authenticated correctly, using require_login() \r
+    and isadmin(), isteacher(), iscreator() or isstudent().</li>\r
+  <li>All access to databases should use the functions in lib/datalib.php whenever \r
+    possible - this allows compatibility across a wide range of databases. You \r
+    should find that almost anything is possible using these functions. Any other \r
+    SQL statements should be: cross-platform; restricted to specific functions \r
+    within your code (usally a lib.php file); and clearly marked.</li>\r
+  <li>All strings should be translatable - create new texts in the &quot;lang/en&quot; \r
+    files and call them using get_string() or print_string().</li>\r
+  <li>All help files should be translatable - create new texts in the &quot;en/help&quot; \r
+    directory and call them using helpbutton().</li>\r
+</ol>\r
+<p>&nbsp;</p>\r
+<h2 class="normaltext">Coding Style</h2>\r
+  \r
+<ol class="normaltext">\r
+  <li>Don't use tabs at all. Use consistent indenting with 4 spaces.</li>\r
+  <li>Braces must always be used for blocks of code (even if there is only one \r
+    line). Moodle uses this style: \r
+    <p class="examplecode"> </font><font color="#006600">if (</font><font color="#0000CC">$quiz</font><font color="#006600">-&gt;</font><font color="#0000CC">attempts</font><font color="#006600">) \r
+      {<br />\r
+      &nbsp;&nbsp;&nbsp;&nbsp;if (</font><font color="#0000CC">$numattempts </font><font color="#006600">&gt; \r
+      </font><font color="#0000CC">$quiz</font><font color="#006600">-&gt;</font><font color="#0000CC">attempts</font><font color="#006600">) \r
+      {<br />\r
+      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000CC">error</font><font color="#006600">(</font><font color="#CC0000">$strtoomanyattempts</font><font color="#006600">, \r
+      </font><font color="#CC0000">"view.php?id=$cm</font><font color="#006600">-&gt;</font><font color="#CC0000">id"</font><font color="#006600">);<br />\r
+      &nbsp;&nbsp;&nbsp;&nbsp;}<br />\r
+      }</font></p>\r
+  </li>\r
+  <li>more to come here .... this document is not nearly finished yet!</li>\r
+  </ol>\r
+\r
+\r
+\r
+<p align="center" class="normaltext">&nbsp;</p>\r
+\r
+<hr>\r
+<p align="CENTER"><font size="1"><a href="." target="_top">Moodle Documentation</a></font></p>\r
+\r
+<p align="CENTER"><font size="1">Version: $Id: faq.html,v 1.6 2003/03/30 13:54:28 \r
+\r
+  moodler Exp $</font></p>\r
+\r
+\r
+\r
+</body>\r
+\r
+</html>\r
+\r