function _Course::meets_min_grade_requirement_of

4.x _Course.php _Course::meets_min_grade_requirement_of(Course $course_req = NULL, $m_grade = "")
5.x _Course.php _Course::meets_min_grade_requirement_of(Course $course_req = NULL, $m_grade = "")

Does $this meed the minimum grade requirement of the supplied course requirement? You may specify either a Course object, or just enter the min_grade in the mGrade variable.

Parameters

Course $course_req:

  • The Course object who has the min grade requirement. Set to NULL if using $m_grade.

string $m_grade:

  • The min grade which $this must meet. Do not use if using $course_req.

Return value

bool

File

classes/_Course.php, line 472

Class

_Course

Code

function meets_min_grade_requirement_of(Course $course_req = NULL, $m_grade = "") 
 {
  // Does $this course meet the min grade requirement
  // of the supplied course requirement?

  // Get these grade definitions from our system settings
  // Configure them in custom/settings.php
  $b_or_better = csv_to_array($GLOBALS ["fp_system_settings"]["b_or_better"]);
  $c_or_better = csv_to_array($GLOBALS ["fp_system_settings"]["c_or_better"]);
  $d_or_better = csv_to_array($GLOBALS ["fp_system_settings"]["d_or_better"]);
  $enrolled_grades = csv_to_array($GLOBALS ["fp_system_settings"]["enrolled_grades"]);

  if ($course_req != null) {
    $min_grade = $course_req->min_grade;
  }
  else {
    $min_grade = $m_grade;
  }



  if ($min_grade == "") 
   { // There is no min grade requirement for this course.
    return true;
  }

  // If the student is currently enrolled, return true.
  if (in_array($this->grade, $enrolled_grades)) 
   {
    return true;
  }


  if ($min_grade == "A" && $this->grade == "A") 
   {
    return true;
  }

  if ($min_grade == "B" && in_array($this->grade, $b_or_better)) 
   {
    return true;
  }

  if ($min_grade == "C" && in_array($this->grade, $c_or_better)) 
   {
    return true;
  }

  if ($min_grade == "D" && in_array($this->grade, $d_or_better)) 
   {
    return true;
  }



  return false;
}