The result of a poll is displayed in the polling form.
%VOTE{id="FavouriteMeal" select1="Drink" options1="Beer,Wine,Milk,Water" select2="Food" options2="Steak,Bread,Pasta,Pizza"}%
displays as (if the plugin is installed and enabled)
and
%VOTE{id="Jazzers" stars1="Herbie Mann" stars2="Horace Silver" stars3="Thelonious Monk"}%
displays as
%VOTE{ … }%
in the text of a topic to define a poll
Name | Description | Example |
---|---|---|
id | 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. | width2="10" |
formatN | Defines the format of the results display. See formatting results, below. | format="$large" |
chartN | 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 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. |
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 Macro VOTEPLUGIN_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 wiki (in %USERSWEB%.SitePreferences).
format
parameter is used to control how this is displayed. It is usually used to define a row in a 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 ) |
$reset |
Expands to a reset button, if the viewer has reset rights (see Resetting a Poll, below). Without reset rights, expands to nothing. |
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. |
$option |
Expands to the name of the option that this bar is for |
$perc |
Expands to 100*$score/$sum |
$score |
Expands to the total number of votes cast for this option |
format
for a select
is: | $key | $prompt | $bars |
chart
is <div>$bar(300) $option $perc% ($score)</div>
format
for stars
is: | $key | $small<br /><small>Score: $score, My vote: $mylast, Total votes: $sum</small> ||
separator
is a newline.
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.
%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,
| *Name* | *Weight* | | AlbertCamus | 100 | | SunTszu | 50 | | NiccoloMachiavelli | 1000 |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,
%VOTEPLUGIN_WEIGHTINGS%
setting.
#Reset
VOTEPLUGIN_RESETTERS
macro. This variable defines a (semicolon-separated) list of wiki names and a (comma-separated) list of the IDs of votes they are allowed to reset. You can use *
as a wildcard in the vote IDs. For example, in a WebPreferences
topic you can write
* Set VOTEPLUGIN_RESETTERS = GeorgeWBush(*);RobertMugabe(zimbabwe);SimonCowell(*Idol, XFactor) * Set FINALPREFERENCES = VOTEPLUGIN_RESETTERSto allow
zimbabwe
,
Idol
and any vote with the ID XFactor
.
format
parameters for the vote, then $reset
will expand to the reset button.
Note that it is important to finalise the setting, otherwise it can be overridden in individual topics by anyone with CHANGE
access. If you don't define VOTEPLUGIN_RESETTERS
no-one can reset any votes.
cd /path/to/foswiki perl tools/extension_installer <NameOfExtension> installIf you have any problems, or if the extension isn't available in
configure
, then you can still install manually from the command-line. See https://foswiki.org/Support/ManuallyInstallingExtensions for more help.
IMPORTANT If you don't want anyone to be able to reset votes on your site, then make sure you:
* Set VOTEPLUGIN_RESETTERS = nonein %USERSWEB%.SitePreferences, and add
VOTEPLUGIN_RESETTERS
to FINALPREFERENCES
.
10 Jun 2009 | Foswikitask:Item8010: incorporate upstream fixes, and port to Foswiki - Foswiki:Main/CrawfordCurrie |
14 Oct 2008 | Item6070 works for hierarchical webs now. - Foswiki:Main/ColasNahaboo |
10 Aug 2008 | Item5768 suppress submission of individual ratings in a multi-row vote Item5769 correct default handling of transcluded rates Item5766 $large is once again large Item5771 support for resetting votes. |
1 Jul 2007: | Item4310 : abstracted out Foswiki:Extensions.RatingContrib, and modified the code to be tolerant of forms within forms - Foswiki:Main/CrawfordCurrie |
24 Jun 2007: | Item4298: fixed secret switch. Item4200: added VarVOTE. - Foswiki:Main/CrawfordCurrie |
11 Jun 2007: | Item4235 - removed excess newlines, fixed separator - Foswiki:Main/CrawfordCurrie |
8 Jun 2007: | Added submit - Foswiki:Main/CrawfordCurrie |
6 Jun 2007: | Added global , open , secret , format , chart , saveto , VOTEPLUGIN_WEIGHTINGS , bayesian averaging - Foswiki:Main/CrawfordCurrie |
31 Aug 2006: | added NO_PREFS_IN_TOPIC |
15 Aug 2006: | added "use strict" and fixed revealing errors |
27 Apr 2006: | added lazy compilation |
7 Dec 2005: | added gif bar; removed debug flag |
9 Oct 2005: | fixed invocation of normalizeFileName |
8 Oct 2005: | added added a little more style flexibility |
7 Oct 2005: | storing votes into _Vote*.txt now (was Vote*.txt before) ; fixed error messaging on empty argument lists |
14 Sep 2005: | fixes for dakar |
14 Apr 2005: | incorporated getLocaldate() function |
16 Mar 2005: | use Cache API only if its there; delayed use <package> |
7 Mar 2005: | Initial version |
Author | Foswiki:Main/MichaelDaum |
Version | 1.34 |
Release | 11 May 2017 |
Repository | https://github.com/foswiki/VotePlugin |
Copyright | 2005-2015, Michael Daum http://michaeldaumconsulting.com |
License | GPL (GNU General Public License) |
Home | Foswiki:Extensions/VotePlugin |
Support | http://foswiki.org/Support/VotePlugin |