I'm trying to find a solution for displaying the average votes of multi-axis votes via views. I need this information to sort my nodes by overall average votes.
For example, given voting scores like below:
First axis: Quality - 60%
Second axis: Value - 50%
Third axis: Reliability - 90%
I'd like to get the overall average of above as = (60+50+90)/3 = 66.67%
I was able to show the average on node page by using this code:
$overall_score = (($quality_rating[0]['value'])+($value_rating[0]['value'])+($reliability_rating[0]['value']))/3;
print theme('fivestar_static', $overall_score, '5'); in page.tpl.php
What is the best way to achieve getting this information in views? Is there a way I can store it in the CCK for each node? I'd also like to be able to search for the overall rating in the database.
Any help would me much appreciated!
Comments
Comment #1
HelloStephanie commentedComment #2
IWasBornToWin commentedWow, everywhere I look for the solution to this question I see old, unanswered questions. Is this module maintained? I need the answer to this question also.
Comment #3
JCB commentedHi Guys,
I have not tried it myself; so this is just pure speculation:
1. Install Computed Field
2. Create a cck field which uses the Computed Field.
3. Place calculations in the Computed Field's configuration
Example can be found here (see #14)
https://drupal.org/node/335493
It will probably look something like below.
4. Install Module Views Custom Field
5. Create a view
add a "Custom PHP" field provided by "Views Custom Field" and enter something like this (where '5' will be your views custom field's value):
If you want to go further to get the overall rating for all average counts.
6. Install Views Calc
7. Calculate the average of a view by using the "Views Calc" module
8. You can now insert the average of the average on a node by embedding a view to a node by printing it to a template file such as node.tpl.php (this is usually tricky and involves a lot of patience)
See this thread for instructions on embedding a view:
https://drupal.org/node/719330
Let me know if this solved your problem :-)
Comment #4
whiteph commentedSee Vote-averaging for multi-axis