score.js 33 KB

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