Anonymous votes in poll plugin

I’m in the process of fixing the import of polls in the phpBB3 importer. I noticed a few days ago that it was completely broken since October. :blush:

Anyway, in phpBB3 it is possible for anonymous users to vote in polls. Up until October I set the voters attribute of the poll and votes of each option manually, so I didn’t lose the original poll result. This isn’t possible anymore since the current version of the poll plugin recalculates all counts on each vote.

I was thinking about adding an anonymous_voters attribute to the custom field polls and save the count of anonymous votes for each option in the polls-votes field. These optional values could be used on every recalculation of the poll result if they exist. I have no intention to expose the anonymous vote feature to the user. It would be an internal thing, mostly in order to not lose votes during imports.

@zogstrip Would you accept a PR for that? Or should I discard anonymous votes and warn users during the import that they are going to lose data?

7 Likes

I definitely would :wink:

3 Likes

can anonymous users vote in a poll now? I mean users that are not login to site.

the topic is quite old! sorry to bring it p, I couldn’t find any other related topic with 10 min search.

No, anon users can’t do anything in Discourse.

2 Likes

@zogstrip I’m using the anonymous_votes property to implement a feature for a client that allows you to set a base number of votes for each option in a poll.

As this is a ‘hidden feature’ of sorts, I’m slightly worried its behaviour may be changed down the line. If you could give me a heads up if you’re planning to remove or change the anonymous_votes or anonymous_voters properties that would be awesome. Thanks :slight_smile:

2 Likes

I actually reaped it in https://github.com/discourse/discourse/pull/6359 since I couldn’t see any use of that hidden feature and completely forgot about this topic.

But I’ll add it back before I get it merged.

3 Likes

Thanks! Phew, glad I mentioned it :slight_smile:

https://github.com/discourse/discourse/commit/4459665deeb84fb43621be90d64378ebc5fbd365

Has been merged with support for anonymous votes :ok_hand:

7 Likes