- //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));
+