Poll UI: Adding Polls through a UI in the Composer Window

(cpradio) #1

I have created a plugin that adds a button to the composer window to add polls.

Clicking on the button opens a modal window where the user can Name their poll, select the type of Poll, Regular, Multiple, or Number

A regular poll, lets the user only select a single option to vote for, Multiple, expands the UI to show a Minimum Number of Entries and a Maximum Number of Entries inputs so the recipients of the poll can select multiple choices, and Number shows a Start and End range, along with a Step, so the user can create a “rating” style poll.

More information can be read up on the type of polls at the Discourse Blog.

And here it is in action!

The GitHub Repo is located at


(2015-10-31) Validation has been added.

Why is there no UI to create a poll?
Problem with enabling discourse-plugin-poll-ui
Option to insert frequently used text in the post editor
(cpradio) #2

Out of curiosity, how many would find it nice to be able to add an “Answer” for the poll?

The idea is, you would provide a question, with choices, and an answer. The markup generated for the answer would use the spoiler functionality and it would discoverable even if you didn’t answer the poll yet, so it is purely asthetic (and built on the honor system).

Turning the answer portion would be a plugin site setting (default off), so you only turn it on, if you think it fits your use of polls.

I sort of like the idea, and it was presented to me from someone here on Meta. What does everyone else think?

(Mittineague) #3

I like the idea. I don’t know if it would be easily possible to code up something “secure” that wasn’t “honor system”.
Many, many years ago (OMG, ten years already!) I put together similar that although not cheat-proof I found interesting and was fun to work with


(cpradio) #4

So again, not fool proof, but this is what I was thinking to start.




What I like:

  • It gives you the ability to format your answer, so you can provide more than just the correct response, but a reason and have it formatted. You can even use links.

What I don’t like:

  • The scrolling. I think I can fix that though.

(cpradio) #5

Version 0.3 now includes the ability to permit answers to be added via the Details/Summary elements.

(Jay Pfaffman) #6

I want to build a template tool that will let people insert templates from the editor and this seems like a good place to start. This is my first experience with developing in Discourse.

I’ve added this to my development server and though I see the settings in admin/plugins, when I compose a message, I don’t see the button. I’ve done

rake assets:clean
rm -rf tmp
bundle install
bundle exec rake db:migrate

and those don’t seem to help. It works on my production site, so it’s not that I am blind to the icon. I also tried force-reload (and then used another browser just in case), but still no joy.

Any hints?


(cpradio) #7

Not sure. You cloned the repo in the discourse/plugins folder? This feels more like a general dev question than this plugin in particular, as there isn’t anything fancy with the plugin’s installation.

(Jay Pfaffman) #8

Right. I did a git clone <url>. I see it in the settings, so it seems to be there.

Yeah. That may be. When I started the post I hadn’t installed it on my production site yet, so I thought maybe something in Discourse had changed.

Nevermind . . .

vagrant halt
git pull
vagrant up

and restarting rails seems to have solved the problem.

So, yeah. A dev problem.


(cpradio) #9

Cool. I wouldn’t have guessed that. So glad you got it. If you get stuck with designing your own, start a topic somewhere and link to the repo, I’ll try to help out when I can.

(Jay Pfaffman) #10


This is a darn steep curve, and I haven’t written code (outside of LaTeX, a tiny bit of R, and some elisp) in a decade.

This looks like a pretty good place to start for what I hope is an attainable goal.

(Jared) #13

Anyone know how to get help on this bug? After adding this plugin (polls) and the plugin (voting) we can no longer use the messaging system. We get the following error any time we try to send a message or view past messages…

Sorry, we couldn’t load that topic, possibly due to a connection problem. Please try again. If the problem persists, let us know.

(cpradio) #14

You need to bring that discussion up with the Voting Plugin, as there is zero possibility of the poll plugin causing that behavior.

(François Eric King) #15

Poll UI is it compatible with https://github.com/iunctis/discourse-formatting-toolbar ?

Poll UI work great alone, but dont work in completation of formating toolbar.

Anyway to make both work togheter?



They should work together.

I don’t exactly use the formatting toolbar (a variation, with more options) and it works fine with cpradio’s plugin (my plugin is based on cpradio’s work)

I think I had this plugin activated during my tests of the formatting toolbar.

I’ll try again in a few hours, maybe I did a mistake anywhere.

(François Eric King) #17


let me know where i can get YOURS variation and i shurly give a try

(cpradio) #18

It works fine…

(François Eric King) #19

oups sorry

i miss to hide preview screen (on mobile version)

All is good.

Poll UI is a very usefull plugin
Thanks a lot @cpradio

(cpradio) #20

Added a new translation and UI element for creating Public Polls.

Those who have submitted translations in the past, if you could submit them again with the new translation key, that’d be great!

(Alan Tan) #21

I’ve just finished pulling the poll ui plugin into core and added unit tests.

@cpradio Can you help me have a look to see if I missed anything? I implemented it differently because we wanted to include it in the gear icon instead of having it as a button on the toolbar. On top of that, I implemented the min, max, step options as computed properties with a combobox such that the user will not be able to select options that violate any validations instead of raising validation errors.

(cpradio) #22

Is this in a branch I can test with? The only thing I see missing from the screenshot is an option to provide an answer which also utilized the <details><summary> tags.

If I can see the code, I can make sure some of the more important things still exist or at least play with it :slight_smile:

But as of right now I’m not seeing where (if anywhere on GitHub) these changes exist.