function _SubstitutionList::find_requirement
Search API
4.x _SubstitutionList.php | _SubstitutionList::find_requirement($course_requirement, $bool_exclude_has_been_applied = false, $group_id = 0) |
5.x _SubstitutionList.php | _SubstitutionList::find_requirement($course_requirement, $bool_exclude_has_been_applied = false, $group_id = 0, $degree_id = 0, $exclude_ids = array()) |
File
- classes/
_SubstitutionList.php, line 7
Class
Code
function find_requirement($course_requirement, $bool_exclude_has_been_applied = false, $group_id = 0, $degree_id = 0, $exclude_ids = array()) {
// Look through the array for a substitution which has this
// course requirement.
// If group_id == -1, no particular group is required.
for ($t = 0; $t < count($this->array_list); $t++)
{
$substitution = $this->array_list [$t];
// Skip if this substitution id is in our list to exclude.
if (in_array($substitution->db_substitution_id, $exclude_ids)) {
continue;
}
if ($bool_exclude_has_been_applied == true && $substitution->bool_has_been_applied == true)
{
// Skip substitutions which we have already applied.
continue;
}
if ($degree_id != 0 && $substitution->db_required_degree_id != $degree_id) {
// Skip substitutions which are for a different degree_id than the one supplied.
continue;
}
$cr = $substitution->course_requirement;
//adminDebug($cr->course_id . " " . $course_requirement->course_id);
if ($group_id == -1)
{ // No particular group_id is required...
if ($cr->course_id == $course_requirement->course_id)
{
return $substitution;
}
}
else {
// ONLY check if it's in the supplied group_id...
if ($cr->course_id == $course_requirement->course_id && $cr->get_bool_assigned_to_group_id($group_id))
{
return $substitution;
}
}
}
return false;
}