Achievement system like here in stackoverflow in php?

Conceptually speaking, how could one write an achievement system for a website using PHP and MySQL?

The only real way to do this is to constantly execute MySQL queries to check for achievements, etc.

+7
php website
source share
3 answers

You might want to consider a similar question on meta to find out if Jeff is ready to share any of his lessons learned from this arena. If you do, the question should be specifically about how SO approached the problem. This question, however, is a topical issue for this site (since it asks about creating a new project inspired by what was done on SO).

I suspect that the SO team has a task that periodically runs a set of queries to search for new badges for awards, and then awards them. This is why badges are not awarded immediately after actions have been taken to earn them.

+1
source share

You have two options and most likely they can be combined:

You may have a cron job that runs every X-minutes, and runs through the database, looking at each user, and checks to see if they deserve a new icon.

For example, StackOverflow implements this for the Nice Answer icon. Each time it starts, it checks how many answers there are with +10 upvotes, and sees if you need to get another badge. (He sees 5 messages with 10 upvotes and 4 wonderful response icons, you get an icon). Jeff has already stated that this means that if you receive a response that will receive 10 votes, then it will be canceled, and then another post will receive 10 votes, you will not receive the badge.

The second option is event-based triggers. Which is really simple:

$badgeSystem->giveBadge("Some Badge Name", $User_ID); 

This can be used for events that you know are happening. Like an autobiographer icon. Most likely, the user will not fill out his profile if the submit button is not pressed, so the site can simply check if the user has filled everything, and if they are, and they still need an icon, they get it.

The cron task should be used for constantly monitored activities. Things like quantitative goals, such as visiting the site for 150 days or editing 500 times.

An event-based trigger should occur when an event occurs only if the user performs a specific action, such as submitting a form.

(You can probably use either almost any situation. An event-based trigger gives faster feedback, though ..)

+14
source share

Another option is to use an API from a platform company for the gaming industry, such as http://iactionable.com

+2
source share

All Articles