Extension:RatePage
This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. |
RatePage Release status: unmaintained |
|
---|---|
Implementation | Database , User interface |
Description | Enables readers to rate pages on a wiki |
Author(s) | Ostrzyciel, Polskacafe (Ostrzycieltalk) |
Latest version | 2.14.0 |
Compatibility policy | Master maintains backward compatibility. |
MediaWiki | 1.35+ |
PHP | 7.3+ |
Database changes | Yes |
License | GNU General Public License 2.0 or later |
Download | GitLab: Note: |
Example | An article on Nonsensopedia with rating widget in the sidebar |
|
|
Translate the RatePage extension | |
The RatePage extension enables readers to rate pages on a wiki. It also provides a functionality for setting up and managing contests in which users rate pages.
On desktop skins (currently tested under Monobook, Vector and Timeless) it adds a widget in the sidebar that allows readers to choose any of five available ratings for a page. The extension also works in mobile mode on Minerva (using Extension:MobileFrontend) and Timeless (on narrow screens or using Extension:MobileFrontend), by adding the widget in the footer. The extension is configurable and allows for disabling of the default frontend and potentially using a different one. The main functionality is provided via an API module and the data is stored in a custom database table (ratepage_vote
).
Installation
[edit]- Download and place the file(s) in a directory called
RatePage
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'RatePage' );
- Run the update script which will automatically create the necessary database tables that this extension needs.
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Configuration
[edit]General
[edit]- $wgRPRatingAllowedNamespaces
- Array of namespace IDs that are allowed to be rated. Default is null, which allows all namespaces. An empty array means no namespaces are allowed.
- $wgRPRatingPageBlacklist
- Array of page titles that are not allowed to be rated. Default is an empty array. You may want to add the main page to the blacklist.
- $wgRPSidebarPosition
- Integer indicating where in the sidebar should the widget be placed (one-based index). Default is 2, which places the widget directly under the first (default) sidebar section.
- $wgRPFrontendEnabled
- Bool indicating whether the default frontend module should be loaded. Default is true. Disable this if you want to write your own custom JS script for voting.
- $wgRPAddSidebarSection
- Bool indicating whether to add the default sidebar section for the widget. Default is true. Disable this if you want to write your own custom JS script for voting and you don't want to rely on the extension adding a section to the sidebar.
- $wgRPFooterRatingStars
- Bool indicating whether to add the default voting widget in the footer of mobile skins or Timeless. Default is true.
- $wgRPRatingMin
- Minimal allowed rating. Default is 1. You may want to change that if you decide to remove the default frontend module and write your own that for example allows for only three different ratings. The default frontend will completely ignore this setting.
- $wgRPRatingMax
- Maximal allowed rating. Default is 5. Changing this will change the number of stars displayed, but high values may cause the stars to become really small. You can always implement your own JS frontend and set it to whatever you like.
- $wgRPShowResultsBeforeVoting
- Whether to show page's rating before the user votes. Default is false.
Semantic MediaWiki
[edit]- $wgRPEnableSMWRatings
- Whether to save page's rating as Semantic MediaWiki properties. Default is true. See the section on SMW for more details.
- $wgRPEnableSMWContests
- Whether to save page's contest ratings as Semantic MediaWiki properties. Default is true. See the section on SMW for more details.
- $wgRPImmediateSMWUpdate
- Whether the SMW data update of the page that was rated should be scheduled after each time a vote is cast. When false, the update is triggered only by SMW itself, for example when the page is saved. Turning this option on may be performance-heavy on busy wikis. Default is false.
MultimediaViewer integration
[edit]- $wgRPUseMMVModule
- Whether to use the optional MultimediaViewer feature. Default is true.
Rate limiting
[edit]RatePage supports rate limiting for its API.
For more information about $wgRateLimits and how to set it up, read Manual:$wgRateLimits, the action key is ratepage
.
User rights
[edit]You can control who can vote in the general page ratings through the use of the $wgGroupPermissions configuration variable in your LocalSettings.php file.
Permission | Description | Default value |
---|---|---|
ratepage-vote | Vote for a page | * |
Contests
[edit]RatePage comes with a functionality that lets you set up "contests" during which users vote on pages on your wiki, but these votes are not counted towards the page's general score. They are kept separately from the main score.
These contests are defined on a special page by users with adequate permissions.
Administration
[edit]All administration of contests is done through the Special:RatePageContests page. There one can define new contests, edit existing ones and view contest results. There is no way to delete a contest once it was created, but this feature will probably be added in the future.
For each contest one can specify a unique ID that cannot be changed later and a human-readable description. A contest can be also disabled or enabled to quickly turn on/off the ability to vote for everyone. You can also allow users to see contest's results before voting (provided they are able to see the results at all).
For each contest there are two permissions that can be granted to any subset of a wiki's user groups: can vote and can see results. For example you can let everyone vote in a contest (even anons), but don't let them see contest results to avoid biased voting.
One can also view the results of a contest in a table with each page assigned a mean score, score count and the number of votes for each score. The table can be exported to wikitable format using the Export results button below the table.
Adding a rating widget
[edit]The only user friendly way to access the contest feature is to embed a voting widget in a page using the {{#ratepage: }}
parser function.
- First (required) parameter is the title of the page you want to rate.
- Second (optional) parameter is the contest ID that you want to use. You can use one contest ID for as many pages as you like. A contest ID must only contain digits and lower- or uppercase latin letters. If you don't specify a contest ID, the widget will be linked to the main score of the page.
- Third (optional) parameter can be used to specify the width of the widget on the page, in pixels.
For example {{#ratepage:Main Page|CONTEST1|250}}
will yield a voting widget 250 pixels wide, that will let you rate the Main Page within contest CONTEST1.
User rights
[edit]You can control access to the contests administration panel through the use of the $wgGroupPermissions configuration variable in your LocalSettings.php file.
Permission | Description | Default value |
---|---|---|
ratepage-contests-view-list | View the list of contests on Special:RatePageContests | * |
ratepage-contests-view-details | View the detailed settings of a contest and its results | sysop |
ratepage-contests-edit | Create and edit contests | sysop |
ratepage-contests-clear | Clear contest results, currently unimplemented | bureaucrat |
MultimediaViewer
[edit]If you have installed the MultimediaViewer extension, a rating widget will be automatically added to the MMV information panel on desktop skins. You can find it by simply scrolling down on the preview of the file.
In order for this to work, you have to load RatePage after MultimediaViewer in your LocalSettings.php file.
You can disable this feature using configuration settings.
Semantic MediaWiki
[edit]If you have Semantic MediaWiki installed, RatePage lets you optionally save the ratings as SMW properties (see: #Configuration).
By default the data in these properties is not updated after every vote, but only after a data update is performed on a page (for example when someone edits it or its parser cache expires). Thus, it can be used as a means of accessing the rating data using wikitext, but there's no guarantee the data is up-to-date. This can be useful when producing page rankings or displaying contest results. The data can be also refreshed after every vote, see the $wgRPImmediateSMWUpdate config setting.
Main score
[edit]The main score is saved using two built-in properties: Average rating and Ratings count. They are both rather self-explanatory. The Average rating property is set only on pages that have been rated at least once.
Contest scores
[edit]For a contest's score to be saved as a SMW property, its results have to be first viewable to everyone. This can be set in the contest management panel. The scores are saved as subobjects of the page, with every subobject corresponding to one contest. Such a subobject consists of three properties: RatePage contest identifier, Average rating and Ratings count.
API
[edit]action = query & prop = pagerating
[edit]Adds information about page ratings in a specific contest to the query module.
- Parameters
prcontest
: Contest ID (optional). If not specified, the API will assume you mean the main score of the page.
- Example
Result |
---|
{
"batchcomplete": "",
"query": {
"pages": {
"123681": {
"pageid": 123681,
"ns": 6,
"title": "Plik:Civic-UFO.jpg",
"pagerating": {
"pageRating": {
"1": 10,
"2": 7,
"3": 12,
"4": 9,
"5": 13
},
"userVote": 2,
"canVote": 0,
"canSee": 1
}
},
"156225": {
"pageid": 156225,
"ns": 6,
"title": "Plik:Znak D-42 ufo.svg",
"pagerating": {
"pageRating": {
"1": 5,
"2": 8,
"3": 7,
"4": 14,
"5": 16
},
"userVote": 4,
"canVote": 0,
"canSee": 1
}
}
}
}
}
|
The canVote
and canSee
fields indicate whether the user can vote and see the results of this contest.
action = ratepage
[edit]Allows a user to rate pages and retrieve all votes that have been submitted so far.
- Parameters
token
: The CSRF tokenpageid
: The id of the pagepagetitle
: The title of the page (you must specify eitherpageid
orpagetitle
answer
: Your rating of the page (optional). If you do not specify theanswer
parameter, the API will just return the current votes.contest
: Contest ID (optional). If not specified, the API will assume you mean the main score of the page.
- Example
Result |
---|
{
"pageId": 1,
"pageRating": {
"1": 4,
"2": 63,
"3": 134,
"4": 205,
"5": 89
},
"userVote": 2,
"canVote": 1,
"canSee": 1
}
|
See also
[edit]- VoteNY - Allows for voting by adding a tag
This extension is included in the following wiki farms/hosts and/or packages: This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |
- Unmaintained extensions
- Database extensions
- User interface extensions
- GPL licensed extensions
- Extensions in GitLab version control
- SidebarBeforeOutput extensions
- LoadExtensionSchemaUpdates extensions
- BeforePageDisplay extensions
- ParserFirstCallInit extensions
- SMW::Property::initProperties extensions
- SMW::Store::BeforeDataUpdateComplete extensions
- All extensions
- Extensions included in Miraheze
- Extensions included in WikiForge
- Rating extensions