| @@ 255-270 (lines=16) @@ | ||
| 252 | ||
| 253 | $form->bind($occurrence); |
|
| 254 | ||
| 255 | if ($this->getRequest()->isPost()) { |
|
| 256 | $data = array_merge( |
|
| 257 | $this->getRequest()->getPost()->toArray(), |
|
| 258 | $this->getRequest()->getFiles()->toArray() |
|
| 259 | ); |
|
| 260 | $occurrence = $service->updateOccurrence($data, $occurrence->getId()); |
|
| 261 | ||
| 262 | if ($occurrence) { |
|
| 263 | // Redirect to list of games |
|
| 264 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The occurrence was edited'); |
|
| 265 | return $this->redirect()->toRoute( |
|
| 266 | 'admin/playgroundgame/instantwin-occurrence-list', |
|
| 267 | array('gameId'=>$this->game->getId()) |
|
| 268 | ); |
|
| 269 | } |
|
| 270 | } |
|
| 271 | return $viewModel->setVariables( |
|
| 272 | array( |
|
| 273 | 'form' => $form, |
|
| @@ 71-88 (lines=18) @@ | ||
| 68 | $question = new QuizQuestion(); |
|
| 69 | $form->bind($question); |
|
| 70 | ||
| 71 | if ($this->getRequest()->isPost()) { |
|
| 72 | $data = array_replace_recursive( |
|
| 73 | $this->getRequest()->getPost()->toArray(), |
|
| 74 | $this->getRequest()->getFiles()->toArray() |
|
| 75 | ); |
|
| 76 | ||
| 77 | $question = $service->createQuestion($data); |
|
| 78 | if ($question) { |
|
| 79 | // Redirect to list of games |
|
| 80 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The question was created'); |
|
| 81 | ||
| 82 | return $this->redirect()->toRoute('admin/playgroundgame/quiz-question-list', array('quizId'=>$quizId)); |
|
| 83 | } else { // Creation failed |
|
| 84 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage( |
|
| 85 | 'The question was not updated - create at least one good answer' |
|
| 86 | ); |
|
| 87 | } |
|
| 88 | } |
|
| 89 | ||
| 90 | return $viewModel->setVariables(array('form' => $form, 'quiz_id' => $quizId, 'question_id' => 0)); |
|
| 91 | } |
|
| @@ 117-134 (lines=18) @@ | ||
| 114 | ||
| 115 | $form->bind($question); |
|
| 116 | ||
| 117 | if ($this->getRequest()->isPost()) { |
|
| 118 | $data = array_replace_recursive( |
|
| 119 | $this->getRequest()->getPost()->toArray(), |
|
| 120 | $this->getRequest()->getFiles()->toArray() |
|
| 121 | ); |
|
| 122 | ||
| 123 | $question = $service->updateQuestion($data, $question); |
|
| 124 | if ($question) { |
|
| 125 | // Redirect to list of games |
|
| 126 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The question was updated'); |
|
| 127 | ||
| 128 | return $this->redirect()->toRoute('admin/playgroundgame/quiz-question-list', array('quizId'=>$quizId)); |
|
| 129 | } else { |
|
| 130 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage( |
|
| 131 | 'The question was not updated - create at least one good answer' |
|
| 132 | ); |
|
| 133 | } |
|
| 134 | } |
|
| 135 | ||
| 136 | return $viewModel->setVariables(array('form' => $form, 'quiz_id' => $quizId, 'question_id' => $questionId)); |
|
| 137 | } |
|