fix issue with check for maxValue
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
bf753480dd
commit
77f05b1c21
@ -146,7 +146,7 @@ class PollService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Form $form
|
* @param Form $form
|
||||||
* @return string
|
* @return array
|
||||||
*/
|
*/
|
||||||
function createPoll(Form $form) {
|
function createPoll(Form $form) {
|
||||||
// Generate poll IDs, loop while poll ID already exists
|
// Generate poll IDs, loop while poll ID already exists
|
||||||
@ -289,7 +289,11 @@ class PollService {
|
|||||||
* @throws ConcurrentVoteException
|
* @throws ConcurrentVoteException
|
||||||
*/
|
*/
|
||||||
private function checkMaxVotes($user_choice, $poll, $poll_id) {
|
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) {
|
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 for this option we have reached maximum value and user wants to add itself too
|
||||||
if ($nb_choice >= $poll->ValueMax && $user_choice[$i] === "2") {
|
if ($nb_choice >= $poll->ValueMax && $user_choice[$i] === "2") {
|
||||||
|
Loading…
Reference in New Issue
Block a user