教师评价数据收集

工作上需要一个评教收集工具,未用框架,结构简陋,请勿效仿。
局域网下使用,机器落后(IE6凑合运行),匿名评教,ip验证。
请在web根目录下新建目录cache/tongjiset,并将下列文件平行放置。conn.php放置数据库配置信息。
源码如下:

conn.php

1
2
3
4
5
6
7
8
9
10
11
12
<?php
$conn=mysqli_connect("192.168.3.6","username","password","database");
if (mysqli_connect_errno())
{
echo "连接失败: " . mysqli_connect_error();
}

@session_start();//启动session会话
mysqli_query($conn,"SET NAMES 'utf8'");//设置字符集和页面代码统一
require_once("function.php");//加载函数库
//require_once("config.php");//加载配置信息
?>

function.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
<?php

/*
* 此函数不能再iis下工作,但是效率比较高
* @return string user IP address
*/
function getUserHostAddressNoIIS() {
switch (true) {
case isset($_SERVER["HTTP_X_FORWARDED_FOR"]):
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
break;
case isset($_SERVER["HTTP_CLIENT_IP"]):
$ip = $_SERVER["HTTP_CLIENT_IP"];
break;
default:
$ip = $_SERVER["REMOTE_ADDR"] ? $_SERVER["REMOTE_ADDR"] : '127.0.0.1';
}
if (strpos($ip, ', ') > 0) {
$ips = explode(', ', $ip);
$ip = $ips[0];
}
return $ip;
}

function jifenTest($fenshu,$str,&$flag) {
if(empty($fenshu) || !is_numeric($fenshu) || $fenshu>100 || $fenshu<0){
mysqli_close($conn);
echo ("<script language='javascript' type='text/javascript'>alert('".$str."必须大于0小于等于100');</script>");
$flag = false;
}
}

function selectTest($select,$str,&$flag) {
if(empty($select) || strlen($select)<2){
mysqli_close($conn);
echo ("<script language='javascript' type='text/javascript'>alert('".$str."必须选择');</script>");
$flag = false;
}
}

function buTD(&$i,$rowNum){
$nullTdNo=ceil($i/$rowNum)*$rowNum-$i;
for($j=0;$j<$nullTdNo;$j++){
echo "<td>&nbsp;</td>";
}
$nowI=$i+$nullTdNo;
$i=$nowI;

$trFlag=$i%$rowNum;
echo $trFlag==($rowNum-1)?"</tr>":"";
echo "</table>";
}
//当前时间-30分钟
function getlastTime(){
return date("Y-m-d H:i:s",strtotime("-30 minute"));
}

function redirect($url){
header('Location: '.$url);
}
?>

index.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
<?php
error_reporting(E_ALL & ~E_NOTICE);
require_once('conn.php');
?>
<html><head>

<title>选择班级</title>
<script languag="javascritp">
function choose(classno){
if(confirm("电脑在30分钟内只能填写一份教师评价表,你选择了 "+ classno + "班 是否继续?")){
form1.action="tc.php";
form1.classno.value=classno;
form1.submit();
}
}
</script>
</head>

<body>
<?php
$rowNum=5;
$filename="cache/static_index.html";
$status=filemtime($filename)+30>time();//判断文件创建及修改时间距当前时间是否超过30秒


if(file_exists($filename)&&$status){
$str=file_get_contents($filename);
echo $str;
}else{
$sql_classz="select gradeno,classno from classz";
$query = mysqli_query($conn,$sql_classz);
if(mysqli_num_rows($query)<=0){
mysqli_free_result($query);
mysqli_close($conn);
die("<script language='javascript' type='text/javascript'>alert('班级不存在!');history.back(1);</script>");
}else{
ob_start();

$i=0;
$lastGradeno="";
while($row=mysqli_fetch_array($query)){
$trFlag=$i%$rowNum;
if($row["gradeno"]!=$lastGradeno){
if($i!=0){
buTD($i,$rowNum);
}
?>
<h2><?php echo $row["gradeno"] ?></h2>
<table width="100%" border="1" align="center" cellpadding="5" cellspacing="1">
<?php
}

echo $trFlag==0?"<tr>":"";
echo "<td><a href=\"javascript:choose('".$row["classno"]."')\">".$row["classno"]."班</a></td>";
echo $trFlag==($rowNum-1)?"</tr>":"";

$lastGradeno=$row["gradeno"];
$i++;
}

buTD($i,$rowNum);
$content= ob_get_contents();//从缓存中获取内容
ob_end_clean();//关闭缓存并清空
file_put_contents($filename, $content);
echo $content;
}
}
?>
<form action="" method="post" name="form1">
<input name="classno" value="" type="hidden"/>
</from>
</body></html>
<?php mysqli_close($conn);?>

