Sunday, July 28, 2013

Gamification, because hard work should be awarded

The time came to add gamification to the mix. The most part of it was research, gamification as powerful as it is gamification does have pitfalls. If someone reading this ever has to do some sort of gamification implementation I found these to be really good:

Of course the first resource should be your own thinking - How would I cheat this system.

The other problem was making some sort of scalable code, and since we don't have a full list of awards as for now it is hard to find the common denominator. In fact for now I have 2 very different awards. The first one is 'First translation' (as the name implies it is given after the user submits their first translation) the other one is 'n-th translation'. The huge difference is that one is given only once, while the other is 'given' or rather updated several times.

The implementation

So I started with 2 functions I knew I would need, one which will do the connection of user and 'gem' - give the user his award. The other which will check if the award has been previously given. This is also the first line of defense, you have the award you are not getting it again. The second line of defense is that if you do try to submit crappy input the admin will probably block you and if you are blocked all the translations, all the votes and all the badges are deleted - Crime and Punishment.

The next step was to check what the award possibilities are. All the awards or gems are saved in a DB table gems, this is filled with data upon installation of the plugin (or rather will be). When a user submits translations the gems in the gems table are taken, the previously awarded gems are subtracted and a list of possible awards is formed.

All the repetitive gems are added to the list via PHP. It just occurred to me that a better way might be to add an additional column to the gems table indicating if the gem can be awarded more than once...

With the list in hand, or array in memory , the code is of to checking if the user has meet criteria to receive awards. The 'First Translation' was easy, the criteria for 'n-th translation' was the problem.

What is n?

And here is where it got a bit tricky. The awards where to be given on a 'regular' basis, so for every n translations you should get acknowledged. The step size had to be increasing. Since we talk about cc 1700 translations a user can submit, per language, I had no intention to hard code all the milestones. There is where math comes in handy. I was off to a Google search (2 awesome pictures at the bottom) to find some nice numerical series with increasing step size , but where the step size does not get too big too fast.
The answer for me was Pentagonal number series. The first few steps are 1, 5, 12, 22, 35, 51, 70, 92, 117, ... and the general rule (3n^2-n)/2.

Another award will be given for n-th week in a row, but this should be basic counting, and for first vote. Both will be implemented during the day.

The interface update

So giving awards is a nice feature, one of the suggestions I got on Geeklog's mailing list was to display all the possible badges to the users, which is work in progress. But the first thing which came to mind was to notify the user that he got something, this however is not made persistent as for now, and I am not sure if ti will be.

The other update to the plugin is it's connection with Geeklog's user profile.
Again as for so many things in the known universe Geeklog has an API for this, all it requires is to put a function named plugin_profileblocksdisplay_<plugin_name>($user_id) in the functions.inc file and return the HTML of the code to be added.





Another request from the mailing list is to allow users to see all the possible badges, so I did a quick update to the function in lib-translator.php which does the badge display. The user profile is as above, but the Crowd Translator public page now looks like this:

There it is the first step, or few small steps towards gamification of the translation process. The community is was helpful, I got a whole load of suggestions and tips, probably not possible but I will try to implement all of them.
And last night while writing the first part of the blog I got a nice surprise, the mailing list had a new entry, of course I went to see what it is and found this:
BTW Thanks for your hard work.

I don't expect it, it is my privilege and pleasure to do this plugin but it sure is nice to hear.

And the 2 awesome pictures: