Пример #1
0
 public static function addCourse($tutorId, $teachingCoursesId, $termId)
 {
     foreach ($teachingCoursesId as $courseId) {
         Course::validateId($courseId);
         if (Tutor::teachesCourseWithIdOnTerm($courseId, $tutorId, $termId)) {
             throw new Exception("Tutor already teaches a course with id {$courseId}");
         }
     }
     Term::validateId($termId);
     Tutor_has_course_has_schedule::addCourses($tutorId, $teachingCoursesId, $termId);
 }
 public static function validateCoursesId($coursesId)
 {
     foreach ($coursesId as $courseId) {
         Course::validateId($courseId);
     }
 }
Пример #3
0
 public static function getTutorsOnTermOnCourse($courseId, $termId)
 {
     Course::validateId($courseId);
     Term::validateId($termId);
     return ScheduleFetcher::retrieveTutorsOnTermOnCourse($courseId, $termId);
 }
Пример #4
0
 public static function getPendingAppointmentsWithCourseAndTutor($tutorId, $courseId, $termId)
 {
     Course::validateId($courseId);
     Term::validateId($termId);
     $appointmentHours = AppointmentFetcher::getPendingAppointmentsWithCourseAndTutor($tutorId, $courseId, $termId);
     $appointmentHoursJSON = [];
     foreach ($appointmentHours as $appointmentHour) {
         $appointmentTitle = $appointmentHour[CourseFetcher::DB_COLUMN_CODE] . " - " . $appointmentHour[UserFetcher::DB_COLUMN_FIRST_NAME] . " " . $appointmentHour[UserFetcher::DB_COLUMN_LAST_NAME];
         $students = AppointmentHasStudentFetcher::retrieveStudentsWithAppointment($appointmentHour[AppointmentFetcher::DB_COLUMN_ID]);
         $appointmentTitle .= " - ";
         foreach ($students as $student) {
             $appointmentTitle .= $student[StudentFetcher::DB_TABLE . "_" . StudentFetcher::DB_COLUMN_FIRST_NAME] . " " . $student[StudentFetcher::DB_TABLE . "_" . StudentFetcher::DB_COLUMN_LAST_NAME] . ", ";
         }
         $appointmentTitle = rtrim($appointmentTitle, ", ");
         $startDate = new DateTime($appointmentHour[AppointmentFetcher::DB_COLUMN_START_TIME]);
         $endDate = new DateTime($appointmentHour[AppointmentFetcher::DB_COLUMN_END_TIME]);
         $appointmentUrl = App::getDomainName() . "/appointments/" . $appointmentHour[UserFetcher::DB_COLUMN_ID];
         switch ($appointmentHour[AppointmentFetcher::DB_COLUMN_LABEL_COLOR]) {
             case Appointment::LABEL_COLOR_PENDING:
                 $color = '#888888';
                 break;
             case Appointment::LABEL_COLOR_CANCELED:
                 $color = '#e5412d';
                 break;
             case Appointment::LABEL_COLOR_SUCCESS:
                 $color = '#3fa67a';
                 break;
             case Appointment::LABEL_COLOR_WARNING:
                 $color = '#f0ad4e';
                 break;
             default:
                 $color = '#444';
                 break;
         }
         $appointmentHoursJSON[] = ['title' => $appointmentTitle, 'start' => $startDate->format('Y-m-d H:i:s'), 'end' => $endDate->format('Y-m-d H:i:s'), 'allDay' => false, 'url' => $appointmentUrl, 'color' => $color];
     }
     return json_encode($appointmentHoursJSON);
 }