From 08f06b1c24868372c72053c47510d0bc5ec5ed30 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Tue, 10 Apr 2012 12:01:52 +0700 Subject: [PATCH] MDL-30955 rating: corrected /rating/index.php as it was determining the maximum rating incorrectly for custom scales --- rating/index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rating/index.php b/rating/index.php index 78a8b86f2e8..db41d98603d 100644 --- a/rating/index.php +++ b/rating/index.php @@ -102,8 +102,10 @@ if (!$ratings) { $table->colclasses = array('', 'firstname', 'rating', 'time'); $table->data = array(); - //if the scale was changed after ratings were submitted some ratings may have a value above the current maximum - $maxrating = count($scalemenu) - 1; + // If the scale was changed after ratings were submitted some ratings may have a value above the current maximum + // We can't just do count($scalemenu) - 1 as custom scales start at index 1, not 0 + $maxrating = max(array_keys($scalemenu)); + foreach ($ratings as $rating) { //Undo the aliasing of the user id column from user_picture::fields() //we could clone the rating object or preserve the rating id if we needed it again -- 2.17.1