Voting Actions 2.0 -- w00t
A bit over a year ago, I wrote a Drupal module called 'Voting Actions' for a client. It allowed modules that used VotingAPI for their rating/voting backend to kick off arbitrary actions whenever votes were cast and certain criteria were met. For example, if someone voted on a news story, and the average vote for that story was 75% or higher, it could be promoted to the front page.
The concept was pure gold, but unfortunately the module was relatively inflexible. Lots of people needed more flexible conditional criteria, and there were lingering bugs I never got around to fixing. I took a stab at rolling a more flexible version of the core functionality directly into VotingAPI, but didn't have time to polish that work up or complete a working UI for it.
Well, I've finally been able to revisit Voting Actions, and version 2.0b2 (for Drupal 5) is finally available. If you're interested in testing it out, or taking a look, download it and install it on a sandbox site and see what you think.
It has a bunch of improvements over the old 4.7 version, including but not limited to:
- Support for a much wider range of conditional checks. Does the author of the node have a particular permission? Is the node being voted on a story, or a page? Did ALL the voters give it at least two stars? Is the average vote at least three stars?
- Modules can expose their own custom conditional checks to be used with Voting Actions. Does a node appear in a particular view? Is the word count of the node high enough? Was the vote cast on a Wednesday? Sure, that's cool.
- Importing and exporting of defined action sets. Like Views module, Voting Actions lets you swap complex action sets by just exporting them as text. Wayyyyy simpler than describing each step when sharing a 'recipe' for a particular setup.
- Modules can define their own action sets. The old version of Voting Actions forced site admins to manually set up every action set. Modules like Vote Up/Down, which provided Digg-like functionality, had no way of providing 'default' conditions and actions. Now, they can. Like views, they just need to implement hook_voting_actions_sets() and return an array structure like the one you get when exporting a manually-built set.
- A UI that doesn't completely suck. The old Voting Actions was... passable. The new one? I'm actually proud of its editing screen, though it can still use some polishing.
- More secret cool bits under the surface. Though the UI for it isn't yet exposed, the ability to have nested sub-sets of conditionals -- actual branching trees of conditions and actions to execute if they're true -- is all there.
I grabbed a quick screenshot of the user interface for the main Action Set editing screen, and hopefully it demonstrates how things have improved:

For those interested in taking a quick peek at it in action, I recorded a super-off-the-cuff videocast on my testing site and posted it to google video. Embedded video after the cut.




terrific
this is freaking fantastic. nice attention to detail on the UI. i can't wait until an upcoming client needs voting.
Survivor clone
It just occurred to me to that we could do a Survivor clone with voting actions and organic groups. Vote people off the group. Hah!
Fantastic. I'm drooling.
This is what I wanted a year ago when I first looked at voting actions. Thanks for delivering!
Extract the conditions?
Can we extract the conditions into a separate module? I'd love to use it on workflow transitions, e-commerce discounts, and a whole raft of other ideas.
I'm thinking a form element would be slick.
Condition
It's definitely doable, though the way it works isn't really conducive to form elements. basically, each condition has a type -- like 'content_property' -- and modules can expose handlers for different condition types. that includes a 'processor' for actually evaluating the condition, and a 'form' handler for returning a snippet of FAPI definition for use in the editor.
A handler can use a custom element type if they like, but it's not necessary...
Right now, the entire UI for the voting actions editing interface is about actions and conditions -- the voting related stuff is just decorative, really. It's certainly conceivable that we might put this into a conditional action execution system and justlet voting api point at *that*.
I'm not sure how well the system would work for things like ecommerce discounts -- it's a similar CONCEPT but the data structures and so on are a lot different. If anyhting, maybe the work on the UI will give birth to some helpful tips for anyone doing similra things...
I am playing with the
I am playing with the voting_actions module and quite like your approach. I asked at Drupal if you had an update facility but assume that you don't at this point.
I looked at the tables and for the moment it looks like I can cope by changing keys and values. However, clearly there is a lot more risk that something goes wrong. I'd appreciate it if you'd let us know when you do an update as this is a very exciting module.
Also, would you quickly address the difference between vote_result vs. all_votes. My assumption is that vote_result is evaluated only at the time of incrementing the vote tally whereas all_votes gets considered by the cron job.
Thanks for your work and information.
Clarifications
Not quite. 'vote result' allows you to check the actual calculated results of a particular vote (ie, what's the average vote). all_votes allows you to check to make sure EACH individual vote matches certain criteria. individual_vote allows you to check that AT LEAST ONE individual vote matches the criteria.
Using those three in combination, you could filter things such that nodes whose average vote is at least 50% get promoted, but ONLY if everyone voted higher than 20% and AT LEAST one person voted 80% or higher.
Clarification
Thanks a lot for the response.
I now came across your icons in CVS and am able to edit.
One more thing that I am not quite clear on. Your screen shot shows the content property evaluation which I don't see in your April 20 release. I suspect that might be because I am using user defined types?
Wow
Freakin' awesome. Will be trying it out soon!
error
hi,
its not working if there are multiple actions.please check druapl issues on this module.
Unusable without icons
I have installed this module and set up an action, but I do not have the interface shown in your video. I think it's because the icons were not included in the download from http://drupal.org/project/voting_actions
Several help forms point to icons herehttp://drupal.org/cvs?commit=65337, but there is actually nothing to download.
Would you mind updating the package on drupal.org so we can download the complete functioning module? Thanks for your hard work on this helpful tool!
Post new comment