I have a use case where I want each of the review axes, but I also want an aggregated score for the node. This is helpful for sorting, etc. I'm not providing a patch here as I'm guessing the quick way I went about this is maybe not the prefered way, however, I am including the code. In nodereview_save_reviews() in nodereview_node_nodereview.inc
foreach ($node->reviews as $aid => $review) {
// Save the text review
db_query("INSERT INTO {nodereview_reviews} (nid, aid, review) VALUES (%d, %d, '%s')", $node->nid, $aid, $review['review']);
// And use the votingapi to save the score
$votes[] = (object)array('value'=>$review['score'], 'tag'=>$axes[$aid]);
// build total score
$total_score = $total_score + $review['score'];
}
$total_score = intval( $total_score / count($node->reviews));
$votes[] = (object) array('value'=>$total_score, 'tag' => t('vote'));
votingapi_set_vote('node', $node->reviewed_nid, $votes, $node->uid);
}
All this code does is add each review axes value together and then divide by the total number. The "total" value is stored in the "vote" container which seems to be standard in votingapi, so no other code needs to be written.
Comments
Comment #1
Fayna commentedMaybe you can help in this issue:
http://drupal.org/node/104997
There is already a patch there.
Comment #2
danielhonrade commentedThis won't be fixed anymore or replicate to verify this issue, we just have to move forward and making version 6 stable and create version 7 dev.
Comment #3
Crell commentedThis is still a valid feature request for later versions.
Comment #4
danielhonrade commentedHi Crell,
I added this feature already on the recent dev
Comment #5
danielhonrade commentedthis is probably a duplicate of this issue http://drupal.org/node/104997
Comment #6
danielhonrade commented