tc.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<?php
error_reporting(E_ALL & ~E_NOTICE);
require_once('conn.php');
?>
<html><head>
<title>学生评教</title>
<style>
.jifen {
width:40px;
}

.other {
width:60px;
}
</style>
<script>
function check(){
return confirm("确定要提交吗?");
}
</script>
</head>
<?php

$ip =getUserHostAddressNoIIS();
//客户端是否输入classno
$classno=trim($_POST["classno"]);
if(empty($classno) || !is_numeric($classno)){
mysqli_close($conn);
die("<script language='javascript' type='text/javascript'>alert('班级不存在!');window.location.href=\"index.php\";</script>");


}
//数据库是否存在classno
$sql_pingjiao="select * from classz where classno='".$classno."' and editflag=1";
$query = mysqli_query($conn,$sql_pingjiao);

if(mysqli_num_rows($query)<=0){
mysqli_free_result($query);
mysqli_close($conn);
die("<script language='javascript' type='text/javascript'>alert('所选班级不能填报!');window.location.href=\"index.php\";</script>");

}else if ($row=mysqli_fetch_array($query)){
$classno=$row["classno"];
$banzhuren=$row["banzhuren"];
$yuwen=$row["yuwen"];
$shuxue=$row["shuxue"];
$waiyu=$row["waiyu"];
$wuli=$row["wuli"];
$huaxue=$row["huaxue"];
$shengwu=$row["shengwu"];
$zhengzhi=$row["zhengzhi"];
$lishi=$row["lishi"];
$dili=$row["dili"];
$tiyu=$row["tiyu"];
$gradeno=$row["gradeno"];
}

