From 2544f5b5629d36658f92d4d0ad111563c2442f1b Mon Sep 17 00:00:00 2001 From: spocky Date: Wed, 2 Apr 2008 12:38:47 +0000 Subject: changed rating display to use 1 digit rounded average, a little bit different than "half star rating" request (Ticket #156), but easily done and also more precise. minor change to sidebar filter display. --- lib/class/rating.class.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'lib/class/rating.class.php') diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php index 14c13753..d844cea1 100644 --- a/lib/class/rating.class.php +++ b/lib/class/rating.class.php @@ -32,6 +32,7 @@ class Rating { /* Generated vars */ var $rating; // The average rating as set by all users + var $preciserating; // Rating rounded to 1 decimal /** * Constructor @@ -46,6 +47,7 @@ class Rating { // Check for the users rating if ($rating == $this->get_user($GLOBALS['user']->id)) { $this->rating = $rating; + $this->preciserating = $rating; } else { $this->get_average(); @@ -93,17 +95,19 @@ class Rating { } // while we're pulling results if ($total > 0) { - $average = floor($total/$i); - $this->rating = $average; + $average = round($total/$i, 1); } elseif ($i >= '1' AND $total == '0') { - $this->rating = '-1'; + $average = -1; } else { - $this->rating = '0'; + $average = 0; } - return $average; + $this->preciserating = $average; + $this->rating = floor($average); + + return $this->rating; } // get_average -- cgit