| @@ 246-258 (lines=13) @@ | ||
| 243 | ||
| 244 | $form->bind($occurrence); |
|
| 245 | ||
| 246 | if ($this->getRequest()->isPost()) { |
|
| 247 | $data = array_merge( |
|
| 248 | $this->getRequest()->getPost()->toArray(), |
|
| 249 | $this->getRequest()->getFiles()->toArray() |
|
| 250 | ); |
|
| 251 | $occurrence = $service->updateOccurrence($data, $occurrence->getId()); |
|
| 252 | ||
| 253 | if ($occurrence) { |
|
| 254 | // Redirect to list of games |
|
| 255 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage('The occurrence was edited'); |
|
| 256 | return $this->redirect()->toUrl($this->adminUrl()->fromRoute('playgroundgame/instantwin-occurrence-list', array('gameId' => $this->game->getId()))); |
|
| 257 | } |
|
| 258 | } |
|
| 259 | return $viewModel->setVariables( |
|
| 260 | array( |
|
| 261 | '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()->toUrl($this->adminUrl()->fromRoute('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-135 (lines=19) @@ | ||
| 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()->toUrl($this->adminUrl()->fromRoute('playgroundgame/quiz-question-list', array('quizId'=>$quizId))); |
|
| 129 | ||
| 130 | } else { |
|
| 131 | $this->flashMessenger()->setNamespace('playgroundgame')->addMessage( |
|
| 132 | 'The question was not updated - create at least one good answer' |
|
| 133 | ); |
|
| 134 | } |
|
| 135 | } |
|
| 136 | ||
| 137 | return $viewModel->setVariables(array('form' => $form, 'quiz_id' => $quizId, 'question_id' => $questionId)); |
|
| 138 | } |
|