/** * Determines the last day of the term * @param int $next Whether to get the day for the next term. Defaults to FALSE * @return \DateTime */ public function determineEndOfTerm($next = false) { $term = \Ventus\Utilities\Functions::fetchSemester(); // Taking the start date of the term following and subtracting one day $key = $next ? 'next1_short' : 'next_short'; return \DateTime::createFromFormat('Yn-d H:i:s', "{$term[$key]}-01 23:59:59")->modify('-1 day'); }
/** * Verify that the client isn't trying to breach the system by injecting items that apply to past semester and years * @param array $data containing student number, course code, session and possibly course section * @return boolean */ public function verifyRequestIsValid(array $data) { //Because client side checking isn't enough- if the semester is < current semester, reject the request $current_semester = \Ventus\Utilities\Functions::fetchSemester(); $current_semester = $current_semester['now_short']; $current_session = (int) substr($current_semester, -1); $current_year = (int) substr($current_semester, 0, 4); $course_session = (int) substr($data['session'], -1); $course_year = (int) substr($data['session'], 0, 4); //Reject anything that applies to < this year OR applies to this year but < the current session if ($course_year < $current_year || $course_year === $current_year && $course_session < $current_session) { return false; } return true; }
/** * For a given semester, indicate whether it belongs in the past(-1), present(0) or future(1) * @param string $session The semester * @return int */ public function fetchSessionStatus($session) { if (!ctype_digit($session)) { throw new \InvalidArgumentException("Session specified is not numeric…"); } $year = substr($session, 0, 4); $semester = substr($session, -1); $current_session = \Ventus\Utilities\Functions::fetchSemester(); $current_session = $current_session['now_short']; $current_year = substr($current_session, 0, 4); $current_semester = substr($current_session, -1); //If the sessions match, things are easy if ($session === $current_session) { return 0; } else { if ($year > $current_year) { return 1; } else { if ($year < $current_year) { return -1; } else { //If the current semester is the first one of the year, everything else in the same year will be in the future if ($current_semester === "1") { return 1; } //If the current semester is the middle one of the year, the current course could be in the past or the future if ($current_semester === "5") { if ($semester === "1") { return -1; } else { if ($semester === "9") { return 1; } } } else { if ($current_semester === "9") { return -1; } } } } } }
$bursary = new Bursaries($dbo); $follow = new FollowUps($dbo); $courses = new Courses($dbo); if (isset($_GET['student_num']) && ctype_digit($_GET['student_num'])) { $studentProfile = $profile->getProfile($_GET['student_num']); } //============================================================================================ // Load the content //============================================================================================ if (!isset($_GET['page'])) { $render = true; if (!empty($studentProfile)) { $thisPage = 'fund'; $followupcount = $follow->fetchFollowUpsCountStudent($_GET['student_num']); $poccount = $profile->countUnlockedPOC($_GET['student_num']); $semester = \Ventus\Utilities\Functions::fetchSemester(); $current_courses = $courses->fetchAllStudentCoursesForSemester($_GET['student_num'], $semester['now_short']); $osap = $bursary->listOsapBursaries($_GET['student_num']); $other = $bursary->listOtherBursaries($_GET['student_num']); $bswd = $bursary->listBswdBursaries($_GET['student_num']); $quebec = $bursary->listQuebecBursaries($_GET['student_num']); $uo = $bursary->listUOBursaries($_GET['student_num']); $l10n->addResource(__DIR__ . '/l10n/bursaries.json'); $viewFile = 'views/bursaries.php'; } } elseif ($_GET['page'] === "add") { $last_added = $bursary->addBursary($_POST); $loggers['audit']->info("Bursary added"); echo $last_added; } elseif ($_GET['page'] === "getosap") { $osapdata = $bursary->getOsapBursary($_POST['id']);
/** * search student by Hash Code * @param string $date The datetime survey email sent on * @return bool */ public function checkSessionExpire($date) { $semester = \Ventus\Utilities\Functions::fetchSemester(); $survey_end = \DateTime::createFromFormat(DATETIME_MYSQL, $semester['session_start'])->modify('+' . SURVEY_EXPIRY_DAYS . 'day'); return $survey_end < new \DateTime(); }
/** * Activative students who have valid disability, active accommodation, and enroll in at least one class during the current fiscal year */ public final function activateAccessStudent() { // get current fiscal year $fiscal = \Ventus\Utilities\Functions::calcFiscalYearDate(); $fiscal_start = $fiscal[0]['start_date']->format(DATETIME_MYSQL); $fiscal_end = $fiscal[0]['end_date']->format(DATETIME_MYSQL); // get semesters based on the begining of the fiscal year $semester = \Ventus\Utilities\Functions::fetchSemester($fiscal_start); /** The following query get a list of access students under the following conditions: 1. Must have a disability 2. Must have an accommodation active during the current fiscal year 3. Must register in a course during the current fiscal year OR it may have an exam at Access service during the current fiscal year 4. Registered course must not be opted-out 5. Access student must create an active student portal account */ $sql = "SELECT DISTINCT vs.student_num, vs.access_profile_status\n FROM ventus_students vs\n JOIN ventus_student_disabilities vsd\n ON vs.student_num = vsd.student_num\n JOIN ventus_student_accommodations vsa\n ON vs.student_num = vsa.student_num\n LEFT JOIN ventus_student_accommodations_exceptions vsae\n ON vs.student_num = vsae.student_num\n LEFT JOIN ventus_exam_requests ver\n ON vs.student_num = ver.student_num\n LEFT JOIN ventus_professor_exam_requests vper\n ON ver.professor_exam_request_id = vper.exam_request_id\n JOIN org_student_course_classes oscc\n ON vs.student_num = oscc.student_id\n JOIN org_course_classes occ\n ON oscc.class_id = occ.class_id\n JOIN org_courses oc\n ON occ.course_id = oc.course_id\n AND (oc.session IN (:summer, :fall, :winter)\n OR (oc.session = vper.session \n AND oc.section = vper.course_section \n AND oc.code = vper.course_code \n AND ver.official_evaluation_starttime BETWEEN date(:fiscal_start6) AND date(:fiscal_end6)))\n LEFT JOIN ventus_students_courses_no_accommodations vscna\n ON vs.student_num = vscna.student_num\n AND vscna.course_code = oc.code\n AND vscna.course_section = oc.section\n AND vscna.session = oc.session\n WHERE vs.access_profile_activated_by_student = 1\n AND vscna.opt_out_id IS NULL\n AND ((date(vsa.effective_on) BETWEEN date(:fiscal_start) AND date(:fiscal_end) OR date(vsa.expires_on) BETWEEN date(:fiscal_start1) AND date(:fiscal_end1))\n OR (date(vsae.effective_on) BETWEEN date(:fiscal_start2) AND date(:fiscal_end2) OR date(vsae.expires_on) BETWEEN date(:fiscal_start3) AND date(:fiscal_end3))\n OR (date(vsa.effective_on) < date(:fiscal_start4) AND date(vsa.expires_on) > NOW())\n OR (date(vsae.effective_on) < date(:fiscal_start5) AND date(vsae.expires_on) > NOW()));"; $this->deactivateAccessStudent($fiscal, $semester, $sql); // re/activate access students that have disability/accommodations/registered in a course $students = $this->db->query($sql, array('summer' => $semester['now_short'], 'fall' => $semester['next_short'], 'winter' => $semester['next1_short'], 'fiscal_start' => $fiscal_start, 'fiscal_end' => $fiscal_end, 'fiscal_start1' => $fiscal_start, 'fiscal_end1' => $fiscal_end, 'fiscal_start2' => $fiscal_start, 'fiscal_end2' => $fiscal_end, 'fiscal_start3' => $fiscal_start, 'fiscal_end3' => $fiscal_end, 'fiscal_start4' => $fiscal_start, 'fiscal_start5' => $fiscal_start, 'fiscal_start6' => $fiscal_start, 'fiscal_end6' => $fiscal_end))->fetchAll(\PDO::FETCH_COLUMN); $activateSql = "UPDATE ventus_students\n SET access_profile_status = 'active', updated_on = NOW()\n WHERE student_num IN (" . implode(',', array_fill(0, sizeof($students), '?')) . ");"; $this->db->query($activateSql, $students); }
// Model and Header and L10N Includes, Authentication //============================================================================================ $model = new Questionnaire($dbo); require FS_INCLUDES . '/l10n/header-external.php'; //============================================================================================ // Load the content //============================================================================================ if (!isset($_GET['user']) || !$model->checkUserExists($_GET['user'])) { $l10n->addResource(__DIR__ . '/l10n/error.json'); require_once FS_PHP . '/header-external.php'; require_once 'views/error.php'; require_once FS_PHP . '/footer-external.php'; } else { $user = $_GET['user']; $student = $model->fetchStudentByHashCode($user); $session = \Ventus\Utilities\Functions::fetchSemester($student['0']['survey_sent_on']); if ($model->checkSessionExpire($student['0']['survey_sent_on'])) { if ($model->checkOtherSurvey($_GET['user'])) { $newQues = $model->fetchOtherSurvey($_GET['user']); } $l10n->addResource(__DIR__ . '/l10n/questionnaire_expire.json'); $l10n->localizeArray($session, 'transcription_session'); $l10n->localizeArray($student[0], 'transcription_service'); $l10n->localizeArray($newQues[0], 'transcription_service'); require_once FS_PHP . '/header-external.php'; require_once 'views/questionnaire_expire.php'; require_once FS_PHP . '/footer-external.php'; } else { $general = $model->listGeneralQuestionnaire(); $particular = $model->listParticularQuestionnaire($student['0']['survey_sent_on_service_id']); if (!isset($_GET['page'])) {
/** * add single student into student-list * @param int $number the student number * @param string $date the day student went to SASS * @param int $id the service id * @return int */ private function addSingleStudentToList($number, $date, $id) { $term = \Ventus\Utilities\Functions::fetchSemester($date); $data = array('student_number' => $number, 'cron_logged' => 0, 'survey_sent_on' => $date, 'email_link' => $this->generateHashCode($number . $term['session_code'] . $id), 'survey_sent_on_service_id' => $id, 'completed' => 0, 'completed_on' => NULL, 'updated_on' => NULL); $this->db->insert('ventus_survey_student_list', $data); return $this->db->lastInsertId(); }
/** * Fetch students whose professor need to receive CAM * @return array */ public function fetchStudentsWhoseProfessorsNeedCam() { $semester = \Ventus\Utilities\Functions::fetchSemester(); $sql = "SELECT DISTINCT s.student_num, o.email, o.year_of_study\n FROM ventus_students s\n JOIN org_students o\n ON o.student_id = s.student_num\n JOIN ventus_student_accommodations va\n ON s.student_num = va.student_num\n WHERE ((s.access_email_permission = 1 AND o.year_of_study NOT IN (1,2,3,4,''))\n OR (s.access_email_permission = 1 OR s.access_email_permission = 0 AND o.year_of_study IN (1,2,3,4,'')))\n AND (s.access_profile_activated_by_student = 1 OR s.access_profile_status = 'active')\n AND (access_cam_letter_sent_on IS NULL OR access_cam_letter_sent_on < :last_cam_sent)\n AND (va.effective_on BETWEEN :session_start AND :session_end\n OR va.expires_on > :session_start2);"; return $this->db->query($sql, array('last_cam_sent' => PROFESSOR_SEND_CAM_TO_THOSE_LAST_RECEIVED_BEFORE, 'session_start' => $semester['session_start'], 'session_end' => $semester['session_end'], 'session_start2' => $semester['session_start']))->fetchAll(); }