Ejemplo n.º 1
0
 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');
 }
Ejemplo n.º 2
0
 /**
  * Summary of getAllCurriculums
  * Get all the curriculums stored in the database
  * 
  * @return array An array of all the curriculum models currently stored in the database
  */
 public static function getAllCurriculums()
 {
     $db = get_instance()->db;
     $data = array();
     $db->select('CurriculumID');
     $db->from('Curriculums');
     $results = $db->get();
     foreach ($results->result_array() as $row) {
         $model = new Curriculum_model();
         $model->loadPropertiesFromPrimaryKey($row['CurriculumID']);
         array_push($data, $model);
     }
     return $data;
 }
Ejemplo n.º 3
0
 private function loadCurriculumCourseSlotEdit($courseSlotIndex = NULL)
 {
     ///get arguments
     if ($courseSlotIndex == NULL) {
         $courseSlotIndex = $this->input->post('courseSlot');
     }
     $curriculum = new Curriculum_model();
     $curriculum->fromSerializedString($_SESSION['curriculum']);
     $courseSlots = $curriculum->getCurriculumCourseSlots();
     $courseSlot = new Curriculum_course_slot_model();
     //find selected course slot
     foreach ($courseSlots as $slot) {
         $index = $slot->getCurriculumIndex();
         if ($index == $courseSlotIndex) {
             //set values manually for clone so it doesn't copy courseSlotID
             if (strcmp($_SESSION['curriculumCourseSlotMethod'], "clone") == 0) {
                 $courseSlot->setMinimumGrade($slot->getMinimumGrade());
                 $courseSlot->setName($slot->getName());
                 $courseSlot->setRecommendedQuarter($slot->getRecommendedQuarter());
                 $courseSlot->setRecommendedYear($slot->getRecommendedYear());
                 $courseSlot->setNotes($slot->getNotes());
                 $courseSlot->setCurriculum($curriculum);
                 $courseSlot->setCurriculumIndex($slot->getCurriculumIndex());
                 $slotValids = $slot->getValidCourseIDs();
                 foreach ($slotValids as $valid) {
                     $courseSlot->addValidCourseID($valid);
                 }
             } else {
                 //copy entire slot for edit
                 $courseSlot = $slot;
             }
             break;
         }
     }
     //set the name to
     if ($courseSlot->getName() == NULL) {
         $courseSlot->setName("New Curriculum Course Slot");
     }
     $courses = new Course_model();
     //set default values for data array if it's a new slot
     if (strcmp($_SESSION['curriculumCourseSlotMethod'], "new") == 0) {
         $courseSlot = new Curriculum_course_slot_model();
         $data = array('name' => "New Curriculum Course Slot", 'courses' => array(), 'recommendedQuarter' => "Fall", 'recommendedYear' => "Freshman", 'minimumGrade' => "F", 'notes' => " ", 'index' => $courseSlotIndex, 'prereqs' => array(), 'coreqs' => array());
     } else {
         $data = array('name' => $courseSlot->getName(), 'courses' => array(), 'recommendedQuarter' => $courseSlot->getRecommendedQuarter(), 'recommendedYear' => $courseSlot->getRecommendedYear(), 'minimumGrade' => $courseSlot->getMinimumGrade(), 'notes' => $courseSlot->getNotes(), 'index' => $courseSlotIndex, 'prereqs' => array(), 'coreqs' => array());
     }
     //find if the co or pre reqs have been edited in this session
     $prereqsEdited = FALSE;
     $coreqsEdited = FALSE;
     if (!empty($_SESSION['reqs'])) {
         foreach ($_SESSION['reqs'] as $reqs) {
             foreach ($courseSlots as $slot) {
                 $reqsSlot = new Curriculum_course_slot_model();
                 $reqsSlot->fromSerializedString($reqs['slot']);
                 //find the right course slot
                 if ($slot->getCurriculumIndex() == $reqsSlot->getCurriculumIndex()) {
                     $prereqsEdited = TRUE;
                     $coreqsEdited = TRUE;
                 }
             }
         }
     }
     //Pass possible and chosen prereq slots
     $currentIndex = $courseSlot->getCurriculumIndex();
     $courseSlotIndex = $courseSlot->getCurriculumIndex();
     $slotPrereqs = $courseSlot->getPrequisiteCourseSlots();
     foreach ($courseSlots as $slot) {
         $arr = ['name' => $slot->getName(), 'id' => $slot->getCurriculumCourseSlotID(), 'index' => $slot->getCurriculumIndex(), 'selected' => FALSE];
         if (!$prereqsEdited) {
             //normal prereq functionality
             if (!empty($slotPrereqs)) {
                 foreach ($slotPrereqs as $prereq) {
                     if ($prereq->getCurriculumIndex() == $arr['index']) {
                         $arr['selected'] = TRUE;
                     }
                 }
             }
         } else {
             //grabbing prereqs from session
             $currReq = new Curriculum_course_slot_model();
             foreach ($_SESSION['reqs'] as $reqs) {
                 foreach ($reqs['prereqs'] as $preRekts) {
                     $currReq->fromSerializedString($preRekts);
                     if ($currReq->getCurriculumIndex() == $arr['index']) {
                         $arr['selected'] = TRUE;
                     }
                 }
             }
         }
         if ($currentIndex != $arr['index']) {
             array_push($data['prereqs'], $arr);
         }
     }
     //Pass possible and chosen coreq slots
     $slotCoreqs = $courseSlot->getCorequisiteCourseSlots();
     foreach ($courseSlots as $slot) {
         $arr = ['name' => $slot->getName(), 'id' => $slot->getCurriculumCourseSlotID(), 'index' => $slot->getCurriculumIndex(), 'selected' => FALSE];
         if (!$prereqsEdited) {
             //normal coreq functionality
             if (isset($slotCoreqs)) {
                 foreach ($slotCoreqs as $coreq) {
                     if ($coreq->getCurriculumIndex() == $arr['index']) {
                         $arr['selected'] = TRUE;
                     }
                 }
             }
         } else {
             //grabbing coreqs from session
             $currReq = new Curriculum_course_slot_model();
             foreach ($_SESSION['reqs'] as $reqs) {
                 foreach ($reqs['coreqs'] as $coRekts) {
                     $currReq->fromSerializedString($coRekts);
                     if ($currReq->getCurriculumIndex() == $arr['index']) {
                         $arr['selected'] = TRUE;
                     }
                 }
             }
         }
         if ($currentIndex != $arr['index']) {
             array_push($data['coreqs'], $arr);
         }
     }
     //get all available courses and pass to data
     $availableCourses = $courses->getAllCourses();
     $validCourse = $courseSlot->getValidCourseIDs();
     foreach ($availableCourses as $course) {
         $arr = ['name' => $course->getCourseName(), 'id' => $course->getCourseID(), 'prereqs' => $course->getPrerequisiteCourses(), 'number' => $course->getCourseNumber(), 'selected' => FALSE];
         foreach ($validCourse as $valid) {
             if (strcmp($valid, $course->getCourseID()) == 0) {
                 $arr['selected'] = TRUE;
             }
         }
         array_push($data['courses'], $arr);
     }
     $_SESSION['courseSlot'] = $courseSlot->toSerializedString();
     $this->load->view('course_slot_edit', array('data' => $data));
 }
 /**
  * Summary of setCurriculum
  * Set the curriculum for this curriculum course slot model to be associated with
  * 
  * @param Curriculum_model $curriculum The curriculum to associate with this model
  */
 public function setCurriculum($curriculum)
 {
     if ($curriculum->getCurriculumID() != null && filter_var($curriculum->getCurriculumID(), FILTER_VALIDATE_INT)) {
         $this->curriculumID = $curriculum->getCurriculumID();
     }
 }
