我需要实现一个带有评级系统的留言板。类似于堆栈溢出的东西,但要简单得多。
我需要对问题/答案进行评分并计算每个用户的评分。
我正在寻找 Drupal 中的模块来实现它。你能给我一些小费吗?
谢谢
最佳答案
Fivestar , 和 User Points可以用于此目的,但您只会得到类似于 Stack Overflow 的东西。
第一个模块(需要 Voting API )可用于允许用户投票,第二个模块可用于将投票转换为已投票用户的点数(除其他外,该模块不限于此)。要集成这两个模块,还有另一个模块,但我不确定它是“用户点”的一部分,还是 User Points Contributed modules .
Fivestar 的问题是允许用户从 1 到 X 投票(我认为可以更改最大投票数),这与 Stack Overflow 使用的投票系统不同,用户可以简单地报告“我喜欢它” ,或“我不喜欢它”。有了 Fivestar,只有赞成票,没有人可以否决评论或节点;可以通过给予最低投票来降低平均水平。
在我列出的模块之间,没有一个模块可以给节点/评论的作者打分;使用“投票 API”和“用户积分”可以做到这一点,但我看过的任何模块都不允许这样做(这意味着你可能会编写一个自定义模块)。
如果您查看 list of the modules包含在安装配置文件中ArrayShift ,您可以了解可用于实现相同目的的模块。
模块列表包括
尤其是作为 ArrayShift Support Modules 一部分的模块。 (as_tweaks) 包含以下代码:
/**
* Below, a bunch of simple hook implementations that award userpoints based
* on various events that happen. In theory, Rules module and various other tools
* could be used to do these things, but most of those modules don't have easy
* to export/import configuration data.
*/
// VotingAPI hook. When a user casts a vote on a node, the author should
// get/lose points..
function as_tweaks_votingapi_insert($votes) {
foreach ($votes as $vote) {
if ($vote['content_type'] == 'node' && ($node = node_load($vote['content_id']))) {
// Award the points
userpoints_userpointsapi(array(
'uid' => $node->uid,
'points' => $vote['value'] * 10,
'operation' => 'vote up',
'entity_id' => $node->nid,
'entity_type' => 'node',
));
}
}
}
// VotingAPI hook. When a user casts a vote on a node, the author should
// get/lose points..
function as_tweaks_votingapi_delete($votes) {
foreach ($votes as $vote) {
if ($vote['content_type'] == 'node' && ($node = node_load($vote['content_id']))) {
// Award the points
userpoints_userpointsapi(array(
'uid' => $node->uid,
'points' => $vote['value'] * -10,
'operation' => 'vote up',
'entity_id' => $node->nid,
'entity_type' => 'node',
));
}
}
}
关于drupal - 用户和帖子(和评论)的评分系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3258920/