public function remove($curriculumID = null) { $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if (!$user->isStudent()) { redirect('Login/logout'); } $curriculum = new Curriculum_model(); if ($curriculum->loadPropertiesFromPrimaryKey($curriculumID)) { $user->removeCurriculum($curriculum); } redirect('Selectcurriculum/index'); }
public function student() { //Load the student mainpage if user is a student if (!isset($_SESSION['UserID'])) { redirect('Login/logout'); } $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if ($user->isStudent()) { $this->load->view('MainPages/student_main_page', array('user' => $user)); } else { index(); } }
public function index() { if (!isset($_SESSION['UserID'])) { redirect('Login/logout'); } //Create new user and load its data $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } //If user did not load, logout the session if (!$user->isStudent()) { redirect('Mainpage'); } //If not a student, redirect to mainpage $advisor = $user->getAdvisor(); $advisorName = $advisor->getName(); $data = array('user' => $user, 'advisor' => $advisor); $this->load->view('advisorInfo', $data); }
public function index() { error_reporting(E_ALL & ~E_WARNING & ~E_STRICT); $this->load->helper('url'); //$uid = $_SESSION['UserID']; /*if (!isset($_SESSION['UserID'])) { redirect('login'); }*/ $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if ($user->isStudent()) { $this->uid = $user->getUserID(); } else { if ($user->isAdvisor()) { if ($this->uri->segment(3)) { $this->uid = $this->uri->segment(3); } else { if ($_SESSION['StudCWID']) { $this->uid = $_SESSION['StudCWID']; } else { redirect('Login'); } } } else { redirect('Login'); } } $_SESSION['StudCWID'] = $this->uid; // $uid = 10210078; //$year = 2015; $prev_form = $this->loadAdvisingForm($this->uid); /*if (isset($_SESSION['StudentFormUID'])) { $prev_form = $this->loadAdvisingForm($_SESSION['StudentFormUID']); } else { $prev_form = $this->loadAdvisingForm($_SESSION['UserID']); }*/ //Get course list for student //First, get all courses for current quarter, set now to 'NAME_SPRING' $quarter = academic_quarter_model::NAME_SPRING; $aqm = academic_quarter_model::getLatestAcademicQuarter(); //$aqm = new academic_quarter_model(); //$aqm->loadPropertiesFromNameAndYear($quarter, $year); $qid = $aqm->getAcademicQuarterID(); $course_sections = $aqm->getAllCourseSections(); //Next, load the current user and get his courses taken $usermod = new user_model(); $usermod->loadPropertiesFromPrimaryKey($this->uid); $courseids = array(); //Get all of the course IDs for courses in the student's curricula $curricula = $usermod->getCurriculums(); foreach ($curricula as $curriculum) { $slots = $curriculum->getCurriculumCourseSlots(); foreach ($slots as $slot) { $validIDs = $slot->getValidCourseIDs(); foreach ($validIDs as $cor) { if (!in_array($cor, $courseids)) { array_push($courseids, $cor); } } } } //Now, remove each course section that does not fit into the student's curricula foreach ($course_sections as $key => $value) { if (!in_array($value->getCourse()->getCourseID(), $courseids)) { unset($course_sections[$key]); } } //Then, we can remove courses whose prerequisites are not met $courseIDs_passed = array(); foreach ($course_sections as $key => $value) { $prereqs = $value->getCourse()->getPrerequisiteCourses(); if (count($prereqs) != 0) { $sig_required = true; foreach ($prereqs as $prereq) { if (array_search($prereq->getCourseID(), $courseIDs_passed) == true) { $sig_required = false; break; } } if ($sig_required) { unset($course_sections[$key]); } } } $courses_taken = $usermod->getAllCoursesTaken(); if (!empty($courses_taken)) { //Populate an array of course IDs for which the course was passed by the student foreach ($courses_taken as $key => $value) { if (!empty($value)) { if (!empty($value[0]->getCourse()->getAllCurriculumCourseSlots())) { $min_grade = $value[0]->getCourse()->getAllCurriculumCourseSlots()[0]->getMinimumGrade(); switch ($min_grade) { case 4: $min_grade = 'A'; break; case 3: $min_grade = 'B'; break; case 2: $min_grade = 'C'; break; case 1: $min_grade = 'D'; break; default: $min_grade = 'ZZZZZZ'; break; } if ($usermod->getGradeForCourseSection($value[0]) <= $min_grade) { array_push($courseIDs_passed, $value[0]->getCourse()->getCourseID()); } } } } } foreach ($course_sections as $key => $value) { if (in_array($value->getCourse()->getCourseID(), $courseIDs_passed)) { unset($course_sections[$key]); } } //Now, we should have a complete list of course sections that are eligible //as well as available $working_list = $this->get_list($course_sections); $course_sections = $aqm->getAllCourseSections(); $full_list = $this->get_list($course_sections); //Container holding course sections for courses already passed //$courseSections_passed = array(); //At this point, the available course sections will be whittled down //based on what courses have already been taken. First, the classes //already completed will be extracted /*foreach($course_sections as $key => $value) { //We've already gotten an array of passed courses. Now we must remove //all sections whose course ID matches a passed one if (in_array($value->getCourse()->getCourseID(), $courseIDs_passed)) { array_push($courseSections_passed, $value); unset($course_sections[$key]); } }*/ //Now, what we need is classes that can be taken. To that end, we will //pull all of the course sections for a quarter and unset and move those //classes whose prerequisites are not met to a signature_required array //First, the array which will hold all course sections where signatures //are required (prerequisites not met) must be declared //$signature_required = array(); //Now, parse through and selectively move sig_required courses /*foreach($course_sections as $key => $value) { $prereqs = $value->getCourse()->getPrerequisiteCourses(); if (count($prereqs) != 0) { $sig_required = true; foreach($prereqs as $prereq) { if (array_search($prereq->getCourseID(), $courseIDs_passed) == true) { $sig_required = false; break; } } if ($sig_required) { array_push($signature_required, $value); unset($course_sections[$key]); } } }*/ //Now, we have a three lists of course sections. One, $courseSections_passed, //contains all course sections for courses offered this quarter that the //student has passed in the past //The second, $signature_required, contains all course sections for which the //prerequisites are not met. For the student to take these courses, //a signature will have to be procured //The third and final array, $course_sections, contains only those sections for //courses that don't fall into the previous two categories. Essentially, they //would be higher priority courses than the others. //At this point, we need to sort each array by subject, then by number, //then by section. //$working_list = $this->get_list($signature_required, $courseSections_passed, $course_sections); //$name_arr = array('Recommended', 'Passed', 'Signature'); //$index = 0; /*foreach ($working_list as $cat) { $name = $name_arr[$index]; $index = $index + 1; foreach($cat as $subj) { foreach($subj as $course) { foreach($course as $sec) { echo $name . "\n" . $sec->getCourse()->getCourseName() . "\n" . $sec->getCourse()->getCourseNumber() . "\n" . $sec->getSectionName() . "\n"; } } } }*/ /*foreach ($working_list as $cat) { echo $cat->getName() . "\n" . $cat->getSubjects()[0]->getName() . "\n" . $cat->getSubjects()[0]->getCourses()[0]->getName() . "\n" . $cat->getSubjects()[0]->getCourses()[0]->getSections()[0]->getSectionName() . "\n"; }*/ /*foreach($working_list['Recommended']->getSubjects() as $subj) { foreach ($subj->getCourses() as $crs) { foreach($crs->getSections() as $sec) { echo $subj->getName() . "\n" . $crs->getName() . "\n" . $sec->getSectionName() . "\n"; } } }*/ $data = array('recommended' => $working_list, 'all_courses' => $full_list, 'quarter_id' => $qid, 'cwid' => $usermod->getUserID(), 'student_name' => $usermod->getName(), 'form' => $prev_form, 'user' => $user); $this->load->view('advising_view', $data); }
public function fill() { $User_model = new User_model(); //All this reiteration is temporary until integrated with the website. in which I will use the $_SESSION data $User_model->loadPropertiesFromPrimaryKey($_SESSION['UserID']); $Advising_schedule = new Advising_schedule_model(); $Advising_appointment = new Advising_appointment_model(); $quarter = Academic_quarter_model::getLatestAcademicQuarter(); $quarter = $quarter->getAcademicQuarterID(); if ($User_model->isStudent()) { $getAdvisor = $User_model->getAdvisor(); $getAdvisor = $getAdvisor->getUserID(); $Advising_schedule->loadPropertiesFromAdvisorIDAndAcademicQuarterID($getAdvisor, $quarter); //load the scedule that corresponds to the students advisor and the acedemic quarter $all_Appointments = $Advising_schedule->getAllAdvisingAppointments(); if (!empty($_POST['student_selection'])) { foreach ($all_Appointments as $selected) { if ($selected->getScheduledStudentUserID() == $_SESSION['UserID'] && $selected->isScheduled()) { $_POST['student_selection'] = 0; } } $aptTime = explode("-", $_POST['student_selection']); //separate the start and end times foreach ($all_Appointments as $selected) { if ($selected->getStartTime() == $aptTime[0] && !$selected->isScheduled()) { $Advising_appointment->loadPropertiesFromPrimaryKey($selected->getAdvisingAppointmentID()); //load the specific appointment from the ID $Advising_appointment->setStudentUserID($_SESSION['UserID']); //set the scheduled student user ID $Advising_appointment->setAdvisingAppointmentState(1); $Advising_appointment->update(); //update the advising appointment with above information it is now marked as shceduled } } } elseif (!empty($_POST['My_Schedule'])) { redirect('Appointment_controller/Student_Cancel'); } } else { if ($User_model->isAdvisor()) { $Advising_schedule->loadPropertiesFromAdvisorIDAndAcademicQuarterID($User_model->getUserID(), $quarter); //load the schedule that corresponds to this advisor and this academic quarter $all_Appointments = $Advising_schedule->getAllAdvisingAppointments(); if (!empty($_POST['appointments'])) { foreach ($_POST['appointments'] as $selected) { $aptTime = explode("-", $selected); //separate the start and end times $Advising_appointment->setAdvisingScheduleID($Advising_schedule->getAdvisingScheduleID()); $Advising_appointment->setStartTime($aptTime[0]); //push start time to the database $Advising_appointment->setEndTime($aptTime[1]); //push the end time to the database $Advising_appointment->create(); //create the advising appointment with above information } } if (!empty($_POST['Open'])) { foreach ($_POST['Open'] as $open) { $aptTime = explode("-", $open); //separate the start and end times foreach ($all_Appointments as $selected) { if ($selected->getStartTime() == $aptTime[0]) { $selected->loadPropertiesFromPrimaryKey($selected->getAdvisingAppointmentID()); $selected->delete(); } } } } if (!empty($_POST['student_scheduled'])) { foreach ($_POST['student_scheduled'] as $slot) { $aptTime = explode("-", $slot); //separate the start and end times foreach ($all_Appointments as $selected) { if ($selected->getStartTime() == $aptTime[0]) { $selected->setAdvisingAppointmentID($selected->getAdvisingAppointmentID()); $selected->setAdvisingAppointmentState(4); $selected->update(); //EMAIL THE STUDENT THAT THE APPOINTMENT WAS CANCELED } } } } } } redirect('appointment_controller'); }
/** * * @param int $uID ID of user to be modified, if this is null a new user should be created. */ public function submitUserForm($uID = NULL) { $this->checkSec(); $userData = array(); $userData['uID'] = $this->input->post('userID'); $userData['email'] = $this->input->post('email'); $userData['fName'] = $this->input->post('fName'); $userData['mName'] = $this->input->post('mName'); $userData['lName'] = $this->input->post('lName'); $userData['pass'] = $this->input->post('pass'); $userData['confPass'] = $this->input->post('confPass'); $roles = array(); for ($i = 1; $i <= 4; $i++) { if ($this->input->post(strval($i)) != NULL) { $roles[$i] = true; } else { $roles[$i] = false; } } $userData['roles'] = $roles; switch ($_SESSION['action']) { case 'create': $userData['uID'] = $this->createUserData($userData); break; case 'modify': $this->saveUserData($userData); break; case 'remove': $this->removeUser($uID); return; } //If the user is selected to have student role //assign an advisor and fill courses taken. $selectedUser = new User_model(); $selectedUser->loadPropertiesFromPrimaryKey($userData['uID']); if ($selectedUser->isStudent()) { $userData['studentCurriculums'] = array(); $this->load->view('student_info_form', $userData); } else { redirect('User/index'); } }