fix issue with check for maxValue

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2018-02-20 19:29:56 +01:00
parent bf753480dd
commit 77f05b1c21
1 changed files with 6 additions and 2 deletions

View File

@ -146,7 +146,7 @@ class PollService {
/**
* @param Form $form
* @return string
* @return array
*/
function createPoll(Form $form) {
// Generate poll IDs, loop while poll ID already exists
@ -289,7 +289,11 @@ class PollService {
* @throws ConcurrentVoteException
*/
private function checkMaxVotes($user_choice, $poll, $poll_id) {
$best_choices = $this->computeBestChoices($this->allVotesByPollId($poll_id));
$votes = $this->allVotesByPollId($poll_id);
if (count($votes) <= 0) {
return;
}
$best_choices = $this->computeBestChoices($votes);
foreach ($best_choices['y'] as $i => $nb_choice) {
// if for this option we have reached maximum value and user wants to add itself too
if ($nb_choice >= $poll->ValueMax && $user_choice[$i] === "2") {