I'm using Voting API and Fivestar Modules to calculate and sort scores. I was just wondering how I could reset the results.

Comments

lyricnz’s picture

Why not have a look at the source for votingapi.module? There's a function in there to find votes (by node mostly), and another function to delete votes. Try something like:

  $votes = _votingapi_get_raw_votes('node', 2);
  votingapi_delete_votes($votes);
Obrittian’s picture

I'm not experienced in writing code. I have absolutely no idea what I would do with that. Do you think you could explain it me?

lyricnz’s picture

Sorry, I made a wrong assumption:

There is currently no function in the UI to delete all the votes for a particular node, so you'll have to execute some custom code. How you do this depends on your application: if you just want to do this once, then you could install "devel" module, enable the execute-PHP block, and paste in the code above.

If you want to do this more often, you could probably ask someone to write you a module, to add this functionality to the UI (or patch fivestar/voting API). If you were doing that, it might be worth doing the code a little more efficiently, since the method above will have issues when there are many (hundreds) of votes for the node.