How to Make Easy & Flexible Star Ratings
nerds.airbnb.com
nerds.airbnb.com
http://www.evanmiller.org/how-not-to-sort-by-average-rating....
So, when this article says "The goal is to avoid having a sprite that looks like this" where the sprite has all the values of stars in a line... why did people switch to doing it that way in the first place? Like the article says, it's a pain to maintain, has lots of pixels, and is not resizable.
That's way less work than all that CSS.
Essentially, I see a number of stars as just a different sort of a "progress-bar"-like graphic, so it's not necessary to set individual stars in the HTML. Just set it as a horizontally-repeating background, with predefined "steps" od the overlay, and the only number you need to pass from the server is the step level. This can even show a partial star if you want.
P.S. I haven't read the OP article prior to writing this comment; that's essentially what they're advising there.
I think that Facebook's like is a good concept that can replace stars rating (a like is a like, no negative feedbacks, and you know that you either like something or you didn't).
Star ratings is too complex, I mean, something I rate 4 star is very different than somebody else's 4 star rating.
Maybe this isn't the place to discuss this but I wanted to let the word out ;)
For example, an Airbnb venue with 5,000 likes would be considered 'better' than one with 500. But add in negative feedback, and consider if the same venue with 5,000 likes also had 4,500 dislikes, while the venue with 500 likes only had 50 dislikes.
Negative feedback helps us discern between if something is 'better' or simply 'popular' -- the latter can be gamed with marketing, while the former is much harder.
For example big demo button on CodDrops: http://tympanus.net/codrops/2011/10/12/flexible-slide-to-top...
I wrote a Raphael powered polyfill for this http://dylanfm.github.com/jquery.ratemate/. Although it requires Raphael (and JS), at least it's a bit more semantic and has a non-JS fallback in browsers that have native support for the meter element. The plugin also provides a way for controlling star ratings on input type number or range elements. However, this really isn't worth using if you're not including Raphael already (fairly large library). I'm thinking about making a canvas alternative.
Star Ratings
I’ve been awfully busy programming lately. My Django-based side project is coming along well and I hope to have it ready for use in a few weeks. Please don’t ask more about it, that’s really all I can say for now. Anyways, I came across an interesting little math problem today and was hoping some skilled programmers out there could come up with a more elegant solution than mine.
Problem: Star Ratings
People can rate cheeseburgers on my website with a star rating of 0-5 stars (whole stars only), 5 being mighty tasty and 0 being disgusting. I would like to show the average of everyone’s ratings of a particular cheeseburger to the nearest half star. I have already calculated the average rating as a float (star_sum) and the total number of people that rated the particular cheeseburger (num_raters). The result should be stored as a float in a variable named “stars.”
My Solution (in Python):
# round to one decimal place and
# separate into whole and fractional parts
parts = str(round(star_sum/num_raters, 1)).split('.')
whole = int(parts[0])
frac = int(parts[1])
if frac < 3:
___frac = 0
elif frac > 7:
___frac = 0
___whole += 1
else:
___frac = 5
# recombine for a star rating rounded to the half
stars = float(str(whole)+’.'+str(frac))
Mmmm… In-N-Out Burgers… Please leave a comment if you’ve got a better solution. round( 2.0 * star_sum / num_raters) / 2.0 stars = round(star_sum * 2 / num_raters)/2def round_to_half(x): if ( x < 1) { if (x < 3) { return 0; else if (x > 7) { return 1.0; } else { return 0.5 } } else { return round_to_half(x/10); } }
x = star_sum/num_raters dec = round_to_half(x) x = floor(x/10) + dec
This way you look smarter for using recursion.