$action = isset($_GET["act"]) ? $_GET["act"] : "";
if($action=="pingjiao"){
$pingjiao_id=$_POST["pingjiao_id"];
$classno_name=$_POST["classno_name"];
$banzhuren_name=$_POST["banzhuren_name"];
$yuwen_name=$_POST["yuwen_name"];
$shuxue_name=$_POST["shuxue_name"];
$waiyu_name=$_POST["waiyu_name"];
$wuli_name=$_POST["wuli_name"];
$huaxue_name=$_POST["huaxue_name"];
$shengwu_name=$_POST["shengwu_name"];
$zhengzhi_name=$_POST["zhengzhi_name"];
$lishi_name=$_POST["lishi_name"];
$dili_name=$_POST["dili_name"];
$tiyu_name=$_POST["tiyu_name"];
$qita_name=$_POST["qita_name"];
$youmo_name=$_POST["youmo_name"];
$aixin_name=$_POST["aixin_name"];
$qianneng_name=$_POST["qianneng_name"];
$xihuan_name=$_POST["xihuan_name"];
$jianyi_name=$_POST["jianyi_name"];

$flag=true;
jifenTest($yuwen_name,$yuwen."教师得分",$flag);
jifenTest($shuxue_name,$shuxue."教师得分",$flag);
jifenTest($waiyu_name,$waiyu."教师得分",$flag);
jifenTest($wuli_name,$wuli."教师得分",$flag);
jifenTest($huaxue_name,$huaxue."教师得分",$flag);
jifenTest($shengwu_name,$shengwu."教师得分",$flag);
jifenTest($zhengzhi_name,$zhengzhi."教师得分",$flag);
jifenTest($lishi_name,$lishi."教师得分",$flag);
jifenTest($dili_name,$dili."教师得分",$flag);

selectTest($youmo_name,"教学中最具幽默感的教师 必须选择",$flag);
selectTest($aixin_name,"最具爱心的教师 必须选择",$flag);
selectTest($qianneng_name,"最能激发学生潜能的教师 必须选择",$flag);
selectTest($xihuan_name,"你最喜欢的教师 必须选择",$flag);
selectTest($banzhuren_name,"对班级工作的整体评价 必须选择",$flag);

if($flag){
$pingjiao_update="update `pingjiao` set "
."banzhuren='".$banzhuren_name."',"
."yuwen=".$yuwen_name.","
."shuxue=".$shuxue_name.","
."waiyu=".$waiyu_name.","
."wuli=".$wuli_name.","
."huaxue=".$huaxue_name.","
."shengwu=".$shengwu_name.","
."zhengzhi=".$zhengzhi_name.","
."lishi=".$lishi_name.","
."dili=".$dili_name.","
.(empty($tiyu) || !is_numeric($tiyu)?"":"tiyu=".$tiyu_name.",")
.(empty($qita) || !is_numeric($qita)?"":"qita=".$qita_name.",")
."youmo='".$youmo_name."',"
."aixin='".$aixin_name."',"
."qianneng='".$qianneng_name."',"
."xihuan='".$xihuan_name."',"
."endtime='".date("Y-m-d H:i:s")."',"
."jianyi='".$jianyi_name."' where id=".$pingjiao_id;
mysqli_query($conn,$pingjiao_update);
// 提交事务
mysqli_commit($conn);
echo("<script language='javascript' type='text/javascript'>alert('评价成功!');</script>");
}
}else{

$sql_pingjiao="select * from pingjiao where classno='".$classno."' and ip='".$ip."'";
$query = mysqli_query($conn,$sql_pingjiao);
if(mysqli_num_rows($query)<=0){
mysqli_free_result($query);
$sql_pingjiao="select * from pingjiao where createtime>'".getlastTime()."' and ip='".$ip."'";
$query = mysqli_query($conn,$sql_pingjiao);
if(mysqli_num_rows($query)<=0){
//mysqli_free_result($query);
$pingjiao_create="INSERT INTO `pingjiao` (`gradeno`,`classno`,`ip`) VALUES ('".$gradeno."','".$classno."','".$ip."')";
$ins = mysqli_query($conn,$pingjiao_create);
// 提交事务
$pingjiao_id=mysqli_insert_id($conn);
mysqli_commit($conn);
mysqli_close($conn);
echo("<script language='javascript' type='text/javascript'>alert('表格编号:".$pingjiao_id.",请认真填写表格。');</script>");
}else{
mysqli_free_result($query);
mysqli_close($conn);
die("<script language='javascript' type='text/javascript'>alert('你在已经填写了一张表格!');history.back(1);</script>");
}
}else if ($row=mysqli_fetch_array($query)){
if(getlastTime()<$row["createtime"]){
$pingjiao_id=$row["id"];
$classno_name=$row["classno"];
$banzhuren_name=$row["banzhuren"];
$yuwen_name=$row["yuwen"];
$shuxue_name=$row["shuxue"];
$waiyu_name=$row["waiyu"];
$wuli_name=$row["wuli"];
$huaxue_name=$row["huaxue"];
$shengwu_name=$row["shengwu"];
$zhengzhi_name=$row["zhengzhi"];
$lishi_name=$row["lishi"];
$dili_name=$row["dili"];
$tiyu_name=$row["tiyu"];
$qita_name=$row["qita"];
$youmo_name=$row["youmo"];
$aixin_name=$row["aixin"];
$qianneng_name=$row["qianneng"];
$xihuan_name=$row["xihuan"];
$jianyi_name=$row["jianyi"];
echo("<script language='javascript' type='text/javascript'>alert('表格编号:".$pingjiao_id.",请尽快修改。');</script>");
}else{
mysqli_free_result($query);
mysqli_close($conn);
die("<script language='javascript' type='text/javascript'>alert('填表超过三十分钟,无法修改!');history.back(1);</script>");
}
}

}
?>
<body>
<form action="?act=pingjiao" method="post" onsubmit="check()">
<input name="pingjiao_id" type="hidden" value="<?php echo $pingjiao_id ?>"/>
<input name="classno" type="hidden" value="<?php echo $classno ?>" />
<h1 style="text-align:center;">河津市第二中学学生评教表(<?php echo $classno ?>班)</h1>
各位同学:<br/>
<p>
评教作为学校的一项常规工作,既是对各位老师一学期的评价,也关系到每一位学生的成长和学校的发展。请同学们比较各位老师的工作,仔细阅读各项计分规则,本着客观公正、实事求是的原则为每一位老师打分,并认真填写问卷调查。感谢你的负责和支持。
</p>
<p><h2>一、评价标准</h2></p>
<table width="100%" border="1" align="center" cellpadding="5" cellspacing="1">
<tr>
<td colspan="3">职业道德 40分</td>
<td colspan="3">教育教学 60分</td>
</tr>

<tr>
<td>教师形象(10分)</td>
<td>依法执教(15分)</td>
<td>教师素养(15分)</td>
<td>教学态度(20分)</td>
<td>教学方法(20分)</td>
<td>教学效果(20分)</td>
</tr>

<tr>
<td>注重形象和人格魅力,严以律己,为人师表;与时俱进、博学多思;追求真善美。</td>
<td>不体罚、辱骂学生,不强行组织学生征订资料,不乱收费,不以教谋私。</td>
<td>诚信民主,尊重、热爱、宽容学生,热情为学生服务,师生关系和谐,情谊浓厚,关注学生全面发展,尊重家长。</td>
<td>乐于奉献,有责任感;不迟到、不旷课;作业批改认真及时,回答学生提问耐心细致。</td>
<td>认真备课;教学严谨有序,课堂充满激情与活力;注重学生能力和素质的培养;具有自己的教学模式和风格。</td>
<td>学生对学习自信,学习效果良好,学习成绩提高,学习方式科学,自主学习能力不断提高。</td>
</tr>
</table>
<p><h2>二、教师评价</h2></p>
<table width="100%" border="1" align="center" cellpadding="5" cellspacing="1">
<tr>
<td>科目</td>
<td>语文</td>
<td>数学</td>
<td>外语</td>
<td>物理</td>
<td>化学</td>
<td>生物</td>
<td>政治</td>
<td>历史</td>
<td>地理</td>
<td>体育</td>
</tr>

