VotePlugin

This plugin can be used to build an online-voting system, or poll.
There are two ways to vote for an item:

select: vote for a given choice from a selection

rate: give something a rating (a number of stars)

A single poll can mix and match the different vote types.

Polls can be open or closed. You don't have to log in to vote in an open
poll, but you are restricted to one vote per poll per user per calendar
date. You have to log in to vote on a closed vote, but you are restricted to
one vote per user. You can change your vote in either open or closed votes,
though if you do that on a different date in an open vote, it will count as
a new vote. Polls are open by default.

The results of a poll can be held in secret. If a poll is secret, no
records are kept of who voted for what. Polls are secret by default.

You can choose whether to save the resuts of the vote in a topic or in a
secret place. If you choose to save the results in a topic, you can protect
that topic using the normal TWiki access control mechanisms, and the vote
will still work. Saving in a topic has the advantage that you can easily
post-process the results in TWiki, but it's a bit more work to set up so
polls are saved in a secret place by default.

Polls are either local to the topic they are defined in, or are global to
the entire TWiki. Each poll has an ID which distinguishes it from other
polls. These IDs are local to the topic for local polls, but can be shared
between topics if the poll is made global.

Syntax Rules

Syntax

The identifier of the poll. You can have multiple independent votes in the same topic.

id="Dining"

selectN

Defines the name of a select vote, where you select one from a ranges of options. N is a number that identifies this item within the poll e.g. select1, select2 etc. You must number all select and stars parameters uniquely and sequentially (e.g. select1 stars2 select3

select1="Drink"

optionsN

Each selectN must have a corresponding optionsN that defines a comma-separated list of the options that can be selected between.

options1="Beer,Wine,Milk"

starsN

Defines the name of a rate vote, where you rate something by giving it a number of stars. N is a number that identifies this item within the poll e.g. select1, stars2 etc. You must number all select and stars parameters uniquely and sequentially (e.g. select1 stars2 select3

stars2="Usability"

widthN

Each starsN must have a corresponding widthN. This gives the number of stars to show e.g. width1="5" will show 5 stars.

Defines the format of a single bar in the results bar chart generated for the corresponding select (for select type only). See formatting results, below.

chart="<p>$option $score</p>"

separator

Defines the string to be used to separate each row in the result.

separator="<br/>"

global

If set to "off", this makes the id local to this topic (the default). If set to "on" it will be a global poll that can be accessed from many topics.

global="on"

open

If set to "off" this is a closed vote. If set to "on" it is open (the default)

open="on"

secret

If set to "off", then the database will record who voted. If set to "on", votes are secret (the default)

secret="on"

saveto

If set to the name of a topic, the poll results will be appended to the end of that topic. The results are formatted as a TWiki table for easy post-processing.

saveto="Main.VoteResults"

bayesian

If set to "on", rating averages will be computed using the Bayesian average of this item against all the other items that have the same item in their stars field. This requires all the participating %VOTEs to be global, or to save their results to the same place using saveto. See http://www.thebroth.com/blog/118/bayesian-rating for more information about Bayesian rating.

bayesian="off"

submit

If set to "off", this makes the %VOTE display the results of the vote without prompting for any input. This is useful when - for example - you want to show the results of a global vote, without permitting more voting.

The style parameter has been deprecated and should not be used
(though it still works). The color and bgcolor parameters have been removed.

You can change the defaults for any or all of the above parameters by defining
the TWikiVariableVOTEPLUGIN_DEFAULTS to be a parameter string e.g.

* Set VOTEPLUGIN_DEFAULTS = open="on" global="on" bayesian="on"

You can do this in an individual topic, for an entire web (in WebPreferences), or for the whole TWiki (in Main.TWikiPreferences).

Formatting the Results

Each item in the poll has a results display next to it (are as part of it in the case of stars). The format parameter is used to control how this is displayed. It is usually used to define a row in a TWiki table, and is expands once for each stars and once for each option in a select.

The format parameter is a string that can include the following formatting tokens:

$key

Expands to the name of the item (e.g. the value of select1).

$prompt

Expands to a drop-down selector that allows the user to pick the option they want to vote for (for select items only)

$bars

Expands to a sorted list of bar charts showing the number of votes for this option. Each bar in the chart is formatted according to the format defined in the corresponding chart parameter.

$sum

Expands to the total number of votes cast

$score

Expands to the mean of all the ratings (for stars)

$perc

Expands to 100*$score/$sum

$mylast

Expands to my last rating (for stars items only)

$small

Expands to the star rating bar, using small stars (mutually exclusive with $large)

$large

Expands to the star rating bar, using large stars (mutually exclusive with $small)

The chart parameter defines the format of each bar in the bar chart that is generated for each option in the corresponding select.

$bar(N)

Expands to the coloured bar used to show the popularity of this option. N is the required total width of the bar in pixels.

select, option, format and chart can all use the standard
formatting tokens
$percnt, $dollar, $quot and $n to render the respective characters.

The %VOTE{ ... }% will generate the selection box(es) and the poll
results.

Weighting the vote

You can weight the vote results by setting the TWikiPreference
%VOTEPLUGIN_WEIGHTINGS% to the name of a topic that is used
to weight the votes of certain members of the community in the final result.
For example,

The numbers are percentages. A user who isn't otherwise weighted has a weighting of 100. A weighting lower that 100 reduces their influence on the vote, and a weighting higher than 100 increases it. In the example above,

AlbertCamus has a weight of 100, as does AdamSmith (who gets the default)

SunTszu's votes only count for half as much as AlbertCamus'

NiccolaMachiavelli has ten times as much influence as AlbertCamus and AdamSmith, and twenty times as much as SunTszu.

The weighting topic applies to all votes in the scope of the %VOTEPLUGIN_WEIGHTINGS% setting.

Plugin Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server where TWiki is running.

Like many other TWiki extensions, this module is shipped with a fully automatic installer script written using the BuildContrib.

If you have TWiki 4.1 or later, you can install from the configure interface (Go to Plugins->Find More Extensions)

The webserver user has to have permission to write to all areas of your installation for this to work.

If you have a permanent connection to the internet, you are recommended to use the automatic installer script

Just download the VotePlugin_installer perl script and run it.

Notes:

The installer script will:

Automatically resolve dependencies,

Copy files into the right places in your local install (even if you have renamed data directories),

check in new versions of any installed files that have existing RCS histories files in your existing install (such as topics).

If the $TWIKI_PACKAGES environment variable is set to point to a directory, the installer will try to get archives from there. Otherwise it will try to download from twiki.org or cpan.org, as appropriate.

(Developers only: the script will look for twikiplugins/VotePlugin/VotePlugin.tgz before downloading from TWiki.org)

If you don't have a permanent connection, you can still use the automatic installer, by downloading all required TWiki archives to a local directory.

Point the environment variable $TWIKI_PACKAGES to this directory, and the installer script will look there first for required TWiki packages.

$TWIKI_PACKAGES is actually a path; you can list several directories separated by :