diff --git a/src/Controller/api/PollController.php b/src/Controller/api/PollController.php index f9cf1b6..30a3190 100644 --- a/src/Controller/api/PollController.php +++ b/src/Controller/api/PollController.php @@ -101,7 +101,7 @@ class PollController extends EmailsController { } $comments = $poll->getComments(); - $stacks = $poll->getStacksOfVotes(); + $stacks = $poll->getStacksOfVotes(); $displayedComments = []; foreach ( $comments as $comment ) { @@ -111,18 +111,21 @@ class PollController extends EmailsController { foreach ( $stacks as $stack ) { $displayedStackOfVotes[] = $stack->display(); } - $pass = $poll->getPassword(); + $displayedChoices = []; + foreach ( $poll->getChoices() as $choice + ) { + $displayedChoices[] = $choice->display(); + } + $pass = $poll->getPassword(); $returnedPoll = [ - 'message' => 'your poll config for ' . $poll->getTitle(), + 'message' => 'your poll config for ' . $poll->getTitle(), - 'poll' => $poll->display(), + 'poll' => $poll->display(), // TODO do not render sub objects of owner, it returns too many thing - 'stacks_count' => count( $poll->getStacksOfVotes() ), - 'stacks' => $displayedStackOfVotes, - 'choices_count' => $poll->computeAnswers(), - 'comments' => $displayedComments, - 'comments_count' => count( $comments ), + 'stacks' => $displayedStackOfVotes, + 'choices' => $displayedChoices, + 'comments' => $displayedComments, ]; /** @@ -138,7 +141,7 @@ class PollController extends EmailsController { } else { // free access to poll // return $this->returnPollData( $poll, $serializer ); - return $this->json($returnedPoll); + return $this->json( $returnedPoll ); // return $this->json($poll); } diff --git a/src/Entity/Poll.php b/src/Entity/Poll.php index 86f5e99..9129903 100755 --- a/src/Entity/Poll.php +++ b/src/Entity/Poll.php @@ -232,7 +232,6 @@ class Poll { } } } - return [ 'counts' => $computedArray, 'maxScore' => $maxScore,