<tr>
<td>姓名</td>
<td><?php echo $yuwen ?></td>
<td><?php echo $shuxue ?></td>
<td><?php echo $waiyu ?></td>
<td><?php echo $wuli ?></td>
<td><?php echo $huaxue ?></td>
<td><?php echo $shengwu ?></td>
<td><?php echo $zhengzhi ?></td>
<td><?php echo $lishi ?></td>
<td><?php echo $dili ?></td>
<td><?php echo $tiyu ?></td>
</tr>

<tr>
<td>计分 </td>
<td><input name="yuwen_name" class="jifen" type="text" value="<?php echo $yuwen_name ?>"/></td>
<td><input name="shuxue_name" class="jifen" type="text" value="<?php echo $shuxue_name ?>"/></td>
<td><input name="waiyu_name" class="jifen" type="text" value="<?php echo $waiyu_name ?>"/></td>
<td><input name="wuli_name" class="jifen" type="text" value="<?php echo $wuli_name ?>"/></td>
<td><input name="huaxue_name" class="jifen" type="text" value="<?php echo $huaxue_name ?>"/></td>
<td><input name="shengwu_name" class="jifen" type="text" value="<?php echo $shengwu_name ?>"/></td>
<td><input name="zhengzhi_name" class="jifen" type="text" value="<?php echo $zhengzhi_name ?>"/></td>
<td><input name="lishi_name" class="jifen" type="text" value="<?php echo $lishi_name ?>"/></td>
<td><input name="dili_name" class="jifen" type="text" value="<?php echo $dili_name ?>"/></td>
<td><?php if(strlen($tiyu)>=2){
?>
<input name="tiyu_name" class="jifen" type="text" value="<?php echo $tiyu_name ?>"/>
<?php
}
?></td>
</tr>
</table>
<p><h2>三、问卷调查</h2></p>
<p><h3>1、问卷调查</h3></p>
<table width="100%" border="1" align="center" cellpadding="5" cellspacing="1">
<tr>
<td>教学中最具幽默感的教师:</td>
<td><input name="youmo_name" type="radio" value="<?php echo $yuwen ?>" <?php if($youmo_name==$yuwen) echo("checked");?>/><?php echo $yuwen ?></td>
<td><input name="youmo_name" type="radio" value="<?php echo $shuxue ?>" <?php if($youmo_name==$shuxue) echo("checked");?>/><?php echo $shuxue ?></td>
<td><input name="youmo_name" type="radio" value="<?php echo $waiyu ?>" <?php if($youmo_name==$waiyu) echo("checked");?>/><?php echo $waiyu ?></td>
<td><input name="youmo_name" type="radio" value="<?php echo $wuli ?>" <?php if($youmo_name==$wuli) echo("checked");?>/><?php echo $wuli ?></td>
<td><input name="youmo_name" type="radio" value="<?php echo $huaxue ?>" <?php if($youmo_name==$huaxue) echo("checked");?>/><?php echo $huaxue ?></td>
<td><input name="youmo_name" type="radio" value="<?php echo $shengwu ?>" <?php if($youmo_name==$shengwu) echo("checked");?>/><?php echo $shengwu ?></td>
<td><input name="youmo_name" type="radio" value="<?php echo $zhengzhi ?>" <?php if($youmo_name==$zhengzhi) echo("checked");?>/><?php echo $zhengzhi ?></td>
<td><input name="youmo_name" type="radio" value="<?php echo $lishi ?>" <?php if($youmo_name==$lishi) echo("checked");?>/><?php echo $lishi ?></td>
<td><input name="youmo_name" type="radio" value="<?php echo $dili ?>" <?php if($youmo_name==$dili) echo("checked");?>/><?php echo $dili ?></td>
<td><?php if(strlen($tiyu)>=2){
?>
<input name="youmo_name" type="radio" value="<?php echo $tiyu ?>" <?php if($youmo_name==$tiyu) echo("checked");?>/><?php echo $tiyu ?>
<?php
}
?></td>
</tr>

