How to Use a jQuery star rating plugin with ASP.NET and SQL Server database
I want to implement a rating system for my application to rate events.
I've been s开发者_C百科earching and I think this is the list that I need to do to achieve the rating system and I'll also attach what I found about each point.
Find a JQuery plugin : JRating, Opineo, RateIt
Find a suitable algorithm: I've searched a lot but didn't find a good algorithm till now
Determine the database structure that I'm going to use
The c# code and the JavaScript code required to implement the plugin and send the poll results to the database
I think that's it! if you have any suggestions or points to add please share it.
I've built a rating system similar to yours, so I'll contribute some additional points to consider:
- As to the rating plugin, I chose jQuery Star Rating, which worked just fine, but I suspect that any of the other mentioned plugins will be fine as well.
- As for an algorithm, I used a simple average of all the ratings for the composite rating of an item. I also made sure to display the count of ratings so people know how reliable the average is.
- As to the database structure, it depends on whether you allow anonymous ratings or not. The application I built only allowed logged-in users to rate items, so I had a table that stored the user ID, the item ID and the rating. This helped prevent the same user from rating an item multiple times and kept all of the data around for me to generate my average. (If you allow anonymous ratings, then I suggest that you store the IP address or session identifier to dissuade people from rating more than once. You won't be able to stop it but you can discourage it.) You'll probably also want to compute aggregate ratings via a batch job, or at least cache the computation so it isn't redone every time an item is viewed.
There's plenty of coding to be done and plenty of issues to consider to implement a "simple" ratings system, so I hope these thoughts help.
精彩评论