function _FlightPath::combine_degree_plans
Search API
5.x _FlightPath.php | _FlightPath::combine_degree_plans($degree_plans, $student_id) |
This function is responsible for combining multiple degree plans into a single unified degree plan, then returning it.
1 call to _FlightPath::combine_degree_plans()
- _FlightPath::init in classes/
_FlightPath.php
File
- classes/
_FlightPath.php, line 253
Class
Code
function combine_degree_plans($degree_plans, $student_id) {
//DEV: // return $degree_plans[0];
$new_degree_plan = new DegreePlan();
// Loop through the degree plans one at a time...
foreach ($degree_plans as $degree_plan) {
$new_degree_plan->combined_degree_ids_array [] = $degree_plan->degree_id;
$new_degree_plan->add_to_required_course_id_array($degree_plan->required_course_id_array);
// Is there a public note to copy over?
if (isset($degree_plan->public_notes_array [$degree_plan->degree_id])) {
$new_degree_plan->public_notes_array [$degree_plan->degree_id] = $degree_plan->public_notes_array [$degree_plan->degree_id];
}
if ($degree_plan->catalog_year == "" || $degree_plan->catalog_year == 0) {
$degree_plan->load_descriptive_data();
}
$new_degree_plan->catalog_year = $degree_plan->catalog_year;
// Okay, now copy whatever we need to into the new_degree_plan.
// First, go through its list of semesters, and copy out all the courses and groups
$degree_plan->list_semesters->reset_counter();
while ($degree_plan->list_semesters->has_more()) {
$sem = $degree_plan->list_semesters->get_next();
// If the semester is the Added by Advisor (-88), or the developmental block (-55) then skip for now.
if ($sem->semester_num == DegreePlan::SEMESTER_NUM_FOR_COURSES_ADDED || $sem->semester_num == DegreePlan::SEMESTER_NUM_FOR_DEVELOPMENTALS) {
// This is the special one that is "added by advisor". Skip it. But remember to add it later to the finished product.
// Or, it's the developmentals block. Add that later too.
continue;
}
// Okay, the semester contains a CourseList called list_courses, and a GroupList caled list_groups.
$new_list_courses = $sem->list_courses->get_clone();
// Now, let's add them to the new_degree_plan's semester...
// if the new degree plan already has this semester, get that instead.
$the_semester = $new_degree_plan->get_semester($sem->semester_num);
if (!$the_semester) {
$the_semester = new Semester($sem->semester_num);
$new_degree_plan->list_semesters->add($the_semester);
}
// Should we rename the_semester's title (because the semester we are grabbing is overriding?)
//$degree_plan->load_descriptive_data(); // Doesn't appear to be necessary at this stage.
$stitle = trim(@$degree_plan->array_semester_titles [$sem->semester_num]);
if ($stitle != "") {
// Meaning we should overwrite the semester title, because this degree isn't using the default title
$the_semester->title = $stitle;
$the_semester->bool_using_default_title = FALSE;
}
// Okay, now add the courses to the_semester
$the_semester->list_courses->add_list($new_list_courses);
////////////////////////////
// Getting the list of groups is going to be similar to getting our list of courses.
// Go through the list of groups for this semester.
$new_list_groups = $sem->list_groups->get_clone(FALSE, FALSE, FALSE);
// Okay, now we can add to our semester
$the_semester->list_groups->add_list($new_list_groups);
// Also add this group list to the degree plan's list_groups.
$new_degree_plan->list_groups->add_list($new_list_groups);
} // while, listing semesters in degree plan.
} // foreach degree_plans
//////////////////////////////
// Okay, now to put the finishing touches on the $new_degree_plan
// Add in the "Developmental Req's" if required for this student.
$new_degree_plan->add_semester_developmental($student_id);
// Add in the "Courses added by advisor"
$new_degree_plan->add_semester_courses_added();
if (count($degree_plans) > 1) {
$new_degree_plan->is_combined_dynamic_degree_plan = TRUE;
$new_degree_plan->degree_id = DegreePlan::DEGREE_ID_FOR_COMBINED_DEGREE; // use constant to make it easier later on.
}
// Make sure all of our groups have reloaded any missing courses.
$new_degree_plan->list_semesters->reset_counter();
while ($new_degree_plan->list_semesters->has_more()) {
$sem = $new_degree_plan->list_semesters->get_next();
$sem->list_groups->reload_missing_courses();
}
return $new_degree_plan;
}