- First commit to issue fork.
- Merge request !16Issue #3035898: Allow admins to alter number of votes cast for a poll → (Open) created by phjou
- 🇨🇦Canada phjou Vancouver 🇨🇦 🇪🇺
I rewrote a patch from scratch that is using the PollChoice entity as @Berdir indicated.
https://git.drupalcode.org/project/poll/-/merge_requests/16.patch
The merge request basically just add a new property "starting_votes" on the PollChoice entity. And then it was just a matter of changing the functions to calculate the totals to use that additional property when needed.
There is a hook_update to run in order to get that new property installed in case the module was already enabled. - Status changed to Needs review
almost 2 years ago 5:12pm 5 April 2023 - Status changed to Needs work
10 months ago 12:17pm 15 April 2024 - ivnish Kazakhstan
I manually tested - works as expected. Still needs automated tests. I'm working on it
- 🇬🇧United Kingdom naheemsays
One issue I have with this patch that can probably be worked around is that its called "starting votes". it can be used for many other things so a more generic term like offset might help.
(example would be manual votes where some use the form and others or no members tell the admin to add them).
Not sure if it is also relevant to here, but the current migrations do not migrate these offsets. Does that need to be added?
- 🇧🇪Belgium BramDriesen Belgium 🇧🇪
I can understand this from a migration perspective.
But what would be the practical need for a content editor to be able to set a starting position for a poll? This seems a bit... unfair/wrong? Just imagine doing a poll about elections on a site, and the content editor is able to bias the results for one (or more) options by changing the starting vote.
- ivnish Kazakhstan
There are different projects with different cases. I have some private projects which needs this functionality. And not only me, this issue has 10 followers :)
- 🇧🇪Belgium BramDriesen Belgium 🇧🇪
The initial request was for migrations, which I totally understand! So I think that's where the majority of followers is coming from.
The issue title describes "admins", I don't see anything permission related in the code. So I would implement logic to only show this for the administer poll permission. Or provide a new permission for this so it can be granted to specific roles. But I'm highly against this just being added as a default option for all content editors who can create polls.
- ivnish Kazakhstan
This functionality disabled by default and needs to enable this in Poll Choices Widget here /admin/config/content/poll/form-display
Usually content editors don't have permissions to change Field UI settings
I will develop migrations
- 🇧🇪Belgium BramDriesen Belgium 🇧🇪
> Usually content editors don't have permissions to change Field UI settings
Correct, but if an admin enables the field, it's visible for all content editors? Or am I wrong here :-)
- ivnish Kazakhstan
@Bram, I need advice on migrations. In Drupal 7, user votes and admin votes are added together. What is the best way to migrate? Subtract user votes from the total number of votes and these will be admin votes for starting_votes new field?
- 🇬🇧United Kingdom naheemsays
I would suggest there would need to be a count of all votes (for the option), compare it with the total recorded votes and what remains is the offset/starting votes.