rating-system

mysql update if some values exists otherwise create a new entry

旧时模样 提交于 2020-12-13 02:57:05
问题 I have a table rating with these fields rate_id, game_id, rating, ip . Let suppose that these fields has the following values 1,130,5,155.77.66.55 When a user try to vote for a game, I want with mysql to check if he has already vote for this game so mysql will check if ip and game_id already exists, if they exists then mysql will update the value of rating otherwise will create a new entry. What is a efficient way to do this? 回答1: Create unique index that covers ip + game_id . After that you

How to avoid that a user removes his session

China☆狼群 提交于 2020-01-14 02:34:33
问题 The use case Currently, I am trying to build a page where users can vote on content ( up/downvote , similar to the function on the StackExchange network). But the users shouldn't need to register themselves to vote on content. So it would be a kind of "anonymous" voting page . It is built with Laravel5 and uses a MySQL database to store the votes. The user sessions are stored in flat-files, but can be also stored in a database table (L5 is quite flexible here). The problem How to make it

Ajaxified Star Rating System is not Updating Correctly

牧云@^-^@ 提交于 2020-01-13 07:03:51
问题 I've implemented a Star Rating System using this tutorial http://eighty-b.tumblr.com/post/1569674815/creating-an-ajaxified-star-rating-system-in-rails-3 The Ajax works perfectly, until I add the Javascript that Submits the form/saves the data after a given user makes a change. For some reason, it will loop through all the elements on my Index Page, and Submits the correct integer value on the selected object, but then submits a bunch of NIL values on the rest. I only want it to update that

How do I edit the CSS of one blog post but not others to have a 5 Star Rating System?

做~自己de王妃 提交于 2020-01-11 07:41:12
问题 I recently created my own blog using Google's Blogger. When I have completed reading a particular book, I have a Book's I Read Section where I would like to have a static 5 Star Rating System in place of some kind. Perhaps with CSS , I can target each book so I will be able to display from 1 to 5 Stars for the visitor to see. I'm not sure how to edit the CSS of individual blog posts so I can target these specific read books, if that's the best method, and would like any tips in creating an

Simulate hover rating stars (made with selectors in css)

為{幸葍}努か 提交于 2020-01-07 02:18:10
问题 I would know how to make my rating star always hover depending on the average rating result (random generated number from 1-5 and random generated number from 10-55 for the number of votes)? Can I simulate hover with jQuery on my star? I saw few solutions to similar problems but none used in their css the General Sibling Selector (~). The star hover funcionality must be in pure css. Everything other can be and is in js(jQuery). When the document loads some stars should already be hovering

Thumbs system on Urban Dictionary

偶尔善良 提交于 2020-01-03 00:21:27
问题 I was thinking of implementing a thumbs system, but mine would require a registration thus ruling out the possibility of people voting more than once unless they create a new account to do so. So I was wondering about Urban Dictionary's thumb system. How does it work? I would imagine that my IP would be stored in a database, so people would not be able to vote more than once however IPs do change pretty often and especially when you're on an iPhone. Probably a combination of cookies and IP

Show number of stars instead of the number

淺唱寂寞╮ 提交于 2019-12-24 19:50:58
问题 I am making i site where people can make reviews of movies and when they make the review they need to put a rating to a movie, in a number of 1 to 5. But when it print out on another page I want to print out stars insted of the number 3 for exemple. For now I got this code: StringBuilder movielistSB = new StringBuilder(); foreach (var moviereview in movielistSB) { filmanmeldelserlisteSB.AppendFormat( "<div id='moviereview'><artitcle><h3>{0}</h3>" + "<table><tr><td>ID:</td><td>{1}</td></tr>" +

unrated versus negative-rated entities with Wilson score — how to handle?

人走茶凉 提交于 2019-12-23 16:22:32
问题 Having read How Not To Sort By Average Rating I thought I should give it a try. CREATE FUNCTION `mydb`.`LowerBoundWilson95` (pos FLOAT, neg FLOAT) RETURNS FLOAT DETERMINISTIC RETURN IF( pos + neg <= 0, 0, ( (pos + 1.9208) / (pos + neg) - 1.96 * SQRT( (pos * neg) / (pos + neg) + 0.9604 ) / (pos + neg) ) / ( 1 + 3.8416 / (pos + neg) ) ); Running some tests, I discover that objects with pos=0 and neg>0 have very small, but non-negative scores, whereas an object with pos=neg=0 has a score of zero

Flooding Bayesian rating creates values out of range

扶醉桌前 提交于 2019-12-21 02:59:07
问题 I'm trying to apply the Bayesian rating formula, but if I rate 1 out of 5 thousand of hundreds, the final rating is greater than 5. For example, a given item has no votes and after voting 170,000 times with 1 star, its final rating is 5.23. If I rate 100, it has a normal value. Here is what I have in PHP. <?php // these values came from DB $total_votes = 2936; // total of votes for all items $total_rating = 582.955; // sum of all ratings $total_items = 202; // now the specific item, it has no

Ruby on Rails display half a star for a decimal rating, e.g. 4.5

一曲冷凌霜 提交于 2019-12-17 20:33:55
问题 I am able to view 5 asterisks for a rating of 5 for a product, and 4 asterisks for a rating of 4 etc. But what I would like to do is replace the asterisks with an image of a star that I have in my assets/images/ directory, and if a rating is of 4.5 then display half a star. Is there a way of doing this? Below is my current code in application_helper.rb and the view in index.html.erb. application_helper.rb: module ApplicationHelper def render_stars(value) output = '' if (1..5).include?(value