Loading...
 
Skip to main content

History: ScoreDev

Preview of version: 3

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:

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.

History

Information Version
Xavier de Pedro 5
View
Bill White 4
View
Luis Henrique Fagundes 3
View
Luis Henrique Fagundes 2
View