diff options
author | spocky <spocky@ampache> | 2008-04-02 12:38:47 +0000 |
---|---|---|
committer | spocky <spocky@ampache> | 2008-04-02 12:38:47 +0000 |
commit | 2544f5b5629d36658f92d4d0ad111563c2442f1b (patch) | |
tree | 74f24fe5d8a40716dfad4f0e5017cce03dd3878b /lib/class/rating.class.php | |
parent | 3c36e58d5441dd5a6990fc24332e69d330edf766 (diff) | |
download | ampache-2544f5b5629d36658f92d4d0ad111563c2442f1b.tar.gz ampache-2544f5b5629d36658f92d4d0ad111563c2442f1b.tar.bz2 ampache-2544f5b5629d36658f92d4d0ad111563c2442f1b.zip |
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.
Diffstat (limited to 'lib/class/rating.class.php')
-rw-r--r-- | lib/class/rating.class.php | 14 |
1 files changed, 9 insertions, 5 deletions
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 |