Dev.openbig.net:Ratings


From Dev.openbig.net

Jump to: navigation, search

Rate this page ( 590 votes )
3.67 / 5
User Comments ( 164 messages, page 1 of 17 )
Next Last

dddd:
eeeee

2010-09-03 20:18:13

Mr Test:
This is a test comment.

2010-09-02 20:30:54

[[User:|]]


test

2010-08-05 07:20:21

counterfx:
good idea

2010-07-20 18:44:14

Brayton:
Hmm

2010-07-04 04:31:06

PoorAdmin:
Just make sure that your "engine" matches the rest of your tables. So if your other tables use "InnoDB" then change your "Ratings" tables from "myISAM" to "InnoDB".

2010-06-15 20:32:41

cyberfun:
testing this wonderful comment box.. :)

2010-06-09 08:45:49

Chris:
WOW! You have made my life complete. If this works out for me, a donation will come.

2010-05-19 10:31:24

godmov:
看看

2010-05-02 18:57:49

[[User:|]]


xyz

2010-05-02 07:30:14

Ratings is a MediaWiki extension that collects users' opinion about a designated subject and present the result as an overall rating. It is created based on the Polls extension with some feature enhancements.

If you like this extension, please donate:

If you use this extension, you can add your website to the end of this page.

Contents

Download

  • Current Version: 1.1.2
  • Previous Versions: repository
  • Release Status: experimental

Demo

See the rating box on the right.

Requirements

Tested on MediaWiki 1.15.4, 1.10.x, 1.11.0 and 1.9.3, please report success running under other MediaWiki versions.

To enable Captcha protection, requires the ReCaptcha extension.

Features

  • Add a Rating box to each MediaWiki page. As the readers a question and ask them to rank from 1 to any number.
  • A comment form (with added spam protection from ReCaptcha for anonymous users) that allows user to leave comments.
  • If the name field in the comment form matches the current logged in user, a link to the User page is provided.
  • Page navigation facilities provided for more than 10 comments.

Future Plan

  • #Known Problems fixing.
  • More sophisticated statistics, including a rank display for all rated pages.
  • Allowing users to choose whether to display the Poll or the Comment section of the Ratings box.
  • Configuration of the default choice for a poll.
  • Allowing users to arrange the poll items with different configurable weighs.
  • More customizable styles with css.
  • Adopt the Unobtrusive AJAX Star Rating as a type of rating style.
  • An administrative interface to remove abusive comments.
  • Instead of using a separate table in database, store the votes in a page in a separate namespace. This adds history tracking and eases installation.
  • Allow the rating widget to be placed anywhere on an article, like in a cell of a table
  • Allow the rating widget to placed in multiple locations on a single article
  • Allow the average rating to be hidden until after the user votes
  • Utilize MediaWiki internal Ajax engine to minimize IO transfer.

Installation

By default, Captcha protection is enabled. To install Ratings extension without Captcha, refer to #Installation Without ReCaptcha Support.

  1. Obtain a pair of recaptcha keys from http://www.recaptcha.org , it is a free service offered by the Carnegie Mellon University.
  2. Install ReCaptcha extension, it is not necessary to enable it in LocalSettings.php unless you need it, but it is strongly recommended. Alternatively, put recaptchalib.php in the $IP/extensions/recaptcha directory.
  3. Extract extension package to $IP/extensions directory
  4. Initialize the MySQL tables by using database initialization SQL queries
  5. Add the following lines to the end of LocalSettings.php:
/* Replace recaptcha_public_key and recaptcha_private_key with the keys obtained from http://www.recaptcha.org */
require_once( "$IP/extensions/Ratings/Ratings.php" );
$recaptcha_public_key = 'recaptcha_public_key';
$recaptcha_private_key = 'recaptcha_private_key';

Installation Without ReCaptcha Support

  1. Extract extension package to $IP/extensions directory
  2. Initialize the MySQL tables by using database initialization SQL queries
  3. Add the following lines to the end of LocalSettings.php:
require_once( "$IP/extensions/Ratings/Ratings.php" );
$wgRatingsUseCaptcha = false;

Upgrade Instructions

  1. Extract extension package to $IP/extensions directory

Upgrade from 1.0.x : Additional Steps

  1. Execute the following SQL commands if $wfDBprefix is not set (or if you do not know what $wfDBprefix is).
RENAME TABLE `poll_info` TO `ratings_info`;
RENAME TABLE `poll_message` TO `ratings_message`;
RENAME TABLE `poll_vote` TO `ratings_vote`;

If $wgDBprefix is set to some value, for example "wiki_", then the SQL statements above needs to be modified accordingly: from ratings_info to wiki_ratings_info, etc.

Database

Run the following SQL commands in the wiki database if $wfDBprefix is not set (or if you do not know what $wfDBprefix is)

-- 
-- Table structure for table `ratings_info`
-- 

