public function testSetInterview() { $intAnswer = new InterviewAnswer(); $interview = new Interview(); $intAnswer->setInterview($interview); $this->assertEquals($interview, $intAnswer->getInterview()); }
/** * 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())); }
/** * Shows and handles the submission of the interview form. * The rendered page is the page used to conduct interviews. * * @param Request $request * @param Application $application * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ public function conductAction(Request $request, Application $application) { if ($this->getUser() == $application->getUser()) { return $this->render('error/control_panel_error.html.twig', array('error' => 'Du kan ikke intervjue deg selv')); } $interview = $application->getInterview(); // 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); } } // $form = $this->createForm(new interviewType(), $interview); $form = $this->createForm(new ApplicationInterviewType(), $application, array('validation_groups' => array('interview'))); $form->handleRequest($request); if ($form->isValid()) { // Set interviewed to true if the form is valid $interview->setInterviewed(true); $application->setLastEdited(new \DateTime()); // Set the conducted datetime to now $interview->setConducted(new \DateTime()); // 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, 'application' => $application, 'form' => $form->createView())); }
public function load(ObjectManager $manager) { $application1 = new Application(); $application1->setFirstName('Marius'); $application1->setLastName('Svendsen'); $application1->setEmail('*****@*****.**'); $application1->setPhone('95321485'); $application1->setUserCreated(false); $application1->setSubstituteCreated(false); $as1 = new ApplicationStatistic(); $as1->setGender(0); $as1->setPreviousParticipation(true); $as1->setAccepted(0); $as1->setYearOfStudy(1); $as1->setFieldOfStudy($this->getReference('fos-1')); $as1->setSemester($this->getReference('semester-1')); $application1->setStatistic($as1); $manager->persist($application1); $application2 = new Application(); $application2->setFirstName('Siri'); $application2->setLastName('Kristiansen'); $application2->setEmail('*****@*****.**'); $application2->setPhone('95254873'); $application2->setUserCreated(false); $application2->setSubstituteCreated(false); $as2 = new ApplicationStatistic(); $as2->setGender(0); $as2->setPreviousParticipation(true); $as2->setAccepted(0); $as2->setYearOfStudy(1); $as2->setFieldOfStudy($this->getReference('fos-2')); $as2->setSemester($this->getReference('semester-1')); $application2->setStatistic($as2); $manager->persist($application2); $application3 = new Application(); $application3->setFirstName('Leonardo'); $application3->setLastName('DiCaprio'); $application3->setEmail('*****@*****.**'); $application3->setPhone('95235816'); $application3->setUserCreated(false); $application3->setSubstituteCreated(false); $as3 = new ApplicationStatistic(); $as3->setGender(0); $as3->setPreviousParticipation(true); $as3->setAccepted(0); $as3->setYearOfStudy(1); $as3->setFieldOfStudy($this->getReference('fos-2')); $as3->setSemester($this->getReference('semester-1')); $application3->setStatistic($as3); $manager->persist($application3); // This application has a conducted interview which takes some code to set up $application4 = new Application(); $application4->setFirstName('Walter'); $application4->setLastName('White'); $application4->setEmail('*****@*****.**'); $application4->setPhone('95254873'); $application4->setUserCreated(false); $application4->setSubstituteCreated(false); $as4 = new ApplicationStatistic(); $as4->setGender(0); $as4->setPreviousParticipation(true); $as4->setAccepted(0); $as4->setYearOfStudy(1); $as4->setFieldOfStudy($this->getReference('fos-1')); $as4->setSemester($this->getReference('semester-1')); $application4->setStatistic($as4); // The interview $interview4 = new Interview(); $interview4->setInterviewed(true); $interview4->setInterviewer($this->getReference('user-2')); $interview4->setInterviewSchema($this->getReference('ischema-1')); $interview4->setApplication($application4); $application4->setInterview($interview4); // Create answer objects for all the questions in the schema foreach ($interview4->getInterviewSchema()->getInterviewQuestions() as $interviewQuestion) { $answer = new InterviewAnswer(); $answer->setAnswer("Test answer"); $answer->setInterview($interview4); $answer->setInterviewQuestion($interviewQuestion); $interview4->addInterviewAnswer($answer); } // The interview score $intScore = new InterviewScore(); $intScore->setDrive(3); $intScore->setExplanatoryPower(3); $intScore->setRoleModel(3); $intScore->setTotalImpression(3); $intScore->setApplicationStatistic($as4); $interview4->setInterviewScore($intScore); // The interview practical $intPrac = new InterviewPractical(); $intPrac->setMonday("Bra"); $intPrac->setTuesday("Bra"); $intPrac->setWednesday("Bra"); $intPrac->setThursday("Bra"); $intPrac->setFriday("Bra"); $intPrac->setComment("Test"); $intPrac->setHeardAboutFrom("Stand"); $intPrac->setEnglish(true); $intPrac->setPosition("2x2"); $intPrac->setSubstitute(true); $intPrac->setApplicationStatistic($as4); $interview4->setInterviewPractical($intPrac); $manager->persist($application4); $application5 = new Application(); $application5->setFirstName('Mark'); $application5->setLastName('Zuckerberg'); $application5->setEmail('*****@*****.**'); $application5->setPhone('95856472'); $application5->setUserCreated(false); $application5->setSubstituteCreated(false); $as5 = new ApplicationStatistic(); $as5->setGender(0); $as5->setPreviousParticipation(true); $as5->setAccepted(0); $as5->setYearOfStudy(1); $as5->setFieldOfStudy($this->getReference('fos-1')); $as5->setSemester($this->getReference('semester-1')); $application5->setStatistic($as5); $interview5 = new Interview(); $interview5->setInterviewed(false); $interview5->setInterviewer($this->getReference('user-2')); $interview5->setInterviewSchema($this->getReference('ischema-1')); $application5->setInterview($interview5); $manager->persist($application5); $manager->flush(); }
public function load(ObjectManager $manager) { $application0 = new Application(); $application0->setUser($this->getReference('user-15')); $application0->setPreviousParticipation(false); $application0->setYearOfStudy(1); $application0->setSemester($this->getReference('semester-1')); $manager->persist($application0); $application1 = new Application(); $application1->setUser($this->getReference('user-10')); $application1->setPreviousParticipation(true); $application1->setYearOfStudy(1); $application1->setSemester($this->getReference('semester-1')); $manager->persist($application1); $application2 = new Application(); $application2->setUser($this->getReference('user-11')); $application2->setPreviousParticipation(false); $application2->setYearOfStudy(1); $application2->setSemester($this->getReference('semester-1')); $manager->persist($application2); $application3 = new Application(); $application3->setUser($this->getReference('user-12')); $application3->setPreviousParticipation(false); $application3->setYearOfStudy(1); $application3->setSemester($this->getReference('semester-1')); $manager->persist($application3); // The interview $interview3 = new Interview(); $interview3->setInterviewed(true); $interview3->setInterviewer($this->getReference('user-2')); $interview3->setInterviewSchema($this->getReference('ischema-1')); $interview3->setUser($this->getReference('user-12')); $application3->setInterview($interview3); // Create answer objects for all the questions in the schema foreach ($interview3->getInterviewSchema()->getInterviewQuestions() as $interviewQuestion) { $answer = new InterviewAnswer(); $answer->setAnswer("Test answer"); $answer->setInterview($interview3); $answer->setInterviewQuestion($interviewQuestion); $interview3->addInterviewAnswer($answer); } // The interview score $intScore = new InterviewScore(); $intScore->setSuitability(6); $intScore->setExplanatoryPower(5); $intScore->setRoleModel(4); $intScore->setSuitableAssistant('Ja'); $interview3->setInterviewScore($intScore); // The interview practical $application3->setMonday("Bra"); $application3->setTuesday("Bra"); $application3->setWednesday("Ikke"); $application3->setThursday("Bra"); $application3->setFriday("Ikke"); $application3->setHeardAboutFrom(array("Stand")); $application3->setEnglish(true); $application3->setPreferredGroup('Bolk 1'); $application3->setDoublePosition(true); $manager->persist($application3); // This application has a conducted interview which takes some code to set up $application4 = new Application(); $application4->setUser($this->getReference('user-13')); $application4->setPreviousParticipation(false); $application4->setYearOfStudy(1); $application4->setSemester($this->getReference('semester-1')); // The interview $interview4 = new Interview(); $interview4->setInterviewed(true); $interview4->setInterviewer($this->getReference('user-2')); $interview4->setInterviewSchema($this->getReference('ischema-1')); $interview4->setUser($this->getReference('user-13')); $application4->setInterview($interview4); // Create answer objects for all the questions in the schema foreach ($interview4->getInterviewSchema()->getInterviewQuestions() as $interviewQuestion) { $answer = new InterviewAnswer(); $answer->setAnswer("Test answer"); $answer->setInterview($interview4); $answer->setInterviewQuestion($interviewQuestion); $interview4->addInterviewAnswer($answer); } // The interview score $intScore = new InterviewScore(); $intScore->setSuitability(6); $intScore->setExplanatoryPower(5); $intScore->setRoleModel(4); $intScore->setSuitableAssistant('Ja'); $interview4->setInterviewScore($intScore); // The interview practical $application4->setMonday("Bra"); $application4->setTuesday("Bra"); $application4->setWednesday("Ikke"); $application4->setThursday("Bra"); $application4->setFriday("Ikke"); $application4->setHeardAboutFrom(array("Stand")); $application4->setEnglish(false); $application4->setPreferredGroup('Bolk 1'); $application4->setDoublePosition(false); $manager->persist($application4); $application5 = new Application(); $application5->setUser($this->getReference('user-14')); $application5->setPreviousParticipation(false); $application5->setYearOfStudy(1); $application5->setSemester($this->getReference('semester-1')); $interview5 = new Interview(); $interview5->setInterviewed(false); $interview5->setInterviewer($this->getReference('user-2')); $interview5->setInterviewSchema($this->getReference('ischema-1')); $interview5->setUser($this->getReference('user-14')); $application5->setInterview($interview5); $manager->persist($application5); $application6 = new Application(); $application6->setUser($this->getReference('user-8')); $application6->setPreviousParticipation(false); $application6->setYearOfStudy(1); $application6->setSemester($this->getReference('semester-1')); $interview6 = new Interview(); $interview6->setInterviewed(false); $interview6->setInterviewer($this->getReference('user-1')); $interview6->setInterviewSchema($this->getReference('ischema-1')); $interview6->setUser($this->getReference('user-8')); $interview6->setCancelled(true); $application6->setInterview($interview6); $manager->persist($application6); $manager->flush(); }