enrich display config of a poll

This commit is contained in:
Tykayn 2021-04-26 15:21:19 +02:00 committed by tykayn
parent 7c1fbf7347
commit 1d72bfe684
2 changed files with 13 additions and 11 deletions

View File

@ -101,7 +101,7 @@ class PollController extends EmailsController {
} }
$comments = $poll->getComments(); $comments = $poll->getComments();
$stacks = $poll->getStacksOfVotes(); $stacks = $poll->getStacksOfVotes();
$displayedComments = []; $displayedComments = [];
foreach ( $comments as $comment ) { foreach ( $comments as $comment ) {
@ -111,18 +111,21 @@ class PollController extends EmailsController {
foreach ( $stacks as $stack ) { foreach ( $stacks as $stack ) {
$displayedStackOfVotes[] = $stack->display(); $displayedStackOfVotes[] = $stack->display();
} }
$pass = $poll->getPassword(); $displayedChoices = [];
foreach ( $poll->getChoices() as $choice
) {
$displayedChoices[] = $choice->display();
}
$pass = $poll->getPassword();
$returnedPoll = [ $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 // TODO do not render sub objects of owner, it returns too many thing
'stacks_count' => count( $poll->getStacksOfVotes() ), 'stacks' => $displayedStackOfVotes,
'stacks' => $displayedStackOfVotes, 'choices' => $displayedChoices,
'choices_count' => $poll->computeAnswers(), 'comments' => $displayedComments,
'comments' => $displayedComments,
'comments_count' => count( $comments ),
]; ];
/** /**
@ -138,7 +141,7 @@ class PollController extends EmailsController {
} else { } else {
// free access to poll // free access to poll
// return $this->returnPollData( $poll, $serializer ); // return $this->returnPollData( $poll, $serializer );
return $this->json($returnedPoll); return $this->json( $returnedPoll );
// return $this->json($poll); // return $this->json($poll);
} }

View File

@ -232,7 +232,6 @@ class Poll {
} }
} }
} }
return [ return [
'counts' => $computedArray, 'counts' => $computedArray,
'maxScore' => $maxScore, 'maxScore' => $maxScore,