Advanced Ratings page
- Overview
- Use this page to configure a "rating" sytem to evaluate tracker items or wiki pages.
- To access
- Click the Ratings icon
on the Admin Panel
or
Access http://yourdomain.com/tiki-admin.php?page=rating
- Note
- Tiki currently supports sorting through advanced rating in:
For wiki pages:
Thus, visitors can provide feedback like:
- Did this page help you solve the issue?
- Was this page easy to understand?
Advanced Rating
Introduced in Tiki5, the advanced rating feature allows for more control over the aggregation of scores.Rating methods are defined globally and will be used for all supported objects. They are defined through the Advanced Rating administration panel (tiki-admin.php?page=rating). Multiple methods can be created. If a method contains type-specific calculations, it will be ignored when performing the calculation.
Features currently supporting sorting through advanced rating:
Sorting items according to advanced rating
Note that the sort mode to use when needing to sort by advanced rating is either adv_rating_xx_asc or adv_rating_xx_desc, where xx is the ratingConfigId.
Feature request: Can we make this take the name of the config instead of the ratingConfigId as well?
Set-up
By default, each calculated value is kept for 1 hour (3600 seconds). This limit does not apply when recalculating on vote, but is used for every other technique to avoid recalculating the same scores over and over again.
The calculation is defined as a small piece of code, similar to functional languages, which is very close to mathematical representations. Creating custom formulas is expected to require some mathematical skills. However, this documentation should provide examples for most frequent cases.
The editor in the administration panel performs extensive validation and will make it impossible to save the formula unless it can be evaluated. Checks are performed for:
- Syntax errors
- Unknown functions
- Missing arguments
- Invalid argument values
- Unknown input variables
Default formula
(rating-average (object type object-id))
It can be altered to limit the vote consideration to a limited time span, 30 days for example.
Recent votes only
(rating-average
(object type object-id)
(range (mul 3600 24 30))
)In the language, spaces do not matter. Only the parenthesis indicate structure. rating-average is a function that fetches the ratings for a given object. type and object-id are standard variables fed when calculating a rating. object and range are configuration options of the function.
mul is a mathematical function. (mul 3600 24 30) is equivalent to 3600*24*30.
The functions can be combined in various ways. For example, we could calculate a score that considers the votes from the past month, but gives extra emphasis on the recent ones.
Combined vote duration
(add
(rating-average
(object type object-id)
(range (mul 3600 24 30)))
(rating-average
(object type object-id)
(range (mul 3600 24 7)))
)Even though the votes are 1-5, the final score can be on an entirely different scale. The language is also extensible if the calculation needs to be combined with other factors or weight. See Rating Language.
All available options are documented in the following section.
Reference
mul (Multiply)
Performs a simple multiplication accepting multiple input values.Examples
(mul 3 4) -> 12 (mul (mul 3 4) 5) -> 60 (mul 3 4 5) -> 60 (mul 4 0.5) -> 2
add (Sum)
Performs a simple sum accepting multiple inputExamples
(add 3 4) -> 7 (add (add 3 4) 5) -> 12 (add 3 4 5) -> 12 (add 4 0.5) -> 4.5
rating-average and rating-sum
The rating functions calculate the score from the rating history table. Each rating performed on the site is kept in the database and can be used to calculate custom ratings on. The various options allow to adapt the score calculation to reflect the importance on the site, whether it is to support quality improvement on documentation or to rank incoming data on a feed aggregator.- object, mandatory and always (object type object-id) in this context.
- range, to limit how long votes are considered. Argument is provided as a number of seconds.
- ignore, with anonymous as an argument to only consider votes from registered users.
- keep, to only consider one vote per visitor. Unless the option is present, all of the votes are taken into account. The option can be either latest or oldest to indicate which one to keep.
- revote can be specified if keep is specified. Indicates the time period required between votes. For example, users could be allowed to vote more than once per day, but only their latest vote each day would be considered, if revote is set to mul(24 3600). If the user voted yesterday as well as today, both votes will be counted.
str
Generates a static string when needed and the processor attempts to process the string as a variable. Any arguments will be concatenated using spaces.Examples
(str hello-world)
-> "hello-world"
(str hello world)
-> "hello world"
(str
hello
world
foobar)
-> "hello world foobar"article-info
Pulls information from an article to include in the calculation. The first argument must always resolve to 'article'. If any other value, the calculation will be skipped for the evaluated object, making the formula type-specific.Available properties:
- rating, the static rating attached to the article
- view-count
- age-second
- age-hour
- age-day
- age-week
- age-month
Examples
(article-info type object-id rating) (article-info (str article) 42 age-month)
attribute
Pulls information from the generic object attributes.Examples
(attribute
(object type object-id)
(property tiki.proposal.accept)
)
-> [value for page in a rating calculation]
(attribute
(object (str wiki page) 14)
(property tiki.proposal.accept)
(default 0)
)
-> [value for page id 14]Appendix
Cron job
<?php
chdir('/path/to/tikiroot');
require_once 'tiki-setup.php';
require_once 'lib/rating/ratinglib.php';
$ratinglib->refresh_all();