"Unvote" a poll

Is posible remove a vote from a poll?

I only can change my vote, but I can’t “cancel”

4 Likes

Not sure if that is possible at the current time.

1 Like

Nope, there’s currently no way to “unvote” on a poll. Added to my :pencil:

8 Likes

This needs to be implemented, please! I was just trying to highlight text of a poll to copy/paste (I don’t see why that’s not allowed, by the way), and now I’ve mistakenly voted in a poll.

1 Like

You can do that, either revote or in some cases there is a remove vote button, not sure if it is a plugin or now available.

I don’t wish to vote for a different option. I was abstaining from the vote. I only wished to click-drag and highlight the text to copy and paste it.

Hi, any news about this? I got a complaint from one of my users who can’t cancel his public vote on a poll.

Similar topic here: Ability to remove my choice in a poll

I still don’t think there is a way, @zogstrip possibly worth assigning this out cause we have meant to do this for a while.

  • 1
  • 2
  • 3

0 voters

Perhaps the first thing here @designers is to figure out if we want to allow this unconditionally, or only on specific polls?

5 Likes

I agree, it’s about time.

@nbianca can you add this to your list?

1 Like

Oh I guess we would only be touching this screen:

Add a button after “Show results” for “Remove Vote”.

Would not impact how polls render you have to dig in to get the options.

2 Likes

I use polls heavily in my plugin to capture structured user input so this would be a great change for me.

Can I ask that we still fire the vote event when votes are removed so that I know there has been a change?

3 Likes

I implemented the unvote functionality in:

9 Likes

Hi, I’ve just pulled down the latest build to my dev environment to test this and I’ve noticed a small, perhaps non-intentional change.

It’s a small change, but it’s significant to me due to the quirky way I use polls.

Previously, if there were no votes in the poll, the “Show results” button would be disabled. That made sense, there are no results to see so the “Show results” button shouldn’t be pressable. It looked like this…


Notice there have been no votes and the “Show results” button is disabled

In the new “Unvote” build it appears that the “Show Results” button is always enabled whether there have been votes or not.


Notice there have been no votes cast but the “Show results” button is enabled

Some questions: Is this the case? Was this intentional or an oversight? Will you be changing it back?

If it’s staying the way it is, then I’ll try another way to achieve my desired outcome.

Either way thanks for the unvote feature which seems to work very well!

Background

Background…

Why is this an issue to me? I use polls to capture the input from (mostly) individual users. i.e. a poll allows me to ask specific questions of an individual user in a specific context. There is seldom more than one vote in a poll but they make gathering structured data very easy.

In my plugin, a topic can feature many polls and these polls can feature lots of options which means a lot of scrolling. To make it easier for the users to navigate, once they have voted, a theme component I wrote removes the other options from the poll UI leaving only the option they selected.

To remove these options, my theme component targets an enabled “Show results” button and “clicks” it, once the results are shown, any options that have no votes are removed.

It ends up looking like this.

At the moment, because the “Show results” button is enabled by default, my code clicks it and as there haven’t been any votes, all of the options are removed and it looks like this…

I’ve just looked at how I might approach this differently now that the results are always shown and have realised that I can accomplish what I want in a far simpler way.

So please leave it as it is! LOL :upside_down_face:

I simply target chosen (or not .chosen) result elements and set them to not display.

div.poll div.poll-container ul.results > li:not(.chosen) {
    display: none;
}

When I wrote my code a couple of years ago, I either didn’t notice the .chosen class or it’s a recent addition?

Either way, what I had was significantly over-engineered (polling Javascript!) as this seems to do what I need.

6451AF5C-2351-49E0-9A1F-C6C0A3D0D5E9

Thanks again.

1 Like

Oh, that’s my bad. I just reimplemented that and it will be available soon:

I think it has been like this for a while.

3 Likes

Just testing it now @nbianca and the button now seems to work like before. Thx!

One other question, I use the DiscoursePoll::Poll.vote method to automatically vote in polls. I’ve run into some issues in my code. Can I confirm that during the refactoring of the poll code, you changed the method signature?

My code was assuming a signature of:

def vote(post_id, poll_name, options, user)

and it now appears that after your changes the signature is

def self.vote(user, post_id, poll_name, options)

i.e. the user parameter was 4th but it is now 1st with all other parameters shifting along.

Can I validate that the above assumption is correct and do you think there are any other similar refactoring changes that might trip me up?

BTW, the poll vote removal seems to work well!

You are correct. I moved user to be the first parameter for most functions because that is the convention we usually follow.

3 Likes

This topic was automatically closed after 9 days. New replies are no longer allowed.