I'm using the VotingAPI to rate tour Guides. Guides are setup as a node type and so are Reviews. One of the requirements that has me puzzled is the ability for one user to rate a Guide multiple times. If they go on multiple trips, they can submit multiple reviews which will each include a rating.

It seems that the VotingAPI does not allow for this in a standard implementation. I currently have individual Review votes applied directly to the Guide instead of the Review (after all we are rating the guide, not the review). However, if a user submits a second review for the same Guide, the 2nd vote replaces the 1st vote in the votingapi_vote table.

To prevent the above replacement issue, I tried creating a unique "tag" (or axis) value for each Guide vote from the same user. That allows multiple votes, but breaks the vote average calculation for the Guide.

I'm wondering if I should have Votes applied to the Review (ie. as if you were rating the review), then write my own separate code to calculate counts and averages for the Guide. This would add some DB overhead (we'd have 2 calculation tables, and VotingAPI's default cache table would never be used), but seems like a better solution than modifying the VotingAPI module.

Comments

mooffie’s picture

One of the requirements [...] is the ability for one user to rate [...] multiple times.
[...]
It seems that the VotingAPI does not allow for this

Why? It seems you can: use votingapi_add_vote() instead of votingapi_set_vote().