Skip to content

Commit 7b8068f

Browse files
committed
Ensure that ballots with no votes don't contribute to quota
1 parent a12d814 commit 7b8068f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/Models/Question.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,12 @@ private function computeElectionResults(): Result
351351
$election->addCandidate($option->id);
352352
}
353353
foreach($this->longAnswers as $ballot){
354-
$election->addVote(array_map('strval', json_decode($ballot->text)));
354+
$preferences = json_decode($ballot->text);
355+
if(count($preferences) == 0){
356+
continue;
357+
}
358+
359+
$election->addVote(array_map('strval', $preferences));
355360
}
356361

357362
return $election->getResult('STV');

0 commit comments

Comments
 (0)