It's been a year since @sam wrote about how we should we implement polls in Discourse and we've been fortunate enough to get our first implementation done by the community (cc. @radq).
However, as pretty much all features in a software, the first version was missing a few things. Most of the feedbacks we got were asking for the possibility to support multiple choices polls.
So, for the past couple of weeks, I've been working on revamping our poll plugin.
Here's how it works
Single (default)
The simplest poll you can make is a single choice poll.
You just need a list surrounded by the [poll]
BBCode tag [/poll]
.
[poll]
- Option A
- Option B
- Option C
[/poll]
This will produce the following poll:
- Option A
- Option B
- Option C
No votes yet. Want to be the first?
Show results
Multiple
If you want to allow multiple choices, you only need to add "type=multiple
" to the tag, like so:
[poll type=multiple]
- Option A
- Option B
- Option C
[/poll]
This will produce the following poll (note the help text)
- Option A
- Option B
- Option C
No votes yet. Want to be the first?
You may choose up to 3 options.
Vote now!Show results
Multiple (with options)
If you want to limit the number of selected options in a multiple choices poll, you can do so using both "min
" and "max
" arguments:
[poll type=multiple min=1 max=2]
- Option A
- Option B
- Option C
[/poll]
This will produce a multiple choice polls allowing up to 2 different options:
- Option A
- Option B
- Option C
No votes yet. Want to be the first?
You may choose up to 2 options.
Vote now!Show results
Number
This 3rd type of polls comes from one of our customers. It can be used when you want to grade or rate something.
If you use the following syntax:
[poll type=number min=1 max=10][/poll]
It will automatically generate a list of numbers from "min
" to "max
", and the result of the poll is the average of all of votes:
Number (with options)
You can use the "step
" argument if you want to reduce the number of generated numbers
[poll type=number min=1 max=10 step=2][/poll]
Customization
By default, polls are using the colors of your forum theme. But you can override both the text and background colors.
Text color
Customizing the text color of the options is as easy as setting the "color
" argument:
[poll color=red]
- Option A
- Option B
- Option C
[/poll]
Will produce this poll with red text:
- Option A
- Option B
- Option C
No votes yet. Want to be the first?
Show results
Background color
The background color can be customized using the "background
" argument:
[poll background=#3f96ca]
- Option A
- Option B
- Option C
[/poll]
Will produce this poll with blue background:
- Option A
- Option B
- Option C
No votes yet. Want to be the first?
Show results
With content
Polls also support inside contrnt like links and emojis
[poll name=with_content]
- A link to [discourse](www.discourse.org)
- Emoji: :smile:
[/poll]
Will produce this nice poll
Multiple polls in the same post
Have you noticed that this post contains several polls? Wonder how's that possible? It's because I'm using a different "name
" for each of the polls
[poll name=single]
- Option A
- Option B
- Option C
[/poll]