Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-489] add multiple votes for same option #539

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

annaos
Copy link
Contributor

@annaos annaos commented Apr 4, 2024

Close #489

  • add new setting --vote-method
  • add new field in dialog
  • update Readme

Changed translation for id poll.newPoll.votesettings.invalidSetting (I'm not sure if make i18n-extract will notice this)

Copy link

codecov bot commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.33%. Comparing base (c8d868e) to head (4a5a7b8).
Report is 1 commits behind head on master.

❗ Current head 4a5a7b8 differs from pull request most recent head fc85078. Consider uploading reports for the commit fc85078 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #539      +/-   ##
==========================================
+ Coverage   93.27%   93.33%   +0.06%     
==========================================
  Files          13       13              
  Lines        1650     1666      +16     
==========================================
+ Hits         1539     1555      +16     
  Misses         84       84              
  Partials       27       27              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kaakaa
Copy link
Contributor

kaakaa commented Apr 7, 2024

Thanks @annaos, but I think the specification is still ambiguous. --multi-votes depends on --votes setting and the maximum of --votes is the number of options, but I don't think it is necessary to follow that limitation for multi-votes. Also, when --votes=1, even if --multi-votes is set, an user can only vote for one option, which is little weird.

@annaos
Copy link
Contributor Author

annaos commented Apr 8, 2024

Can I do something here? Do you have any ideas?

@kaakaa
Copy link
Contributor

kaakaa commented Apr 12, 2024

It might be just a question of wording, but the existing --votes=X setting also has the meaning of "multiple votes", so I don't think --multiple-votes is a suitable setting name. As far as I googled, the voting method for #489 is called Cumulative voting. (--votes=X would be Limited voting).

In order to make users aware that the settings we are trying to implement this time are different from current Matterpoll's voting methods, I think it would be better to use one of the following formats for the settings.

  1. Add the setting --cumulative-votes=X in addition to --votes=X (mutually exclusive)
  2. Add a setting such as --vote-method=cumulative in addition to --votes=X

In both cases, I think it's better to remove the limitation that "the number of votes that can be selected is limited to the maximum number of options" for Cumulative voting.

The above is my thought. I'm glad to hear any thoughts on this, thanks. @annaos @hanzei

@annaos
Copy link
Contributor Author

annaos commented Apr 14, 2024

I like the idea of the --vote-method. It opens up more possibilities for the future. If it is ok with you, I will change this PR to implement this solution.

UPD I tried this solution to have a look at it and did it complete.
If the solution is ok, I need help with the failed test: I suppose for ... range in server/poll/transform.go:217 change the order of displaNames randomly. How do I get it to work when testing?

@kaakaa
Copy link
Contributor

kaakaa commented Apr 19, 2024

Thanks for updating @annaos , and it looks great to me 👍 It may be a work in progress, but I think there are a few things that need to be addressed.

  • ResetVote doesn't support Cumulative correctly yet
  • Need to think about how to validate MaxVotes in the case of cumulative
    • Should be able to specify any number of votes regardless of the number of vote options, but a limit may be needed (10? 30? 100?)
  • Need to tally the votes of the same people in RHS card (ref. Add RHS informations card to show users votes #431)
  • With ExperimentalUI, it would be better to display how many votes an user added to each option. (This can be another issue)

UPD I tried this solution to have a look at it and did it complete.
If the solution is ok, I need help with the failed test: I suppose for ... range in server/poll/transform.go:217 change the order of displaNames randomly. How do I get it to work when testing?

Hm... I came up with the following two ways to follow some sort of order, but I prefer 2. in that it can represent the order of votes.

  1. Sort keys of voters (alphabetical?)
  2. Create new slice to keep the order of the voters like the following
...
if !p.Settings.Anonymous {
	voters := make(map[string]int)
	uniques := []string{} // to keep the order of the voters
	for i := 0; i < len(o.Voter); i++ {
		displayName, err := convert(o.Voter[i])
		if err != nil {
			return nil, err
		}
		voters[displayName]++
		if !slices.Contains(uniques, displayName) {
			uniques = append(uniques, displayName)
		}
	}

        for _, u := range uniques {
        ...
...

@kaakaa kaakaa added Docs/Needed Requires documentation go Pull requests that update Go code labels Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. To Review Docs/Needed Requires documentation go Pull requests that update Go code
Development

Successfully merging this pull request may close these issues.

Same Option Multivote
3 participants