Displaying average of all votes (sum up the multi-axis)

deanloh - November 9, 2009 - 08:31
Project:Voting API
Version:6.x-2.3
Component:Views Integration
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

With the help at http://drupal.org/node/457886, I have managed to come as far as setting up the review system, consists of 2 node types (supplier, review) and 3 axis: Quality, Value, Reliability.

I was able to configure Views to display the average of votes on a view page. See screenshot: http://dropbox.akandatang.info/multi-axis.png

But now I'm faced with the new challenge: to display the average of overall votes (by summing up all 3 axis, then average.)

For example, given a voting scores like below:

First axis: Quality - 60%
Second axis: Value - 50%
Third axis: Reliability - 90%

Therefore the average of the above = (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');

But what I need now is to add a column to the views page and display the average. What should I do to achieve that?

#1

deanloh - November 13, 2009 - 03:04

I had eventually found the solution to this. For the benefit of others who might be looking for this, the solution is by using http://drupal.org/project/views_customfield.

#2

deanloh - November 13, 2009 - 03:06
Status:active» closed
 
 

Drupal is a registered trademark of Dries Buytaert.