Example #1
0
 /**
  * Sends faculty members an email for missing exams
  */
 public final function missingExamEmailReminders()
 {
     $model = new \Ventus\Faculty\Faculty();
     $range = $this->getExamDateRange(time());
     $rangeStart = $range['start'];
     $rangeEnd = $range['end'];
     // Get all exams that do not have files
     $sql = "SELECT CONCAT_WS('', r.course_code, course_section) AS course_code_section,\n                       GROUP_CONCAT(DISTINCT CONCAT(cc.professor_last_name, ', ', cc.professor_first_name) SEPARATOR ' | ') AS prof\n                  FROM ventus_professor_exam_requests r\n             LEFT JOIN org_courses c\n                    ON (r.course_code = c.code AND r.course_section = c.section AND r.session = c.session)\n             LEFT JOIN org_course_classes cc\n                    ON (c.course_id = cc.course_id AND r.teach_method = cc.teaching_method)\n                 WHERE r.exam_request_id NOT IN (\n                SELECT request_id\n                  FROM ventus_faculty_files\n                       )\n                   AND r.exam_request_id IN (\n                SELECT professor_exam_request_id\n                  FROM ventus_exam_requests\n                 WHERE is_cancelled = 0\n                       )\n                   AND r.exam_date BETWEEN :start AND :end\n                   AND r.faculty_cron_logged = 0\n                   AND r.deleted = 0\n                   AND r.is_confirmed = 1\n              GROUP BY r.exam_request_id, c.course_id;";
     $exams = $this->db->query($sql, array('start' => $rangeStart->format(DATETIME_MYSQL), 'end' => $rangeEnd->format(DATETIME_MYSQL)))->fetchAll();
     foreach ($exams as $e) {
         // Check permissions
         $users = $model->fetchUsersWithPermission($e['course_code_section'], true);
         $emails = array();
         foreach ($users as $u) {
             $emails[] = $u['email'];
         }
         if (!empty($emails)) {
             $html = parent::fetchEmailContent(FS_FACULTY . '/emails/missing-exams-reminder.php', $this->db->pick(array('course_code_section', 'prof'), $e));
             $message = \Swift_Message::newInstance('Examens en attente / Pending exams')->setFrom(EMAIL_ALIAS_ACCESS_SERVICE_EXAMS . EMAIL_ORG_STAFF_DOMAIN)->setTo($emails)->setCc(EMAIL_ALIAS_ACCESS_SERVICE_EXAMS . EMAIL_ORG_STAFF_DOMAIN)->setBcc(EMAIL_ALIAS_ACCESS_SERVICE_VENTUS_COMMUNICATION . EMAIL_ORG_STAFF_DOMAIN);
             parent::sendEmail($message, $html);
         }
     }
     // Update faculty_cron_logged
     $uSql = "UPDATE ventus_professor_exam_requests\n                    SET faculty_cron_logged = 1\n                  WHERE exam_request_id NOT IN (\n                 SELECT request_id\n                   FROM ventus_faculty_files\n                        )\n                    AND exam_date BETWEEN :start AND :end;";
     $this->db->query($uSql, array('start' => $rangeStart->format(DATETIME_MYSQL), 'end' => $rangeEnd->format(DATETIME_MYSQL)));
 }
Example #2
0
 /**
  * Inform those responsible for the course that a paper copy has been received
  * @param int $request_id The exam request ID
  */
 public function notifyDocumentReceived($request_id)
 {
     if (!ctype_digit($request_id) && !is_int($request_id)) {
         throw new \InvalidArgumentException("Invalid exam request ID");
     }
     $sql = "SELECT p.exam_duration, p.course_code, p.course_section, p.teach_method, p.exam_date\n                  FROM ventus_professor_exam_requests p\n                  JOIN ventus_exam_requests r\n                    ON p.exam_request_id = r.professor_exam_request_id\n                 WHERE r.request_id = :request_id;";
     $request_details = $this->db->query($sql, array('request_id' => $request_id))->fetch();
     if (!empty($request_details)) {
         $to = array();
         // Check against these factors for faculty user permissions
         $facultyModel = new \Ventus\Faculty\Faculty();
         $users = $facultyModel->fetchUsersWithPermission($request_details['course_code'] . $request_details['course_section'], true);
         foreach ($users as $u) {
             $to[] = $u['email'];
         }
         if (!empty($to)) {
             $html = parent::fetchEmailContent(FS_EXAMS . '/emails/documents-received.php', $request_details);
             $message = \Swift_Message::newInstance("Copie papier reçu / Hard copy received ({$request_details['course_code']} {$request_details['course_code']} {$request_details['course_section']} - " . date('Y-m-d', strtotime($request_details['exam_date'])) . ')')->setFrom(EMAIL_ALIAS_ACCESS_SERVICE_EXAMS . EMAIL_ORG_STAFF_DOMAIN)->setTo($to)->setBcc(EMAIL_ALIAS_ACCESS_SERVICE_VENTUS_COMMUNICATION . EMAIL_ORG_STAFF_DOMAIN);
             parent::sendEmail($message, $html);
         }
     }
 }