public function testSetSemesterEndDate()
 {
     // New datetime variable
     $today = new DateTime("now");
     // new entity
     $semester = new Semester();
     // Use the setSemesterEndDate method
     $semester->setSemesterEndDate($today);
     // Assert the result
     $this->assertEquals($today, $semester->getSemesterEndDate());
 }
 public function testSetSemester()
 {
     // new assistantHistory entity
     $assistantHistory = new AssistantHistory();
     // new semester entity
     $semester = new Semester();
     // Set some random datat to the entity
     $semester->setName("Huehue");
     // Set the entity to assistantHistory
     $assistantHistory->setSemester($semester);
     // Assert the result
     $this->assertEquals($semester->getName(), $assistantHistory->getSemester()->getName());
 }
示例#3
0
 public function load(ObjectManager $manager)
 {
     $semester1 = new Semester();
     $semester1->setSemesterTime('Vår');
     $semester1->setYear(2016);
     $semester1->setDepartment($this->getReference('dep-1'));
     $semester1->setAdmissionStartDate(new \DateTime('2016-01-01'));
     $semester1->setAdmissionEndDate(new \DateTime('2016-05-30'));
     $semester1->setSemesterStartDate(new \DateTime('2016-01-01'));
     $semester1->setSemesterEndDate(new \DateTime('2016-06-30'));
     $manager->persist($semester1);
     $semester2 = new Semester();
     $semester2->setSemesterTime('Vår');
     $semester2->setYear(2015);
     $semester2->setDepartment($this->getReference('dep-2'));
     $semester2->setAdmissionStartDate(new \DateTime('2015-01-01'));
     $semester2->setAdmissionEndDate(new \DateTime('2015-05-30'));
     $semester2->setSemesterStartDate(new \DateTime('2015-01-01'));
     $semester2->setSemesterEndDate(new \DateTime('2015-06-30'));
     $manager->persist($semester2);
     $semester3 = new Semester();
     $semester3->setSemesterTime('Vår');
     $semester3->setYear(2015);
     $semester3->setDepartment($this->getReference('dep-3'));
     $semester3->setAdmissionStartDate(new \DateTime('2015-01-01'));
     $semester3->setAdmissionEndDate(new \DateTime('2015-05-30'));
     $semester3->setSemesterStartDate(new \DateTime('2015-01-01'));
     $semester3->setSemesterEndDate(new \DateTime('2015-06-30'));
     $manager->persist($semester3);
     $semester4 = new Semester();
     $semester4->setSemesterTime('Vår');
     $semester4->setYear(2015);
     $semester4->setDepartment($this->getReference('dep-4'));
     $semester4->setAdmissionStartDate(new \DateTime('2015-01-01'));
     $semester4->setAdmissionEndDate(new \DateTime('2015-05-30'));
     $semester4->setSemesterStartDate(new \DateTime('2015-01-01'));
     $semester4->setSemesterEndDate(new \DateTime('2015-06-30'));
     $manager->persist($semester4);
     $semester5 = new Semester();
     $semester5->setSemesterTime('Høst');
     $semester5->setYear(2015);
     $semester5->setDepartment($this->getReference('dep-1'));
     $semester5->setAdmissionStartDate(new \DateTime('2014-08-01'));
     $semester5->setAdmissionEndDate(new \DateTime('2014-12-30'));
     $semester5->setSemesterStartDate(new \DateTime('2014-08-01'));
     $semester5->setSemesterEndDate(new \DateTime('2014-12-30'));
     $manager->persist($semester5);
     $manager->flush();
     $this->addReference('semester-1', $semester1);
     $this->addReference('semester-2', $semester2);
     $this->addReference('semester-3', $semester3);
     $this->addReference('semester-4', $semester4);
     $this->addReference('semester-5', $semester5);
 }
 public static function getAll()
 {
     $con = Connection::getConnectionObject()->getConnection();
     // Check connection
     if (mysqli_connect_errno()) {
         echo "Failed to connect to MySQL: " . mysqli_connect_error();
     }
     $semesters = array();
     //Make an empty array
     $stmt = $con->prepare('SELECT id,name FROM semester');
     $stmt->execute();
     $stmt->bind_result($id, $name);
     while ($stmt->fetch()) {
         $semester = new Semester();
         $semester->id = $id;
         $semester->setName($name);
         array_push($semesters, $semester);
         //Push one by one
     }
     $stmt->close();
     return $semesters;
 }
