score.js 37 KB

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