function _DegreePlan::find_courses
Search API
4.x _DegreePlan.php | _DegreePlan::find_courses($course_id, $group_id = 0, $semester_num) |
5.x _DegreePlan.php | _DegreePlan::find_courses($course_id, $group_id = 0, $semester_num, $degree_id = 0) |
File
- classes/
_DegreePlan.php, line 684
Class
Code
function find_courses($course_id, $group_id = 0, $semester_num)
{
// This will locate a course within the degree plan, and return
// back either that course object, or FALSE.
$new_course = new Course($course_id);
$new_semester = new Semester($semester_num);
$rtn_course_list = new CourseList();
// Okay, if the course is within a group, then
// we can first use the find_group method.
if ($group_id != 0)
{
if ($group = $this->find_group($group_id))
{
if (!($group->list_courses->is_empty))
{
if ($cL = $group->find_courses($new_course))
{
$rtn_course_list->add_list($cL);
}
}
if (!($group->list_groups->is_empty))
{
// Look within each sub group for the course...
$group->list_groups->reset_counter();
while ($group->list_groups->has_more())
{
$branch = $group->list_groups->get_next();
if (!$branch->list_courses->is_empty)
{
if ($cL = $branch->find_courses($new_course))
{
$rtn_course_list->add_list($cL);
}
}
// Here we can look for groups within groups...
}
}
}
return $rtn_course_list;
}
else if ($semester_num != -1) {
// No group specified. This course is on the
// bare degree plan. We were given a specific semester,
// so try to find it there...
if ($semester = $this->list_semesters->find_match($new_semester))
{
if ($cL = $semester->list_courses->find_all_matches($new_course))
{
$rtn_course_list->add_list($cL);
return $rtn_course_list;
}
}
}
else if ($semester_num == -1)
{
// Meaning, we do not know which semester it goes in, so
// attempt all semesters, and return with the first instance.
$this->list_semesters->reset_counter();
while ($this->list_semesters->has_more())
{
$sem = $this->list_semesters->get_next();
if ($cL = $sem->list_courses->find_all_matches($new_course))
{
$rtn_course_list->add_list($cL);
return $rtn_course_list;
}
}
}
return false;
}