function DegreePlan::calculate_progress_hours

7.x DegreePlan.php DegreePlan::calculate_progress_hours($bool_get_local_only_hours = FALSE, $types = array())
6.x DegreePlan.php DegreePlan::calculate_progress_hours($bool_get_local_only_hours = FALSE, $types = array())

Calculate and store progress hour information. Stores in the $this->gpa_calculations array.

Parameters

$bool_get_local_only_hours - If set to TRUE, then "local" courses (non-transfer) will be separated into their own indexes.:

$types - the type codes we care about. If left as an emtpy array, it will get all the types defined + "degree" for degree total.: The array structure should be "code" => "code". Ex: array('a' => 'a')

File

classes/DegreePlan.php, line 174

Class

DegreePlan

Code

function calculate_progress_hours($bool_get_local_only_hours = FALSE, $types = array()) 
 {

  // Let's go through our requirement types by code, and collect calcuations on them
  // in the gpa_calculations array.
  if (count($types) == 0) {
    // Wasn't set, so use ALL of the known requirement types.
    $types = fp_get_requirement_types($this->school_id);
  }

  // Add a pseudo-code in for "degree", which the functions will convert into a blank.
  $types ["degree"] = t("Degree (total)");

  // We want to do this for all possible degrees.
  $all_degree_ids = array();

  $all_degree_ids [0] = 0; // Add in the default "0" degree, meaning, don't look for a specific degree_id.

  if ($this->degree_id != DegreePlan::DEGREE_ID_FOR_COMBINED_DEGREE) {

    // Not a combined degree, just use the current degree_id.
    // $all_degree_ids[] = $this->degree_id;  // comment out... not needed?
  }
  else {

    // Add in all the degrees we are combined with.      
    $all_degree_ids = array_merge($all_degree_ids, $this->combined_degree_ids_array);
  }


  foreach ($all_degree_ids as $degree_id) {

    foreach ($types as $code => $desc) {
      // Make sure to skip appropriate codes we don't care about.      

      if ($code == 'x') {
        continue;
      }

      $this->gpa_calculations [$degree_id][$code]["total_hours"] = $this->get_progress_hours($code, TRUE, FALSE, FALSE, $degree_id);
      $this->gpa_calculations [$degree_id][$code]["fulfilled_hours"] = $this->get_progress_hours($code, FALSE, FALSE, FALSE, $degree_id);
      $this->gpa_calculations [$degree_id][$code]["qpts_hours"] = $this->get_progress_hours($code, FALSE, TRUE, FALSE, $degree_id);


      if ($bool_get_local_only_hours) {
        // Get ONLY local hours, too....
        $this->gpa_calculations [$degree_id][$code . "_local"]["total_hours"] = $this->get_progress_hours($code, TRUE, FALSE, TRUE, $degree_id);
        $this->gpa_calculations [$degree_id][$code . "_local"]["fulfilled_hours"] = $this->get_progress_hours($code, FALSE, FALSE, TRUE, $degree_id);
        $this->gpa_calculations [$degree_id][$code . "_local"]["qpts_hours"] = $this->get_progress_hours($code, FALSE, TRUE, TRUE, $degree_id);
      }

    } // foreach types as code

  } //foreach all_degree_ids


  // Note that we have run this function for this degree.
  $this->bool_calculated_progess_hours = TRUE;

}