Ogni progetto di tipo collaborativo ha bisogno che coerenza e stabilit� siano veramente robuste.
Queste linee guida vogliono rappresentare un riferimento da osservare da parte di tutti i programmi di Moodle. E' vero che parte dei programmi pi� vecchi non lo rispettano, ma alla fine saranno tutti corretti. Tutta la nuova programmazione deve aderire definitivamente, il pi� possibile, a questi standard.
So che pu� essere un p� antipatico cambiare il proprio stile, se ne avete uno, ma paragonate, per un momento, questa antipatia con quella di tutte le persone che successivamente cercheranno di capire i programmi di Moodle scritti con stili diversi. Ci sono ovviamente tante buone ragioni a favore e contro ogni stile usato in giro, ma lo stile di Moodle � definito, quindi, per favore, attenetevi strettamente ad esso.
GOOD: $quiz
GOOD: $errorstring
GOOD: $assignments (for an array of objects)
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,
"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$