function CourseList::find_specific_course

7.x CourseList.php CourseList::find_specific_course($course_id = 0, $term_id = 0, $bool_transfer = false, $bool_exclude_substitutions = true, Course $use_course = null, $sub_req_by_degree_id = 0)
6.x CourseList.php CourseList::find_specific_course($course_id = 0, $term_id = 0, $bool_transfer = false, $bool_exclude_substitutions = true, Course $use_course = null, $sub_req_by_degree_id = 0)

Find and return a specific course from the list.

Parameters

int $course_id:

  • The course_id to look for. Do not set if using $use_course.

int $term_id:

  • The term_id for the course to look for. Do not set if using $use_course.

bool $bool_transfer:

  • Is the course we are looking for a transfer course? Do not use if using $use_course.

bool $bool_exclude_substitutions:

  • If TRUE, we will not consider courses which have been used in a substitution.

Course $use_course:

  • Optional. If you already have a course object which can be used as a template to search for, specify it here. Otherwise, set to NULL. If using this, then $course_id, $term_id, and $bool_transfer will be ignored.

Int $sub_req_by_degree_id:

  • Optional. If set, we will only exclude substituted courses if they were substitutions made for this degree_id. Leave 0 if not sure what to use.

Return value

Course

File

classes/CourseList.php, line 133

Class

CourseList

Code

function find_specific_course($course_id = 0, $term_id = 0, $bool_transfer = false, $bool_exclude_substitutions = true, Course $use_course = null, $sub_req_by_degree_id = 0) 
 {
  if ($use_course != null && is_object($use_course)) 
   {
    $course_id = $use_course->course_id;
    $term_id = $use_course->term_id;
    $bool_transfer = $use_course->bool_transfer;
  }
  // Look through the array for a course with this id, termId, and
  // transfer credit status.
  for ($t = 0; $t < $this->count; $t++) 
   {
    $course = $this->array_list [$t];

    $check_course_id = $course->course_id;
    if ($bool_transfer == true && is_object($course->course_transfer)) 
     {
      $check_course_id = $course->course_transfer->course_id;
    }

    if ($check_course_id == $course_id && $course->term_id == $term_id && $course->bool_transfer == $bool_transfer) 
     {

      if ($bool_exclude_substitutions == true) 
       {
        if ($course->get_bool_substitution($sub_req_by_degree_id) == TRUE) 
         {
          continue;
        }

      }

      return $course;
    }
  }

  return false;
}