<tr>
<td>最具爱心的教师:</td>
<td><input name="aixin_name" type="radio" value="<?php echo $yuwen ?>" <?php if($aixin_name==$yuwen) echo("checked");?>/><?php echo $yuwen ?></td>
<td><input name="aixin_name" type="radio" value="<?php echo $shuxue ?>" <?php if($aixin_name==$shuxue) echo("checked");?>/><?php echo $shuxue ?></td>
<td><input name="aixin_name" type="radio" value="<?php echo $waiyu ?>" <?php if($aixin_name==$waiyu) echo("checked");?>/><?php echo $waiyu ?></td>
<td><input name="aixin_name" type="radio" value="<?php echo $wuli ?>" <?php if($aixin_name==$wuli) echo("checked");?>/><?php echo $wuli ?></td>
<td><input name="aixin_name" type="radio" value="<?php echo $huaxue ?>" <?php if($aixin_name==$huaxue) echo("checked");?>/><?php echo $huaxue ?></td>
<td><input name="aixin_name" type="radio" value="<?php echo $shengwu ?>" <?php if($aixin_name==$shengwu) echo("checked");?>/><?php echo $shengwu ?></td>
<td><input name="aixin_name" type="radio" value="<?php echo $zhengzhi ?>" <?php if($aixin_name==$zhengzhi) echo("checked");?>/><?php echo $zhengzhi ?></td>
<td><input name="aixin_name" type="radio" value="<?php echo $lishi ?>" <?php if($aixin_name==$lishi) echo("checked");?>/><?php echo $lishi ?></td>
<td><input name="aixin_name" type="radio" value="<?php echo $dili ?>" <?php if($aixin_name==$dili) echo("checked");?>/><?php echo $dili ?></td>
<td><?php if(strlen($tiyu)>=2){
?>
<input name="aixin_name" type="radio" value="<?php echo $tiyu ?>" <?php if($aixin_name==$tiyu) echo("checked");?>/><?php echo $tiyu ?>
<?php
}
?></td>
</tr>

<tr>
<td>最能激发学生潜能的教师:</td>
<td><input name="qianneng_name" type="radio" value="<?php echo $yuwen ?>" <?php if($qianneng_name==$yuwen) echo("checked");?>/><?php echo $yuwen ?></td>
<td><input name="qianneng_name" type="radio" value="<?php echo $shuxue ?>" <?php if($qianneng_name==$shuxue) echo("checked");?>/><?php echo $shuxue ?></td>
<td><input name="qianneng_name" type="radio" value="<?php echo $waiyu ?>" <?php if($qianneng_name==$waiyu) echo("checked");?>/><?php echo $waiyu ?></td>
<td><input name="qianneng_name" type="radio" value="<?php echo $wuli ?>" <?php if($qianneng_name==$wuli) echo("checked");?>/><?php echo $wuli ?></td>
<td><input name="qianneng_name" type="radio" value="<?php echo $huaxue ?>" <?php if($qianneng_name==$huaxue) echo("checked");?>/><?php echo $huaxue ?></td>
<td><input name="qianneng_name" type="radio" value="<?php echo $shengwu ?>" <?php if($qianneng_name==$shengwu) echo("checked");?>/><?php echo $shengwu ?></td>
<td><input name="qianneng_name" type="radio" value="<?php echo $zhengzhi ?>" <?php if($qianneng_name==$zhengzhi) echo("checked");?>/><?php echo $zhengzhi ?></td>
<td><input name="qianneng_name" type="radio" value="<?php echo $lishi ?>" <?php if($qianneng_name==$lishi) echo("checked");?>/><?php echo $lishi ?></td>
<td><input name="qianneng_name" type="radio" value="<?php echo $dili ?>" <?php if($qianneng_name==$dili) echo("checked");?>/><?php echo $dili ?></td>
<td><?php if(strlen($tiyu)>=2){
?>
<input name="qianneng_name" type="radio" value="<?php echo $tiyu ?>" <?php if($qianneng_name==$tiyu) echo("checked");?>/><?php echo $tiyu ?>
<?php
}
?></td>
</tr>

<tr>
<td>你最喜欢的教师:</td>
<td><input name="xihuan_name" type="radio" value="<?php echo $yuwen ?>" <?php if($xihuan_name==$yuwen) echo("checked");?>/><?php echo $yuwen ?></td>
<td><input name="xihuan_name" type="radio" value="<?php echo $shuxue ?>" <?php if($xihuan_name==$shuxue) echo("checked");?>/><?php echo $shuxue ?></td>
<td><input name="xihuan_name" type="radio" value="<?php echo $waiyu ?>" <?php if($xihuan_name==$waiyu) echo("checked");?>/><?php echo $waiyu ?></td>
<td><input name="xihuan_name" type="radio" value="<?php echo $wuli ?>" <?php if($xihuan_name==$wuli) echo("checked");?>/><?php echo $wuli ?></td>
<td><input name="xihuan_name" type="radio" value="<?php echo $huaxue ?>" <?php if($xihuan_name==$huaxue) echo("checked");?>/><?php echo $huaxue ?></td>
<td><input name="xihuan_name" type="radio" value="<?php echo $shengwu ?>" <?php if($xihuan_name==$shengwu) echo("checked");?>/><?php echo $shengwu ?></td>
<td><input name="xihuan_name" type="radio" value="<?php echo $zhengzhi ?>" <?php if($xihuan_name==$zhengzhi) echo("checked");?>/><?php echo $zhengzhi ?></td>
<td><input name="xihuan_name" type="radio" value="<?php echo $lishi ?>" <?php if($xihuan_name==$lishi) echo("checked");?>/><?php echo $lishi ?></td>
<td><input name="xihuan_name" type="radio" value="<?php echo $dili ?>" <?php if($xihuan_name==$dili) echo("checked");?>/><?php echo $dili ?></td>
<td><?php if(strlen($tiyu)>=2){
?>
<input name="xihuan_name" type="radio" value="<?php echo $tiyu ?>" <?php if($xihuan_name==$tiyu) echo("checked");?>/><?php echo $tiyu ?>
<?php
}
?></td>
</tr>

