score.js 37 KB

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