views:

67

answers:

3

hi,

I need to implement a message board with rating system. Something similar to stack overflow, but much simpler.

I need to rate both questions / answers and compute the rating for each user.

I'm looking modules in Drupal to implement it. Could you give me some tip ?

thanks

A: 

The Drupal Fivestar works great.

gearsdigital
ok I found "fivestars extra" module to rate comments. It is still not clear if i can compute an user rating from its posts/comments ratings. I don't want to directly evaluate users, but compute the rating from their posts.
Patrick
The Fivestar works on nodes. As far as i know in drupal everyting is a node. Imho it should work for your purposes.
gearsdigital
"Fivestars extra" works on comments (it is an extension). I will check if I can compute users points with these modules thanks.
Patrick
+1  A: 

Try http://drupal.org/project/userpoints

gagarine
+1  A: 

(Updated after verifying some points)

Fivestar, and User Points could be used for the purpose, but you only get something similar to Stack Overflow.
The first module (which requires Voting API) can be used to allow the users to vote, and the second module can be used to transform the votes in points for the users who voted (among other things — the module is not limited to this). To integrate the two modules, there is another module, but I am not sure it's part of "User Points", or User Points Contributed modules.

The problem with Fivestar is that users are allowed to give a vote from 1 to X (I think the maximum vote can be changed), which is different from the voting system used by Stack Overflow, where users can simply report "I like it", or "I don't like it". With Fivestar there would be only positive votes, and nobody would be able to down vote a comment, or a node; it would be possible to lower the average by giving the minimum vote.

Between the modules I listed, there isn't a module that allows to give points to the author of the node / comment; using "Voting API", and "User Points" it would possible to do that, but no module I looked allows to do it (this means that you could probably write a custom module).

If you look at the list of the modules included in the installation profile ArrayShift, you can get an idea of the modules you can use to reach the same purpose.
The list of modules includes

  • Node comments, which transforms comments in full nodes; with this module, in example, is possible to use a voting module that works only for nodes with comments too.
  • Voting API.
  • Vote UP/Down that allows users to up vote, or down vote.
  • User Points.
  • ArrayShift Support Modules; it is probable that this module contains code that allows node authors to get points every time a node they created is voted.

In particular, a module that is part of ArrayShift Support Modules (as_tweaks) contains the following code:

/**
 * 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',
      ));
    }
  }
}
kiamlaluno
thanks, very interesting links. And very interesting explaination about combining Fivestar and User points. I will play with these modules. thanks
Patrick
I'm checking the Points settings, and I don't see how to update user score if its comments or posts (nodes) are rated. Could you give me some insight about it ?
Patrick
The module that integrates Vote API with User Points is User Points Voting API (http://drupal.org/project/userpoints_votingapi).
kiamlaluno
yeah I have it already installed. But I cannot find the options page to determine how to compute user scores according to their posts / comments rating. Is there any User Points Voting API configuration page ?
Patrick
I've only found the "Voting API" section in the admin page Points Settings. But it doesn't work, I'm rating with another user the 5 stars and the owner of the article still has 0 points. Also, there is no distinction between posts and comments in computing the score.
Patrick
@Patrick: The name of the module is misleading. It's described as "sites using voting tools like Fivestar, Voting, or Latest and Greatest (to name a few) can now award their users points for voting"; this means it gives points to who votes. Fivestar allows users to give a vote from 1 to X; if you want to replicate the functionality in SO, the closer module is "Plus 1", but it doesn't work for comments. I will update my answer.
kiamlaluno
@kiamlaluno. 1) I can actually vote for comments as well with "Fivestar extra" module. It extends Fivestar for comments. But I probably need to make comments work as nodes in order to assign the score to the user. 2) I don't need to have a website like stackoverflow. The rating from 1 to 5 is fine, but I need to map this score into users points, let's say 1 = -2, 2 = - 1, 3 = 0, 4 = +1, 5 = +2. This is what I need. Both for nodes and comments.
Patrick
@Patrick: There aren't any modules that convert node votes in user points as you report; that is why I was suggesting to look at http://drupal.org/project/as_support_modules. It is probable it implements code that transforms the votes in user points.
kiamlaluno
@kiamlaluno. Ok, sorry I don't want to insist too much. The module (drupal.org/project/userpoints_votingapi), add this section to the Point Settings page: http://dl.dropbox.com/u/72686/5star_voting_api.png There is a voice: "Points for author receiving positive votes:" and in the module description it says it works with Fivestar module. Is this a lie ?
Patrick
@Patrick: I missed that; it works, but with Fivestar no user is receiving a negative vote.
kiamlaluno
@kiamlaluno: is it really working ? For me it is not working at all. How can I configure it ? Did you click on "Moderate votes" ? My users scores are always 0. Did you create rules ? thanks
Patrick
@Patrick: I tried it on my test site, by voting a node created with another user account, and it works (http://img.skitch.com/20100716-dnb8urr44xcgs9tengkupxjy3q.png). What can make a difference is when votes tallying happens; I set that option to "Tally results whenever a vote is cast".
kiamlaluno
@kiamlaluno: it is really strange. After 1 day, I've just found out that it works only if 2 users (at least, I guess) vote the same post. And the user has always score 1, regardless the stars rating. For you everything works perfectly ? 1 to 5 scores ? I dunno why I have all these issues
Patrick
@Patric: I logged in with a different account, and voted the same node; the account used to write the node received 5 more points, and the account used to vote received 2 points, which is what I have set.
kiamlaluno

related questions