From: moodler Date: Tue, 26 Nov 2002 02:29:54 +0000 (+0000) Subject: For the case when there are forums using ratings, but no ratings, and X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=83173d563c2a52d1c89a29e333913184dd49cd86;p=moodle.git For the case when there are forums using ratings, but no ratings, and the teacher is looking at grades, don't try and loop on an empty array --- diff --git a/mod/journal/lib.php b/mod/journal/lib.php index 35ce8c7f6c..e06d6ea946 100644 --- a/mod/journal/lib.php +++ b/mod/journal/lib.php @@ -165,15 +165,18 @@ function journal_grades($journalid) { /// Must return an array of grades, indexed by user, and a max grade. global $JOURNAL_RATING; - $return->grades = get_records_sql_menu("SELECT user,rating FROM journal_entries WHERE journal = '$journalid'"); - foreach ($return->grades as $key => $value) { - if ($value) { - $return->grades[$key] = $JOURNAL_RATING[$value]; - } else { - $return->grades[$key] = "-"; + if ($return->grades = get_records_sql_menu("SELECT user,rating + FROM journal_entries + WHERE journal = '$journalid'")) { + foreach ($return->grades as $key => $value) { + if ($value) { + $return->grades[$key] = $JOURNAL_RATING[$value]; + } else { + $return->grades[$key] = "-"; + } } + $return->maxgrade = ""; } - $return->maxgrade = ""; return $return; }