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.

@todo The ignore list should be database-based. Should just get it from the settings.

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 1234

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) 
 {
  // 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];

    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;
      }

    }

    if ($course->bool_substitution_new_from_split == 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->bool_substitution == false) 
       { // not being used in another sub, so skip it.				  
        continue;
      }
    }

    $h_get_hours = $course->get_hours();


    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->hours_awarded;
      }
    }

    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;
      }
    }


    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...
      if ($course->requirement_type == "uc" && $requirement_type == "c") 
       {
        $count = $count + $h_get_hours;
      }

      if ($course->requirement_type == "um" && $requirement_type == "m") 
       {
        $count = $count + $h_get_hours;
      }


    }
  }

  return $count;
}