-
Notifications
You must be signed in to change notification settings - Fork 0
/
studentscore.php
102 lines (102 loc) · 3.49 KB
/
studentscore.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
<?php
require "sessionstart.php";
require "constants.php";
echo '<meta charset="utf-8" />';
if (isset($_POST['score'])) {
$score = $_POST['score'];
require "connectdatabase.php";
if (isset($_GET['coursename'])) {
$checklist = mysql_query("SELECT * FROM coursechoose WHERE teacherid='" . $user . "' AND courseName='" . $_GET['coursename'] . "' ORDER BY courseID, id");
}
else {
$checklist = mysql_query("SELECT * FROM coursechoose WHERE teacherid='" . $user . "' ORDER BY courseID, id");
}
$error = false;
while ($row = mysql_fetch_array($checklist)) {
$value = $score[0];
if ($value < 0 || $value > 100) {
echo "<script>alert('输入的成绩超出范围!\\n错误信息:" . $row['name'] . " " .
$row['courseName'] . " " . $value . "');</script>";
$error = true;
}
else {
mysql_query("UPDATE coursechoose SET score='" . $value . "' WHERE recordID='" . $row['recordID'] . "'");
}
array_shift($score);
}
$faulttext = "";
if ($error == true) {
$faulttext = "\\n输入出错的数据均保留原值。";
}
echo '<script>alert("修改学生成绩成功!' . $faulttext . '");</script>';
echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php?page=studentscore\">";
die("");
}
?>
<link rel="stylesheet" type="text/css" href="css/common.css" />
<div id="main" style="line-height:28px;width:95%;">
<h3>学生成绩评定</h3>
<p>
<span>按课程名称过滤:</span>
<select onchange="self.location.href='index.php?page=studentscore' + options[selectedIndex].value" name="select">
<?php
if (isset($_GET['coursename'])) {
$coursename = $_GET['coursename'];
}
else {
$coursename = "所有课程";
}
echo '<option value="">所有课程</option>';
require "connectdatabase.php";
$checklist = mysql_query("SELECT name FROM courseinformation WHERE teacherid='" . $user . "' ORDER BY id");
while ($row = mysql_fetch_array($checklist)) {
if ($row['name'] == $coursename) {
$selected = ' selected="selected"';
}
else {
$selected = "";
}
echo '<option value="&coursename=' . $row['name'] . '"' . $selected . '>' . $row['name'] . '</option>';
}
?>
</select>
</p>
<form action="studentscore.php" method="post">
<table style="border:1px solid #99F;width:100%;">
<tr style="background-color:#CCC;">
<td>课程编号</td><td>课程名称</td><td>学生学号</td><td>学生姓名</td><td>应得分数</td>
</tr>
<?php
require "connectdatabase.php";
if (isset($_GET['coursename'])) {
$checklist = mysql_query("SELECT * FROM coursechoose WHERE teacherid='" . $user . "' AND courseName='" . $_GET['coursename'] . "' ORDER BY courseID, id");
}
else {
$checklist = mysql_query("SELECT * FROM coursechoose WHERE teacherid='" . $user . "' ORDER BY courseID, id");
}
$i = 0;
while ($row = mysql_fetch_array($checklist)) {
$i++;
if ($i % 2 == 0) {
$highlight = " style=\"background-color:#DDD;\"";
}
else {
$highlight = " style=\"background-color:#EEE;\"";
}
echo "<tr" . $highlight . ">";
echo "<td>" . $row['courseID'] . "</td>";
echo "<td>" . $row['courseName'] . "</td>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo '<td><input name="score[]" type="text" style="text-align:center;" value="' . $row['score'] . '" /></td>';
echo "</tr>";
}
?>
</table>
<p>
<input type="submit" value="保存修改" />
<input type="reset" value="返回修改前状态" />
</p>
</form>
<br />
</div>