Пример #1
0
 if (!empty($buckets)) {
     //exams have been sorted based on priority and placed into buckets reprsenting exan dates
     foreach ($buckets as $dateBucket) {
         //iterate through each exam on a particular day
         foreach ($dateBucket as $exam) {
             $nrOfExamsInBucket++;
             //reinitalize flags for each bucket
             $hasConflicts = false;
             $noAccommodations = false;
             $found = false;
             //iterate through each active seat and check whether to seat is eligible
             foreach ($seats as $seat) {
                 //retrieve accommodation data and sheduling conflicts if applicable
                 $conflicts = $assignments->getConflicts($exam['request_id'], $seat['seat_id'], $exam['official_evaluation_starttime'], $exam['official_evaluation_endtime']);
                 $examAccs = $model->getExamAccommodationsById($exam['request_id']);
                 $seatAccs = $seatManagement->getSeatAccommodations($seat['seat_id']);
                 //case where the seat is suitable, increment statistical values, assign this exam to the seat, and generate a log entry for the success
                 if (!$conflicts && $assignments->seatHasAccommodations($examAccs, $seatAccs)) {
                     $found = true;
                     $examsScheduled++;
                     $seatsAssigned++;
                     $assignments->assignSeat($exam['request_id'], $seat['seat_id']);
                     $logEntry = array('successful' => 1, 'exam_request_id' => $exam['request_id'], 'assigned_seat_id' => $seat['seat_id'], 'message_id' => '5');
                     $assignments->updateLog($logEntry);
                     break;
                 }
                 //otherwise store flags for the reason of failure
                 if (!$assignments->seatHasAccommodations($examAccs, $seatAccs)) {
                     $noAccommodations = true;
                 }
                 if ($conflicts) {