-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathifhod-result.php
198 lines (196 loc) · 4.68 KB
/
ifhod-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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
session_start();
$user = $_SESSION['user'];
$msg="";
require "config/config.php";
if ( $_SESSION['ifhod'] != "log"){
header ("Location: index.php");
}
function per($question,$subject)
{
include 'config/config.php';
$res = mysqli_query($db_handle,"SELECT * FROM `if_feed` WHERE subject='$subject'");
$values = Array();
$i = 0;
$sum = $total = 0;
while ($db_field = mysqli_fetch_assoc($res))
{
$values[$i] = $db_field["$question"];
$sum = $sum + $values[$i];
$total = $total + 4;
$i++;
}
if($sum!=0)
{
return (intval(($sum/$total)*100));
}
else {
return 0;
}
}
?>
<html>
<title>Feedback Result</title>
<div class="wrapper">
<head>
<link href="css/mystyle.css" rel="stylesheet" type="text/css"/>
<table><tr><td><h1>IF Result</h1></td>
<td width="1000px" align="right"><a href="logout.php" class="logout">Logout</a></td></tr></table>
<div id="cssmenu">
<ul>
<li><a href="ifhod.php">Home</a></li>
<li><a href="ifhod-add-if.php">Add Student</a></li>
<li><a href="ifhod-del-stud.php">Delete Student</a></li>
<li><a href="ifhod-result.php">See Result</a><li>
<li><a href="ifhod-stud-msg.php">Students Messages</a></li>
<li><a href="#">Profile</a>
<ul>
<li><a href="ifhod-changepass.php">Change Password</a></li>
</ul>
</ul>
</div>
<link rel="stylesheet" href="css/normalize.css"><br><br>
<style>
.wrapper {
display: flex;
align-items: center;
flex-direction: column;
width: 97%;
min-height: 97%;
padding: 20px;
background: rgba(4, 40, 68, 0.85);
color:white;
font-size: 14px;
}
form{
text-align: left;
align-items: center;
color:white;
}
input,select{
color: black;
}
h1{color:#FFF;}
</style>
</head>
<body>
<form action="ifhod-result.php" method="POST">
<input type="submit" name="year" class="logout" value="FY">
<input type="submit" name="year" class="logout" value="SY">
<input type="submit" name="year" class="logout" value="TY">
</form>
<link href="css/stud.css" rel="stylesheet" type="text/css"/>
<?php echo "$msg"; ?><br><br>
<?php
if(isset($_POST['year'])){
$year = $_POST['year'];
$res = mysqli_query($db_handle,"SELECT * FROM `if_subject` WHERE year='$year'");
$subjects = array();
$i=0;
while($db_field = mysqli_fetch_assoc($res))
{
$subjects[$i] = $db_field['name'];
$i++;
}
$res = mysqli_query($db_handle,"SELECT * FROM ques");
$questions = array();
$i=0;
while($db_field = mysqli_fetch_assoc($res))
{
$questions[$i] = $db_field['question'];
$i++;
}
$res1 = mysqli_query($db_handle,"SELECT * FROM users WHERE year='$year' AND chk='1' AND branch='IF'");
$given = mysqli_num_rows($res1);
if(mysqli_num_rows($res1) == 0)
{
$msg = "Sorry no one have given feedback yet.";
echo "$msg";
}
else
{
$msg = "$given students have given feedback yet and results are according to that in Percentage.";
echo "$msg";
echo "<div id='print-content'><br><br><table class='reference' style='width:100%''>";
$i = $j = 0;
$sum = 0;
$total = array();
$value = array();
for($i=0;$i<count($subjects);$i++)
{
$sum = 0;
$total[$i] = 0;
for($j=0;$j<count($questions);$j++)
{
$value[$j][$i] = per($questions[$j],$subjects[$i]);
$sum = $sum + $value[$j][$i];
}
$total[$i] = intval($sum/(count($questions)));
}
print "<th>Subject</th>";
$re = mysqli_query($db_handle,"SELECT * FROM ques");
$questions = array();
$i=0;
while ($db_field = mysqli_fetch_assoc($re))
{
$questions[$i] = $db_field['question'];
$j = $i + 1;
echo "<th>Question $j</th>";
$i++;
}
echo"<th>Total</th><th>Grade</th></tr>";
$sub_count = count($subjects);
$que_count = count($questions);
for($i=0;$i<$sub_count;$i++)
{
print "<tr>";
print "<td>$subjects[$i]</td>";
for($j=0;$j<=$que_count;$j++)
{
if($j != $que_count)
{
$e = $value[$j][$i];
print "<td>$e</td>";
}
else
{
$e = $total[$i];
print "<td>$e</td>";
if($e<=25){
print "<td>Poor</td>";
}
else if($e<=50 && $e>25){
print "<td>Satisfactory</td>";
}
else if($e<=75 && $e>50){
print "<td>Good</td>";
}
else{
print "<td>Excellent</td>";
}
}
}
print "</tr>";
}
}
}
?>
</tr>
</table></div>
<br><br>
<style>
button{
position: relative;
}
</style>
<input type="button" onClick="printDiv('print-content')" value="Print Result!"/>
<script type="text/javascript">
function printDiv(divName){
var printContents = document.getElementById(divName).innerHTML;
w= window.open();
w.document.write(printContents);
w.print();
w.close();
}</script>
</body>
</html>