I have my Fivestar widgets set to display the average vote as stars, and also display the average vote as text underneath the stars. Whenever an average is not a whole number (e.g. 3.5) the stars do not correctly represent the value. It seems to be rounding up the average to the nearest whole number (3.5 is shown as 4 full stars), while the text of the actual average remains accurate.
I'm fairly sure this is related to whether or not the widget is shown as static, but I don't know why. For example, anonymous users cannot vote and upon visiting the page they see the static Fivestar widgets (which display the fractional stars correctly). But authenticated users always see the "active" widget regardless of whether or not they have already voted (it seems the module is designed this way - to allow users to change their vote at any time) and the "active" widget appears to only display values in whole numbers.
It would seem to be a basic feature to have users see the average vote displayed accurately. Looks kind of silly to have a widget showing 4 stars directly above the text that says 3.5 stars.
Comments
Comment #1
epiphany22 commentedbump. Edited the Issue Title for better accuracy. Any help would be greatly appreciated.
Comment #2
whiteph commentedThere are several things going on here. If you don't permission users to vote then Fivestar displays the static widget, which as you say displays the average 3.5 correctly. Normally anonymous users would't be permissioned to vote, so they see the static widget. All good so far.
Permissioned users see the active form-based widget. The biggest issue for me is that when configured as "average/average" it's overloaded. It has to display the average, yet also has to accept valid votes. In your case the average is 3.5 yet valid votes are 1,2, 3, 4, and 5. The widget could be programmed to display the average, but accept only integral number of stars as a vote. The question then is what should it do once the user has voted? Go back to displaying the average, or display the user's vote? As it's configured as "average/average", I'd say it should go back to the average. But somehow it has to confirm the user's vote as well.
I don't like the overloading, and suggest the alternative "dual" widget, configured as "both/both". Then you get two Fivestar widgets: one static instance which displays the average nicely in all circumstances, and one active instance which displays the user's vote.
Going back to the "average/average" configuration, why does the average get rounded? I think it is rooted in the design goal of gracefully degrading to static HTML when javascript isn't enabled/available. Fivestar does this by the server-side PHP generating a select list (drop-down box) for the widget. The select list has to be populated with valid votes which the user can select i.e. 1,2,3,4, or 5. It can't add a kind or random 3.5 or 2.87 into that list to represent the average, as the widget is offering those values as valid voting options. So, it rounds the average to the next highest integral value and sets that as the "selected" default value. When the page is loaded, if javascript is enabled, it harvests the data from the select list and lights up the stars up to the default value. It then hides the select list, so the user isn't even aware of it. I'd argue that the average should be rounded up/down to the nearest integer rather than rounded up, although an average of 0.49 or less would of to zero; but zero is also overloaded to mean "no votes as yet".
All in all, given the design constraints, I think Fivestar is doing a good job here. As I say, the "both,both" option gives you a clean way out of the dilemma.
Comment #3
whiteph commented