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;
 }
Esempio n. 2
0
 public function testSetAdmissionEndDate()
 {
     // New datetime variable
     $today = new DateTime("now");
     // new entity
     $semester = new Semester();
     // Use the setAdmissionEndDate method
     $semester->setAdmissionEndDate($today);
     // Assert the result
     $this->assertEquals($today, $semester->getAdmissionEndDate());
 }