From 8c2ad610a5730be68f0320fe57bbee1dacf86b63 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Tue, 27 Apr 2021 11:17:41 +0200 Subject: [PATCH] compute answers in choices --- src/Entity/Poll.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Entity/Poll.php b/src/Entity/Poll.php index 2383a38..98612c5 100755 --- a/src/Entity/Poll.php +++ b/src/Entity/Poll.php @@ -263,7 +263,7 @@ class Poll { , 'password_protected' => $this->getPassword() ? 'yes' : 'no', 'max_score' => $computedAnswers[ 'max_score' ], - 'choices' => $displayedChoices, + 'choices' => $computedAnswers[ 'answers' ], 'stacks' => $displayedStackOfVotes, 'comments' => $displayedComments, ]; @@ -321,9 +321,13 @@ class Poll { } } } + $answersWithStats = []; + foreach ( $computedArray as $choice_stat ) { + $answersWithStats[] = $choice_stat; + } return [ - 'answers' => $computedArray, + 'answers' => $answersWithStats, 'max_score' => $maxScore, ]; }