</table>
<p><h3>2、对班级工作的整体评价:</h3> <lable><input name="banzhuren_name" type="radio" value="优秀" <?php if($banzhuren_name=="优秀") echo("checked");?>/>优秀</lable>
<lable><input name="banzhuren_name" type="radio" value="良好" <?php if($banzhuren_name=="良好") echo("checked");?>/>良好</lable>
<lable><input name="banzhuren_name" type="radio" value="一般" <?php if($banzhuren_name=="一般") echo("checked");?>/>一般</lable>
<lable><input name="banzhuren_name" type="radio" value="较差" <?php if($banzhuren_name=="较差") echo("checked");?>/>较差</lable>
</p>
<p><h3>3、请写下您对代课教师、班级工作的建议和要求:</h3></p>
<textarea name="jianyi_name" rows="10" cols="50"><?php echo $jianyi_name ?></textarea>
<span align="center"><input type="submit" value="提交"/></span>
</form>
</body></html>
<?php mysqli_close($conn);?>

tongji.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
<?php
error_reporting(E_ALL & ~E_NOTICE);
require_once('conn.php');
?>
<html><head>

<title>选择班级</title>
<script languag="javascritp">
function choose(classno){
form1.classno.value=classno;
form1.action="tongjiset.php";
form1.submit();
}

function updateFlag(classno,editflag){
form1.classno.value=classno;
form1.editflag.value=editflag;
form1.action="tongji.php?act=updateFlag";
form1.submit();
}
</script>
</head>


<body>
<?php
$action = isset($_GET["act"]) ? $_GET["act"] : "";

if($action=="updateFlag"){
$whereStr="";

$classno=trim($_POST["classno"]);
$editflag=trim($_POST["editflag"]);
if (!is_numeric($editflag)){
die("<script language='javascript' type='text/javascript'>alert('参数错误!');history.back(1);</script>");
}else if(is_numeric($classno) && $classno !=-1){
$whereStr=" where classno='".$classno."'";
}else if(!is_numeric($classno)){
$whereStr=" where gradeno='".$classno."'";
}

$sql="update `classz` set editflag=".$editflag.$whereStr;
mysqli_query($conn,$sql);
redirect("tongji.php");
}
$rowNum=5;

$sql_classz="select gradeno,classno,editflag from classz";
$query = mysqli_query($conn,$sql_classz);
if(mysqli_num_rows($query)<=0){
die("<script language='javascript' type='text/javascript'>alert('班级不存在!');history.back(1);</script>");
}else{
?>
<h1 style="text-align:center;"><a href="javascript:choose('-1')">全部班级</a>(<a href="javascript:updateFlag('-1',1)">全部打开</a>)(<a href="javascript:updateFlag('-1',0)">全部关闭</a>)</h1>
<?php
$i=0;
$lastGradeno="";
while($row=mysqli_fetch_array($query)){
$trFlag=$i%$rowNum;
if($row["gradeno"]!=$lastGradeno){
if($i!=0){
buTD($i,$rowNum);
}
?>
<h2><a href="javascript:choose('<?php echo $row["gradeno"] ?>')"><?php echo $row["gradeno"] ?></a>|(<a href="javascript:updateFlag('<?php echo $row["gradeno"] ?>',1)">全部打开</a>)(<a href="javascript:updateFlag('<?php echo $row["gradeno"] ?>',0)">全部关闭</a>)</h2>
<table width="100%" border="1" align="center" cellpadding="5" cellspacing="1">
<?php
}

echo $trFlag==0?"<tr>":"";
echo "<td><a href=\"javascript:choose('".$row["classno"]."')\">".$row["classno"]."班</a>|<a style=\"color:".($row["editflag"]==0?"red":"green").";\" href=\"javascript:updateFlag('".$row["classno"]."',".($row["editflag"]==0?"1":"0").")\">".($row["editflag"]==0?"已关闭(点击打开)":"已打开(点击关闭)")."</a></td>";
echo $trFlag==($rowNum-1)?"</tr>":"";

$lastGradeno=$row["gradeno"];
$i++;
}

buTD($i,$rowNum);

}


