-
Notifications
You must be signed in to change notification settings - Fork 5
/
view_result.php
165 lines (148 loc) · 4.77 KB
/
view_result.php
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
session_start();
require "php/config.php";
require_once "php/functions.php";
$user = new login_registration_class();
$admin_id = $_SESSION['admin_id'];
$admin_name = $_SESSION['admin_name'];
if(!$user->get_admin_session()){
header('Location: index.php');
exit();
}
if(isset($_REQUEST['vr'])){
$stid = $_REQUEST['vr'];
$name = $_REQUEST['vn'];
}
?>
<?php
$pageTitle = "Student Result";
include "php/headertop_admin.php";
?>
<div class="all_student fix">
<?php
//custom function check credit hour and grade point
function credit_hour($x){
if($x=="DBMS") return 3;
elseif($x == "DBMS Lab") return 1;
elseif($x == "Mathematics") return 4;
elseif($x == "Programming") return 3;
elseif($x == "Programming Lab") return 1;
elseif($x == "English") return 4;
elseif($x == "Physics") return 3;
elseif($x == "Chemistry") return 3;
elseif($x == "Psychology") return 3;
}
function grade_point($gd){
if($gd<60) return 0;
elseif($gd>=60 && $gd<70) return 1;
elseif($gd>=70 && $gd<80) return 2;
elseif($gd>=80 && $gd<90) return 3;
elseif($gd>=90 && $gd<=100) return 4;
}
?>
<!--Infomation of student-->
<div>
<p style="text-align:center;color:#fff;background:purple;margin:0;padding:8px;"><?php echo "Name: ".$name."<br>Student ID: " . $stid; ?></p>
</div>
<div>
<p style="float:left;margin:0 0 5px 0;width:100%;text-align:center;"><a href="view_cgpa.php?vr=<?php echo $stid; ?>&vn=<?php echo $name; ?>"><button class="editbtn">View cgpa & completed course</button></a></p>
</div>
<form action="" method="post" style="width:23%;margin:0 auto;padding-bottom:5px;">
<select name="seme" id="">
<option value="1st">1st semester</option>
<option value="2nd">2nd semester</option>
<option value="3rd">3rd semester</option>
</select>
<input type="submit" value="view Result" />
</form>
<?php
//select semester
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$semester = $_POST['seme'];
$i=0;
$ch = 0;
$gp = 0;
//$get_result = $user->show_marks();
$get_result = $user->show_marks($stid,$semester);
if($get_result){
?>
<p><?php echo "<p style='text-align:center;background:#ddd;color:#01C3AA;padding:5px;width:84%;margin:0 auto'>".$semester." Semester Result"?></p>
<table class="tab_two" style="text-align:center;width:85%;margin:0 auto">
<th>Subject</th>
<th>Marks</th>
<th>Grade</th>
<th>Credit hr.</th>
<th>Status</th>
<?php
while($rows = $get_result->fetch_assoc()){
$i++;
//count total credit hour;
$ch = $ch + credit_hour($rows['sub']);
?>
<tr>
<td><?php echo $rows['sub'];?></td>
<td><?php echo $rows['marks'];?></td>
<td>
<?php
//set grade for individual subject
$mark = $rows['marks'];
if($mark<60){echo "F";}
elseif($mark>=60 && $mark<70){echo "D";}
elseif($mark>=70 && $mark<80){echo "C";}
elseif($mark>=80 && $mark<90){echo "B";}
elseif($mark>=90 && $mark<=100){echo "A";}
//total grade point
$gp = $gp + (credit_hour($rows['sub']) * grade_point($rows['marks']));
?>
</td>
<td><?php echo credit_hour($rows['sub']); ?></td>
<td>
<?php
$stat = $rows['marks'];
if($stat<60){
echo "<span style='background:red;padding:3px 11px;color:#fff;'>Fail</span>";
}elseif($stat>=60 && $stat<70){
echo "<span style='background:yellow'>Retake</span>";
}else{
echo "<span style='background:green;padding:3px 6px;color:#fff;'>Pass</span>";
}
?>
</td>
</tr>
<?php } ?>
<tr>
<td colspan="2">SGPA : </td>
<td colspan="2">
<?php
$sg = $gp/$ch;
echo "<span style='color:green;padding:3px 6px;font-size:20px'>" . round($sg,2) . "</span>"; ?>
</td>
<td>
<?php
if($sg>=3.5){
echo "<span style='background:purple;padding:3px 6px;color:#fff;'>Excellent";
}elseif($sg>=3.0 && $sg<3.5){
echo "<span style='background:green;padding:3px 6px;color:#fff;'>Good";
}elseif($sg>=2.5 && $sg<3.0){
echo "<span style='background:gray;padding:3px 6px;color:#fff;'>Average";
}else{
echo "<span style='background:red;padding:3px 6px;color:#fff;'>Probation";
}
?>
</td>
</tr>
</table>
<?php
}
else{
echo "<p style='color:red;text-align:center'>Nothing Found</p>";
}
?>
<p style="float:left; text-align:right;margin:20px 0;width:49%"><a href="st_result_update.php?ar=<?php echo $stid?>&seme=<?php echo $semester?>&vn=<?php echo $name?>"><button class="editbtn">Edit Result</button></a></p>
<?php
}
?>
<p style="float:right;text-align:left;margin:20px 0;width:49%"><a href="st_result.php"><button class="editbtn">Back to list</button></a></p>
</div>
<?php include "php/footerbottom.php";?>
<?php ob_end_flush() ; ?>