-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path成绩分析系统.html
More file actions
222 lines (195 loc) · 6.62 KB
/
Copy path成绩分析系统.html
File metadata and controls
222 lines (195 loc) · 6.62 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
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
<!DOCTYPE html>
<html>
<head>
<title>成绩分析系统</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.16.9/xlsx.full.min.js"></script> <!-- 导入SheetJS库 -->
<style>
body {
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
background-color: #f2f2f2;
}
.container {
width: 800px;
margin: 20px auto;
padding: 20px;
background-color: white;
border-radius: 6px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
h1 {
font-size: 36px;
font-weight: bold;
color: #333;
margin-bottom: 20px;
text-align: center;
}
.upload-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 200px;
border: 2px dashed #ccc;
border-radius: 6px;
margin-bottom: 20px;
}
.upload-icon {
font-size: 48px;
color: #ccc;
}
.upload-text {
font-size: 18px;
color: #666;
margin-top: 10px;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th {
background-color: #008CBA;
color: white;
padding: 10px;
}
td {
text-align: center;
padding: 10px;
border: 1px solid #ccc;
}
th:first-child,
td:first-child {
position: sticky;
left: 0px;
background-color: #f2f2f2;
z-index: 1;
}
th:last-child,
td:last-child {
background-color: #f2f2f2;
}
tr:last-child td {
font-weight: bold;
}
form {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-bottom: 20px;
}
input[type="number"] {
width: 60px;
margin-right: 10px;
text-align: center;
vertical-align: middle;
}
input[type="submit"] {
padding: 8px 16px;
font-size: 16px;
background-color: #008CBA;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #0077A3;
}
.export-btn {
display: inline-block;
padding: 8px 16px;
font-size: 16px;
background-color: #008CBA;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
margin-left: 10px;
}
.export-btn:hover {
background-color: #0077A3;
}
</style>
</head>
<body>
<div class="container">
<h1>成绩分析系统</h1>
<div>
<label for="full-score-input">满分:</label>
<input type="number" id="full-score-input" min="1" max="100" step="1" value="100">
</div>
<form id="input-form">
<div>
<label for="score-input">成绩:</label>
<input type="number" id="score-input" min="0" step="1" required>
</div>
<div>
<label for="name-input">姓名:</label>
<input type="text" id="name-input" required>
</div>
<input type="submit" value="分析">
</form>
<table id="result-table" style="display: none;"></table>
<button class="export-btn" onclick="exportTable()">导出表格(仅电脑端可用)</button>
</div>
<script>
var fullScoreInput = document.getElementById("full-score-input");
var inputForm = document.getElementById("input-form");
var resultTable = document.getElementById("result-table");
var rows = [];
inputForm.addEventListener("submit", function(event) {
event.preventDefault();
var scoreInput = document.getElementById("score-input");
var nameInput = document.getElementById("name-input");
var score = parseInt(scoreInput.value);
var name = nameInput.value;
var fullScore = parseInt(fullScoreInput.value);
if (!isNaN(score) && name !== "") {
rows.push([name, score, fullScore]);
showResult(rows, fullScore);
scoreInput.value = "";
nameInput.value = "";
}
});
function showResult(result, fullScore) {
// 以下是成绩分析的代码
var header = ["姓名", "成绩", "得分率"];
var rowCount = result.length;
var colCount = header.length;
var totalScore = 0;
var maxScore = -Infinity;
var minScore = Infinity;
for (var i = 0; i < rowCount; i++) {
var row = result[i];
var score = parseInt(row[1]);
totalScore += score;
maxScore = Math.max(maxScore, score);
minScore = Math.min(minScore, score);
}
var averageScore = totalScore / rowCount;
var passingCount = 0;
for (var i = 0; i < rowCount; i++) {
var row = result[i];
var score = parseInt(row[1]);
if (score >= 60) {
passingCount++;
}
}
var passRate = passingCount / rowCount * 100;
passRate = passRate.toFixed(2); // 保留两位小数
// 以下是将成绩分析结果展示在表格中的代码
<script>
document.addEventListener("DOMContentLoaded", function() {
var exportButton = document.getElementById("exportButton");
exportButton.addEventListener("click", function() {
// 弹出提示框,提示用户前往电脑网页导出表格文件
window.alert("要导出表格文件,请前往电脑网页:https://youreln.gitee.io/youreln-toolbox/成绩分析");
});
});
</script>
</script>
</body>
</html>