-
Notifications
You must be signed in to change notification settings - Fork 1
/
sec_back-up_getscore.php
executable file
·376 lines (366 loc) · 14.9 KB
/
sec_back-up_getscore.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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<? include("model/header.php") ?>
<body>
<? include("model/nav.php") ?>
<? navShow("exam", "Haofenshu") ?>
<?php if (!isset($_GET["id"]))
{
?>
<div class="ui container main">
<div class="ui action input">
<input type="text" placeholder="Test ID...">
<button class="ui right labeled icon button primary">前往
<i class="angle right icon"></i></button>
</div>
<code id="rmessage"></code>
<div id="shows" class="spaces">
</div>
</div>
<?php } else { ?>
<div class="ui modal">
<i class="close icon"></i>
<div class="header">
关于获取成绩
</div>
<div class="content">
<div class="description">
<div class="ui header"></div>
<p>我们根据HFS数据,进行处理。请注意!您选择对方成绩如果有小数是暂时不可能计算的,对于满分>100分的考试也是不精准的!!!但最终成绩应该与实际分数差距控制在10分以内</p>
<p>请注意,使用该工具时,对方会收到"PK"信息</p>
<p>而且,手里没有非VIP账号,无法模拟。</p>
<p>HFS有相关PK次数限制。请珍惜</p>
</div>
</div>
<div class="actions">
<div class="ui positive right labeled icon button">
OK
<i class="checkmark icon"></i>
</div>
</div>
</div>
<div class="ui container main">
<div id="titles" class="titles">
<h1>考试</h1>
</div>
<button class="ui labeled icon button primary" onclick="getUsers()">
<i class="redo icon"></i>
刷新列表
</button>
<button class="ui labeled icon button brown" onclick="$('.ui.modal').modal('show');">
<i class="help icon"></i>
这是吮磨
</button>
<!--<button class="ui button primary" onclick="change()">切换隐藏状态</button>-->
<code id="rmessage"></code>
<div id="users" class="spaces">
<div class="ui card totals"><div class="content">
<div class="ui form">
<div class="field">
<label>选择用户</label>
<div class="ui selection dropdown">
<input type="hidden" name="gender">
<i class="dropdown icon"></i>
<div class="default text">选择同学</div>
<div class="menu" id="test">
</div>
</div>
</div></div>
</div>
<button class="ui button primary" onclick="view()">查看</button>
</div>
</div>
<div id="shows" class="spaces">
</div>
</div>
<?php } ?>
<script>
function getCookie(cname)
{
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++)
{
var c = ca[i].trim();
if (c.indexOf(name)==0) return c.substring(name.length,c.length);
}
return "";
}
function makeCard(title, bodys, extraCode, classs)
{
var res = "";
res = "<div class='ui card ";
res += classs;
res += "'><div class='content'><div class='header'>" + title + "</div></div><div class='content'>" + bodys + "</div>";
if (extraCode != "nothing")
res += "<div class='extra content'>" + extraCode + "</div>";
res += "</div>";
return res;
}
function getScoreHtml(total, score)
{
var av = score / total;
var rgbs = [0,0,0];
console.log(av);
if (av <= 0.60)
{
rgbs[0] = 255;
rgbs[1] = 0;
rgbs[2] = 0;
}
else if (av <= 0.75)
{
rgbs[0] = 244;
rgbs[1] = 176 + (0.75 - av) * 10;
rgbs[2] = 132;
}
else
{
rgbs[0] = 198 - (av - 0.75) * 30;
rgbs[1] = 239 - (av - 0.75) * 30;
rgbs[2] = 206 - (av - 0.75) * 30;
}
return "<font style='color:rgb("+rgbs[0]+","+rgbs[1]+","+rgbs[2]+")'>"+score+"</font>";
}
function getAnalyse()
{
$.ajax({
url: "https://jump.hfs.lzx.smallfang.fun/v3/exam/"+<?php echo $_GET["id"] ?>+"/same-group-analysis",
dataType: 'json',
method: 'get',
xhrFields: { withCredentials: true },
success: function(res) {
var datas = [];
var _i = 0, _l = res.data.groups.length;
var peopleCount = 0;
for (_i = 0; _i < _l; _i ++ )
{
datas[_i] = new Array();
datas[_i]["score"] = res.data.groups[_i].min;
peopleCount += res.data.groups[_i].gradeStuNum;
datas[_i]["people"] = peopleCount;
}
var maxNuber = peopleCount;
const totalC = new G2.Chart({
container: 'totalScoreQ',
autoFit: true,
height: 200,
min: 0,
max: maxNuber + 100,
tickInterval: 100,
tickCount: 30,
renderer: 'svg'
});
totalC.data(datas);
totalC.scale('people', {
nice: true,
max: maxNuber+15,
tickInterval:20,
});
totalC.scale('score', {
nice: true,
tickInterval:20,
});
totalC.tooltip({
showMarkers: false
});
totalC.interaction('active-region');
totalC.line().position('score*people').label('people');
totalC.point().position('score*people');
totalC.render();
datas = [];
var _i = 0, _l = res.data.groups.length;
var peopleCount = 0;
for (_i = _l - 1; _i >= 0; _i -- )
{
datas[_i] = new Array();
datas[_i]["score"] = res.data.groups[_i].min;
peopleCount += res.data.groups[_i].gradeStuNum;
datas[_i]["people"] = peopleCount;
}
var maxNuber = peopleCount;
const totalH = new G2.Chart({
container: 'totalScoreH',
autoFit: true,
height: 200,
tickCount: 30,
renderer: 'svg'
});
console.log(maxNuber + 50);
totalH.data(datas);
totalH.scale('people', {
nice: true,
max: maxNuber+15,
tickInterval:20,
});
totalH.scale('score', {
nice: true,
tickInterval:20,
});
totalH.tooltip({
showMarkers: false
});
totalH.interaction('active-region');
totalH.line().position('score*people').label('people');
totalH.point().position('score*people');
totalH.render();
}
});
}
function getRanks()
{
console.log("write now");
$.ajax({
url: "https://jump.hfs.lzx.smallfang.fun/v3/exam/"+<?php echo $_GET["id"] ?>+"/same-group-analysis",
dataType: 'json',
method: 'get',
xhrFields: { withCredentials: true },
success: function(resA) {
$.ajax({
url: "https://jump.hfs.lzx.smallfang.fun/v3/exam/"+<?php echo $_GET["id"] ?>+"/papers-analysis",
dataType: 'json',
method: 'get',
xhrFields: { withCredentials: true },
success: function(paperR) {
console.log(resA);console.log(paperR);
var _i = 0, _l = resA.data.groups.length;
var peopleCount = 0;
var rankD = 0;
var _len2 = resA.data.myGradeIndex;
console.log(_len2);
for (_i = _l - 1; _i >= _len2+ 1; _i -- )
{
rankD = rankD + resA.data.groups[_i].gradeStuNum;
peopleCount += resA.data.groups[_i].gradeStuNum;
}
for (_i = _len2 ; _i >= 0; _i -- )
{
peopleCount += resA.data.groups[_i].gradeStuNum;
}
rankD += (resA.data.groups[_len2].gradeStuNum*((100-paperR.data.examSameGroupBeat)*0.01));
var extraMessage = "";
if(Math.ceil(rankD) != rankD)
{
extraMessage = " 精度损耗,排名可能在1-2名内波动。";
rankD = Math.ceil(rankD);
}
var html = makeCard("排名计算", rankD + "/" + peopleCount + extraMessage, "nothing", "ranksd totals");
document.getElementById("extra").innerHTML = html;
}
});
}
});
}
function getUsers()
{
//console.log(getCookie('hfs-session-id'));
document.getElementById("rmessage").innerText = "Loading...";
$.ajax({
url: "https://jump.hfs.lzx.smallfang.fun/v2/exam/"+<?php echo $_GET["id"] ?>+"/class-students-info?withPkInfo=true",
dataType: 'json',
method: 'get',
xhrFields: { withCredentials: true },
success: function(res) {
console.log(res);
document.getElementById("rmessage").innerText = res.msg;
var _len = res.data.length;
var _i = 0;
var html = "";
//<div class="item" data-value="1">Male</div>
for (_i = 0; _i < _len; _i ++ )
{
html += "<div class='item' data-value='"+res.data[_i].id+"'>"+res.data[_i].name+"</div>";
}
document.getElementById("test").innerHTML = html;
$('.selection.dropdown')
.dropdown()
;
}
});
}
function change()
{
$.ajax({
url: "https://jump.hfs.lzx.smallfang.fun/v2/exam/"+<?php echo $_GET["id"] ?>+"/comparison/"+"switch",
dataType: 'json',
method: 'post',
data: {"status":2},
xhrFields: { withCredentials: true },
success: function(res) {
document.getElementById("rmessage").innerText = "更改状态成功";
}
});
}
function view()
{
var userID = $('.selection.dropdown').dropdown('get value');
$.ajax({
url: "https://jump.hfs.lzx.smallfang.fun/v2/exam/"+<?php echo $_GET["id"] ?>+"/students/"+userID+"/comparison",
dataType: 'json',
method: 'post',
data: {"examId":"<?php echo $_GET["id"] ?>","payerType":5,"studentId":userID},
xhrFields: { withCredentials: true },
success: function(res) {
var html = "学科. - 您的成绩 - 对方成绩 - 差距<br>";
var _len = res.data.subjects.length;
var uS = 0, rS = 0;
for (var _i = 0; _i < _len; _i ++ )
{
uS += res.data.subjects[_i].myRatio;
rS += res.data.subjects[_i].targetRatio;
if (res.data.subjects[_i].myRatio >= res.data.subjects[_i].targetRatio)
{
html += "<font style='color:green'>";
}
else
{
html += "<font style='color:red'>";
}
html += "<strong>" + res.data.subjects[_i].subject + "</strong>";
html += "</font>";
html += " - " + res.data.subjects[_i].myRatio + " - " + res.data.subjects[_i].targetRatio;
if (res.data.subjects[_i].myRatio >= res.data.subjects[_i].targetRatio)
{
html += "<font style='color:green'> +";
}
else
{
html += "<font style='color:red'> ";
}
html += res.data.subjects[_i].myRatio - res.data.subjects[_i].targetRatio;
html += "</font>";
html += "<br>";
}
if (uS >= rS)
{
html += "<font style='color:green'>";
}
else
{
html += "<font style='color:red'> ";
}
html += "<strong>总科</strong></font>";
html += " - " + uS + " - " + rS ;
if (uS > rS)
{
html += "<font style='color:green'> +";
}
else
{
html += "<font style='color:red'> ";
}
html += uS - rS;
html += "<br>";
document.getElementById("shows").innerHTML = makeCard("Data", html, "nothing", " totals");
}
});
}
function calcData()
{
getRanks();
}
getUsers();
$('.selection.dropdown')
.dropdown()
;
</script>
<? include ("model/footer.php") ?>
</body>