Extension:Semantic Rating/en

The Semantic Rating extension adds three parser functions to display a star rating:


 *   - displays a rating inline
 *   - displays a rating to the left of the title at the top of the page
 *   - displays a rating to the right of the title at the top of the page

The parser functions are capable of displaying empty (gray), full (yellow), and half stars.

By default, the   and   parser functions will insert the rating in the title at the top of a page for any skin that puts the title in an HTML element with id   such as the default Vector skin. This can be changed for other skins using the  configuration variable. This approach can also be used to have the rating appear at other places in the page by using a  and appropriate choice of.

Special thanks to Bernadette Clemente for the original idea that inspired this extension and to Kelly Hatfield for an early implementation of this extension.

Displaying a Rating
The following displays a 3 star rating inline using the default maximum number of stars:

If the default maximum is 5, it will display 3 yellow stars and 2 gray stars. If the default maximum is 10, it will display 3 yellow stars and 7 gray stars.

To explicitly set the maximum number of stars to 10, use the following:

To display the rating at the top of the page with the page title instead, use (again with an optional maximum value):

or

Displaying the Result of a Semantic Query as a Five Star Rating
While SemanticRating does not require Semantic MediaWiki to be installed, the two extensions do work well togther. Semantic Rating also works well with Cargo. For example, below are several more advanced examples that illustrate how this extension can be used with Semantic MediaWiki.

Consider the case where users can review a wiki page. In this example, each review is itself a wiki page in category Reviews. Each review page has a property, Item, that is a link to the page being reviewed. Each review page also has a property, Rating, that has a value between 1 and 5 (with 0 being reserved for the case where no rating is assigned).

On the page being reviewed, the page's average rating can be displayed by the following query:

Further, assume that each page being reviewed has a property, Author, pointing to a page for the author of the page being reviewed. On the author's page, using the ParserFunctions and Arrays extensions, the average rating for all pages authored by that author (an average of the average page ratings) can be displayed by the following:

Release Notes

 * Version 4.0.1
 * Added check that parser function parameter is numeric


 * Version 4.0
 * Removed form input, since it is now part of the Page Forms extension; this extension no longer requires Page Forms to be installed


 * Version 3.0
 * Removed use of inline JavaScript that caused issues in MediaWiki 1.26
 * Converted to new extension registration style
 * Removed support for old style i18n and extension registration
 * Renamed configuration variables with $wg prefix to support new extension registration format


 * Version 2.2.1
 * Minor changes: improved coding style, several internal tweaks, license to show on "Special:Version"


 * Version 2.2
 * Added  and updated coding style.