Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IA04binôme2A
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gabrielle Van De Vijver
IA04binôme2A
Commits
8d5c938f
Commit
8d5c938f
authored
1 year ago
by
Balthazar Wilson
Browse files
Options
Downloads
Patches
Plain Diff
fix: vote with options
parent
84ca5451
No related branches found
Branches containing commit
No related tags found
1 merge request
!7
Partie serveur
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
agt/ballotagent/new_ballot.go
+13
-7
13 additions, 7 deletions
agt/ballotagent/new_ballot.go
with
13 additions
and
7 deletions
agt/ballotagent/new_ballot.go
+
13
−
7
View file @
8d5c938f
...
...
@@ -12,7 +12,7 @@ import (
type
BallotInfo
struct
{
profile
cs
.
Profile
options
[]
int
options
[]
[]
int
votersId
[]
string
nbAlts
int
isOpen
bool
...
...
@@ -59,7 +59,7 @@ func (rsa *BallotServerAgent) createBallot(w http.ResponseWriter, r *http.Reques
resp
.
BallotID
=
fmt
.
Sprintf
(
"scrutin%d"
,
len
(
rsa
.
ballots
)
+
1
)
rsa
.
ballots
[
resp
]
=
BallotInfo
{
profile
:
make
(
cs
.
Profile
,
0
),
options
:
make
([]
int
,
0
),
options
:
make
([]
[]
int
,
0
),
votersId
:
req
.
VotersID
,
nbAlts
:
req
.
NbAlts
,
isOpen
:
true
,
...
...
@@ -75,8 +75,8 @@ func (rsa *BallotServerAgent) createBallot(w http.ResponseWriter, r *http.Reques
go
rsa
.
handleBallot
(
resp
,
cs
.
MajoritySWF
,
cs
.
MajoritySCF
,
tb
,
deadline
)
case
"borda"
:
go
rsa
.
handleBallot
(
resp
,
cs
.
BordaSWF
,
cs
.
BordaSCF
,
tb
,
deadline
)
//
case "approval":
//
go rsa.handleBallot(resp, cs.ApprovalSWF, cs.ApprovalSCF, tb, deadline)
case
"approval"
:
go
rsa
.
handleBallot
WithSingleOption
(
resp
,
cs
.
ApprovalSWF
,
cs
.
ApprovalSCF
,
tb
,
deadline
)
default
:
w
.
WriteHeader
(
http
.
StatusNotImplemented
)
msg
:=
fmt
.
Sprintf
(
"Unkonwn rule '%s'"
,
req
.
Rule
)
...
...
@@ -126,7 +126,7 @@ func (rsa *BallotServerAgent) handleBallot(
fmt
.
Println
(
targetBallot
)
}
func
(
rsa
*
BallotServerAgent
)
handleBallotWithOption
s
(
func
(
rsa
*
BallotServerAgent
)
handleBallotWith
Single
Option
(
ballot
rad
.
Ballot
,
swf
func
(
cs
.
Profile
,
[]
int
)
(
cs
.
Count
,
error
),
scf
func
(
cs
.
Profile
,
[]
int
)
([]
cs
.
Alternative
,
error
),
...
...
@@ -147,11 +147,17 @@ func (rsa *BallotServerAgent) handleBallotWithOptions(
return
}
// Only the fist element of the agents' options is filled/matters
singleOptions
:=
make
([]
int
,
len
(
options
))
for
i
,
option
:=
range
options
{
singleOptions
[
i
]
=
option
[
0
]
}
tb
:=
cs
.
TieBreakFactory
(
orderedTBAlts
)
ballotSWF
:=
cs
.
SWFFactoryWithOptions
(
swf
,
tb
)
ballotSCF
:=
cs
.
SCFFactoryWithOptions
(
scf
,
tb
)
ranking
,
_
:=
ballotSWF
(
profile
,
o
ptions
)
winner
,
err
:=
ballotSCF
(
profile
,
o
ptions
)
ranking
,
_
:=
ballotSWF
(
profile
,
singleO
ptions
)
winner
,
err
:=
ballotSCF
(
profile
,
singleO
ptions
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment