score.js 33 KB

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