CREATE TABLE `ratings_info` (
  `poll_id` varchar(32) collate utf8_unicode_ci NOT NULL,
  `poll_txt` text collate utf8_unicode_ci,
  `poll_date` datetime default NULL,
  `poll_title` varchar(255) collate utf8_unicode_ci default NULL,
  `poll_domain` varchar(10) collate utf8_unicode_ci default NULL,
  PRIMARY KEY  (`poll_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

-- 
-- Table structure for table `ratings_message`
-- 

CREATE TABLE `ratings_message` (
  `poll_id` varchar(32) collate utf8_unicode_ci NOT NULL,
  `poll_user` varchar(255) collate utf8_unicode_ci NOT NULL,
  `poll_ip` varchar(255) collate utf8_unicode_ci default NULL,
  `poll_msg` text collate utf8_unicode_ci,
  `poll_date` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`poll_id`,`poll_date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

-- 
-- Table structure for table `ratings_vote`
-- 

CREATE TABLE `ratings_vote` (
  `poll_id` varchar(32) collate utf8_unicode_ci NOT NULL,
  `poll_user` varchar(255) collate utf8_unicode_ci NOT NULL,
  `poll_ip` varchar(255) collate utf8_unicode_ci NOT NULL,
  `poll_answer` int(3) default NULL,
  `poll_date` datetime default NULL,
  PRIMARY KEY  (`poll_id`,`poll_ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

If $wgDBprefix is set to some value, for example "wiki_", then the SQL statements above needs to be modified accordingly: from ratings_info to wiki_ratings_info, etc.

Usage

This extension adds a tag <Ranking> to the MediaWiki. The first new line inside the tag is the title of the poll, and the lines below are poll item descriptions that will be shown in the drop-down box of the Rating form.

<Rating>
Poll Title
Poll Item 1 (Weigh = 1)
Poll Item 2 (Weigh = 2)
...
Poll Item n (Weigh = n)
</Rating>

Parameters

  • vote - default is true, setting vote to false removes the vote widget from the resulting ratings box, leaving only the comment box.
Note: Setting vote to false makes Poll Title and Poll Items invisible to the user, however when having multiple comment boxes in the same page, it is important to fill in an identifier in the Poll Title field so the extension can separate one comment box from another.
  • comment - default is true, setting comment to false removes the comment widget from the resulting ratings box, leaving only the vote widget.
Setting both vote and comment to false is the same as having true in both parameters.

Example

Page with multiple comment boxes

<Rating vote=false>
Question 1
</Rating>

<Rating vote=false>
Question 2
</Rating>

<Rating vote=false>
Question 3
</Rating>

Page with a single rating (1-5) but without the comment widget

<Rating comment=false>
How do you think about the A380 airbus?
1 (Hated it)
2
3
4
5 (Loved it)
</Rating>

Page with a single rating (1-5) with the comment widget

<Rating>
How do you think about the A380 airbus?
1 (Hated it)
2
3
4
5 (Loved it)
</Rating>

Configurations

Redefine the following variables in LocalSettings.php to customize the extension.

  • $wgRatingsMaxTextLengthPerLine - Maximum number of characters per line (<br/>s will be added to not break the Rating bounding box) for texts. Default: 36
  • $wgRatingsMaxNameLength - Maximum number of characters for the name field of the message form, extra characters will be truncated. Default: 36
  • $wgRatingsMaxPollItemLength - Maximum number of characters for each poll item description, extra characters will be truncated. Default: 24
  • $wgRatingsMaxPollTitleLength - Maximum number of characters for the poll title, extra characters will be truncated. Default: 240
  • $wgRatingsMaxMessageLength - Maximum number of characters for user's comment, an error message will be shown when attempting to leave a message longer than this length. Default: 480
  • $wgRatingsUseCaptcha - When true, an extra ReCaptcha question will be shown in the user's comment form for users that are not logged in. When false, the extension does not depend on the ReCaptcha extension. Default: true

Internationalization (i18n)

This extension is fully ready for internationalization. Currently only the following languages are supported:

  • en (English)
  • zh-hk (Chinese Traditional Hong Kong)

To translate the extension into your language, first modify recaptcha_ajax.i18n.js. Add a new element in array RecaptchaLangMap.

var RecaptchaLangMap = { 
  "en": RecaptchaTemplates_en,
  "zh-hk": RecaptchaTemplates_zhhk,
  "new_lang": RecaptchaTemplates_new_lang
};

Then create a new variable RecaptchaTemplates_new_lang just before the declaration of RecaptchaLangMap, which is a translated version of RecaptchaTemplates_en.

Finally translate the content of Ratings.i18n-en.php and save it as Ratings.i18n-new_lang.php.

Feature Requests

Please leave your feature requests in the Talk page.

Known Problems

  • When having more than one Rating box in a page, the message forms needs to be separated a little bit to work properly.
  • With some browser and font settings, long unicode character strings inputs can still break the Rating bounding box.
  • Modifying the page title, and any text within <Ranking></Ranking> tags, will reset the poll, however there's a workaround: you can modify manually from the database the poll_id of these votes. Alternatively you can protect the voting page or use a protected template.
  • Parameter substitution does not work when the Ranking tag is in a template.

Update History

  • 1.1.2
    • Fixed a few bugs reported by the users: most noticeably the non-logged in user in comment box problem.
    • Added German translation by Alkopedia
  • 1.1.1
    • Added parameters vote and comment that allows user to create just a poll with no comment box, or vice versa.
    • Partially rewritten the comment box javascripts to allow for multiple comment boxes in the same page.
    • Use a more elegant method to determine the user page url.
  • 1.1.0
    • Fixed a small bug in message page navigation
    • Added a framework to a new special page Special:RatingsAdminPanel (non i18n compatible) which currently displays the last 10 messages of all ratings site-wide
    • Added $wgDBprefix support (as a result, the tables needs to be copied using the update script)
    • As the result of the above item, changed the database access method to the proper MediaWiki &wfGetDB(DB_SLAVE)->query type.
    • PHP_beautified code
  • 1.0.2.2
    • Fixed i18n files shorthand problem
    • Implemented workaround for performance problem
  • 1.0.2.1
    • Increased i18n files compatibility under Windows platform.
  • 1.0.2
    • Fixed a small bug concerning the interaction between this extension and wiki code parser.
    • Removed carriage return characters introduced while editing i18n files on Windows platform.
  • 1.0.1
    • Changed release package to tar gz for better file permission control
    • Fixed a bug for installation without ReCaptcha
    • Changed the display of current rating to CurrentRating / MaxRating
  • 1.0.0

See Also

Extension Page in MediaWiki.org

Sites Using This Extension

Personal tools