1

I am planning to build a community based website where users would be able to rate the content uploaded by others. I have gone through many blog posts and Stack Exchange questions too, but what I want could not be answered in any of it.

What I got:

  • User Points module: To associate points to author of a node (content) if the node (content) is up-voted or downn-voted - This, as I understand, can be done using Rules.
  • Rate module or Fivestar module - To provide rating mechanism for a particular node (content) provided by the author.

I would want to extract statistics like:

  • Highest rated article for a period of time - Like 1 month or between 'from' and 'to' date etc.
  • User who has accumulated highest points within a period of time
  • Etc.

This basically lets me evaluate and find out the most 'liked' or 'popular' user or most 'liked' or 'popular' article within a period of time to award them some goodies.

So, how can I achieve this?

I have done some homework, stumbled upon some threads but could not find what exactly I needed:

1

I haven't used User Points Module but for fivestar module or module based on Voting api you can create a view of content and add a relationship with vote results and you will get the aggregation you need i.e average/total number/total score for that node then you can add a Vote results :Timestamp filter to get the results in between dates. You can add sort and limit to display the way you want.

| improve this answer | |
  • Just to be clear "Vote results :Timestamp" is this something which has to be done in code? Or, is it a filter feature provided by the module? – Raj Pawan Gumdal Jun 13 '14 at 13:11
  • 1
    It is a field, if you are providing a static value then you can create a filter for this field and set the value or if you are going to execute this view through code then you can set the value using $view->exposed_input. But if you want to change this dynamicaly then add this as a field instead of a filter then write hook_views_query_alter(&$view, &$query) to add the condition for this field – wolverine Jun 13 '14 at 13:25
1

If you're looking for a working module example with user voting, ratings and statistics, you may want to have a look at the Answers module (which enables the content types Question and Answer, whereas Answers are displayed below the Question they relate to). Together with (at least) 2 of its submodules, i.e.:

  • Answers Voting, to implement a system to upvote or downvote either Questions and/or Answers (which uses the Rate module).
  • Answers Userpoints, to increase or decrease "reputation points" (which uses the Userpoints module) on events such as up- or down-voting on a question or answer, or marking an Answer as the "Best Answer".

Head over to its project page for more details.

To extract nodes related statistics, just use the Views module, similar to what is shown on the Answers demo site (in read only mode for anonymous users). It includes Views based lists of:

Refer to my answer to "How to get the node ids of answers for a question in Drupal Services (REST)?" for more details about these views.

Quite a lot of the "business logic" of the Answers module is implemented via all sorts of configurable rules (using the Rules module). As an example, if you don't agree with the out-of-the-box rules about how much "userpoints" are granted to an upvoted (or downvoted) question (or answer), you just use the Rules UI to tune the amount of such points to your requirements.

Disclosure: I'm a (co-)maintainer of the Answers module.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.