function _Course::get_quality_points

4.x _Course.php _Course::get_quality_points()
5.x _Course.php _Course::get_quality_points($degree_id = 0)

Calculate the quality points for this course's grade and hours.

Parameters

string $grade:

int $hours:

Return value

int

File

classes/_Course.php, line 1178

Class

_Course

Code

function get_quality_points($degree_id = 0) {

  $hours = $this->get_hours($degree_id);
  $grade = $this->grade;

  $pts = 0;
  $qpts_grades = array();

  // Let's find out what our quality point grades & values are...
  if (isset($GLOBALS ["qpts_grades"])) {
    // have we already cached this?
    $qpts_grades = $GLOBALS ["qpts_grades"];
  }
  else {
    $tlines = explode("\n", variable_get("quality_points_grades", "A ~ 4\nB ~ 3\nC ~ 2\nD ~ 1\nF ~ 0\nI ~ 0"));
    foreach ($tlines as $tline) {
      $temp = explode("~", trim($tline));
      if (trim($temp [0]) != "") {
        $qpts_grades [trim($temp [0])] = trim($temp [1]);
      }
    }

    $GLOBALS ["qpts_grades"] = $qpts_grades; // save to cache
  }

  // Okay, find out what the points are by multiplying value * hours...

  if (isset($qpts_grades [$grade])) {
    $pts = $qpts_grades [$grade] * $hours;
  }


  return $pts;

}