コード例 #1
0
 /**
  * @param \_OurBrand_\Quiz\Domain\Model\Quiz $quiz
  *
  * @throws \Exception
  */
 public function editAction($quiz)
 {
     if (!$this->accessHelper->canUserEditQuiz($this->currentUser, $quiz)) {
         $this->throwStatus(403);
     }
     if ($quiz->getSnapshotOf() instanceof Quiz) {
         $this->redirect('edit', 'quiz', '_OurBrand_.quiz', array('quiz' => $quiz->getSnapshotOf()));
     }
     // TODO: Work over
     $sessions = $this->studentQuizSessionRepository->findByQuiz($quiz);
     if ($sessions->count() > 0) {
         throw new \Exception('Can not edit quiz that has been assigned');
     }
     $this->view->assign('quiz', $quiz);
     $this->view->assign('isEditingQuiz', 1);
     $this->view->assign('defaultDuration', $this->defaultDuration / 60);
     $this->view->assign('typeOptions', $this->typeOptions);
     $this->view->assign('subjectOptions', $this->subjectRepository->findAll());
     $this->view->assign('teamLevelOptions', $this->teamLevelRepository->findAll());
     $this->view->assign('teamLevelPlaceholder', $this->translateById('quiz.placeholder.teamLevel'));
     $this->view->assign('typePlaceholder', $this->translateById('quiz.placeholder.type'));
     $this->view->assign('subjectPlaceholder', $this->translateById('quiz.placeholder.subject'));
     $this->view->assign('introductionPlaceholder', $this->translateById('quiz.placeholder.introduction'));
 }