check.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"
  6. />
  7. <title>作业批改</title>
  8. <link rel="stylesheet" type="text/css" href="../css/api.css" />
  9. <link rel="stylesheet" type="text/css" href="../css/style.css" />
  10. <link rel="stylesheet" type="text/css" href="../css/check.css" />
  11. </head>
  12. <body id="data-box">
  13. <div class="container">
  14. <div class="fn-left handle_menu_wrap">
  15. <div class="menu_title">
  16. 工具
  17. </div>
  18. <div id="tools" class="handle_btn_list">
  19. <div class="handle_btn active" data-type="right">
  20. <div class="handle_btn_img">
  21. <img src="../image/check/all-true.png" class="center-self" alt="">
  22. </div>
  23. <div class="handle_btn_name">
  24. 全对
  25. </div>
  26. </div>
  27. <div class="handle_btn" data-type="rectangle">
  28. <div class="handle_btn_img">
  29. <img src="../image/check/label-icon.png" class="center-self" alt="">
  30. </div>
  31. <div class="handle_btn_name">
  32. 错题标注
  33. </div>
  34. </div>
  35. <div class="handle_btn" data-type="wrong">
  36. <div class="handle_btn_img">
  37. <img src="../image/check/all-wrong.png" class="center-self" alt="">
  38. </div>
  39. <div class="handle_btn_name">
  40. 全错
  41. </div>
  42. </div>
  43. <div class="handle_btn" data-type="smallright">
  44. <div class="handle_btn_img">
  45. <img src="../image/check/true-icon.png" class="center-self" alt="">
  46. </div>
  47. <div class="handle_btn_name">
  48. 正确处
  49. </div>
  50. </div>
  51. <div class="handle_btn" data-type="smallwrong">
  52. <div class="handle_btn_img">
  53. <img src="../image/check/wrong-icon.png" class="center-self" alt="">
  54. </div>
  55. <div class="handle_btn_name">
  56. 错误处
  57. </div>
  58. </div>
  59. <div class="handle_btn" data-type="remove">
  60. <div class="handle_btn_img">
  61. <img src="../image/check/erasure-icon.png" class="center-self" alt="">
  62. </div>
  63. <div class="handle_btn_name">
  64. 擦除
  65. </div>
  66. </div>
  67. <div class="handle_btn" data-type="help">
  68. <div class="handle_btn_img">
  69. <img src="../image/check/help-icon.png" class="center-self" alt="">
  70. </div>
  71. <div class="handle_btn_name">
  72. 帮助
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="fn-right correct_main">
  78. <div class="wrong_list_wrap">
  79. <div class="wrong_list_title">
  80. <i class="before_icon fn-left"></i>
  81. <div>错题</div>
  82. </div>
  83. <div class="wrong_list">
  84. <div id="errMsg" class="wrong_list_inner">
  85. </div>
  86. </div>
  87. </div>
  88. <div class="main_score">
  89. <div class="main_score_title">
  90. <i class="before_icon fn-left"></i>
  91. <div>字迹评分</div>
  92. </div>
  93. <div id="fontScore" class="main_score_num_list fn-clear">
  94. <div class="main_score_num_item fn-left active">1</div>
  95. <div class="main_score_num_item fn-left">2</div>
  96. <div class="main_score_num_item fn-left">3</div>
  97. <div class="main_score_num_item fn-left">4</div>
  98. <div class="main_score_num_item fn-left">5</div>
  99. <div class="main_score_num_item fn-left">6</div>
  100. <div class="main_score_num_item fn-left">7</div>
  101. <div class="main_score_num_item fn-left">8</div>
  102. <div class="main_score_num_item fn-left">9</div>
  103. <div class="main_score_num_item fn-left">10</div>
  104. </div>
  105. </div>
  106. <div id="subBut" class="small_btn_blue confirm">
  107. 确认完成
  108. </div>
  109. <div id="moreBtn" class="more_btn"></div>
  110. <div id="moreDiv" class="other_btn_wrap fn-hide">
  111. <div id="expBtn" class="mark_exce">
  112. 异常标记
  113. </div>
  114. <div id="giveupBtn" class="give_up">
  115. 放弃任务
  116. </div>
  117. </div>
  118. </div>
  119. <div class="fn-right preview">
  120. <div id="simgDiv" class="swiper-container">
  121. </div>
  122. <div class="homework_total center-self-x">
  123. <span id="currentNum">1</span>/
  124. <span id="sumNum">1</span>
  125. </div>
  126. </div>
  127. <div class="view">
  128. <div id="canvasDiv" class="swiper-container center-self-x">
  129. </div>
  130. </div>
  131. </div>
  132. <div id="maskDiv" class="mask_modal" style="display: none;">
  133. <div class="top">
  134. <div style="width: 100%;padding-left: 30%;padding-top: 20%">数据提交中,请稍等...</div>
  135. </div>
  136. </div>
  137. <div id="errModal" class="mark_error_modal fn-hide">
  138. <div class="top"></div>
  139. <div class="mark_error_box center-self">
  140. <div class="mark_error_box_title">
  141. <div class="fn-left">
  142. 选择错误标签
  143. </div>
  144. <div id="hideModal" class="fn-right close_icon fn-clear fn-hide">
  145. <img src="../image/check/close-icon.png" class="fn-left" alt="">
  146. </div>
  147. </div>
  148. <div id="errTags" class="wrong_label_list">
  149. </div>
  150. <div id="errVerify" class="small_btn_blue center-self-x confirm_mark">
  151. 确认
  152. </div>
  153. </div>
  154. </div>
  155. <div id="testImg">
  156. </div>
  157. </body>
  158. <script type="text/javascript" src="../js/check/fontsize.js"></script>
  159. <script type="text/javascript" src="../js/jquery.min.js"></script>
  160. <script type="text/javascript" src="../js/check/qiniu.min.js"></script>
  161. <script type="text/javascript" src="js/fabric.min.js"></script>
  162. <script type="text/javascript" src="js/check/canvas.js"></script>
  163. <script type="text/javascript" src="js/check/config.js"></script>
  164. <script type="text/javascript" src="js/tools/md5.min.js"></script>
  165. <script type="text/javascript" src="js/tools/uuid.js"></script>
  166. <script type="text/javascript" src="js/tools/upload.js"></script>
  167. <script type="text/javascript">
  168. jQuery(function () {
  169. var canvasInit = []; //已经初始化的canvas
  170. var uploadImageArray = []; //需要上传的图片集合{"name":"xxx","base64":"xxx"}
  171. var errTagType = {
  172. '语文': ['遗漏', '理解不清晰', '粗心大意', '审题不清', '基础不牢', '积累不够', '运用错误', '区分错误', '缺乏逻辑'],
  173. '数学': ['计算错误', '审题错误', '遗漏', '基础不牢固', '粗心大意', '概念不清', '换算错误', '公式不熟练', '缺乏解题技巧', '书写不端正'],
  174. '英语': ['粗心大意', '审题错误', '基础不牢固', '书写不规范', '单词拼写错误', '遗漏', '介词搭配错误', '单复数错误']
  175. };
  176. var img = decodeURIComponent(getUrlParam('img')); //图片集合
  177. var subject = decodeURIComponent(getUrlParam('subject')); //科目
  178. if (!img && JSON.parse(img)) {
  179. alert("网络错误");
  180. }
  181. img = JSON.parse(img);
  182. jQuery('#sumNum').text(img.length);
  183. var simgEle = "";
  184. for (var i = 0; i < img.length; i++) {
  185. if (i == 0) {
  186. jQuery("#canvasDiv").append('<canvas id="c0" height="1100" width="825"></canvas>');
  187. canvasInit.push("c0");
  188. switchCanvas(img[i].i, 0);
  189. simgEle += '<div class="swiper-slide swiper-slide-visible swiper-slide-active active-nav">';
  190. } else {
  191. simgEle += '<div class="swiper-slide swiper-slide-visible">';
  192. }
  193. simgEle += ('<div class="slide_inner"><img src="' + img[i].s + '" class="center-self"></div></div>');
  194. }
  195. jQuery("#simgDiv").append(simgEle);
  196. //点击缩略图
  197. jQuery(".swiper-slide-visible").on("click", function () {
  198. var _index = jQuery(this).index(),
  199. _cid = "c" + _index;
  200. if (canvasInit.indexOf(_cid) == -1) {
  201. jQuery("#canvasDiv").append('<canvas id="' + _cid + '" height="1100" width="825"></canvas>');
  202. canvasInit.push(_cid);
  203. }
  204. jQuery(this).addClass("active-nav").siblings().removeClass("active-nav");
  205. switchCanvas(img[_index].i, _index);
  206. jQuery("#currentNum").text(1 + _index);
  207. });
  208. //隐藏弹窗
  209. jQuery("#hideModal").on("click", function () {
  210. jQuery("#errModal").addClass("fn-hide");
  211. });
  212. //弹窗科目错误设置
  213. if (subject && errTagType[subject] && errTagType[subject].length > 0) {
  214. for (var i = 0; i < errTagType[subject].length; i++) {
  215. jQuery('#errTags').append('<div name="etag" class="wrong_label fn-left">' + errTagType[subject][i] + '</div>');
  216. }
  217. }
  218. //错误标签点击
  219. jQuery("div[name=etag]").on("click", function () {
  220. jQuery(this).toggleClass("active");
  221. });
  222. //错误标签选定
  223. jQuery("#errVerify").on("click", function () {
  224. var errTags = jQuery('#errTags').find(".active");
  225. if (errTags.length <= 0) {
  226. alert('请先选中标签!');
  227. return false;
  228. }
  229. var errSonEle = '<div class="wrong_item">';
  230. errSonEle += ' <i class="serial_number fn-left" value="' + appErrCount + '">' + appErrCount + '</i>';
  231. errSonEle += '<div class="wrong_content fn-clear">';
  232. for (var i = 0; i < errTags.length; i++) {
  233. errSonEle += '<div class="wrong_label fn-left">' + jQuery(errTags[i]).text() + '</div>';
  234. }
  235. errSonEle += '</div></div>';
  236. jQuery("#errMsg").prepend(errSonEle);
  237. jQuery("#errModal").addClass("fn-hide");
  238. });
  239. //绑定工具事件
  240. jQuery("#tools").find(".handle_btn").on("click", function () {
  241. //设置样式
  242. jQuery(this).addClass("active").siblings().removeClass("active");
  243. drawType = jQuery(this).attr("data-type");
  244. // window.drawType = drawType;
  245. canvas.isDrawingMode = false;
  246. if (drawType == "pen") {
  247. canvas.isDrawingMode = true;
  248. } else if (drawType == "remove") {
  249. canvas.selection = true;
  250. canvas.skipTargetFind = false;
  251. canvas.selectable = true;
  252. } else if (drawType == "help") {
  253. jQuery("#c").toggleClass("fn-hide");
  254. }
  255. else {
  256. canvas.skipTargetFind = true; //画板元素不能被选中
  257. canvas.selection = false; //画板不显示选中
  258. }
  259. });
  260. //get七牛token
  261. var qiniuToken = undefined;
  262. jQuery.ajax({
  263. type: "GET",
  264. cache: false,
  265. dataType: "jsonp",
  266. url: config.tokenURL,
  267. data: {},
  268. success: function (res) {
  269. qiniuToken = res.token;
  270. }
  271. });
  272. //提交作业
  273. jQuery("#subBut").on("click", function () {
  274. jQuery("#maskDiv").show();
  275. var fs = jQuery("#fontScore").find("div.active").index() + 1;
  276. if (fs <= 0) {
  277. alert("操作失败,请先选择字迹评分!");
  278. return false;
  279. }
  280. if (true) { //TODO:confirm("确认作业批改完成?")
  281. var checkJson = {
  282. "pages": [],
  283. "font": fs,
  284. "callback": {
  285. "task_id": (getUrlParam("task_id") || ""),
  286. "task_list_id": (getUrlParam("task_list_id") || ""),
  287. "userinfo": (getUrlParam("userinfo") || ""),
  288. "type": (getUrlParam("type") || "")
  289. }
  290. };
  291. window.checkJson = undefined;
  292. for (var i = 0; i < canvasArr.length; i++) {
  293. if (canvasArr[i]) {
  294. var canvasJson = {
  295. "question": [],
  296. "page": {
  297. "img": "",
  298. "imgorg": "",
  299. "w": 0,
  300. "h": 0,
  301. "index": i
  302. }
  303. };
  304. var objs = canvasArr[i].getObjects();
  305. var checkObj = [];
  306. for (var j = 0; j < objs.length; j++) {
  307. if (objs[j].type && objs[j].type != 'image') {
  308. checkObj.push(objs[j]);
  309. } else {
  310. var _imgName = md5(uuid.uuid() + new Date().getTime()) + ".png";
  311. canvasJson.page.imgorg = objs[j]._element.src;
  312. canvasJson.page.img = config.imgDomain + _imgName;
  313. canvasJson.page.w = objs[j].width;
  314. canvasJson.page.h = objs[j].height;
  315. addUploadImg(canvasArr[i], objs[j], _imgName, false);
  316. }
  317. }
  318. checkObj.sort(function (x, y) { return x.top - y.top; }); //根据控件top排序
  319. var itemSmallRight = 0, itemSmallWrong = 0, prevSmallType = true, errImg = "", errIndexs = [];
  320. for (var j = 0; j < checkObj.length; j++) {
  321. switch (checkObj[j].type) {
  322. case 'smallright':
  323. ++itemSmallRight;
  324. errIndexs.push(checkObj[j].eindex);
  325. break;
  326. case 'smallwrong':
  327. ++itemSmallWrong;
  328. errIndexs.push(checkObj[j].eindex);
  329. break;
  330. case 'right':
  331. case 'wrong':
  332. prevSmallType = false;
  333. break;
  334. case 'rectangle': //框
  335. var _imgName = md5(uuid.uuid() + new Date().getTime()) + ".png";
  336. errImg = config.imgDomain + _imgName;
  337. addUploadImg(canvasArr[i], checkObj[j], _imgName, true);
  338. prevSmallType = false;
  339. break;
  340. default:
  341. break;
  342. }
  343. if (prevSmallType == false || j == (checkObj.length - 1)) {
  344. //下一题为整题对/错 || 最后一题 (结算上一题[小错/对])
  345. if (itemSmallRight > 0 || itemSmallWrong > 0) {
  346. var errJson = [];
  347. if (errIndexs.length > 0) {
  348. for (var m = 0; m < errIndexs.length; m++) {
  349. var _eindex = errIndexs[m];
  350. var txt = getErrTagsByIndex(_eindex);
  351. errJson.push({
  352. "id": _eindex + 1,
  353. "desc": txt,
  354. "x": checkObj[m].left,
  355. "y": checkObj[m].top
  356. });
  357. }
  358. }
  359. canvasJson.question.push({ 'r': 0, 'w': 0, 'sr': itemSmallRight, 'sw': itemSmallWrong, 'eimg': errImg, 'err': errJson });
  360. errImg = "";
  361. errIndexs = [];
  362. itemSmallRight = 0, itemSmallWrong = 0;
  363. }
  364. prevSmallType = true;
  365. }
  366. //录入本次大题
  367. if (checkObj[j].type == 'right') {
  368. canvasJson.question.push({ 'r': 1, 'w': 0, 'sr': 0, 'sw': 0, 'eimg': '', 'err': [] });
  369. } else if (checkObj[j].type == 'wrong') {
  370. var errJson = [];
  371. var _eindex = checkObj[j].eindex;
  372. var txt = getErrTagsByIndex(_eindex);
  373. errJson[0] = {
  374. "id": _eindex + 1,
  375. "desc": txt,
  376. "x": checkObj[j].left,
  377. "y": checkObj[j].top
  378. };
  379. canvasJson.question.push({ 'r': 0, 'w': 1, 'sr': 0, 'sw': 0, 'eimg': errImg, 'err': errJson });
  380. errImg = "";
  381. }
  382. }
  383. checkJson.pages.push(canvasJson);
  384. } else {
  385. //这里的图片没有点击初始化
  386. }
  387. }
  388. window.checkJson = JSON.stringify(checkJson);
  389. //上传图片+请求服务器
  390. uploadImg(uploadImageArray, qiniuToken);
  391. }
  392. });
  393. //更多操作
  394. jQuery("#moreBtn").on("click", function () {
  395. jQuery("#moreDiv").toggleClass("fn-hide");
  396. });
  397. //异常订单
  398. jQuery("#expBtn").on("click", function () {
  399. jQuery("#moreDiv").toggleClass("fn-hide");
  400. if (confirm("确认为异常订单?")) {
  401. //TODO:业务
  402. }
  403. });
  404. //放弃订单
  405. jQuery("#giveupBtn").on("click", function () {
  406. jQuery("#moreDiv").toggleClass("fn-hide");
  407. if (confirm("确认为放弃订单?")) {
  408. //TODO:业务
  409. }
  410. });
  411. //字体打分
  412. jQuery("#fontScore").find("div").on("click", function () {
  413. jQuery(this).addClass("active").siblings().removeClass("active");
  414. });
  415. //获取url中的参数
  416. function getUrlParam(name) {
  417. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  418. var r = window.location.search.substr(1).match(reg);
  419. if (r != null) return decodeURI(r[2]);
  420. return null;
  421. }
  422. //添加上传图片 (isRemove:类型bool,是否需要移除截图在添加)
  423. function addUploadImg(canvas, canvasControl, imgName, isRemove) {
  424. if (isRemove) {
  425. canvas.remove(canvasControl);
  426. }
  427. var base64 = canvas.toDataURL({
  428. format: 'png',
  429. left: canvasControl.left,
  430. top: canvasControl.top,
  431. width: canvasControl.width,
  432. height: canvasControl.height
  433. });
  434. uploadImageArray.push({ "name": imgName, "base64": base64 });
  435. // jQuery("#testImg").append('<img src="' + base64 + '"/><br />');
  436. if (isRemove) {
  437. canvas.add(canvasControl);
  438. }
  439. }
  440. //获取错误标签描述集合(根据标号)
  441. function getErrTagsByIndex(eindex) {
  442. var txt = "";
  443. var txtCt = jQuery('#errMsg').find('.wrong_item > i[value="' + (eindex + 1) + '"]').siblings().find('div');
  444. for (var k = 0; k < txtCt.length; k++) {
  445. txt += txtCt.eq(k).text();
  446. if (k != (txtCt.length - 1)) {
  447. txt += ",";
  448. }
  449. }
  450. return txt;
  451. }
  452. });
  453. </script>
  454. </html>