Permalink
Browse files

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
  • Loading branch information...
1 parent fc05fcc commit 83173d563c2a52d1c89a29e333913184dd49cd86 moodler committed Nov 26, 2002
Showing with 10 additions and 7 deletions.
  1. +10 −7 mod/journal/lib.php
View
@@ -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;
}

0 comments on commit 83173d5

Please sign in to comment.