Closed (won't fix)
Project:
Voting API
Version:
6.x-2.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
11 May 2011 at 17:23 UTC
Updated:
7 Dec 2017 at 08:37 UTC
Jump to comment: Most recent
Comments
Comment #1
x-drup commentedSubscribe!
Comment #2
ymeiner commentedIf you only need the number you can actualy use math field. add the fields, exclude them and calculate the result.
Comment #3
huslabs commentedsame issue !!
need to make a view sort the results by ( Who is the best !! ) ??
subscribed :)
Comment #4
x-drup commented/**
* Implementation of hook_votingapi_results_alter().
*/
function mymodule_votingapi_results_alter(&$results, $content_type, $content_id) {
$vote_avg_sum = 0;
$vote_avg_count = 0;
$vote_tags = 0;
foreach($results as $tag => $data) {
if($tag != 'vote') {
$vote_avg_sum += $data['percent']['average'];
$vote_avg_count += $data['percent']['count'];
$vote_tags++;
}
}
if($vote_tags > 0) {
$results['vote']['percent']['average'] = $vote_avg_sum/$vote_tags;
$results['vote']['percent']['count'] = $vote_avg_count/$vote_tags;
}
}
it works for me. in views with relation ships by axis, and sortable by votes results.
Comment #5
Louis Bob commentedIs this code ok for the D7 version of the module?
Comment #6
legolasboDrupal 6 is no longer supported. Closing old issues to clean up the issue queue.
Please reopen and update this issue if this is still an issue in the D7 or D8 version.