diff --git a/lang/en/docs/coding.html b/lang/en/docs/coding.html index 8122605ba7c..a50830f15d3 100755 --- a/lang/en/docs/coding.html +++ b/lang/en/docs/coding.html @@ -1,5 +1,4 @@ -
Any collaborative project needs consistency and stability + to stay strong.
+These guidelines are to provide a goal for all Moodle code + to strive to. It's true that some of the older existing code falls short in + a few areas, but it will all be fixed eventually. All new code definitely must + adhere to these standards as closely as possible.
I know it can be a little annoying to change your style + if you're used to something else, but balance that annoyance against the annoyance + of all the people trying later on to make sense of Moodle code with mixed styles. + There are obviously many good points for and against any style that people use, + but the current style just is, so please stick to it.
GOOD: $quiz
+ GOOD: $errorstring
+ GOOD: $i (but only in little loops)
+
+ BAD: $Quiz
+ BAD: $aReallyLongVariableNameWithoutAGoodReason
+ BAD: $error_string
define("FORUM_MODE_FLATOLDEST", + 1);
+ function forum_set_display_mode($mode=0)
+ {
+ global $USER,
+ $CFG;
+
+ if ($mode)
+ {
+ $USER->mode
+ = $mode;
+ } else if (empty($USER->mode))
+ {
+ $USER->mode
+ = $CFG->forum_displaymode;
+ }
+ }
if ($quiz->attempts)
{
if ($numattempts >
$quiz->attempts)
{
- error($strtoomanyattempts,
+ error($strtoomanyattempts,
"view.php?id=$cm->id");
}
}
$var = 'some text without any
+ variables';
+ $var = "with special characters like a new line \n";
+ $var = 'a very, very long string with a '.$single.' variable in it';
+ $var = "some $text with $many variables $within it";
function forum_get_ratings_mean($postid,
+ $scale, $ratings=NULL)
+ {
+ /// Return the mean rating of a post given
+ to the current user by others.
+ /// Scale is an array of possible ratings in the scale
+ /// Ratings is an optional simple array of actual ratings (just integers)
+
+ if (!$ratings)
+ {
+ $ratings
+ = array(); //
+ Initialize the empty array
+ if ($rates
+ = get_records("forum_ratings",
+ "post", $postid))
+ {
+ //
+ Process each rating in turn
+ foreach
+ ($rates as $rate)
+ {
+ ....etc
foreach ($objects
+ as $key =>
+ $thing) {
+ process($thing);
+
+ }
+
+ if ($x ==
+ $y)
+ {
+ $a
+ = $b;
+ } else if ($x ==
+ $z) {
+ $a
+ = $c;
+ } else {
+ $a
+ = $d;
+ }
-
Version: $Id: faq.html,v 1.6 2003/03/30 13:54:28 - moodler Exp $
- - - - -