|
@@ 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 |
|
} |