1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00

sort poll display

This commit is contained in:
Tykayn 2022-02-07 11:24:53 +01:00 committed by tykayn
parent 83978f1757
commit 40d0914b47
2 changed files with 5 additions and 3 deletions

View File

@ -104,7 +104,8 @@ class PollController extends EmailsController {
} else { } else {
// free access to poll // free access to poll
return $this->json( sort( $poll->display()) ); $pollResult = $poll->display();
return $this->json( $pollResult );
} }
} }

View File

@ -243,13 +243,13 @@ class Poll
$content['admin_key'] = $this->getAdminKey(); $content['admin_key'] = $this->getAdminKey();
$content['password_hash'] = $this->getPassword(); $content['password_hash'] = $this->getPassword();
$content['id'] = $this->getId(); $content['id'] = $this->getId();
ksort($content);
return $content; return $content;
} }
// counts each number of answer for this choice // counts each number of answer for this choice
public function display() public function display(): array
{ {
$computedAnswers = $this->computeAnswers(); $computedAnswers = $this->computeAnswers();
@ -289,6 +289,7 @@ class Poll
'votes_allowed' => $this->getVotesAllowed(), 'votes_allowed' => $this->getVotesAllowed(),
'votes_max' => $this->getVotesMax(), 'votes_max' => $this->getVotesMax(),
]; ];
ksort($resp);
return $resp; return $resp;
} }