用户和帖子(和评论)的评级系统

时间:2010-07-15 18:55:55

标签: drupal drupal-6

我需要实施一个带评级系统的留言板。类似于堆栈溢出的东西,但更简单。

我需要对每个问题/答案进行评分并计算每个用户的评分。

我正在寻找Drupal中的模块来实现它。你能给我一些小费吗?

感谢

2 个答案:

答案 0 :(得分:2)

FivestarUser Points可用于此目的,但您只能获得与Stack Overflow类似的内容。
第一个模块(需要Voting API)可用于允许用户投票,第二个模块可用于转换投票用户的点数(除其他外 - 模块不受限制)对此)。要集成这两个模块,还有另一个模块,但我不确定它是“用户点”的一部分,还是User Points Contributed modules

Fivestar的问题是允许用户从1到X进行投票(我认为可以更改最大投票数),这与Stack Overflow使用的投票系统不同,后者用户可以简单地报告“I喜欢它,“或”我不喜欢它“。使用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',
      ));
    }
  }
}

答案 1 :(得分:1)

Drupal Fivestar效果很好。

相关问题