function _DegreePlan::load_degree_plan

4.x _DegreePlan.php _DegreePlan::load_degree_plan()
5.x _DegreePlan.php _DegreePlan::load_degree_plan()

Load our complete degree plan, including all courses and groups.

1 call to _DegreePlan::load_degree_plan()

File

classes/_DegreePlan.php, line 502

Class

_DegreePlan

Code

function load_degree_plan() {


  // Load this degree plan from the database and fully
  // assemble it.
  $degree_id = $this->degree_id;

  $old_semester = "";
  $table_name1 = "degrees";
  $table_name2 = "degree_requirements";
  if ($this->bool_use_draft) {
    $table_name1 = "draft_$table_name1";
    $table_name2 = "draft_$table_name2";
  }

  // Degrees we should exclude from the "appears in" counts.  Used later...
  $exclude_degree_ids = system_get_exclude_degree_ids_from_appears_in_counts();


  $res = $this->db->db_query("SELECT * FROM $table_name1 a, $table_name2 b
            							WHERE a.degree_id = '?'
            							AND a.degree_id = b.degree_id 
            							ORDER BY semester_num ", $this->degree_id);
  while ($cur = $this->db->db_fetch_array($res)) 
   {
    $this->title = $cur ["title"];
    $this->major_code = $cur ["major_code"];
    $this->degree_level = strtoupper(trim($cur ["degree_level"]));
    if ($this->degree_level == "") {
      $this->degree_level = "UG"; // undergrad by default
    }
    $this->degree_class = $cur ["degree_class"];
    $this->db_override_degree_hours = $cur ["override_degree_hours"];
    $this->db_advising_weight = intval($cur ["advising_weight"]);
    $data_entry_value = trim($cur ['data_entry_value']);

    $this->db_track_selection_config = trim($cur ["track_selection_config"]);
    $this->parse_track_selection_config(); // load into the track_selection_config_array as needed.

    $semester_num = $cur ["semester_num"];
    if ($semester_num != $old_semester) 
     {
      // This is a new semester object we are dealing with.
      $old_semester = $semester_num;
      $obj_semester = new Semester($semester_num);
      $obj_semester->title = trim(@$this->array_semester_titles [$semester_num]);
      if ($obj_semester->title == "") {
        $obj_semester->assign_title();
      }
      $this->list_semesters->add($obj_semester);
    }

    if ($cur ["course_id"] * 1 > 0) 
     {
      // A course is the next degree requirement.

      //if ($this->bool_use_draft) $cat_year = $this->catalog_year;        
      $cat_year = $this->catalog_year;

      $course_c = new Course($cur ["course_id"], false, $this->db, false, $cat_year, $this->bool_use_draft);
      $course_c->assigned_to_semester_num = $semester_num;
      $course_c->min_grade = trim(strtoupper($cur ["course_min_grade"]));
      if ($course_c->min_grade == "") 
       { // By default, all courses have a
        // min grade requirement of D.
        $course_c->min_grade = "D";
      }
      $course_c->requirement_type = trim($cur ["course_requirement_type"]);

      // Set which degree_id this course is a requirement of (for multiple degrees)
      $course_c->req_by_degree_id = $this->degree_id;

      //adminDebug($course_c->to_string() . $course_c->getCatalogHours());

      $obj_semester->list_courses->add($course_c);

      if (!in_array($this->degree_id, $exclude_degree_ids)) {
        // array is sectioned like:  course_id | degree_id | group_id.    Group id = 0 means "on the bare degree plan"
        $this->required_course_id_array [$course_c->course_id][$this->degree_id][0] = TRUE;
      }

    } // if course_id > 0




    if ($cur ["group_id"] * 1 > 0) 
     {
      // A group is the next degree requirement.
      //$group_g = new Group($cur["group_id"], $this->db, $semester_num);



      $title = "";
      $icon_filename = "";
      // Add the real Group (with all the courses, branches, etc)
      // to the DegreePlan's group list!
      // First, see if this group alread exists.  If it does,
      // simply add the number of hours required to it.  If not,
      // create it fresh.
      //if ($new_group = $this->find_group($cur["group_id"]))
      if ($new_group = $this->find_group($cur ["group_id"] . '_' . $this->degree_id)) // group_id's will always have db_group_id _ degree_id from now on...
       {
        // Was already there (probably in another semester),
        // so, just increment the required hours.

        if (!isset($new_group->hours_required_by_type [$cur ["group_requirement_type"]])) {
          $new_group->hours_required_by_type [$cur ["group_requirement_type"]] = 0;
        }

        $new_group->hours_required = $new_group->hours_required + ($cur ["group_hours_required"] * 1);
        $new_group->hours_required_by_type [$cur ["group_requirement_type"]] += ($cur ["group_hours_required"] * 1);
        //Set which degree_id this is required by.
        $new_group->req_by_degree_id = $this->degree_id;

        $title = $new_group->title;
        $icon_filename = $new_group->icon_filename;
      }
      else {
        // Was not already there; insert it.
        $group_n = new Group($cur ["group_id"] . '_' . $this->degree_id, $this->db, $semester_num, $this->student_array_significant_courses, $this->bool_use_draft, $cur ["group_requirement_type"]);
        $group_n->hours_required = $cur ["group_hours_required"] * 1;

        if (!isset($group_n->hours_required_by_type [$cur ["group_requirement_type"]])) {
          $group_n->hours_required_by_type [$cur ["group_requirement_type"]] = 0;
        }
        $group_n->hours_required_by_type [$cur ["group_requirement_type"]] += $group_n->hours_required;
        $group_n->set_req_by_degree_id($this->degree_id);
        if (trim($cur ["group_min_grade"]) != "") 
         {
          $group_n->assign_min_grade(trim(strtoupper($cur ["group_min_grade"])));
        }
        $title = $group_n->title;
        $icon_filename = $group_n->icon_filename;

        $this->list_groups->add($group_n);
      }


      // Add a placeholder to the Semester....
      $group_g = new Group();
      $group_g->bool_use_draft = $this->bool_use_draft;
      $group_g->group_id = $cur ["group_id"] . '_' . $this->degree_id;
      $group_g->set_req_by_degree_id($this->degree_id);
      $group_g->load_descriptive_data();
      $group_g->set_requirement_type($cur ["group_requirement_type"]);
      if (trim($cur ["group_min_grade"]) != "") 
       {
        $group_g->assign_min_grade(trim(strtoupper($cur ["group_min_grade"])));
      }
      $group_g->assigned_to_semester_num = $semester_num;
      $group_g->title = "$title";
      $group_g->icon_filename = $icon_filename;
      $group_g->hours_required = intval($cur ["group_hours_required"]);
      $group_g->min_hours_allowed = intval($cur ["group_min_hours_allowed"]);
      $group_g->bool_placeholder = true;
      $obj_semester->list_groups->add($group_g);


    }
    // if group_id > 0

  } // while db results


  $this->list_groups->sort_priority();

  if (!in_array($this->degree_id, $exclude_degree_ids)) {
    $group_course_id_array = $this->list_groups->get_group_course_id_array();
    // Add to our required_course_id_array.      
    foreach ($group_course_id_array as $group_id => $details) {
      foreach ($group_course_id_array [$group_id] as $course_id => $val) {
        $this->required_course_id_array [$course_id][$this->degree_id][$group_id] = $val;
      }
    }
  }





  // When we load this degree plan, let's also check for any hooks.
  // Since this class might be used outside of FP, only do this if we know
  // that the bootstrap.inc file has been executed.
  if ($GLOBALS ["fp_bootstrap_loaded"] == TRUE) {
    invoke_hook("degree_plan_load", array(&$this));
  }




}