开发者

PHP Class to Calculate GPA

开发者 https://www.devze.com 2023-01-05 08:24 出处:网络
I\'m looking for a PHP class or script that i can use the calculate a students GPA from a Grade point scale.

I'm looking for a PHP class or script that i can use the calculate a students GPA from a Grade point scale.

Example: http://www.williams.edu/registrar/records/gpa.html

Also, need to take into account Honor and AP classes. 开发者_高级运维(If class is chosen as honors assign additional .5 points to letter grade. If chosen as AP or IB assign 1 additional point to letter grade)


It's not hard to re-create one myself, i'm just looking for something already pre-made i can use to save me some time.


  1. Get a list of weightings per grade e.g (A-4,B-3,C-2 etc).
  2. Sum the weightings for each grade.
  3. Divide by total number of grades/courses.


$score_arr = array(4.0, 3.2, 2.2);

function getGPA($score_arr) {
     $count = count($score_arr);
     $sum = array_sum($score_arr);

     $gpa = $sum / $count;

     return $gpa;

}

Add: Could be modified to accept letter grades, compare via the chart, and sum scores appropriately. The details were missing when I began the post.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号