Introduction / Problem Statement
My friends and I decided we would hold an annual contest to see who’s home brewed beer was best. The first problem we ran into was voting, mostly because we didn’t plan ahead and coming up with a way to accurately count 100 hand-written ballots after “sampling” the contest entries was troublesome. Being techies the solution seemed obvious: Develop an application that allows people to enter their own votes into a central place and tally the results when the contest ends.
I set out to create such an app using LAMP hosted on a ISP who charged $7 per month. That worked fine for the first few years, but when Salesforce.com announced Force.com Free Edition I quickly converted and dropped the account with the ISP(which was best because I only need the contest app once a year but kept the account at $84 annual). There is no charge (duh, it’s Free) and I can keep the app all year without activity and use it again each following brewfest.
What does it do?
Ninety percent of what the contest app does is allow the contest administrator to create contests, add contestants and entries, and generate ballots. The other ten percent of the app has to with the actual voting. I’m using the one Site that comes with Free Edition to host a set of Visualforce pages that let users enter their ballot id then the score for each of the contest entries. The app forces voters to enter a valid ballot id so they don’t vote more than once.
When the contest is over I update the contest record to indicate voting is closed then print out the related list of entries sorted by score, and viola, we have a winning home brewed ale. All without the hassle of five slightly inebriated guys arguing about how to count votes then having to make up spreadsheets then having one guy read them and another guy enter them.
How does it work?
As with all good apps let’s start with the data model. Please excuse my lack of a good ERD here. I’m looking for something free that will do ERDs and I’m not going to draw all this out in mspaint. My main objects are Contest, Contestant, and Entry. The Contest defines the event, the Contestant is the brewer, and the Entry names the brewed beer being judged. The relationships are pretty much the way you’d expect them to be.
Outside the main obects I’ve got one for Ballots, Votes, and a cheater for Ballot Generation. Ballots looks up to Contest. Votes is slightly more complicated because it has a Master-Detail relationship to Entry(so I can do a roll-up summary), a lookup to Ballot, and a numeric field for the score.
I’m using standard page layouts to maintain all of this data, except for the cheater object. I didn’t want to write any Visualforce for the app administrator’s sake, so to generate ballots in bulk I insert a new record in the Ballot Generation object (which looks up to Contest), enter the number of ballots to generate, say “50″, into a numeric field, then the trigger fires and creates 50 Ballot records that look up to the Contest then inserts them. Honestly I don’t know what made me do that because it seems like a crappy solution, but it works and I’m the only one that knows I did it that way(until now).
The Site hosts a three page wizard that gets the ballot code(page 1), displays the contestants and entries next to an <apex:SelectRadio> with 1 through 5 as options(page 2), and finally a “thank you” page that tells the voter they’re done(page 3). The site isn’t fancy which has everything to do with the fact that “sexy web sites” aren’t my forte’, but people are hitting this site with mobile devices as well as desktops so the simpler the better.
How is it used?
When people show up to brewfest and are ready to start making the rounds they pick up a contest sheet, a golf pencil, and a ballot code (this year the ballot codes are going to be stickers on the contest sheet), then walk around and sample the home brews. Discreetly or indiscreetly they fill in the circles on the contest sheet like the old scantron test from high school. When they’re done they find a computer provided at the party or use their smart devices to go to the voting web site, enter their ballot code, and vote. This year I added a QR image on the ballot so that people with smart devices that have bar code readers on them can scan the QR code and be taken right to the voting site and have their ballot code automatically entered.
I had planned on using Twilio to let people vote by touch tone phone call, but I had a problem maintaining the state after the caller entered their ballot code, so I dropped it. I would pick it up again, just to say I did it, but it’s not a high value item for me. If anyone reading this has suggestions on how to maintain state in a Twilio call(session) please send me your comments. I’m probably missing something simple.
I toyed with the idea of creating an Android app, but then I started to get too busy with “work” work, and this spare time, impress my friends at brewfest fun work started getting to be too much. There’s always next year for that. Or maybe I’ll publish the app on the AppExchange and pay the $300 review cost just to say I’ve got an app out there. I could create a repository for it on github.com and go all open source with it. That way maybe other people could benefit from it and add to it with apps for mobile devices or maybe even a sexier user interface.
Overall this is a really fun experience. I’ve expanded my knowledge of the Force.com platform by playing with Force.com Free Edition and created a great app that handles the voting at brewfest. Creating something useful is always rewarding. I’m also using Free Edition in the office in a change management application that helps us manage our product backlog, development sprints, resources, and deployments, but that’s a topic for another blog.