function _CourseList::remove_previously_fulfilled

4.x _CourseList.php _CourseList::remove_previously_fulfilled(CourseList $list_courses, $group_id, $bool_keep_repeatable_courses = true, $list_substitutions)
5.x _CourseList.php _CourseList::remove_previously_fulfilled(CourseList $list_courses, $group_id, $bool_keep_repeatable_courses = true, $list_substitutions, $degree_id = 0)

Remove courses from THIS list which appear in listCourses under these conditions:

  • the listCourses->"assigned_to_group_id" != $group_id

This function is being used primarily with $list_courses being the list of courses that students have taken. Also checking substitutions for courses substituted into groups.

Parameters

CourseList $list_courses:

int $group_id:

bool $bool_keep_repeatable_courses:

SubstitutionList $list_substitutions:

$degree_id The degree id to look for. If it's -1, then ignore it. If it's 0, use the course's req_by_degree_id.:

File

classes/_CourseList.php, line 762

Class

_CourseList

Code

function remove_previously_fulfilled(CourseList $list_courses, $group_id, $bool_keep_repeatable_courses = true, $list_substitutions, $degree_id = 0) 
 {

  $rtn_list = new CourseList();

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

    if ($bool_keep_repeatable_courses == true) 
     { // We can always keep repeatable courses in the list.
      if ($course->repeat_hours > $course->min_hours) 
       {
        $rtn_list->add($course);
        continue;
      }
    }

    // Has the course been substituted?
    if ($test_sub = $list_substitutions->find_requirement($course, false, -1)) 
     {
      // it WAS substituted, so we should NOT add it to our
      // rtnList.				
      // We should only skip it if the test_sub's degree_id matches the one supplied...
      if ($degree_id >= 0) {
        if ($test_sub->assigned_to_degree_id == $degree_id) {
          continue;
        }
      }
      else if ($degree_id < 0) {
        // degree_id is -1, so we don't care what degree it was assigned to.
        continue;
      }
    }

    // Okay, now check if $course is anywhere in $list_courses
    //if ($test_course = $list_courses->find_match($course))
    // Instead of using simply find_match(), which does not allow for any hook interventions, switch to using find_best_match.
    // Thanks for Logan Buth for this.
    if ($test_course = $list_courses->find_best_match($course, '', FALSE, $degree_id, TRUE, FALSE, $group_id)) 
     {
      // Yes, it found a match.
      // I am taking out this part where I say if it is in
      // this group then we can keep it.  I think that shouldn't
      // be in.
      // This course is in another group, so do nothing
      // and skip it.

      // perhaps the course is on the degreePlan in excess with a W
      // or F?
      if (!$test_course->meets_min_grade_requirement_of(null, "D")) 
       {
        // Meaning, this was a failed attempt, so we can add
        // our original course back in.
        $rtn_list->add($course);
        continue;
      }

      // perhaps this course was purposefully excluded from
      // this list because it did not meet the min grade
      // requirements?  If this is the case, $course should
      // still appear in THIS list.
      if (!$test_course->meets_min_grade_requirement_of($course)) 
       {
        // Meaning, this was attempt did not meet the
        // min grade of the original requirement, so we can add
        // our original requirement back in.
        $rtn_list->add($course);
        continue;
      }

    }
    else {
      // The course was NOT found in the courseList,
      // so its safe to add it back in.
      $rtn_list->add($course);
    }

  }


  $this->array_list = $rtn_list->array_list;
  $this->reset_counter();

}