diff --git a/rating/index.php b/rating/index.php
index 50a63bed791..ff9b1214a24 100644
--- a/rating/index.php
+++ b/rating/index.php
@@ -92,7 +92,8 @@ if (!$ratings) {
echo "
";
echo "";
- $maxrating = count($scalemenu);
+ //if the scale was changed after ratings were submitted some ratings may have a value above the current maximum
+ $maxrating = count($scalemenu) - 1;
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