| @@ 35-42 (lines=8) @@ | ||
| 32 | ||
| 33 | if (!$entry) { |
|
| 34 | $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
|
| 35 | if ($lastEntry === null) { |
|
| 36 | return $this->redirect()->toUrl( |
|
| 37 | $this->frontendUrl()->fromRoute( |
|
| 38 | 'postvote', |
|
| 39 | array('id' => $this->game->getIdentifier()) |
|
| 40 | ) |
|
| 41 | ); |
|
| 42 | } |
|
| 43 | ||
| 44 | $lastEntryId = $lastEntry->getId(); |
|
| 45 | $lastPost = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntryId)); |
|
| @@ 80-87 (lines=8) @@ | ||
| 77 | } |
|
| 78 | } |
|
| 79 | ||
| 80 | if (! $this->game->getForm()) { |
|
| 81 | return $this->redirect()->toUrl( |
|
| 82 | $this->frontendUrl()->fromRoute( |
|
| 83 | 'postvote', |
|
| 84 | array('id' => $this->game->getIdentifier()) |
|
| 85 | ) |
|
| 86 | ); |
|
| 87 | } |
|
| 88 | ||
| 89 | $form = $this->getGameService()->createFormFromJson($this->game->getForm()->getForm(), 'postvoteForm'); |
|
| 90 | ||
| @@ 159-167 (lines=9) @@ | ||
| 156 | { |
|
| 157 | $entry = $this->getGameService()->findLastActiveEntry($this->game, $this->user); |
|
| 158 | ||
| 159 | if (!$entry) { |
|
| 160 | // the user has already taken part of this game and the participation limit has been reached |
|
| 161 | return $this->redirect()->toUrl( |
|
| 162 | $this->frontendUrl()->fromRoute( |
|
| 163 | 'postvote/'.$this->game->nextStep('preview'), |
|
| 164 | array('id' => $this->game->getIdentifier()) |
|
| 165 | ) |
|
| 166 | ); |
|
| 167 | } |
|
| 168 | ||
| 169 | // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
|
| 170 | $post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0)); |
|
| @@ 172-179 (lines=8) @@ | ||
| 169 | // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
|
| 170 | $post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $entry, 'status' => 0)); |
|
| 171 | ||
| 172 | if (! $post) { |
|
| 173 | return $this->redirect()->toUrl( |
|
| 174 | $this->frontendUrl()->fromRoute( |
|
| 175 | 'postvote', |
|
| 176 | array('id' => $this->game->getIdentifier()) |
|
| 177 | ) |
|
| 178 | ); |
|
| 179 | } |
|
| 180 | ||
| 181 | if ($this->getRequest()->isPost()) { |
|
| 182 | $post = $this->getGameService()->confirmPost($this->game, $this->user); |
|
| @@ 231-238 (lines=8) @@ | ||
| 228 | // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
|
| 229 | $post = $this->getGameService()->getPostVotePostMapper()->findById($postId); |
|
| 230 | ||
| 231 | if (! $post || $post->getStatus() === 9) { |
|
| 232 | return $this->redirect()->toUrl( |
|
| 233 | $this->frontendUrl()->fromRoute( |
|
| 234 | 'postvote', |
|
| 235 | array('id' => $this->game->getIdentifier()) |
|
| 236 | ) |
|
| 237 | ); |
|
| 238 | } |
|
| 239 | ||
| 240 | $formModeration = new Form(); |
|
| 241 | $formModeration->setAttribute('method', 'post'); |
|
| @@ 340-347 (lines=8) @@ | ||
| 337 | // Je recherche le post associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
|
| 338 | $post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntry)); |
|
| 339 | ||
| 340 | if (! $post) { |
|
| 341 | return $this->redirect()->toUrl( |
|
| 342 | $this->frontendUrl()->fromRoute( |
|
| 343 | 'postvote', |
|
| 344 | array('id' => $this->game->getIdentifier()) |
|
| 345 | ) |
|
| 346 | ); |
|
| 347 | } |
|
| 348 | ||
| 349 | // DEPRECATED: we should be able to add a specific view to each action |
|
| 350 | // based on config in the admin (tab design) |
|
| @@ 923-930 (lines=8) @@ | ||
| 920 | // Has the user finished the game ? |
|
| 921 | $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
|
| 922 | ||
| 923 | if ($lastEntry === null) { |
|
| 924 | return $this->redirect()->toUrl( |
|
| 925 | $this->frontendUrl()->fromRoute( |
|
| 926 | 'postvote', |
|
| 927 | array('id' => $this->game->getIdentifier()) |
|
| 928 | ) |
|
| 929 | ); |
|
| 930 | } |
|
| 931 | ||
| 932 | $post = $this->getGameService()->getPostVotePostMapper()->findOneBy(array('entry' => $lastEntry)); |
|
| 933 | ||
| @@ 341-349 (lines=9) @@ | ||
| 338 | $userTimer = array(); |
|
| 339 | ||
| 340 | $lastEntry = $this->getGameService()->findLastEntry($this->game, $this->user); |
|
| 341 | if (!$lastEntry) { |
|
| 342 | return $this->redirect()->toUrl( |
|
| 343 | $this->frontendUrl()->fromRoute( |
|
| 344 | 'quiz', |
|
| 345 | array('id' => $this->game->getIdentifier()), |
|
| 346 | array('force_canonical' => true) |
|
| 347 | ) |
|
| 348 | ); |
|
| 349 | } |
|
| 350 | ||
| 351 | // je compte les bonnes réponses et le ratio |
|
| 352 | $maxCorrectAnswers = $this->game->getMaxCorrectAnswers(); |
|
| @@ 89-97 (lines=9) @@ | ||
| 86 | } |
|
| 87 | ||
| 88 | $lastEntry = $this->getGameService()->findLastInactiveEntry($this->game, $this->user); |
|
| 89 | if (!$lastEntry) { |
|
| 90 | return $this->redirect()->toUrl( |
|
| 91 | $this->frontendUrl()->fromRoute( |
|
| 92 | 'memory', |
|
| 93 | array('id' => $this->game->getIdentifier()), |
|
| 94 | array('force_canonical' => true) |
|
| 95 | ) |
|
| 96 | ); |
|
| 97 | } |
|
| 98 | ||
| 99 | // Je recherche le score associé à entry + status == 0. Si non trouvé, je redirige vers home du jeu. |
|
| 100 | $score = $this->getGameService()->getMemoryScoreMapper()->findOneBy(array('entry' => $lastEntry)); |
|