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.
- Get a list of weightings per grade e.g (A-4,B-3,C-2 etc).
- Sum the weightings for each grade.
- 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.
精彩评论