Esempio n. 1
0
 public function index($advisorUserID = "all", $studentUserID = "all", $advisingLogEntryType = "all")
 {
     $user = new User_model();
     if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) {
         redirect('Login/logout');
     }
     if (!$user->isProgramChair() && !$user->isAdvisor()) {
         redirect('Login/logout');
     }
     if ($advisingLogEntryType === "all") {
         $advisingLogEntryType = null;
     }
     if ($advisorUserID === "all") {
         $advisorUserID = null;
     }
     if ($user->isAdvisor() && !$user->isProgramChair() && ($advisorUserID == null || $advisorUserID != $user->getUserID())) {
         $advisorUserID = $user->getUserID();
     }
     if ($studentUserID === "all") {
         $studentUserID = null;
     }
     $advisors = $user->isProgramChair() ? User_model::getAllAdvisors() : array($user);
     $students = $user->isProgramChair() ? array() : $user->getAdvisees();
     $types = Advising_log_entry_model::getAllAdvisingLogEntryTypes();
     $data = array('user' => $user, 'logEntries' => Advising_log_entry_model::getAllAdvisingLogEntries($advisorUserID, $studentUserID, $advisingLogEntryType), 'advisors' => $advisors, 'students' => $students, 'types' => $types, 'advisorUserID' => $advisorUserID == null ? "all" : $advisorUserID, 'studentUserID' => $studentUserID == null ? "all" : $studentUserID, 'advisingLogEntryType' => $advisingLogEntryType == null ? "all" : $advisingLogEntryType);
     $this->load->view('advisinglog_index_view', $data);
 }
Esempio n. 2
0
 public function index()
 {
     $user = new User_model();
     if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) {
         redirect('Login/logout');
     }
     if (!$user->isAdvisor()) {
         redirect('Login/logout');
     }
     $data = array("user" => $user);
     $this->load->view('view_advisees', $data);
 }
Esempio n. 3
0
 public function advisor()
 {
     //Load the advisor mainpage if user is an advisor
     if (!isset($_SESSION['UserID'])) {
         redirect('Login/logout');
     }
     $user = new User_model();
     if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) {
         redirect('Login/logout');
     }
     if ($user->isAdvisor()) {
         $this->load->view('MainPages/advisor_main_page', array('user' => $user));
     } else {
         index();
     }
 }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
 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');
 }
Esempio n. 6
0
 public function send($userID = NULL, $email = NULL)
 {
     $session_user = new User_model();
     if (!$session_user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) {
         redirect('Login/logout');
     }
     if (!$session_user->isAdvisor()) {
         redirect('Login/logout');
     }
     $this->load->library('email');
     $user = new User_model();
     $user->loadPropertiesFromPrimaryKey($userID);
     if ($user->getAdvisor()->getUserID() != $session_user->getUserID()) {
         redirect('Login/logout');
     }
     //Loads user's email if optional email wasn't set
     if ($email == NULL) {
         $email = $user->getEmailAddress();
     }
     //Array of characters to generate password
     $charset = array('!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '~', '=', '+', '_', '-', '?', '/', '>', '<', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'w', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'W', 'Z');
     //Generate random password
     $passlen = mt_rand(8, 12);
     $pass = NULL;
     for ($i = 0; $i < $passlen; $i++) {
         $pass = $pass . $charset[mt_rand(0, count($charset) - 1)];
     }
     //Set user password
     //Email user their login information
     $this->email->from('*****@*****.**', 'Admin Name');
     $this->email->to('*****@*****.**');
     $this->email->subject('Subject');
     $this->email->message('Password: '******'Username: '******'headers', 'subject', 'body'));
     $user->setPassword($pass);
     //Email user their login information
     $this->load->library('email');
     $config['protocol'] = 'smtp';
     $config['smpt_crypt'] = 'ssl';
     $config['smtp_host'] = 'ssl://smtp.gmail.com';
     $config['smtp_port'] = '465';
     $config['smtp_user'] = '******';
     $config['smtp_pass'] = '******';
     $config['mailtype'] = 'html';
     $config['charset'] = 'utf-8';
     $config['newline'] = "\r\n";
     $config['validate'] = FALSE;
     $config['bcc_batch_mode'] = FALSE;
     $config['bcc_batch_size'] = 200;
     $this->email->initialize($config);
     $this->email->from('*****@*****.**', 'Senior');
     $list = array('*****@*****.**');
     $this->email->to($list);
     $this->email->reply_to('*****@*****.**', 'Senior');
     $this->email->subject('Subject');
     $this->email->message('Email works great!');
     if ($user->update() && $this->email->send()) {
         $_SESSION['activation.message'] = "Success!";
     } else {
         $_SESSION['activation.error'] = "Sending email failed!<br />" . $this->email->print_debugger();
     }
     redirect('Activation/index');
 }
Esempio n. 7
0
 /**
  * Summary of setAdvisor
  * Set the advisor to be associated with this student user model
  * 
  * @param User_model $advisor A user model that has the role of advisor
  * @return booelan True if the advisor was successfully associated with the student in the database, false otherwise
  */
 public function setAdvisor($advisor)
 {
     if ($this->userID != null && $this->isStudent() && $advisor->getUserID() != null && $advisor->isAdvisor()) {
         $this->db->where('StudentUserID', $this->userID);
         $this->db->delete('StudentAdvisors');
         $data = array('StudentUserID' => $this->userID, 'AdvisorUserID' => $advisor->getUserID());
         $this->db->insert('StudentAdvisors', $data);
         return $this->db->affected_rows() > 0;
     }
     return false;
 }