function Student::calculate_cumulative_hours_and_gpa

6.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 552

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);
  }


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

}