Ave Rating in Table View

misterlawrence - August 18, 2007 - 03:41
Project:userreview
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

I have a content type called "Book to Review", and I have connected userreview to this content type.

I have created a view that shows all nodes of type "Book to Review", and I would like to list the average userreview rating next to each book.

Which field should I add? I have tried a number of the votingapi fields, and end up with either a blank field in my table or a lengthy SQL error.

#1

misterlawrence - August 20, 2007 - 13:29

Does anyone have any thoughts on solving this? I'm sure it's doable...I just can't figure it out.

#2

crawfish - August 30, 2007 - 02:14

I have exactly the same problem! And seeing that your post get no answer, it seems I won't get help anytime soon. Therefore I did a bit of research and here's what I found:
In the view fields list you will see something like "VotingAPI percent userreview:abc result (average)" and "VotingAPI percent vote result (average)", where "abc" is the node type you enabled userreview. If you select "VotingAPI percent vote result (average)" you get null value, as it's looking for values that tagged "vote", whereas anything posted by userreview is tagged "userreview:abc", so apparently you need to select "VotingAPI percent userreview:abc result (average)". Unfortunatly that gives a sql error. It seems Mysql does not like "userreview:abc". I am a Mysql newbie so I don't know why.
Anyway I changed "userreview:abc" into "urabc", that means open userreview.module and do a search for "userreview:" and replace with "ur" (I found 2 occurances). If you have already voted with userreview then get into tables "votingapi_cache", "votingapi_vote" and "userreview", change any "userreview:abc" into "urabc".
You may need to disable and then re-enable userreview and voting api modules for the changes to take effect. Then choose "VotingAPI percent urabc result (average)" and I get the result.
I know this is ugly and there should be more elegant fix, but I know next to nothing about PHP and Mysql so that's all I can do and at least it worked for me.

#3

misterlawrence - August 30, 2007 - 20:00

For what it's worth, I decided to deactivate the module, and I am using five star module instead, combined with the amazon node module. It's working fine, and is a bit more flexible for my needs.

This is a neat module though, and if it could be fixed (and perhaps made a bit more configurable) I would certainly consider using it again.

#4

royal007 - September 25, 2007 - 19:19

i am having the exact same problem

if i use the "VotingAPI percent userreview:review value" in views it shows the vote, but if the node has several votes, the view shows the same title over and over with the other votes next to them.

Title: Vote:
Finding Nemo 9
Finding Nemo 7
Finding Nemo 9
Finding Nemo 8

I want them to be like

Title: Vote:
Finding Nemo 8.5 (this being the average of all votes)

I think the one to select is "VotingAPI percent userreview:review result (average)" but when I do so, I get this error.

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':review_percent_average ON node.nid = votingapi_cache_userreview:review_pe' at line 1 query: SELECT count(node.nid) FROM node node LEFT JOIN term_node term_node ON node.nid = term_node.nid LEFT JOIN term_hierarchy term_hierarchy ON term_node.tid = term_hierarchy.tid LEFT JOIN votingapi_vote votingapi_vote_userreview_review_percent ON node.nid = votingapi_vote_userreview_review_percent.content_id AND votingapi_vote_userreview_review_percent.content_type = 'node' AND votingapi_vote_userreview_review_percent.value_type = 'percent' AND votingapi_vote_userreview_review_percent.tag = 'userreview:review' LEFT JOIN votingapi_cache votingapi_cache_userreview:review_percent_average ON node.nid = votingapi_cache_userreview:review_percent_average.content_id AND votingapi_cache_userreview:review_percent_average.content_t in /home/content/g/a/m/html/includes/database.mysql.inc on line 172.

any idea how to fix this??, I tried what someone mentioned above but it did not work.

#5

royal007 - September 26, 2007 - 03:37

ignore my previous post, i got this fixed.

#6

misterlawrence - September 28, 2007 - 20:04

royal007, could you share how you fixed your problem?

#7

dewolfe - October 29, 2007 - 18:49

I am having the same problem and would also like to know how you fix it. Thanks.

#8

Summit - January 10, 2008 - 13:27

+1 for the fix!

greetings,
Martijn

#9

asak - February 6, 2008 - 18:43

Nice fix crawfish !

now my question is - how do i get views to show "7.5" (as i see in the node display) and not "7.66667" in the view?

#10

Vasilisa - July 26, 2008 - 17:00

royal007, how did you do it? Could you post it here?

 
 

Drupal is a registered trademark of Dries Buytaert.