function _CourseList::count_hours

4.x _CourseList.php _CourseList::count_hours($requirement_type = "", $bool_use_ignore_list = false, $bool_correct_ghost_hour = true, $bool_force_zero_hours_to_one_hour = false)
5.x _CourseList.php _CourseList::count_hours($requirement_type = "", $bool_use_ignore_list = false, $bool_correct_ghost_hour = true, $bool_force_zero_hours_to_one_hour = false, $bool_exclude_all_transfer_credits = FALSE, $degree_id = 0)

Returns hour many hours are in $this CourseList.

Parameters

string $requirement_type:

  • If specified, we will only count courses which match this requirement_type.

bool $bool_use_ignore_list:

Return value

int

File

classes/_CourseList.php, line 1720

Class

_CourseList

Code

function count_hours($requirement_type = "", $bool_use_ignore_list = false, $bool_correct_ghost_hour = true, $bool_force_zero_hours_to_one_hour = false, $bool_exclude_all_transfer_credits = FALSE, $degree_id = 0) 
 {
  // Returns how many hours are being represented in this courseList.
  // A requirement type of "uc" is the same as "c"
  // (university capstone is a core requirement)

  $count = 0;
  for ($t = 0; $t < $this->count; $t++) 
   {
    $course = $this->array_list [$t];

    // Does this course belong to the same degree we are interested in?  If not, skip it.
    if ($degree_id > 0) {
      if ($course->req_by_degree_id != $degree_id && $course->get_has_been_assigned_to_degree_id($degree_id) != TRUE) {
        continue;
      }
    }



    if ($bool_use_ignore_list == true) 
     {
      // Do ignore some courses...
      $temp_course_name = $course->subject_id . " " . $course->course_num;
      // Check in our settings to see if we should ignore this course
      // (configured in /custom/settings.php)
      if (in_array($temp_course_name, csv_to_array(@$GLOBALS ["fp_system_settings"]["ignore_courses_from_hour_counts"]))) {
        continue;
      }

      // Also, if the course's requirement_type is "x" it means we should ignore it.
      if ($course->requirement_type == 'x') {
        continue;
      }


    }

    if ($course->get_bool_substitution_new_from_split($degree_id) == TRUE) 
     {
      // Do not count the possible fragments that are created
      // from a new substitution split.  This is causing problems
      // in getting accurate numbers on the pie charts.

      // BUT-- only skip if this new fragment isn't also being
      // substituted somewhere else!
      if ($course->get_bool_substitution($degree_id) == FALSE) 
       { // not being used in another sub, so skip it.				  
        continue;
      }
    }

    $h_get_hours = $course->get_hours($degree_id);

    if ($bool_correct_ghost_hour) {
      // If this course has a ghosthour, then use the
      // hours_awarded (probably 1).  However, if it was substituted,
      // then we actually want the 0 hour.  Confusing, isn't it?
      if ($course->bool_ghost_hour) {
        $h_get_hours = $course->get_hours_awarded($degree_id);
      }
    }

    if ($bool_force_zero_hours_to_one_hour) {
      // We want to force anything with a 0 hour to be 1 hour.
      // Helps when selecting 0 hour courses from groups.
      if ($h_get_hours == 0) {
        $h_get_hours = 1;
      }
    }


    // Make sure we aren't trying to exclude any transfer credits.
    if ($bool_exclude_all_transfer_credits) {
      if ($course->bool_transfer) {
        continue;
      }
      // Is this a requirement which has been fulfilled by a course?  And if so, is THAT course a transfer?
      if ($course->course_list_fulfilled_by->is_empty == false) {
        $cc = $course->course_list_fulfilled_by->get_first();
        if ($cc->bool_transfer) {
          continue;
        }
      }
    }





    if ($requirement_type == "") 
     {
      $count = $count + $h_get_hours;
    }
    else {
      // Requirement Type not blank, so only count these hours
      // if it has the set requirement type.
      if ($course->requirement_type == $requirement_type) 
       {
        $count = $count + $h_get_hours;
        continue;
      }

      // For specifically "university capstone" courses (which have a 'u' in front)...
      if ($course->requirement_type == "u" . $requirement_type) 
       {
        $count = $count + $h_get_hours;
      }



    }
  }

  return $count;
}