How would you implement an icon system like SO?

I need to make a similar icon system within zend.

I do not know how to implement it, although I mean an event / observer and some actions to trigger an action to check, or a cron that will run every 10 minutes, for example, etc.

Any ideas?

+6
source share
4 answers

As the developer of Django, who wrote a plug-in for screwing up for a client, I used Qaru and BigDoor as my inspiration. It turns out that gamification is very easy, and at the same time getting harder.

Assuming that you already have a User table in your database, the guessing kernel of your application occupies exactly two tables: "Currency" and "User Currency". There is one required field in the "Currency" table, "name", but I also recommend a "description". If you write an administrative interface for your level of play, the description helps a lot.

There are three things in the CurrencyUser table: user ID, currency identifier, and the amount of the currency that the user earned.

"Currency" is a buzzword for the game; it does not apply to money, but to what you are tracking. For example, SO keeps track of how many omissions you have chosen, how many votes, how many times you have a different answer than yours, and how many times one of your upvotes answers goes through 10 (note that the latter: other people do it, not you!). For each of these events, SO scans a list of criteria, gets the associated currency, and increases or creates a new UserCurrency for those that have been executed.

When an increment occurs, this is also an event, and the second level of functions is launched, and if the threshold is skipped, an icon is displayed.

SO also has "secret" badges. Did you know that You donโ€™t get an icon for them, but the flag is shown in another table - permission to edit, permission to comment, permission to control the wiki, etc.

I mention secret icons so that it is clear: the code for tracking user events that award currency is one independent plug-in loosely connected to your application, the code for tracking currency events that lead to icons is the second, independent, freely connected part The code and code for tracking currency events that lead to permissions is the third independent, loosely coupled piece of code. The interiors of each of them can change to some extent without unnecessary effort if the APIs between them are clear.

Thus, legalizing is easy.

This is also difficult. SO is an inspiration because they really thought a lot about what their users wanted to do. The progressive permission system prevents glaring trolling, the icon system informs users about the get-go icon system ("First post badge!"), But also informs the user about what else the user can do. The names and descriptions of the icons are delightful, insightful, and let the user know more. "Gamification" is not just interaction, but a kind of documentation that tells the user: "Now that you understand that X, you can go for the Y reward!" If you cannot strike at this mark, do not interfere with gamphlation.

+15
source

I would do this:

  • create many parameters for users (for example, answers to questions, votes received, etc.)
  • create badges with preconditions for these parameters (5 questions, 10 votes received, etc.)
  • every time you update a user, check for new icons and enable them on user icons.

I think he should do the trick (:


If you do not need to warn the user when he receives a new badge, you do not even need to search for badges every time. Just run a query showing the icons matching the prerequisites.

+1
source

I would accomplish this with triggers (pseudo code :)

On update votes_table create new row in users_points (how_many, for_what, when, ...); on update users_points call check_if_enough_for_some_badge(); 
+1
source

I approach this as follows: firstly, almost all user actions are recorded as an event, starting from the moment of launch, as new icons and conditions will be added in the future, and some of them will take place over long periods of time.

The application I'm working on is a game / platform for e-learning, so the types of events will consist of something like: Quiz, User, Community and the events inside them may be something like: (for Quiz) Answers Question Correct , answers the question incorrectly, completes the quiz (for the user) Login, logout, full profile, (for the community) sends a question to the forum, message Answers the forum, answer Rating +1, etc.

Each event will receive a timestamp.

The criteria for filling the icon / level / etc is stored in the function, and the function name is in the table with the icon. This allows me to simplify table storage and make more creative use of the code.

Cron runs at short intervals to go through the icon / level / etc queue for everything in the event table, with cross-references to the user's activity log. In other words, only when the user logs in, is he added to the queue.

Any suggestions to go with this, especially. regarding scalability would be appreciated!

+1
source

Source: https://habr.com/ru/post/886726/


All Articles