function _Student::calculate_cumulative_hours_and_gpa

4.x _Student.php _Student::calculate_cumulative_hours_and_gpa()
5.x _Student.php _Student::calculate_cumulative_hours_and_gpa()

This function will look at the courses which the student has taken, to calculate the cumulative hours and gpa, rather than just load them from the db table.

It will then return the values in an assoc array for later use. For example, you may want to set $this->cumulative_hours and $this->gpa to them.

1 call to _Student::calculate_cumulative_hours_and_gpa()

File

classes/_Student.php, line 486

Class

_Student

Code

function calculate_cumulative_hours_and_gpa() {

  $cumulative_hours = 0;
  $cumulative_points = 0;

  $cumulative_total_hours = $this->list_courses_taken->count_credit_hours("", FALSE, TRUE, FALSE);
  $cumulative_quality_hours = $this->list_courses_taken->count_credit_hours("", FALSE, TRUE, TRUE);
  $cumulative_quality_points = $this->list_courses_taken->count_credit_quality_points("", FALSE, TRUE);

  $cgpa = FALSE;
  if ($cumulative_quality_hours > 0) {
    $cgpa = fp_truncate_decimals($cumulative_quality_points / $cumulative_quality_hours, 3);
  }

  fpm("This student: <b>$cumulative_total_hours total hours</b>, 
		            $cumulative_quality_hours qual hours, $cumulative_quality_points cpoints. <b>gpa: $cgpa</b>");


  return array(
    "cumulative_total_hours" => $cumulative_total_hours,
    "cumulative_quality_hours" => $cumulative_quality_hours,
    "cumulative_quality_points" => $cumulative_quality_points,
    "cumulative_gpa" => $cgpa,
  );

}