mirror of
https://github.com/moodle/moodle.git
synced 2025-01-22 08:11:26 +01:00
166 lines
4.2 KiB
HTML
166 lines
4.2 KiB
HTML
<html>
|
|
|
|
<head>
|
|
<title>Moodle Docs: Coding Guidelines</title>
|
|
<link rel="stylesheet" href="../theme/standard/styles.php" type="TEXT/CSS">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<style type="text/css">
|
|
|
|
<!--
|
|
li {
|
|
padding-top: 10px;
|
|
}
|
|
|
|
.question {
|
|
|
|
font-size: medium;
|
|
|
|
font-weight: bold;
|
|
|
|
font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
|
|
|
|
border: 1px dotted;
|
|
|
|
padding: 10px;
|
|
|
|
background-color: #EEEEEE;
|
|
|
|
}
|
|
|
|
.answer {
|
|
|
|
font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
|
|
|
|
font-size: medium;
|
|
|
|
border: none;
|
|
|
|
padding-left: 40px;
|
|
|
|
}
|
|
|
|
-->
|
|
|
|
</style>
|
|
<style type="text/css">
|
|
|
|
<!--
|
|
|
|
.normaltext {
|
|
|
|
font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
|
|
|
|
font-size: medium;
|
|
|
|
border: none;
|
|
|
|
padding-left: 10px;
|
|
|
|
}
|
|
|
|
.answercode {
|
|
|
|
font-family: "Courier New", Courier, mono;
|
|
|
|
font-size: small;
|
|
|
|
border: none;
|
|
|
|
padding-left: 60px;
|
|
|
|
}
|
|
|
|
.questionlink {
|
|
|
|
font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
|
|
|
|
font-size: medium;
|
|
|
|
border: none;
|
|
|
|
padding-left: 40px;
|
|
|
|
}
|
|
|
|
-->
|
|
|
|
</style>
|
|
<style type="text/css">
|
|
<!--
|
|
.examplecode {
|
|
font-family: "Courier New", Courier, mono;
|
|
font-size: small;
|
|
border: thin dashed #999999;
|
|
background-color: #FBFBFB;
|
|
margin: auto;
|
|
padding: 30px;
|
|
height: auto;
|
|
width: auto;
|
|
}
|
|
-->
|
|
</style>
|
|
</head>
|
|
|
|
|
|
|
|
<body bgcolor="#FFFFFF">
|
|
|
|
<h2>Moodle Coding Guidelines</h2>
|
|
|
|
<h2 class="normaltext">General Rules</h2>
|
|
|
|
<ol class="normaltext">
|
|
<li>All files should use the .php extension.</li>
|
|
<li>All existing copyright notices must be retained. You can add your own if
|
|
necessary.</li>
|
|
<li>Each file should include the main config.php file.</li>
|
|
<li>Each file should check that the user is authenticated correctly, using require_login()
|
|
and isadmin(), isteacher(), iscreator() or isstudent().</li>
|
|
<li>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.</li>
|
|
<li>All strings should be translatable - create new texts in the "lang/en"
|
|
files and call them using get_string() or print_string().</li>
|
|
<li>All help files should be translatable - create new texts in the "en/help"
|
|
directory and call them using helpbutton().</li>
|
|
</ol>
|
|
<p> </p>
|
|
<h2 class="normaltext">Coding Style</h2>
|
|
|
|
<ol class="normaltext">
|
|
<li>Don't use tabs at all. Use consistent indenting with 4 spaces.</li>
|
|
<li>Braces must always be used for blocks of code (even if there is only one
|
|
line). Moodle uses this style:
|
|
<p class="examplecode"> <font color="#006600">if (</font><font color="#0000CC">$quiz</font><font color="#006600">-></font><font color="#0000CC">attempts</font><font color="#006600">)
|
|
{<br />
|
|
if (</font><font color="#0000CC">$numattempts </font><font color="#006600">>
|
|
</font><font color="#0000CC">$quiz</font><font color="#006600">-></font><font color="#0000CC">attempts</font><font color="#006600">)
|
|
{<br />
|
|
</font><font color="#0000CC">error</font><font color="#006600">(</font><font color="#CC0000">$strtoomanyattempts</font><font color="#006600">,
|
|
</font><font color="#CC0000">"view.php?id=$cm</font><font color="#006600">-></font><font color="#CC0000">id"</font><font color="#006600">);<br />
|
|
}<br />
|
|
}</font></p>
|
|
</li>
|
|
<li>more to come here .... this document is not nearly finished yet!</li>
|
|
</ol>
|
|
|
|
|
|
|
|
<p align="center" class="normaltext"> </p>
|
|
|
|
<hr>
|
|
<p align="CENTER"><font size="1"><a href="." target="_top">Moodle Documentation</a></font></p>
|
|
|
|
<p align="CENTER"><font size="1">Version: $Id: faq.html,v 1.6 2003/03/30 13:54:28
|
|
|
|
moodler Exp $</font></p>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|