I try to implement something like amazon or newegg's interface: give a summary of votings. and list the percentage for each score, from 1 to 5. please see the screenshot i have attached.

I guess i can get it by doing my own SQL query from votingapi's tables to get the percentage (or count) of each rank. but wanted to ask if there is any API which has already had it covered.

thanks.

CommentFileSizeAuthor
newegg.png3.87 KBxqi
amazon.png4.38 KBxqi

Comments

quicksketch’s picture

Project: Fivestar » Voting API
Version: 5.x-1.9 » 5.x-1.6

You can do this by leveraging the functions of VotingAPI. Since this has to do with the retrieval of data rather than the Fivestar interface, I've moved to ticket over there.

You can get a raw collection of all votes by using the votingapi_get_voting_results('node', $nid) function. However, this would probably retrieve a lot more information that you need, since it would retrieve all the voting tags (not just 'vote' or whatever axis it is that you're rating on). To get more complicated there's the _votingapi_get_raw_votes() function which I'm not sure if it'd be better or worse than making a direct SQL query. Drupal 6's votingAPI 2 is much more flexible in this regard, but for D5, a direct query might be the best way to go.

xqi’s picture

thank you quicksketch. i will directly query the field table for now.

eaton’s picture

Status: Active » Closed (fixed)