function _CourseList::find_most_recent_match

4.x _CourseList.php _CourseList::find_most_recent_match(Course $course_c, $min_grade = "D", $bool_mark_repeats_exclude = false)
5.x _CourseList.php _CourseList::find_most_recent_match(Course $course_c, $min_grade = "", $bool_mark_repeats_exclude = false, $degree_id = 0, $bool_skip_already_assigned_to_degree = TRUE, $bool_skip_subs = FALSE, $group_id = 0)

Find a list of matches to Course courseC, which fulfill the min_grade requirement, ordered by most recently taken.

Returns FALSE if no matches were found, else it will return the matched Course object.

Parameters

Course $course_c:

string $min_grade:

bool $bool_mark_repeats_exclude:

Return value

Course

1 call to _CourseList::find_most_recent_match()
_CourseList::find_best_match in classes/_CourseList.php
Find the "best" match for this course, based on what the university considers a best match. This largely has to do with repeats. If the student has more than one credit, what is the "best" match?

File

classes/_CourseList.php, line 277

Class

_CourseList

Code

function find_most_recent_match(Course $course_c, $min_grade = "D", $bool_mark_repeats_exclude = false) 
 {
  // Get a list of all matches to courseC, and
  // then order them by the most recently taken course
  // first.
  // We should, too, check for minimum grades here
  // as well.


  if (!$list_matches = parent::find_all_matches($course_c)) 
   {
    return false;
  }


  $list_matches = CourseList::cast($list_matches);


  // Don't just return if it's only got a size of 1,
  // so that it forces it to do the min grade checking.
  /*		if ($list_matches->getSize() == 1)
		{
		return $list_matches->get_next();
		}
		*/
  if ($list_matches->is_empty) 
   {
    return false;
  }

  // If we are here, then we have more than one match.
  // Meaning, we have more than one class which might fit
  // into this course requirement.

  // Sort the courses into most recently taken first.
  $list_matches->sort_most_recent_first();


  // So, now that it's sorted, we should look through the list,
  // checking the min grade requirements (if any).  When we find
  // a good one, we will select it.

  $list_matches->reset_counter();
  while ($list_matches->has_more()) 
   {
    $c = $list_matches->get_next();

    if ($c->bool_exclude_repeat == true) 
     {
      continue;
    }
    //////////////////////////////////////////
    ///  Check for min grade, etc, here.
    if (!$c->meets_min_grade_requirement_of(null, $min_grade)) 
     {
      if ($bool_mark_repeats_exclude == true) 
       {
        // Since this course does not meet the min_grade,
        // check to see if it may be repeated.  If it can't,
        // then we must mark ALL previous attempts at this
        // course as being excluded from further consideration.
        // (ULM policy on repeats).
        // We don't do this consideration if they simply
        // withdrew from a course...
        if ($c->grade == "W") {
          continue;
        }

        if ($c->min_hours < 1 || $c->min_hours == "") {
          $c->load_descriptive_data(); // make sure we get hour data for this course.
        }

        if ($c->repeat_hours <= $c->min_hours) 
         {
          // No repeats.
          $this->mark_repeats_exclude($c);
          return false;

        }
        else {
          // Repeats allowed, so just continue.
          continue;
        }

      }
      else {
        continue;
      }
    }

    // Has the course already been assigned?
    if ($c->bool_has_been_assigned) 
     { // Skip over it.  Now, this is an important part here, because actually, we should
      // only skip it (and look at the next one) if this course is allowed to be
      // repeated.  If it cannot be repeated, or if the student has taken the
      // maximum allowed hours, then we should return false right here.
      continue;
    }

    return $c;
  }

  return false;

}