Score Details

Implementation

The field `score` in users_users holds user's total score.

The table tiki_users_score logs events so that users aren't scored twice for same thing

  • user - user's login
  • event_id - an unique id for this event
  • expire - expiration time for this scoring. so that users can earn points per 10 minutes in a chat, for example
  • tstamp - timestamp of this score


Every time the user makes some scoring action, the event will be given a unique id (for example, read_article_10 if he's reading article with id 10). If there is no event for this user with same event id, or if the event has expired, this new event will be logged and the user's score will be updated. TODO: old events (with age configurable) should be erased for performance.

The table tiki_score holds all events and respective punctuation:

  • event - the name of the event. In the previous example 'read_article' would be the event's name.
  • score - number of points for these events
  • expiration - how long, in seconds, before the user can earn points again for the same event. 0 indicates only once.


All events are listed in lib/score/events.php. This file loads the array $events, each element is an array with properties of an event. The properties are, by array index:

0 - dependent features, separated by space or comma. Event will only appear in admin if all features listed here are set to "y".
1 - category name
2 - event name - a string identifier for the event
3 - description, must be inside tra()
4 - default score
5 - default expiration

Elements in $events file are sorted as they appear in admin, they must be grouped by category.

Creating new event


Edit lib/score/events.php and add the new event. Find in code where the event occurs and put the hook:

Copy to clipboard
global $user, $tikilib, $feature_score; // if not in global scope if ($feature_score == 'y') { $this->score_event($user, "EVENT_NAME"); }

Future expansion and ideas


In the future Score and Karma will be integrated in one system. lfagundes aka batawata has some ideas not yet documented, but by now everyone is invited to write here any ideas for these cool features.

Ideas for these cool features

  • Upload/download ratio. It would be nice to see a file gallery upload/download ratio. Maybe this is a "Score" feature, or maybe it's a "Gallery" feature. It's probably familiar to some people as a feature of online bulletin board systems. It encourages people to contribute file uploads. The ratio requirement should only apply to a particular group, and should return a message when the ratio has been exceeded. An option would allow the first download "free." The system could tell the user his ratio, and how many downloads he has available, before he commits to making a download. Download failures, to the extent detectable, would not be counted.

  • Score results in privileges. For example, a user who a member of a basic group and attains a certain minimum score is included in another group that has the download privilege.

  • Score phases out. Here a user's score erodes over time if he doesn't continue to participate. For example, the points for creating a wiki page could have a life of six months and then expire. When combined with the previous item, this user could lose his download privilege because of his inactivity, but could re-establish it by creating another wiki page.

  • Dual Ratings. I like the idea of having two separate ratings, one for karma, one for points. Points could perhaps be redeemed for various stuff for example. Karma should reflect the level of respect for a member regardless of their level of activity. In other words, a casual user can have karma just as good as a power user. I don't think its fair to give those with higher karma greater leverage in doling out karma ratings either.