I need to do a similar badge system in zend framework.
I don't know how to implement, I though about a Event/Observer and some actions to trigger an action to check, or a cron which will run every 10 minutes for example, etc..
Any ideas?
As a Django developer who's written a gamification plug-in for a client, I used Stack Overflow and BigDoor as my inspirations. It turns out that Gamification is very easy, and freaking hard all at the same time.
Assuming that you already have a User table in your database, the core of gamifying your application takes exactly two tables: "Currency" and "UserCurrency." The Currency table has one required field, "name", but I recommend a "description" as well. If you write an administrative interface to your gamification layer, the description helps a lot.
The CurrencyUser table has three things: the ID of a user, the ID of a Currency, and the amount of that currency the user has earned.
"Currency" is a gamification buzzword; it does not refer to money, but to whatever it is that you're tracking. For example, SO tracks how many bounties you've put out, how many votes, how many times you've upvoted an answer other than your own, and how many times one of your answers' upvotes passes 10 (note that last one: other people do that, not you!). For each of these events, SO runs through a list of criteria, gets the associated currency, and increments or creates a new UserCurrency for those that have been met.
When the increment happens, that too is an event, and a second tier of functions is triggered, and if a threshold is passed, a badge is awarded.
There are also "secret" badges in SO. Did you know that? You don't get a badge for these, but a flag is set in a different table-- permission to edit, permission to comment, permission to manage the wiki, and so on.
I mention the secret badges to make this clear: the code for tracking user events that award currency is one independent plug-in loosely-coupled to your application, the code for tracking currency events that lead to badges is a second, independent, loosely-coupled piece of code, and the code for tracking currency events that lead to permissions is a third, independent, loosely-coupled piece of code. The internals of each can change to some degree without lousing up the others, so long as the APIs between each are clear.
So gamification is easy to write.
It's also hard as heck. SO is an inspiration because they really thought hard about what they wanted their users to do. The progressive permissions system prevents egregious trolling, the badge system educates users about the badge system from the get-go ("First post badge!") but it also educates the user about what more the user can do. The names and descriptions of badges are delightful, insightful, and lead the user to learn more. "Gamification" is not just about engagement, but it is a kind of documentation that tells the user, "Now that you've figured out X, you can go for award Y!" If you can't hit that mark, don't bother gamifiying.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With