-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcal.php
More file actions
executable file
·90 lines (89 loc) · 2.05 KB
/
cal.php
File metadata and controls
executable file
·90 lines (89 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/*
* Author: Ilemona Achimugu
* Year: 2019
* For: Schools in Credit to Trinity Bible College Ojuwo Anyigba
*/
header('Content-type:application/JSON');
if(isset($_GET)){
$max = $_GET['max'];
//print_r($_GET);
$inputs = array_slice($_GET,1);
$totpoint = 0;
$totunit = 0;
$final = array('output' => 'failed','reasons'=>'none','gp' => 0,'cod' => 0);
if(array_search('',$inputs)){
//echo 1;
$final['output'] = 'failed';
$final['reasons'] = 'Complete All Fields';
$final['gp'] = 0;
$final['cod'] = 'none';
echo json_encode($final);
}
else{
//print_r($inputs);
for($i=1; $i<=$max; $i++){
$score = $_GET['score'.$i];
$unit = $_GET['unit'.$i];
if($score > 100 || !is_numeric($score) || empty($score) || $score == "")
{
//echo 2;
$final['output'] = 'failed';
$final['reasons'] = 'Enter a Valid Score';
$final['gp'] = 0;
$final['cod'] = 'none';
echo json_encode($final);
exit;
}
else
{
$totpoint += (do_point($score) * $unit);
$totunit += $unit;
}
}
$gp = $totpoint/$totunit;
//echo number_format($gp,2).'<br/>'.print_r($final);
$final['output'] = 'Sucess';
$final['reasons'] = 'Your GP was Computed';
$final['gp'] = number_format($gp,2);
$final['cod'] = cod($gp);
echo json_encode($final);
}
}
function do_point($score){
if($score > 69){ $point = 5;}
else if($score > 59 && $score < 70) {$point = 4;}
else if($score > 49 && $score < 60) {$point = 3;}
else if($score > 44 && $score < 50) {$point = 2;}
else if($score > 39 && $score < 45) {$point = 1;}
else{$point = 0;}
return $point;
}
function cod($gp){
if ($gp >= 4.50)
{
$class = "<span> First Class </span>";
}
else if (($gp < 4.50) && ($gp >= 3.50))
{
$class = "<span> Second Class Upper (2.1) </span>";
}
else if (($gp < 3.50) && ($gp >=2.40))
{
$class = "<span> Second Class Lower Division (2.2)</span>";
}
else if (($gp < 2.40) && ($gp >=1.50))
{
$class = "<span> Third Class </span>";
}
else if (($gp < 1.50) && ($gp >= 1.00))
{
$class = "<span> Pass </span>";
}
else
{
$class = "<span> Failed </span>";
}
return $class;
}
?>