?>
<form action="" method="post" name="form1">
<input name="classno" value="" type="hidden"/>
<input name="editflag" value="" type="hidden"/>
</from>
</body></html>
<?php
mysqli_free_result($query);
mysqli_close($conn);
?>

tongjiset.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
<?php
error_reporting(E_ALL & ~E_NOTICE);
require_once('conn.php');
?>
<html><head>
<title>学生评教</title>
<style>
.jifen {
width:40px;
}

.other {
width:60px;
}
</style>
</head>

<body>
<?php
$classno=trim($_POST["classno"]);
$filename="cache/tongjiset/static_classno_".$classno.".html";
$status=filemtime($filename)+30>time();//判断文件创建及修改时间距当前时间是否超过30秒

if(file_exists($filename)&&$status){
$str=file_get_contents($filename);
echo $str;
}else{
ob_start();
$whereStr=" where endtime is not null";
//客户端是否输入classno


if(empty($classno)){
mysqli_close($conn);
die("<script language='javascript' type='text/javascript'>alert('班级不存在!');history.back(1);</script>");
}else if(is_numeric($classno) && $classno !=-1){
//数据库是否存在classno
$sql_pingjiao="select * from classz where classno='".$classno."'";
$query = mysqli_query($conn,$sql_pingjiao);

if(mysqli_num_rows($query)<=0){
mysqli_free_result($query);
mysqli_close($conn);
die("<script language='javascript' type='text/javascript'>alert('班级不存在!');history.back(1);</script>");

}else if ($row=mysqli_fetch_array($query)){
mysql_free_result($query);
$classno=$row["classno"];
$banzhuren=$row["banzhuren"];
$yuwen=$row["yuwen"];
$shuxue=$row["shuxue"];
$waiyu=$row["waiyu"];
$wuli=$row["wuli"];
$huaxue=$row["huaxue"];
$shengwu=$row["shengwu"];
$zhengzhi=$row["zhengzhi"];
$lishi=$row["lishi"];
$dili=$row["dili"];
$tiyu=$row["tiyu"];
}

$whereStr=" where classno='".$classno."'";
}else if(!is_numeric($classno)){
$whereStr=" where gradeno='".$classno."'";
}

?>

<h1 style="text-align:center;">河津市第二中学学生评教统计(<?php echo $classno==-1?"全部":$classno ?>班)</h1>
<table width="100%" border="1" align="center" cellpadding="5" cellspacing="1">
<tr>
<th>编号</th>
<th>IP</th>
<th>填表开始<br/>时间</th>
<th>填表结束<br/>时间</th>
<th>语文<?php echo $yuwen ?></th>
<th>数学<?php echo $shuxue ?></th>
<th>外语<?php echo $waiyu ?></th>
<th>物理<?php echo $wuli ?></th>
<th>化学<?php echo $huaxue ?></th>
<th>生物<?php echo $shengwu ?></th>
<th>政治<?php echo $zhengzhi ?></th>
<th>历史<?php echo $lishi ?></th>
<th>地理<?php echo $dili ?></th>
<th>体育<?php echo $tiyu ?></th>
<th>最具幽默<br/>感的教师</th>
<th>最具爱心<br/>的教师</th>
<th>最能激发<br/>学生潜能</th>
<th>最喜欢<br/>的教师</th>
<th>班级工作<br/>整体评价</th>
<th>建议和要求</th>
</tr>


<?php
$qry = mysqli_query($conn,"select * from pingjiao" .$whereStr);
$recordcount = max(mysqli_num_rows($qry),0);

while($qrow=mysqli_fetch_array($qry))
{
?>
<tr>
<td><?php echo $qrow["id"] ?></td>
<td><?php echo $qrow["ip"] ?></td>
<td><?php echo $qrow["createtime"] ?></td>
<td><?php echo $qrow["endtime"] ?></td>
<td><?php echo $qrow["yuwen"] ?></td>
<td><?php echo $qrow["shuxue"] ?></td>
<td><?php echo $qrow["waiyu"] ?></td>
<td><?php echo $qrow["wuli"] ?></td>
<td><?php echo $qrow["huaxue"] ?></td>
<td><?php echo $qrow["shengwu"] ?></td>
<td><?php echo $qrow["zhengzhi"] ?></td>
<td><?php echo $qrow["lishi"] ?></td>
<td><?php echo $qrow["dili"] ?></td>
<td><?php echo $qrow["tiyu"] ?></td>
<td><?php echo $qrow["youmo"] ?></td>
<td><?php echo $qrow["aixin"] ?></td>
<td><?php echo $qrow["qianneng"] ?></td>
<td><?php echo $qrow["xihuan"] ?></td>
<td><?php echo $qrow["banzhuren"] ?></td>
<td><?php echo $qrow["jianyi"] ?></td>
</tr>
<?php
}

mysqli_free_result($qry);

?>
</table>
<?php
$content= ob_get_contents();//从缓存中获取内容
ob_end_clean();//关闭缓存并清空
file_put_contents($filename, $content);
echo $content;
}
?>
</body></html>
<?php mysqli_close($conn);?>

