public function testSetInterviewSchema()
 {
     $interview = new Interview();
     $intSchema = new InterviewSchema();
     $interview->setInterviewSchema($intSchema);
     $this->assertEquals($intSchema, $interview->getInterviewSchema());
 }
Esempio n. 2
0
 /**
  * Shows and handles the submission of the interview form.
  * The rendered page is the page used to conduct interviews.
  *
  * @param Request $request
  * @param Interview $interview
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function conductAction(Request $request, Interview $interview)
 {
     // Only admin and above, or the assigned interviewer should be able to conduct an interview
     if (!$this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN') && !$interview->isInterviewer($this->getUser())) {
         throw $this->createAccessDeniedException();
     }
     $em = $this->getDoctrine()->getManager();
     // If the interview has not yet been conducted, create up to date answer objects for all questions in schema
     if (!$interview->getInterviewed()) {
         foreach ($interview->getInterviewSchema()->getInterviewQuestions() as $interviewQuestion) {
             // Create a new answer object for the question
             $answer = new InterviewAnswer();
             $answer->setInterview($interview);
             $answer->setInterviewQuestion($interviewQuestion);
             // Add the answer object to the interview
             $interview->addInterviewAnswer($answer);
         }
         // If the interview is deleted after it has been conducted, and a new is made, we need to check for score and practical in the database,
         // which are connected to application statistics (score, practical and statistics are stored in the database even if application/interview is deleted)
         $interview->setInterviewScore($interview->getApplication()->getStatistic()->getInterviewScore());
         $interview->setInterviewPractical($interview->getApplication()->getStatistic()->getInterviewPractical());
     }
     $form = $this->createForm(new interviewType(), $interview);
     $form->handleRequest($request);
     if ($form->isValid()) {
         // Set interviewed to true if the form is valid
         $interview->setInterviewed(true);
         // Set the conducted datetime to now
         $interview->setConducted(new \DateTime());
         // Link the application statistic object to the practical and score objects
         $interview->getInterviewScore()->setApplicationStatistic($interview->getApplication()->getStatistic());
         $interview->getInterviewPractical()->setApplicationStatistic($interview->getApplication()->getStatistic());
         // Persist
         $em->persist($interview);
         $em->flush();
         return $this->redirect($this->generateUrl('admissionadmin_show', array('status' => 'interviewed')));
     }
     return $this->render('interview/conduct.html.twig', array('interview' => $interview, 'form' => $form->createView()));
 }