Ejemplo n.º 5
0
 /**
  * Summary of getCurriculums
  * Get all of the curriculums that this user model is bound to
  *
  * @return Array An array containing all of the curriculum models this user is bound to
  */
 public function getCurriculums()
 {
     $models = array();
     $this->db->select('CurriculumID');
     $this->db->from('UserCurriculums');
     $this->db->where('UserID', $this->userID);
     $results = $this->db->get();
     if ($results->num_rows() > 0) {
         foreach ($results->result_array() as $row) {
             $model = new Curriculum_model();
             if ($model->loadPropertiesFromPrimaryKey($row['CurriculumID'])) {
                 array_push($models, $model);
             }
         }
     }
     return $models;
 }
Ejemplo n.º 6
0
 private function collectCourseData($curriculumID)
 {
     #get list of all curriculumcourseslots for names of courses
     $curriculum = new Curriculum_model();
     $curriculum->loadPropertiesFromPrimaryKey($curriculumID);
     $currCourseList = $curriculum->getCurriculumCourseSlots();
     #Courses list to grab courseIDs from courseName and course Number
     $course = new Course_model();
     $courseList = $course->getAllCourses();
     #Create a list of CourseIDs to reference courses
     $courseIDList = array();
     #loop through each currCourseListName and grab the matching courseID's
     #with matching CourseNames and CourseNumbers
     foreach ($currCourseList as $currCourse) {
         $currCourseName = $currCourse->getName();
         $nameLength = strlen($currCourseName);
         $cName = preg_split('%[0-9]%', $currCourseName);
         $cName = strtoupper($cName[0]);
         $cNumber = $currCourseName[$nameLength - 3] . $currCourseName[$nameLength - 2] . $currCourseName[$nameLength - 1];
         foreach ($courseList as $course) {
             if ($course->getCourseName() . ' ' . $course->getCourseNumber() == $cName . $cNumber) {
                 array_push($courseIDList, $course->getCourseID());
             }
         }
     }
     #now that we have a list of all courseIDs we need to make a list of
     #courseSectionIDs
     #first make a list of all courseSections
     $courseSections = new Course_section_model();
     $courseSectionList = $courseSections->getAllCourseSections();
     #next make a list to store the courseSectionIDs we need
     $courseSectionIDList = array();
     foreach ($courseIDList as $courseID) {
         foreach ($courseSectionList as $courseSection) {
             if ($courseSection->getCourse()->getCourseID() == $courseID) {
                 array_push($courseSectionIDList, $courseSection->getCourseSectionID());
             }
         }
     }
     $allCourseData = array();
     foreach ($courseSectionIDList as $csID) {
         $courseData = array('sectionID' => null, 'courseName' => null, 'quarterID' => null, 'quarterName' => null, 'quarterYear' => null, 'sectionNum' => null);
         $cSection = new Course_section_model();
         $cSection->loadPropertiesFromPrimaryKey($csID);
         $course = $cSection->getCourse();
         $cName = $course->getCourseName();
         $cNumber = $course->getCourseNumber();
         $courseData['quarterID'] = $cSection->getAcademicQuarter()->getAcademicQuarterID();
         $courseData['quarterName'] = $cSection->getAcademicQuarter()->getName();
         $courseData['quarterYear'] = $cSection->getAcademicQuarter()->getYear();
         $courseData['sectionNum'] = $cSection->getSectionName();
         $courseData['sectionID'] = $csID;
         $courseData['courseName'] = $cName . $cNumber;
         array_push($allCourseData, $courseData);
     }
     return $allCourseData;
 }