From 163c84ef63170702814ec2129ddbd2c33352bb59 Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 4 Jul 2003 13:24:10 +0000 Subject: [PATCH] Made a small start on the coding guidelines --- lang/en/docs/coding.html | 164 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100755 lang/en/docs/coding.html diff --git a/lang/en/docs/coding.html b/lang/en/docs/coding.html new file mode 100755 index 0000000000..2df9540f4a --- /dev/null +++ b/lang/en/docs/coding.html @@ -0,0 +1,164 @@ + + + +Moodle Docs: Coding Guidelines + + + + + + + + + + + +

Moodle Coding Guidelines

+ +

General Rules

+ +
    +
  1. All files should use the .php extension.
  2. +
  3. All copyright notices should be retained. You can add your own if necessary.
  4. +
  5. Each file should include the main config.php file.
  6. +
  7. Each file should check that the user is authenticated correctly, using require_login() + and isadmin(), isteacher(), iscreator() or isstudent().
  8. +
  9. All access to databases should use the functions in lib/datalib.php whenever + possible - this allows compatibility across a wide range of databases. You + should find that almost anything is possible using these functions. Any other + SQL statements should be: cross-platform; restricted to specific functions + within your code (usally a lib.php file); and clearly marked.
  10. +
  11. All strings should be translatable - create new texts in the "lang/en" + files and call them using get_string() or print_string().
  12. +
  13. All help files should be translatable - create new texts in the "en/help" + directory and call them using helpbutton().
  14. +
+

 

+

Coding Style

+ +
    +
  1. Don't use tabs at all. Use consistent indenting with 4 spaces.
  2. +
  3. Braces must always be used for blocks of code (even if there is only one + line). Moodle uses this style: +

    if ($quiz->attempts) + {
    +     if (
    $numattempts > + $quiz->attempts) + {
    +         
    error($strtoomanyattempts, + "view.php?id=$cm->id");
    +     }
    + }

    +
  4. +
  5. more to come here .... this document is not nearly finished yet!
  6. +
+ + + +

 

+ +
+

Moodle Documentation

+ +

Version: $Id: faq.html,v 1.6 2003/03/30 13:54:28 + + moodler Exp $

+ + + + + + + -- 2.39.5