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();
$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);
}

View File

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