示例#5
0
 public function load(ObjectManager $manager)
 {
     $semester1 = new Semester();
     $semester1->setName('NTNU Vår 2015');
     $semester1->setDepartment($this->getReference('dep-1'));
     $semester1->setAdmissionStartDate(new \DateTime('2015-01-01'));
     $semester1->setAdmissionEndDate(new \DateTime('2015-05-30'));
     $semester1->setSemesterStartDate(new \DateTime('2015-01-01'));
     $semester1->setSemesterEndDate(new \DateTime('2015-06-30'));
     $manager->persist($semester1);
     $semester2 = new Semester();
     $semester2->setName('HiST Vår 2015');
     $semester2->setDepartment($this->getReference('dep-2'));
     $semester2->setAdmissionStartDate(new \DateTime('2015-01-01'));
     $semester2->setAdmissionEndDate(new \DateTime('2015-05-30'));
     $semester2->setSemesterStartDate(new \DateTime('2015-01-01'));
     $semester2->setSemesterEndDate(new \DateTime('2015-06-30'));
     $manager->persist($semester2);
     $semester3 = new Semester();
     $semester3->setName('NMBU Vår 2015');
     $semester3->setDepartment($this->getReference('dep-3'));
     $semester3->setAdmissionStartDate(new \DateTime('2015-01-01'));
     $semester3->setAdmissionEndDate(new \DateTime('2015-05-30'));
     $semester3->setSemesterStartDate(new \DateTime('2015-01-01'));
     $semester3->setSemesterEndDate(new \DateTime('2015-06-30'));
     $manager->persist($semester3);
     $semester4 = new Semester();
     $semester4->setName('UiO Vår 2015');
     $semester4->setDepartment($this->getReference('dep-4'));
     $semester4->setAdmissionStartDate(new \DateTime('2015-01-01'));
     $semester4->setAdmissionEndDate(new \DateTime('2015-05-30'));
     $semester4->setSemesterStartDate(new \DateTime('2015-01-01'));
     $semester4->setSemesterEndDate(new \DateTime('2015-06-30'));
     $manager->persist($semester4);
     $manager->flush();
     $this->addReference('semester-1', $semester1);
     $this->addReference('semester-2', $semester2);
     $this->addReference('semester-3', $semester3);
     $this->addReference('semester-4', $semester4);
 }
 /**
  * @Route("/admin/", name="admin_home")
  */
 public function indexAction(Request $request)
 {
     $semesters = Semester::getAll();
     return $this->render('admin/home.html.twig', array('semesters' => $semesters));
 }
 public function testRemoveSemester()
 {
     // new entity
     $department = new Department();
     $semester1 = new Semester();
     $semester1->setSemesterTime("Høst");
     $semester2 = new Semester();
     $semester2->setSemesterTime("Vår");
     $semester3 = new Semester();
     $semester3->setSemesterTime("Vår");
     // Use the addSemester method
     $department->addSemester($semester1);
     $department->addSemester($semester2);
     $department->addSemester($semester3);
     // Remove $semester1 from department
     $department->removeSemester($semester1);
     // Semesters are stored in an array
     $semesters = $department->getSemesters();
     // Loop through the array
     foreach ($semesters as $semester) {
         // Assert the result
         $this->assertNotEquals($semester1, $semester);
     }
 }
 /**
  * @Route("/semester/view", name="semester_viewAll")
  */
 public function viewallAction(Request $request)
 {
     $semesters = Semester::getAll();
     $semResults = Semester_results::getAll();
     return $this->render('semester/viewall.html.twig', array('semesters' => $semesters, 'results' => $semResults));
 }
 public function determineCurrentStep(Semester $semester, $interviewedAssistantsCount, $assignedInterviewsCount, $totalAssistantsCount)
 {
     $today = new DateTime("now");
     // Step 1 Before Admission
     if ($today < $semester->getAdmissionStartDate() && $today > $semester->getSemesterStartDate()) {
         return 1 + ($today->format('U') - $semester->getSemesterStartDate()->format('U')) / ($semester->getAdmissionStartDate()->format('U') - $semester->getSemesterStartDate()->format('U'));
     }
     // Step 2 Admission has started
     if ($today < $semester->getAdmissionEndDate() && $today > $semester->getAdmissionStartDate()) {
         return 2 + ($today->format('U') - $semester->getAdmissionStartDate()->format('U')) / ($semester->getAdmissionEndDate()->format('U') - $semester->getAdmissionStartDate()->format('U'));
     }
     // Step 3 Interviewing
     // No interviews are assigned yet
     if ($assignedInterviewsCount == 0 && $interviewedAssistantsCount == 0) {
         return 3;
     } elseif ($assignedInterviewsCount > 0) {
         return 3 + $interviewedAssistantsCount / ($assignedInterviewsCount + $interviewedAssistantsCount);
     }
     // Step 4 Distribute to schools
     // All interviews are conducted, but no one has been accepted yet
     if ($totalAssistantsCount == 0) {
         return 4;
     }
     // Step 5 Operating phase
     if ($today < $semester->getSemesterEndDate() && $today > $semester->getAdmissionEndDate()) {
         return 5 + ($today->format('U') - $semester->getAdmissionEndDate()->format('U')) / ($semester->getSemesterEndDate()->format('U') - $semester->getAdmissionEndDate()->format('U'));
     }
     // Something is wrong
     return -1;
 }