create.sql

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
CREATE TABLE `classz` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '编号',
`gradeno` VARCHAR(45) NOT NULL COMMENT '年级',
`level` VARCHAR(45) NULL DEFAULT NULL COMMENT '层次',
`classno` VARCHAR(45) NOT NULL COMMENT '班级',
`banzhuren` VARCHAR(45) NOT NULL COMMENT '班主任',
`yuwen` VARCHAR(45) NOT NULL COMMENT '语文',
`shuxue` VARCHAR(45) NOT NULL COMMENT '数学',
`waiyu` VARCHAR(45) NOT NULL COMMENT '外语',
`wuli` VARCHAR(45) NOT NULL COMMENT '物理',
`huaxue` VARCHAR(45) NOT NULL COMMENT '化学',
`shengwu` VARCHAR(45) NOT NULL COMMENT '生物',
`zhengzhi` VARCHAR(45) NOT NULL COMMENT '政治',
`lishi` VARCHAR(45) NOT NULL COMMENT '历史',
`dili` VARCHAR(45) NOT NULL COMMENT '地理',
`yinyue` VARCHAR(45) NULL DEFAULT NULL COMMENT '音乐',
`tiyu` VARCHAR(45) NULL DEFAULT NULL COMMENT '体育',
`meishu` VARCHAR(45) NULL DEFAULT NULL COMMENT '美术',
`xinxi` VARCHAR(45) NULL DEFAULT NULL COMMENT '信息',
`tongyong` VARCHAR(45) NULL DEFAULT NULL COMMENT '通用',
`qita` VARCHAR(45) NULL DEFAULT NULL COMMENT '其他',
`editflag` TINYINT(1) UNSIGNED ZEROFILL NULL DEFAULT '0',
PRIMARY KEY (`id`),
INDEX `Index 2` (`classno`)
)
COMMENT='班级'
COLLATE='utf8_general_ci'
ENGINE=MyISAM
ROW_FORMAT=COMPACT
AUTO_INCREMENT=58
;
CREATE TABLE `pingjiao` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '编号',
`classno` VARCHAR(45) NOT NULL COMMENT '班级',
`gradeno` VARCHAR(45) NULL DEFAULT NULL,
`banzhuren` VARCHAR(45) NULL DEFAULT NULL COMMENT '班主任',
`yuwen` TINYINT(4) NULL DEFAULT NULL COMMENT '语文',
`shuxue` TINYINT(4) NULL DEFAULT NULL COMMENT '数学',
`wuli` TINYINT(4) NULL DEFAULT NULL COMMENT '物理',
`waiyu` TINYINT(4) NULL DEFAULT NULL COMMENT '外语',
`huaxue` TINYINT(4) NULL DEFAULT NULL COMMENT '化学',
`shengwu` TINYINT(4) NULL DEFAULT NULL COMMENT '生物',
`lishi` TINYINT(4) NULL DEFAULT NULL COMMENT '历史',
`dili` TINYINT(4) NULL DEFAULT NULL COMMENT '地理',
`zhengzhi` TINYINT(4) NULL DEFAULT NULL COMMENT '政治',
`yinyue` TINYINT(4) NULL DEFAULT NULL COMMENT '音乐',
`tiyu` TINYINT(4) NULL DEFAULT NULL COMMENT '体育',
`meishu` TINYINT(4) NULL DEFAULT NULL COMMENT '美术',
`xinxi` TINYINT(4) NULL DEFAULT NULL COMMENT '信息',
`tongyong` TINYINT(4) NULL DEFAULT NULL COMMENT '通用',
`qita` TINYINT(4) NULL DEFAULT NULL COMMENT '其他',
`youmo` VARCHAR(50) NULL DEFAULT NULL COMMENT '最具幽默感的教师',
`aixin` VARCHAR(50) NULL DEFAULT NULL COMMENT '最具爱心的教师',
`qianneng` VARCHAR(50) NULL DEFAULT NULL COMMENT '最能激发学生潜能的教师',
`xihuan` VARCHAR(50) NULL DEFAULT NULL COMMENT '你最喜欢的教师',
`jianyi` TEXT NULL COMMENT '意见或建议',
`ip` VARCHAR(45) NOT NULL COMMENT 'ip地址',
`createtime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '表单创建时间',
`endtime` DATETIME NULL DEFAULT NULL COMMENT '表单完成时间',
PRIMARY KEY (`id`),
INDEX `Index 2` (`classno`),
INDEX `Index 3` (`ip`)
)
COMMENT='评教'
COLLATE='utf8_general_ci'
ENGINE=MyISAM
ROW_FORMAT=COMPACT
AUTO_INCREMENT=14
;