score.js 37 KB

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