function _AdvisingScreen::get_quality_points

4.x _AdvisingScreen.php _AdvisingScreen::get_quality_points($grade, $hours)
5.x _AdvisingScreen.php _AdvisingScreen::get_quality_points($grade, $hours)

Calculate the quality points for a grade and hours.

This function is very similar to the one in the Course class. It is only slightly different here. Possibly, the two functions should be merged.

Parameters

string $grade:

int $hours:

Return value

int

1 call to _AdvisingScreen::get_quality_points()
_AdvisingScreen::draw_course_row in classes/_AdvisingScreen.php
This is used by lots of other functions to display a course on the screen. It will show the course, the hours, the grade, and quality points, as well as any necessary icons next to it.

File

classes/_AdvisingScreen.php, line 3223

Class

_AdvisingScreen

Code

function get_quality_points($grade, $hours) {

  $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;

}