将权重纳入 5 星投票系统?
我已经有了一个 5 星级评级系统(用户投票 1-5...并显示平均分数 - 我有一个他们投票的页面,并将其插入数据库中的用户名和投票),但是我现在想要改进它通过整合某种权重来增加您的投票对内容平均得分的影响。它使您的投票比其他情况更“有分量”。
我目前有一个 $level
(这是每个用户拥有的 1-10 之间的数字...其中 10 是最高的,因此效果最大),我想将其用于考虑。
我只是不确定如何去做。
I already have a 5 star rating system in place (user votes 1-5...and average score is displayed - i have a page where they vote and it inserts into the DB there username and vote), however I now want to improve it by integrating some sort of weight which functions solely to increase the impact your vote has on the average score of the content. It makes your vote "weigh" more than it would otherwise.
I currently have a $level
(which is a number between 1-10 each user has...where 10 is the highest therefore having the most effect) which I'd like to use for consideration.
I'm just not sure on how to go by doing this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法是为每个级别在数据库中插入一票。
The easiest way to do this is to just insert one vote into the DB for every level.
如果用户的级别为 X,您可以让他/她的投票权重为 X 级 1 票。您可以在表格中添加另一个字段“权重”,并显示
投票*权重
的平均值:(其中?是您需要的id)
如果您认为这对于您的需求来说太复杂(并且您已经存储进行投票的用户),您可以使用以下查询:
If a user has level X, you can make his/her vote weigh X level 1 votes. You can add another field "weight" to the table, and show an average of
vote*weight
:(where ? is you needed id)
If you think this is too complicated for your needs (and you already store the user that made the vote), you can use this query: