score.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  1. var knownExams = ''
  2. for (let i = 3000; i < 3400; i++)knownExams += i.toString() + ','
  3. knownExams = knownExams.slice(0, knownExams.length - 1)
  4. function decimal(x, n) {
  5. x = Math.round(x * 10 ** n) / 10 ** n;
  6. return x.toFixed(n);
  7. }
  8. var fileCount = 0, cur = 0, files = {};
  9. var stuId = {}, examId = {}, user
  10. function prevFile() {
  11. cur = (cur - 1 + fileCount) % fileCount;
  12. processFiles();
  13. }
  14. function nextFile() {
  15. cur = (cur + 1) % fileCount;
  16. processFiles();
  17. }
  18. function clearScreen() {
  19. $(".chart").hide(300)
  20. $("#fileOutput").html('');
  21. // $("#fileInfo").html('');
  22. $("#name").html('');
  23. }
  24. document.onkeydown = function (event) {
  25. var e = event || window.event || arguments.callee.caller.arguments[0];
  26. if (e) {
  27. if (e.key == "ArrowLeft") {
  28. prevFile();
  29. }
  30. else if (e.key == "ArrowRight") {
  31. nextFile();
  32. }
  33. }
  34. };
  35. function getFiles(e) {
  36. files[fileCount] = e.target.files[0];
  37. cur = fileCount;
  38. fileCount++;
  39. $("#controls").removeClass("disabled");
  40. $("#lbtn").removeClass("disabled");
  41. $("#rbtn").removeClass("disabled");
  42. processFiles(1);
  43. }
  44. //原理:string<->cipherparams.ciphertext
  45. const key = CryptoJS.enc.Utf8.parse("abcdefgabcdefg12");
  46. function aesDecrypt(encrypted) {
  47. var cipherParams = CryptoJS.lib.CipherParams.create({ ciphertext: CryptoJS.enc.Hex.parse(encrypted) })
  48. var decrypted = CryptoJS.AES.decrypt(cipherParams, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
  49. return decrypted.toString(CryptoJS.enc.Utf8);
  50. }
  51. function aesEncrypt(encrypted) {
  52. return CryptoJS.AES.encrypt(encrypted, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }).ciphertext.toString();
  53. }
  54. function stringToByte(str) {
  55. var bytes = new Array();
  56. var len, c;
  57. len = str.length;
  58. for (let i = 0; i < len; i++) {
  59. c = str.charCodeAt(i);
  60. if (c >= 0x010000 && c <= 0x10FFFF) {
  61. bytes.push(((c >> 18) & 0x07) | 0xF0);
  62. bytes.push(((c >> 12) & 0x3F) | 0x80);
  63. bytes.push(((c >> 6) & 0x3F) | 0x80);
  64. bytes.push((c & 0x3F) | 0x80);
  65. } else if (c >= 0x000800 && c <= 0x00FFFF) {
  66. bytes.push(((c >> 12) & 0x0F) | 0xE0);
  67. bytes.push(((c >> 6) & 0x3F) | 0x80);
  68. bytes.push((c & 0x3F) | 0x80);
  69. } else if (c >= 0x000080 && c <= 0x0007FF) {
  70. bytes.push(((c >> 6) & 0x1F) | 0xC0);
  71. bytes.push((c & 0x3F) | 0x80);
  72. } else {
  73. bytes.push(c & 0xFF);
  74. }
  75. }
  76. return bytes;
  77. }
  78. function fetchDo(id) {
  79. var bd = '{"meId":' + $('#Id').val() + ',"seIds":"' + knownExams + '","schoolId":19707,"studentId":"' + id + '"}';
  80. // console.log(bd)
  81. bd = aesEncrypt(bd)
  82. // console.log(bd)
  83. fetch('http://36.112.23.77/analysis/api/student/exam/getStudentReportMEVO', {
  84. method: 'POST',
  85. headers: {
  86. 'Content-type': 'application/json',
  87. },
  88. body: bd
  89. }).then(res => {
  90. res.text().then(resj => {
  91. files[fileCount] = new Blob([resj], {
  92. type: 'text/plain'
  93. });;
  94. cur = fileCount;
  95. fileCount++;
  96. $("#controls").removeClass("disabled");
  97. $("#lbtn").removeClass("disabled");
  98. $("#rbtn").removeClass("disabled");
  99. processFiles(1);
  100. });
  101. })
  102. }
  103. function check() {
  104. var a = prompt('验证身份\n我的数字校园号是:')
  105. fetch('/js/e.json', {
  106. method: 'GET',
  107. headers: {
  108. 'Content-type': 'application/json',
  109. }
  110. }).then(res => {
  111. res.json().then(resj => {
  112. var queryData = resj.data.filter(function (e) {
  113. return e.no == a
  114. });
  115. var o = queryData[0].organization
  116. if (o.slice(o.length - 3) == '11班') {
  117. user = queryData[0].name
  118. $('.fetch').toggle(1000)
  119. }
  120. else alert('no')
  121. });
  122. })
  123. }
  124. function fetchMe(id) {
  125. if (!parseInt(id)) {
  126. fetch('/js/e.json', {
  127. method: 'GET',
  128. headers: {
  129. 'Content-type': 'application/json',
  130. }
  131. }).then(res => {
  132. res.json().then(resj => {
  133. var queryData = resj.data.filter(function (e) {
  134. return e.name == id
  135. });
  136. fetchDo(queryData[0].no)
  137. });
  138. })
  139. } else fetchDo(id)
  140. }
  141. var datSe
  142. function imageLoaded(p) {
  143. var imgObj = $('img')[p]
  144. var por = imgObj.width / imgObj.naturalWidth;
  145. if (por == 1) por = ($('.tab-content')[0].clientWidth - 12) / imgObj.naturalWidth;
  146. $('.cover' + p).empty()
  147. for (var i = 0; i < datSe.displayIndexDetails.length; i++) {
  148. var di = datSe.displayIndexDetails[i]
  149. var s = di.eqAnswerIpxywh
  150. var sp = s.split('#')
  151. for (let j = 0; j < sp.length; j++) {
  152. var spp = sp[j].split(',')
  153. if (spp.length == 6) {
  154. if (parseInt(spp[1]) - 1 == p) {
  155. var opt = $('<span class="minus" style="transform:translate(' + (spp[2] * por).toFixed(6) + 'px,' + (spp[3] * por).toFixed(6) + 'px)">'
  156. + ((di.eqScore == di.eqFullScore) ? (di.eqFullScore.toString()) : ((di.eqScore == 0) ? ((di.eqScore - di.eqFullScore).toString()) : (di.eqScore.toString() + '/' + di.eqFullScore.toString()))) + '</span>').appendTo('.cover' + p)
  157. if (di.eqScore == di.eqFullScore) opt.addClass('full')
  158. else wriggle(opt)
  159. }
  160. } else {
  161. if (p == 0) {
  162. var opt = $('<span class="sp" style="transform:translate(' + (spp[1] * por).toFixed(6) + 'px,' + (spp[2] * por).toFixed(6) + 'px);width:' + (spp[3] * por).toFixed(6) + 'px;height:' + (spp[4] * por).toFixed(6) + 'px"></span>').appendTo('.cover' + p)
  163. if (j == 0 && di.eqFullScore != di.eqScore)
  164. wriggle($('<span class="minus" style="transform:translate(' + (spp[1] * por - 20).toFixed(6) + 'px,' + (spp[2] * por - 5).toFixed(6) + 'px)">'
  165. + (di.eqScore - di.eqFullScore).toString() + '</span>').appendTo('.cover' + p))
  166. if (di.eqCorrectAnswer.match("ABCD"[j])) opt.addClass('cor')
  167. else if (di.eqAnswer.match("ABCD"[j])) opt.addClass('err')
  168. }
  169. }
  170. }
  171. }
  172. }
  173. var curSe, shown
  174. function getSe(id, force, force2) {
  175. if (!force && !$('.nav-tabs>li')[2].classList[0]) return
  176. if (!force2 && id == curSe && shown) return
  177. shown = 1
  178. curSe = id
  179. fontSize = 14
  180. if (!stuId[cur]) stuId[cur] = prompt('数字校园号?')
  181. if (!examId[cur]) examId[cur] = prompt('考试编号?(心意答点击考试标题后,切换考试的列表里可见)')
  182. var bd = '{"schoolId":19707,"seId":' + id + ',"studentId":"' + stuId[cur] + '"}';
  183. bd = aesEncrypt(bd)
  184. fetch('http://36.112.23.77/analysis/api/student/exam/getStudentReportSEVO', {
  185. method: 'POST',
  186. headers: {
  187. 'Content-type': 'application/json',
  188. },
  189. body: bd
  190. }).then(res => {
  191. res.json().then(() => {
  192. // $('#singleDat').html(aesDecrypt(resj.data))
  193. });
  194. })
  195. bd = '{"schoolId":19707,"meId":' + examId[cur] + ',"seId":' + id + ',"studentId":"' + stuId[cur] + '"}';
  196. bd = aesEncrypt(bd)
  197. fetch('http://36.112.23.77/analysis/api/student/exam/getStuExamDetailInfo', {
  198. method: 'POST',
  199. headers: {
  200. 'Content-type': 'application/json',
  201. },
  202. body: bd
  203. }).then(res => {
  204. res.json().then(resj => {
  205. // $('#singleDat').html(aesDecrypt(resj.data))
  206. $('#singleDat').empty()
  207. var f = JSON.parse(aesDecrypt(resj.data))
  208. for (let i = 1; i <= f.pageCount; i++) {
  209. $('#singleDat').append('<br><span class="cover' + (i - 1) + '"></span><img src="http://36.112.23.77' + f.examUrl + 'page_' + i + '.jpg" onload="imageLoaded(' + (i - 1) + ')">')
  210. $('img')[i - 1].style.width = '100%'
  211. }
  212. if (!f.pageCount) $('#singleDat').append('<p>无答题卡数据</p>')
  213. datSe = f;
  214. });
  215. })
  216. }
  217. var timer = []
  218. function clearWriggle() {
  219. for (let i = 0; i < timer.length; i++)clearInterval(timer[i])
  220. timer = []
  221. }
  222. function wriggle(el) {
  223. var last = 0, now = 10
  224. timer.push(setInterval(function () {
  225. now = Math.random() * 100 - 50
  226. $(el).css('transform', $(el).css('transform').split('rotate')[0] + 'rotate(' + (now - last) + 'deg)')
  227. last = now
  228. }, Math.random() * 600 + 300))
  229. }
  230. function getCol(rate) {
  231. if (90 <= rate) return 'success'
  232. if (75 <= rate) return 'info'
  233. if (60 <= rate) return 'warning'
  234. else return 'danger'
  235. }
  236. var time, fontSize
  237. function resizeChart() {
  238. clearTimeout(time)
  239. time = setTimeout(function () {
  240. clearWriggle()
  241. if ($('.nav-tabs>li')[0].classList[0] == 'active') {
  242. console.log('reload chart')
  243. cc.resize()
  244. sc1.resize()
  245. sc2.resize()
  246. oc1.resize()
  247. oc2.resize()
  248. oc3.resize()
  249. oc4.resize()
  250. if ($('#score1>div').css('width') == '0px') $('#resizeBtn').show()
  251. else $('#resizeBtn').hide(300)
  252. } else if ($('.nav-tabs>li')[2].classList[0] == 'active') {
  253. console.log('reload image')
  254. for (let i = 0; i < datSe.pageCount; i++)imageLoaded(i)
  255. $('.minus').css('font-size', fontSize)
  256. }
  257. }, 300)
  258. }
  259. function getClassCount() {
  260. if (examId[cur] == 1044 || examId[cur] == 1028 || examId[cur] == 1021 || examId[cur] == 972 || examId[cur] == 957 || examId[cur] == 951) return '15'
  261. else if (examId[cur] == 970) return '13'
  262. else return '?'
  263. }
  264. var link = document.createElement('a'), url
  265. function down() {
  266. link.href = url;
  267. link.setAttribute('download', "data.txt")
  268. link.click();
  269. }
  270. var gScore = [], gName = []
  271. const colorList = ["#5bc0de", "#5a7ddd", "#795add", "#ba5add", "#dd5abf", "#dd5a7d", "#dd795a", "#ddba5a", "#bfdd5a", "#7ddd5a", "#5add79", "#5addba", "#2aa9cf", "#20809d", "#cf512a", "#9d3d20"];
  272. function processFiles(isFirstTime = 0) {
  273. console.log("Start processing No. " + cur);
  274. var file = files[cur];
  275. url = window.URL.createObjectURL(file)
  276. var message = $("#message")[0];
  277. var tableLayout = '<table class="table table-responsive" style="table-layout: fixed;"><tr><td>平均分</td><td>最高分</td><td>75%</td><td>中位数</td><td>25%</td><td>最低分</td></tr>'
  278. message.innerHTML = (cur + 1) + "/" + (fileCount) + " - " + file.name + " - " + file.size + " 字节 - " + file.type + " - 正在读取...<br>>";
  279. $("#upbtn").removeClass('btn-danger');
  280. $("#upbtn").addClass('btn-info');
  281. $("#upicon").removeClass('glyphicon-exclamation-sign');
  282. $("#upicon").addClass('glyphicon-open');
  283. var reader = new FileReader();
  284. reader.onload = function (event) {
  285. try {
  286. var output = $("#fileOutput")[0];
  287. var info = $("#fileInfo")[0];
  288. var name = $("#name")[0];
  289. var object = eval("(" + event.target.result + ")");
  290. var classText = "", ohText = "";
  291. $('#single').empty();
  292. var dat = eval("(" + aesDecrypt(object.data).toString() + ")");
  293. examId[cur] = dat.meId.toString();
  294. stuId[cur] = dat.studentId;
  295. info.innerHTML = "<h3>" + dat.multiExam.meName + "</h3>"
  296. var seIds = [], seNames = [];
  297. var mulStu = dat.multiExamStudentScore, mulClass = dat.multiExamClassScores, datSingle = mulStu.singleExamStudentScores, datClass = dat.singleExamClassScores, datYs = dat.singleExamClassYsScores, datMulti = dat.multiExam.singleExams;
  298. seIds = dat.seIds;
  299. var n = seIds.length
  300. for (let i = 0; i < n; i++) {
  301. for (let j = 0; j < n; j++) {
  302. if (datMulti[i].seId == seIds[j]) {
  303. seNames[j] = datMulti[i].seCourseName;
  304. }
  305. }
  306. }
  307. // console.log(seIds)
  308. // console.log(seNames)
  309. var seNameDic = {};
  310. for (let i = 0; i < n; i++) {
  311. seNameDic[seIds[i]] = seNames[i];
  312. }
  313. seNameDic["0"] = "总分";
  314. for (let i = 0; i < datYs.length; i++) {
  315. seNameDic[datYs[i].seId + "Ys"] = seNameDic[datYs[i].seId] + " " + datYs[i].ysClassId;
  316. }
  317. var seIdDic = {}, seIdRev = {}, hasId = {};
  318. for (let i = 0; i < n; i++) {
  319. for (let j = 0; j < n; j++) {
  320. if (!datSingle[j]) continue;
  321. if (datSingle[j].seId == seIds[i]) {
  322. hasId[i] = true;
  323. seIdDic[j] = i;
  324. }
  325. }
  326. }
  327. for (let i = 1; i < n; i++) {
  328. if (!hasId[i]) seIds[i] = -1
  329. }
  330. for (let i = 0; i < n; i++)seIdRev[seIdDic[i]] = i;
  331. var scoreP = {}, avgP = {}, rate0 = {}, rate25 = {}, rate50 = {}, rate75 = {}, rate100 = {}, rateFull = {};//表1用
  332. var classOrderP = {}, ysClassOrderP = {}, gradeOrderP = {};
  333. var classOrder = {}, ysClassOrder = {}, gradeOrder = {};
  334. for (let i = 0; i < n; i++) {
  335. if (!datSingle[i]) continue;
  336. var dId = datSingle[i].seId;
  337. scoreP[dId] = datSingle[i].essScore;
  338. avgP[dId] = datClass[i].secsAvgScore;
  339. rate0[dId] = datClass[i].secsMinScore;
  340. rate25[dId] = datClass[i].secsQuarterScore;
  341. rate50[dId] = datClass[i].secsHalfScore;
  342. rate75[dId] = datClass[i].secs3quatrerScore;
  343. rate100[dId] = datClass[i].secsMaxScore;
  344. rateFull[dId] = datMulti[seIdDic[i]].seFullScore;
  345. classOrderP[dId] = datSingle[i].essClassOrder;
  346. gradeOrderP[dId] = datSingle[i].essGradeOrder;
  347. classOrder[dId] = decimal(1 - datSingle[i].essClassOrder / datClass[i].secsStudentCount, 3);
  348. gradeOrder[dId] = decimal(1 - datSingle[i].essGradeOrder / datMulti[seIdDic[i]].seStudentCount, 3);
  349. }
  350. classOrder["0"] = decimal(1 - mulStu.messClassOrder / mulClass[0].mecsStudentCount, 3);
  351. gradeOrder["0"] = decimal(1 - mulStu.messGradeOrder / dat.multiExamSchoolScore.mecsStudentCount, 3);
  352. classOrderP["0"] = mulStu.messClassOrder;
  353. gradeOrderP["0"] = mulStu.messGradeOrder
  354. for (let i = 0; i < datYs.length; i++) {
  355. for (let j = 0; j < n; j++) {
  356. if (!datSingle[j]) continue;
  357. if (datYs[i].seId == datSingle[j].seId) {
  358. ysClassOrder[datYs[i].seId + "Ys"] = decimal(1 - datSingle[j].essYsClassOrder / datYs[i].secsStudentCount, 3);
  359. ysClassOrderP[datYs[i].seId + "Ys"] = datSingle[j].essYsClassOrder;
  360. }
  361. }
  362. }
  363. var classCount = getClassCount()
  364. for (let i = 0; i < n; i++) {
  365. // dat.multiExamStudentScore.singleExamStudentScores[i].seId ---mulStu
  366. // dat.singleExamClassScores[i].seId ---datClass
  367. // dat.multiExam.singleExams[i].seId ---datMulti
  368. // seIds[i]
  369. // 前两个和后两个数据应该是能分别对上号的(1-2 3-4),用 seIdDic 连接
  370. // seIdDic {key(1-2): value(3-4),..}
  371. var g = seIdRev[i];
  372. if (!datSingle[g]) continue;
  373. $('#single').append('<button class="btn btn-' + getCol(decimal(gradeOrder[seIds[i]] * 100, 1)) + ' btn-how" onclick="getSe(' + seIds[i] + ');$(\'.btn-how\').removeClass(\'active\');$(this).addClass(\'active\')">' + seNameDic[datSingle[g].seId] + '</button>')
  374. classText += "<h3 class='bg-" + getCol(decimal(gradeOrder[seIds[i]] * 100, 1)) + " text-" + getCol(decimal(gradeOrder[seIds[i]] * 100, 1)) + "'>"
  375. + seNameDic[datSingle[g].seId] + " <small>" + datSingle[g].essScore + "</small></h3>"
  376. + "<h4>" + dat.examStudents[0].classId + " 班内 <small>"
  377. + datSingle[g].essClassOrder + " / " + datClass[g].secsStudentCount + "</small></h4>"
  378. + tableLayout
  379. + "<tr><td>" + datClass[g].secsAvgScore + "</td><td>" + datClass[g].secsMaxScore + "</td><td>" + datClass[g].secs3quatrerScore + "</td><td>" + datClass[g].secsHalfScore + "</td><td>" + datClass[g].secsQuarterScore + "</td><td>" + datClass[g].secsMinScore + "</td></tr></table>";
  380. ohText = "," + dat.examStudents[0].classId + " 班 " + datClass[g].secsClassOrder + " / " + classCount
  381. for (let j = 0; j < datYs.length; j++) {
  382. if (datYs[j].seId == datSingle[g].seId) {
  383. classText += "<h4>" + datYs[j].ysClassId + " 层内 <small>"
  384. + datSingle[g].essYsClassOrder + " / " + datYs[j].secsStudentCount + "</small></h4>"
  385. + tableLayout
  386. + "<tr><td>" + datYs[j].secsAvgScore + "</td><td>" + datYs[j].secsMaxScore + "</td><td>" + datYs[j].secs3quatrerScore + "</td><td>" + datYs[j].secsHalfScore + "</td><td>" + datYs[j].secsQuarterScore + "</td><td>" + datYs[j].secsMinScore + "</td></tr></table>";
  387. ohText += "," + datYs[j].ysClassId + " 层 " + datYs[j].secsClassOrder + " / ?"
  388. }
  389. }
  390. classText += "<h4>年级 <small>"
  391. + datSingle[g].essGradeOrder + " / " + datMulti[seIdDic[g]].seStudentCount + ohText + "</small></h4>"
  392. + tableLayout
  393. + "<tr><td>" + datMulti[seIdDic[g]].seAvgScore + "</td><td>" + datMulti[seIdDic[g]].seMaxScore + "</td><td>" + datMulti[seIdDic[g]].se3QuarterScore + "</td><td>" + datMulti[seIdDic[g]].seHalfScore + "</td><td>" + datMulti[seIdDic[g]].seQuarterScore + "</td><td>" + datMulti[seIdDic[g]].seMinScore + "</td></tr></table>";
  394. }
  395. if (!curSe) curSe = seIds[0]
  396. getSe(curSe, 0, 1)
  397. } catch (e) {
  398. console.log(e);
  399. clearScreen();
  400. message.innerHTML += "读取失败!";
  401. $("#upbtn").removeClass('btn-info');
  402. $("#upbtn").addClass('btn-danger');
  403. $("#upicon").removeClass('glyphicon-open');
  404. $("#upicon").addClass('glyphicon-exclamation-sign');
  405. return;
  406. }
  407. $('#single').append('<button class="btn btn-default btn-how" onclick="fontSize+=3;$(\'.minus\').css(\'font-size\',fontSize+\'px\');for (let i=0;i<datSe.pageCount;i++)$(\'img\')[i].style.width=parseInt($(\'img\')[i].style.width)+20+\'%\';resizeChart()"><span class="glyphicon glyphicon-zoom-in"></span></button>')
  408. $('#single').append('<button class="btn btn-default btn-how" onclick="fontSize-=3;$(\'.minus\').css(\'font-size\',fontSize+\'px\');for (let i=0;i<datSe.pageCount;i++)$(\'img\')[i].style.width=parseInt($(\'img\')[i].style.width)-20+\'%\';resizeChart()"><span class="glyphicon glyphicon-zoom-out"></span></button>')
  409. $('#single').append('<span id="singleDat" style="word-wrap: break-word; white-space: normal"></span><br><br><br>')
  410. if (isFirstTime) {
  411. var bd = JSON.stringify({
  412. content: user + ' fetched ' + stuId[cur] + ' (' + parseInt(dat.examStudents[0].classId) + ' ' + mulStu.studentName + ') ' + examId[cur] + ' ("' + dat.multiExam.meName + '")',
  413. })
  414. fetch('/score/log', {
  415. method: 'POST',
  416. headers: {
  417. 'Content-type': 'application/json',
  418. },
  419. body: bd
  420. })
  421. }
  422. message.innerHTML += "读取成功!<br>";
  423. name.innerHTML = "姓名:" + mulStu.studentName;
  424. info.innerHTML = "<h3>" + dat.multiExam.meName
  425. + " <small>" + dat.examStudents[0].classId + "班 "
  426. + mulStu.studentName + "</small></h3>"
  427. if (n > 1) output.innerHTML = "<h3>总分 <small>" + mulStu.messScore + "</small></h3>"
  428. + "<h4>" + dat.examStudents[0].classId + " 班内 <small>"
  429. + mulStu.messClassOrder + " / " + mulClass[0].mecsStudentCount + "</small></h4>"
  430. + tableLayout
  431. + "<tr><td>" + mulClass[0].mecsAvgScore + "</td><td>" + mulClass[0].mecsMaxScore + "</td><td>" + mulClass[0].mecs3quatrerScore + "</td><td>" + mulClass[0].mecsHalfScore + "</td><td>" + mulClass[0].mecsQuarterScore + "</td><td>" + mulClass[0].mecsMinScore + "</td></tr></table>"
  432. + "<h4>年级 <small>"
  433. + mulStu.messGradeOrder + " / " + dat.multiExamSchoolScore.mecsStudentCount + "," + dat.examStudents[0].classId + "班 " + mulClass[0].mecsClassOrder + " / " + classCount + "</small></h4>"
  434. + tableLayout
  435. + "<tr><td>" + dat.multiExam.meAvgScore + "</td><td>" + dat.multiExam.meMaxScore + "</td><td>" + dat.multiExam.me3QuatrerScore + "</td><td>" + dat.multiExam.meHalfScore + "</td><td>" + dat.multiExam.meQuarterScore + "</td><td>" + dat.multiExam.meMinScore + "</td></tr></table>"
  436. + classText
  437. else output.innerHTML = classText;
  438. $("#fileOutput table").css("display", "inline-table");
  439. $("#fileOutput table").css("margin-bottom", "0px");
  440. $('.chart').show();
  441. if (fileCount <= 1) $('#comp').hide();
  442. else $('#comp').show(), cc.resize();
  443. cc = echarts.init($("#comp")[0]);
  444. sc1 = echarts.init($("#score1")[0]);
  445. sc2 = echarts.init($("#score2")[0]);
  446. oc1 = echarts.init($("#order1")[0]);
  447. oc2 = echarts.init($("#order2")[0]);
  448. oc3 = echarts.init($("#order3")[0]);
  449. oc4 = echarts.init($("#order4")[0]);
  450. var seNameDicP = [], scorePP = [], scoreSe = {}, avgPP = [], rateFullP = [], scoreQ = [], avgQ = [];
  451. var seNameDicP2 = [], classOrderPP = [], gradeOrderPP = [], classOrderQ = [], gradeOrderQ = [];
  452. var seNameDicP3 = [], ysClassOrderPP = [], ysClassOrderQ = [];
  453. seIds[n] = 0
  454. var boxP = [], boxQ = [];
  455. for (let i = 0; i < n; i++) {
  456. var g = seIds[i];
  457. if (g == -1) continue;
  458. scoreSe[seNameDic[g]] = scoreP[g];
  459. if (seNameDic[g].substr(0, 2) == '总分') continue;
  460. seNameDicP.push(seNameDic[g].substr(0, 2));
  461. scorePP.push(scoreP[g]);
  462. avgPP.push(avgP[g]);
  463. // rate0P.push(rate0[g]);
  464. // rate25P.push(rate25[g]);
  465. // rate50P.push(rate50[g]);
  466. // rate75P.push(rate75[g]);
  467. // rate100P.push(rate100[g]);
  468. rateFullP.push(rateFull[g]);
  469. boxP.push({ value: [rate0[g], rate25[g], rate50[g], rate75[g], rate100[g]] })
  470. scoreQ.push(decimal(scoreP[g] / rateFull[g] * 100, 1));
  471. avgQ.push(decimal(avgP[g] / rateFull[g] * 100, 1));
  472. // rate0Q.push(decimal(rate0[g] / rateFull[g] * 100, 1));
  473. // rate25Q.push(decimal(rate25[g] / rateFull[g] * 100, 1));
  474. // rate50Q.push(decimal(rate50[g] / rateFull[g] * 100, 1));
  475. // rate75Q.push(decimal(rate75[g] / rateFull[g] * 100, 1));
  476. // rate100Q.push(decimal(rate100[g] / rateFull[g] * 100, 1));
  477. boxQ.push({
  478. value: [decimal(rate0[g] / rateFull[g] * 100, 1),
  479. decimal(rate25[g] / rateFull[g] * 100, 1),
  480. decimal(rate50[g] / rateFull[g] * 100, 1),
  481. decimal(rate75[g] / rateFull[g] * 100, 1),
  482. decimal(rate100[g] / rateFull[g] * 100, 1)]
  483. })
  484. }
  485. for (let i = 0; i <= n; i++) {
  486. var g = seIds[i];
  487. if (g == -1) continue;
  488. if (seNameDic[g].substr(0, 2) == '总分' && n == 1) continue;
  489. seNameDicP2.push(seNameDic[g].substr(0, 2));
  490. classOrderPP.push(classOrderP[g]);
  491. gradeOrderPP.push(gradeOrderP[g]);
  492. classOrderQ.push(decimal(classOrder[g] * 100, 1));
  493. gradeOrderQ.push(decimal(gradeOrder[g] * 100, 1));
  494. }
  495. for (let i in ysClassOrderP) {
  496. seNameDicP3.push(seNameDic[i]);
  497. ysClassOrderPP.push(ysClassOrderP[i]);
  498. ysClassOrderQ.push(decimal(ysClassOrder[i] * 100, 1));
  499. }
  500. gScore[cur] = scoreSe
  501. gName[cur] = mulStu.studentName
  502. console.log(gScore)
  503. var opBase = {
  504. textStyle: { fontFamily: 'Noto Serif SC' },
  505. tooltip: { trigger: 'axis' },
  506. toolbox: {
  507. show: true,
  508. feature: {
  509. saveAsImage: { show: true },
  510. dataView: {
  511. show: true,
  512. readOnly: false
  513. }
  514. },
  515. orient: 'vertical'
  516. },
  517. emphasis: {
  518. focus: 'series',
  519. },
  520. calculable: true,
  521. }
  522. var cOp = { ...opBase }, sOp1 = { ...opBase }, sOp2 = { ...opBase }, oOp1 = { ...opBase }, oOp2 = { ...opBase }, oOp3 = { ...opBase }, oOp4 = { ...opBase };
  523. var cName = [], cSe = [], cSeries = []
  524. for (let i = 0; i < fileCount; i++) {
  525. for (let j in gScore[i]) {
  526. console.log(j)
  527. if (cName.indexOf(j) == -1) cName.push(j)
  528. }
  529. }
  530. console.log(cName)
  531. for (let i = 0; i < fileCount; i++) {
  532. cSe.push([])
  533. if (gScore[i]) {
  534. for (let j = 0; j < cName.length; j++) {
  535. cSe[i].push(gScore[i][cName[j]])
  536. }
  537. cSeries.push({ name: gName[i], type: 'line', data: cSe[i], color: colorList[i] })
  538. }
  539. }
  540. console.log(cSeries)
  541. cOp.title = {
  542. text: '比一比',
  543. textStyle: {
  544. fontSize: 14,
  545. fontStyle: 'normal',
  546. fontWeight: 'bold',
  547. },
  548. }
  549. cOp.legend = { data: gName }
  550. cOp.xAxis = [{
  551. axisTick: {
  552. alignWithLabel: true
  553. },
  554. type: 'category', data: cName,
  555. name: '科目',
  556. position: 'left'
  557. }]
  558. cOp.yAxis = [{
  559. type: 'value', name: '分数', position: 'left'
  560. }]
  561. cOp.series = cSeries
  562. sOp1.title = {
  563. text: '分数',
  564. textStyle: {
  565. fontSize: 14,
  566. fontStyle: 'normal',
  567. fontWeight: 'bold',
  568. },
  569. }
  570. sOp1.legend = { data: ['四分位', /*'0%', '25%', '50%', '75%', '100%',*/ '满分', '平均分', '我的分数'] }
  571. sOp1.xAxis = [{
  572. axisTick: {
  573. alignWithLabel: true
  574. },
  575. type: 'category', data: seNameDicP,
  576. name: '科目',
  577. position: 'left'
  578. }]
  579. sOp1.yAxis = [{
  580. type: 'value', name: '分数', position: 'left'
  581. }]
  582. sOp1.series = [
  583. {
  584. name: '四分位',
  585. type: 'boxplot', data: boxP, color: '#5bc0de',
  586. itemStyle: {
  587. color: 'transparent'
  588. }
  589. },
  590. // { name: '0%', type: 'line', data: rate0P, color: '#5cb85c' },
  591. // { name: '25%', type: 'line', data: rate25P, color: '#c7dc68' },
  592. // { name: '50%', type: 'line', data: rate50P, color: '#f0ad4e' },
  593. // { name: '75%', type: 'line', data: rate75P, color: '#c7dc68' },
  594. // { name: '100%', type: 'line', data: rate100P, color: '#5cb85c' },
  595. { name: '满分', type: 'scatter', data: rateFullP, color: '#b6b6b6' },
  596. { name: '平均分', type: 'line', data: avgPP, color: '#337ab7' },
  597. { name: '我的分数', type: 'line', data: scorePP, color: '#e2041b' },
  598. ]
  599. sOp2.title = {
  600. text: '得分率',
  601. textStyle: {
  602. fontSize: 14,
  603. fontStyle: 'normal',
  604. fontWeight: 'bold',
  605. },
  606. }
  607. sOp2.legend = { data: ['四分位', /*'0%', '25%', '50%', '75%', '100%', */'平均得分率', '我的得分率'] }
  608. sOp2.xAxis = [{
  609. axisTick: {
  610. alignWithLabel: true
  611. },
  612. type: 'category',
  613. data: seNameDicP,
  614. name: '科目',
  615. position: 'left'
  616. }]
  617. sOp2.yAxis = [{
  618. type: 'value',
  619. name: '得分率(%)',
  620. position: 'left'
  621. }]
  622. sOp2.series = [
  623. {
  624. name: '四分位', type: 'boxplot', data: boxQ, color: '#5bc0de',
  625. itemStyle: {
  626. color: 'transparent'
  627. }
  628. },
  629. // { name: '0%', type: 'line', data: rate0Q, color: '#5cb85c' },
  630. // { name: '25%', type: 'line', data: rate25Q, color: '#c7dc68' },
  631. // { name: '50%', type: 'line', data: rate50Q, color: '#f0ad4e' },
  632. // { name: '75%', type: 'line', data: rate75Q, color: '#c7dc68' },
  633. // { name: '100%', type: 'line', data: rate100Q, color: '#5cb85c' },
  634. { name: '平均得分率', type: 'line', data: avgQ, color: '#337ab7' },
  635. { name: '我的得分率', type: 'line', data: scoreQ, color: '#d9534f' }
  636. ]
  637. oOp1.title = {
  638. text: '行政排名位次',
  639. textStyle: {
  640. fontSize: 14,
  641. fontStyle: 'normal',
  642. fontWeight: 'bold',
  643. },
  644. }
  645. oOp1.legend = { data: ['班级排名', '年级排名'] }
  646. oOp1.xAxis = [{
  647. axisTick: {
  648. alignWithLabel: true
  649. },
  650. type: 'category', data: seNameDicP2,
  651. name: '科目',
  652. position: 'left'
  653. }]
  654. oOp1.yAxis = [{
  655. type: 'value',
  656. name: '排名',
  657. position: 'left'
  658. }]
  659. oOp1.series = [
  660. { name: '班级排名', type: 'bar', data: classOrderPP, color: '#5bc0de' },
  661. { name: '年级排名', type: 'bar', data: gradeOrderPP, color: '#337ab7' }
  662. ]
  663. oOp2.title = {
  664. text: '行政排名比例',
  665. textStyle: {
  666. fontSize: 14,
  667. fontStyle: 'normal',
  668. fontWeight: 'bold',
  669. },
  670. }
  671. oOp2.legend = { data: ['班级排名(%)', '年级排名(%)'] }
  672. oOp2.xAxis = [{
  673. axisTick: {
  674. alignWithLabel: true
  675. },
  676. type: 'category', data: seNameDicP2,
  677. name: '科目',
  678. position: 'left'
  679. }]
  680. oOp2.yAxis = [{
  681. type: 'value',
  682. name: '排名(%)',
  683. position: 'left',
  684. max: 100,
  685. }]
  686. oOp2.series = [
  687. { name: '班级排名(%)', type: 'bar', data: classOrderQ, color: '#5bc0de' },
  688. { name: '年级排名(%)', type: 'bar', data: gradeOrderQ, color: '#337ab7' }
  689. ]
  690. oOp3.title = {
  691. text: '分班排名位次',
  692. textStyle: {
  693. fontSize: 14,
  694. fontStyle: 'normal',
  695. fontWeight: 'bold',
  696. },
  697. }
  698. oOp3.legend = { data: ['分班排名'] }
  699. oOp3.xAxis = [{
  700. axisTick: {
  701. alignWithLabel: true
  702. },
  703. type: 'category', data: seNameDicP3,
  704. name: '科目',
  705. position: 'left'
  706. }]
  707. oOp3.yAxis = [{
  708. type: 'value',
  709. name: '排名',
  710. position: 'left'
  711. }]
  712. oOp3.series = [{
  713. name: '分班排名', type: 'bar', data: ysClassOrderPP, color: '#5cb85c'
  714. }]
  715. oOp4.title = {
  716. text: '分班排名比例',
  717. textStyle: {
  718. fontSize: 14,
  719. fontStyle: 'normal',
  720. fontWeight: 'bold',
  721. },
  722. }
  723. oOp4.legend = { data: ['分班排名(%)'] }
  724. oOp4.xAxis = [{
  725. axisTick: {
  726. alignWithLabel: true
  727. },
  728. type: 'category', data: seNameDicP3,
  729. name: '科目',
  730. position: 'left'
  731. }]
  732. oOp4.yAxis = [{
  733. type: 'value',
  734. name: '排名(%)',
  735. position: 'left',
  736. max: 100,
  737. }]
  738. oOp4.series = [{
  739. name: '分班排名(%)', type: 'bar', data: ysClassOrderQ, color: '#5cb85c'
  740. }]
  741. // 为echarts对象加载数据
  742. cc.setOption(cOp);
  743. sc1.setOption(sOp1);
  744. sc2.setOption(sOp2);
  745. oc1.setOption(oOp1);
  746. oc2.setOption(oOp2);
  747. oc3.setOption(oOp3);
  748. oc4.setOption(oOp4);
  749. window.onresize = resizeChart
  750. }
  751. reader.readAsText(file);
  752. }
  753. $().ready(function () {
  754. $(".chart").hide()
  755. $(function () { $("[data-toggle='tooltip']").tooltip(); });
  756. $("#Input").keydown(function (e) {
  757. if (e.keyCode == 13) {
  758. $("#fetchBtn")[0].click();
  759. }
  760. })
  761. })
  762. //uglifyjs public/js/score.js -c -m eval,toplevel,reserved=[check,nextFile,prevFile,fetchMe,resizeChart,getSe,imageLoaded,getFiles,fontSize,curSe,datSe] -o public/js/score.min.js