| @@ 70-87 (lines=18) @@ | ||
| 67 | $question = new QuizQuestion(); |
|
| 68 | $form->bind($question); |
|
| 69 | ||
| 70 | if ($this->getRequest()->isPost()) { |
|
| 71 | $data = array_replace_recursive( |
|
| 72 | $this->getRequest()->getPost()->toArray(), |
|
| 73 | $this->getRequest()->getFiles()->toArray() |
|
| 74 | ); |
|
| 75 | ||
| 76 | $question = $service->createQuestion($data); |
|
| 77 | if ($question) { |
|
| 78 | // Redirect to list of games |
|
| 79 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The question was created'); |
|
| 80 | ||
| 81 | return $this->redirect()->toRoute('admin/playgroundgame/quiz-question-list', array('quizId'=>$quizId)); |
|
| 82 | } else { // Creation failed |
|
| 83 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage( |
|
| 84 | 'The question was not updated - create at least one good answer' |
|
| 85 | ); |
|
| 86 | } |
|
| 87 | } |
|
| 88 | ||
| 89 | return $viewModel->setVariables(array('form' => $form, 'quiz_id' => $quizId, 'question_id' => 0)); |
|
| 90 | } |
|
| @@ 116-133 (lines=18) @@ | ||
| 113 | ||
| 114 | $form->bind($question); |
|
| 115 | ||
| 116 | if ($this->getRequest()->isPost()) { |
|
| 117 | $data = array_replace_recursive( |
|
| 118 | $this->getRequest()->getPost()->toArray(), |
|
| 119 | $this->getRequest()->getFiles()->toArray() |
|
| 120 | ); |
|
| 121 | ||
| 122 | $question = $service->updateQuestion($data, $question); |
|
| 123 | if ($question) { |
|
| 124 | // Redirect to list of games |
|
| 125 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The question was updated'); |
|
| 126 | ||
| 127 | return $this->redirect()->toRoute('admin/playgroundgame/quiz-question-list', array('quizId'=>$quizId)); |
|
| 128 | } else { |
|
| 129 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage( |
|
| 130 | 'The question was not updated - create at least one good answer' |
|
| 131 | ); |
|
| 132 | } |
|
| 133 | } |
|
| 134 | ||
| 135 | return $viewModel->setVariables(array('form' => $form, 'quiz_id' => $quizId, 'question_id' => $questionId)); |
|
| 136 | } |
|
| @@ 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, |
|