angular.login.js 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135
  1. app.controller('LoginCtrl', [ '$rootScope', '$scope', '$http', '$location', '$q', '$timeout', '$sce', function($rootScope, $scope, $http, $location, $q, $timeout, $sce) {
  2. $scope.currStep = 'LoginName';
  3. $scope.clientMac = '';
  4. $scope.currentNum = 0;
  5. // $scope.launchFullscreen = function(element) {
  6. // if (document.documentElement.requestFullscreen) {
  7. // document.documentElement.requestFullscreen();
  8. // } else if (document.documentElement.mozRequestFullScreen) {
  9. // document.documentElement.mozRequestFullScreen();
  10. // } else if (document.documentElement.webkitRequestFullscreen) {
  11. // document.documentElement.webkitRequestFullscreen();
  12. // } else if (document.documentElement.msRequestFullscreen) {
  13. // document.documentElement.msRequestFullscreen();
  14. // }
  15. // }
  16. $scope.isWillCheckPhoneCode = false;
  17. $scope.checkCodeForm = {
  18. phone_code : ""
  19. }
  20. $scope.sendPhoneCodeSuccess = "";
  21. $scope.aliPlayer = null;
  22. $scope.changeLogin = function($event) {
  23. if ($event.target.value == '' || $event.target.value.length < 3)
  24. return;
  25. if ($event.keyCode == 13) {
  26. $('#login_pass').focus();
  27. }
  28. }
  29. $scope.changeLoginName = function($event) {
  30. if ($event.target.value == '' || $event.target.value.length < 3)
  31. return;
  32. if ($event.keyCode == 13) {
  33. $scope.queryJudge($.trim($event.target.value));
  34. }
  35. }
  36. $scope.showLoginName = function() {
  37. $scope.group = undefined;
  38. $scope.room = undefined;
  39. $scope.judge = undefined;
  40. $scope.currStep = 'LoginName';
  41. $timeout(function() {
  42. $('#login_name').focus();
  43. }, 100);
  44. }
  45. $scope.queryJudge = function(login_name) {
  46. //
  47. var login_pass = document.getElementById('login_pass');
  48. $rootScope.ajaxRequest({
  49. url : '../exam/judge/grade/info/loginname.htm',
  50. data : {
  51. login_name : document.getElementById('login_name').value,
  52. login_pass : (login_pass== undefined || login_pass == '') ? '': login_pass.value
  53. }
  54. }, function(response) {
  55. $scope.group = response.map.Room.group;
  56. $scope.room = response.map.Room;
  57. $scope.judge = response.map.Judge;
  58. $scope.disArr = response.map.discipline;
  59. // 单独评分 手机短信验证
  60. $scope.isWillCheckPhoneCode = (($scope.ParamMap['ExamJudgeGradeType'] !== undefined && $scope.ParamMap['ExamJudgeGradeType'].param_value == 'Judge') ? true : false);
  61. if (!$scope.isWillCheckPhoneCode)
  62. $scope.currStep = 'ConfrimJudge';
  63. })
  64. }
  65. $scope.sendPhoneCode = function() {
  66. $rootScope.ajaxRequest({
  67. url : '../exam/judge/sendPhoneCode.htm',
  68. data : {
  69. judge_id : $scope.judge.judge_id
  70. }
  71. }, function(response) {
  72. if (response.success) {
  73. $rootScope.sendPhoneCodeSuccess = true;
  74. $scope.codeCountDown = 30;
  75. $scope.countDownFn();
  76. $scope.checkPhoneCodeSucMsg = "短信验证码发送成功,30秒后未收到可重新发送!";
  77. } else {
  78. $scope.checkPhoneCodeErrMsg = response.errorMsg;
  79. }
  80. })
  81. }
  82. $scope.checkPhoneCode = function() {
  83. if ($scope.checkCodeForm.phone_code.length == 0) {
  84. alert('请输入手机验证码!');
  85. return;
  86. }
  87. $rootScope.ajaxRequest({
  88. url : '../exam/judge/checkPhoneCode.htm',// TODO
  89. data : {
  90. phone_code : $scope.checkCodeForm.phone_code
  91. }
  92. }, function(response) {
  93. if (response.success) {
  94. $scope.isWillCheckPhoneCode = false;
  95. $scope.currStep = 'ConfrimJudge';
  96. }
  97. })
  98. }
  99. $scope.countDownFn = function() {
  100. $timeout(function() {
  101. console.log($rootScope.codeCountDown);
  102. $scope.codeCountDown--;
  103. if ($scope.codeCountDown > 0) {
  104. $scope.countDownFn();
  105. }
  106. }, 1000);
  107. }
  108. $scope.showVideo = function(video_file, skips){
  109. var v = $('#video-player');
  110. v.html('');
  111. v.css("background-color","");
  112. //width: 575px;
  113. // height: 270px;
  114. $scope.aliPlayer = new Aliplayer({
  115. "id": "video-player",
  116. "source": video_file,
  117. "width": "575px",
  118. "height": "270px",
  119. "autoplay": true,
  120. "isLive": false,
  121. "rePlay": false,
  122. "playsinline": true,
  123. "preload": true,
  124. "controlBarVisibility": "hover",
  125. "useH5Prism": true
  126. }, function (player) {
  127. player.play();
  128. player.seek(skips);
  129. /*
  130. player.on('autoplay',function(data){
  131. // 浏览器支持自动播放
  132. if(!data.paramData){
  133. // 自动播放
  134. player.play();
  135. }else{
  136. // 提示用户点击播放
  137. }
  138. })
  139. */
  140. }
  141. );
  142. }
  143. $scope.closeVideo = function(){
  144. $scope.aliPlayer.dispose();
  145. }
  146. $scope.changeVideoSource = function(video_file, skips) {
  147. $scope.aliPlayer.loadByUrl(video_file);
  148. //自动播放
  149. $scope.aliPlayer.play();
  150. $scope.aliPlayer.seek(skips);
  151. }
  152. $scope.showGroup = function() {
  153. $rootScope.ajaxRequest({
  154. url : '../exam/judge/grade/group/list.htm',
  155. data : {
  156. exam_date : '2020-02-12'
  157. }
  158. }, function(response) {
  159. $scope.groupArray = response.array;
  160. $scope.currStep = 'ChooseGroup';
  161. })
  162. }
  163. $scope.chooseGroup = function(group) {
  164. $scope.group = group;
  165. $rootScope.ajaxRequest({
  166. url : '../exam/judge/grade/room/list.htm',
  167. data : {
  168. exam_date : '2020-02-12',
  169. ly_group_id : group.ly_group_id
  170. }
  171. }, function(response) {
  172. $scope.roomArray = response.array;
  173. $scope.currStep = 'ChooseRoom';
  174. })
  175. }
  176. $scope.chooseRoom = function(room) {
  177. $scope.room = room;
  178. $rootScope.ajaxRequest({
  179. url : '../exam/judge/grade/judge/list.htm',
  180. data : {
  181. ly_room_id : room.ly_room_id
  182. }
  183. }, function(response) {
  184. $scope.judgeArray = response.array;
  185. $scope.currStep = 'ChooseJudge';
  186. })
  187. }
  188. $scope.chooseJudge = function(judge) {
  189. $scope.judge = judge;
  190. $scope.currStep = 'ConfrimJudge';
  191. }
  192. $scope.judgeLogin = function() {
  193. // 生成mac
  194. var padMac = localStorage.getItem('padMac');
  195. if(!padMac) {
  196. padMac = $scope.judge.room_id + '_' + $scope.judge.judge_seq + "_" + $scope.judge.room_id + "_" + $scope.clientMac;
  197. }
  198. $rootScope.ajaxRequest({
  199. url : '../exam/judge/grade/login.htm',
  200. data : {
  201. ly_room_id : $scope.room.ly_room_id,
  202. judge_id : $scope.judge.judge_id,
  203. login_name : $scope.judge.login_name,
  204. // client_mac : ($scope.judge.room_id + '_' + $scope.judge.judge_seq + "_" + $scope.judge.room_id + "_" + $scope.clientMac)
  205. client_mac : padMac
  206. }
  207. }, function(response) {
  208. $scope.ExamParamMap = response.map;
  209. $scope.refreshTime = $rootScope.longMinuteString(new Date());
  210. var key = "";
  211. angular.forEach(response.map.Judge.des_type, function(k) {
  212. if (k == '1')
  213. key += response.map.Judge.judge_id;
  214. else if (k == '2')
  215. key += response.map.Judge.judge_seq;
  216. else if (k == '3')
  217. key += response.map.Judge.login_name;
  218. else if (k == '4')
  219. key += $scope.room.ly_room_id;
  220. else if (k == '5')
  221. key += $scope.room.room_key;
  222. else if (k == '6')
  223. key += $scope.room.ly_group_id;
  224. else if (k == '7')
  225. key += $scope.room.ly_agent_id;
  226. });
  227. // 444111
  228. if (key.length < 16) {
  229. var len = 16 - key.length;
  230. for (var i = 0; i < len; i++)
  231. key = "0" + key;
  232. }
  233. key = key.substring(0, 16);
  234. response.map.Judge.des_key = key;
  235. response.map.Judge.real_exam_seq = 0;
  236. $scope.judge = response.map.Judge;
  237. $scope.StdArray = [];
  238. $scope.nextExamSeq();
  239. $scope.currStep = 'Examing';
  240. $scope.scoreStdTotal = 0;
  241. })
  242. }
  243. /***************************************************************************
  244. * 评分相关函数
  245. */
  246. $scope.getParamValue = function(param_name, default_value) {
  247. if ($scope.ParamMap == undefined)
  248. return undefined;
  249. if ($scope.ParamMap[param_name] == undefined)
  250. return default_value;
  251. return $scope.ParamMap[param_name].param_value;
  252. }
  253. /***************************************************************************
  254. * 查找下一个考生
  255. */
  256. $scope.nextExamSeq = function() {
  257. if ($scope.judge == undefined)
  258. return;
  259. if ($scope.group.judge_cache_num <= $scope.StdArray.length) {
  260. // 超出等待限制
  261. $timeout($scope.nextExamSeq, parseInt($scope.getParamValue('NextExamSeqTicketSeconds', '10000'), 10));
  262. return;
  263. }
  264. $scope.last_next_time = new Date();
  265. $rootScope.ajaxRequest({
  266. url : '../exam/judge/grade/std/next.htm',
  267. data : $scope.judge,
  268. error : function() {
  269. // 网络错误等情况,要考虑延迟的问题
  270. $timeout($scope.nextExamSeq, parseInt($scope.getParamValue('NextExamSeqTicketSeconds', '5000'), 10));
  271. }
  272. }, function(data) {
  273. $scope.lastRequestTime = data.map.QueryNextTime;
  274. $scope.jsonValue = angular.toJson(data);
  275. var std = data.map.ExamStd;
  276. //debugger;
  277. if (data.map.ExVideoList && data.map.ExVideoList.length > 0){
  278. //std['material_file'] = data.map.ExVideo['video_file'];
  279. std.ExVideoList = data.map.ExVideoList;
  280. }
  281. if (data.map.RealExamSeq) {
  282. $scope.judge.real_exam_seq = data.map.RealExamSeq;
  283. }
  284. if (std && std.std_id) {
  285. // 是否是新考生
  286. var flag = true;
  287. for (var k = 0; k < $scope.StdArray.length; k++) {
  288. $scope.time_type = $scope.StdArray[k].time_type;
  289. if ($scope.StdArray[k].std_id - std.std_id == 0) {
  290. flag = false;
  291. return;
  292. }
  293. }
  294. if (flag) {
  295. std.SubjectArray = data.map.SubjectArray;
  296. var avoid = false;
  297. angular.forEach(std.SubjectArray, function(sb) {
  298. $scope.time_type = sb.time_type;
  299. if (sb.judge_avoid == 'Active') {
  300. avoid = true;
  301. } else {
  302. if (sb.judge_record_score != undefined && sb.judge_record_score != sb.judge_score) {
  303. sb.judge_score = sb.judge_record_score;
  304. }
  305. }
  306. });
  307. // 该考生被回避
  308. if (avoid) {
  309. angular.forEach(std.SubjectArray, function(sb) {
  310. sb.judge_avoid = 'Active';
  311. sb.judge_score = undefined;
  312. sb.judge_record_score = undefined;
  313. });
  314. std.avoid_flag = 'Active';
  315. } else {
  316. std.avoid_flag = undefined;
  317. }
  318. std.tracksArray = data.map.TracksArry;
  319. $scope.StdArray.push(std);
  320. // 如果当前考生不为空,判断是否焦点要自动下移
  321. if ($scope.currentStd != undefined) {
  322. // 判断是否给过分
  323. var score_flag = true;
  324. angular.forEach($scope.currentStd.SubjectArray, function(sb) {
  325. if (sb.judge_score == undefined && sb.judge_avoid != 'Active') {
  326. score_flag = false;
  327. }
  328. });
  329. if (score_flag) {
  330. // 所有科目已经给过分,光标下移
  331. //$scope.chooseStd(std);
  332. }
  333. } else {
  334. $scope.chooseStd(std);
  335. }
  336. $scope.checkGradeTotol();
  337. }
  338. $scope.judge.real_exam_seq = std.real_exam_seq;
  339. // 有新考生,1秒轮询
  340. $timeout($scope.nextExamSeq, 500);
  341. //计算总分
  342. $scope.getTotalScore(std);
  343. } else {
  344. // 没有新考生,按照规定的时间去轮询
  345. $timeout($scope.nextExamSeq, parseInt($scope.getParamValue('NextExamSeqTicketSeconds', '5000'), 10));
  346. }
  347. });
  348. }
  349. //多科目 多个视频--切换视频
  350. $scope.changeSubjVideo = function(ex_video, index) {
  351. $scope.currentNum = index;
  352. //debugger;
  353. var v = document.getElementById('video-player');
  354. if (v) {
  355. let skips = parseInt(ex_video["skip_prepare_secs"]);
  356. $scope.changeVideoSource(ex_video.video_file,skips);
  357. }
  358. }
  359. //计算总分
  360. $scope.getTotalScore = function(std) {
  361. if(std && std.SubjectArray.length > 1) {
  362. std.totalScore = 0;
  363. for(const subject of std.SubjectArray) {
  364. std.totalScore += parseInt(subject.judge_score == undefined ? 0 : subject.judge_score);
  365. }
  366. }
  367. }
  368. /***************************************************************************
  369. * 选择某个考生
  370. */
  371. $scope.chooseStd = function(std) {
  372. var avoid = false;
  373. // $scope.disciplineFlag = 'InActive';
  374. angular.forEach(std.SubjectArray, function(sb) {
  375. if (sb.judge_avoid == 'Active') {
  376. avoid = true;
  377. } else {
  378. // if (sb.judge_record_score != undefined &&
  379. // sb.judge_record_score !=
  380. // sb.judge_score) {
  381. // sb.judge_score = sb.judge_record_score;
  382. // }
  383. }
  384. });
  385. // 该考生被回避
  386. if (avoid) {
  387. angular.forEach(std.SubjectArray, function(sb) {
  388. sb.judge_avoid = 'Active';
  389. sb.judge_score = undefined;
  390. sb.judge_record_score = undefined;
  391. });
  392. std.avoid_flag = 'Active';
  393. } else {
  394. std.avoid_flag = undefined;
  395. }
  396. $scope.currentStd = std;
  397. // 首次自动加载初始化视频
  398. if ($scope.currentStd && $scope.getParamValue('JudgeVideoScore', 'InActive') == 'Active'
  399. && $scope.currentStd.separate_score == 'Active') {
  400. setTimeout(function() {
  401. var v = document.getElementById('video-player');
  402. //debugger;
  403. if (v && std.ExVideoList.length >=1 ) {
  404. let skips = parseInt(std.ExVideoList[0]["skip_prepare_secs"]);
  405. $scope.showVideo(std.ExVideoList[0].video_file, skips);
  406. $scope.first_load = false;
  407. }
  408. }, 2000);
  409. }
  410. if (std.SubjectArray.length == 1) {
  411. $scope.chooseSubject(std.SubjectArray[0]);
  412. } else {
  413. $scope.scoreStep = 'subjectPanel';
  414. }
  415. }
  416. /***************************************************************************
  417. * 点击列表选择某个考生
  418. */
  419. $scope.clickChooseStd = function(std) {
  420. var avoid = false;
  421. $scope.showScore = false;
  422. $scope.currentScore = undefined;
  423. angular.forEach(std.SubjectArray, function(sb) {
  424. if (sb.judge_avoid == 'Active') {
  425. avoid = true;
  426. } else {
  427. // if (sb.judge_record_score != undefined &&
  428. // sb.judge_record_score !=
  429. // sb.judge_score) {
  430. // sb.judge_score = sb.judge_record_score;
  431. // }
  432. }
  433. });
  434. // 该考生被回避
  435. if (avoid) {
  436. angular.forEach(std.SubjectArray, function(sb) {
  437. sb.judge_avoid = 'Active';
  438. sb.judge_score = undefined;
  439. sb.judge_record_score = undefined;
  440. });
  441. std.avoid_flag = 'Active';
  442. } else {
  443. std.avoid_flag = undefined;
  444. }
  445. $scope.currentStd = std;
  446. //开启评委视频评分
  447. if($scope.getParamValue('JudgeVideoScore', 'InActive') == 'Active' && $scope.currentStd.separate_score == 'Active') {
  448. if (std.ExVideoList && std.ExVideoList.length > 0) {
  449. let skips = parseInt(std.ExVideoList[0]["skip_prepare_secs"]);
  450. $scope.changeVideoSource(std.ExVideoList[0].video_file, skips);
  451. }
  452. }
  453. if (std.SubjectArray.length == 1) {
  454. $scope.chooseSubject(std.SubjectArray[0]);
  455. } else {
  456. $scope.scoreStep = 'subjectPanel';
  457. }
  458. if($scope.getParamValue('NineScore', 'InActive') == 'Active') {
  459. $scope.nineExit();
  460. }
  461. }
  462. /***************************************************************************
  463. * 选择评分科目(多科目情况下)
  464. */
  465. $scope.chooseSubject = function(sb) {
  466. if ($scope.currentStd.avoid_flag == 'Active')
  467. return;
  468. $scope.currentSubject = sb;
  469. for (var i = 0; i < $scope.ExamParamMap['SubjectScore_' + sb.subject_id].length; i++) {
  470. var score = $scope.ExamParamMap['SubjectScore_' + sb.subject_id][i];
  471. if (score.master_flag == 'Active') {
  472. $scope.chooseScore(score)
  473. break;
  474. }
  475. }
  476. //开启分评
  477. if($scope.getParamValue('JudgeVideoScore', 'InActive') == 'Active' && $scope.currentStd.separate_score == 'Active'
  478. && $scope.currentStd.SubjectArray.length > 1 ) {
  479. $scope.aliPlayer.loadByUrl(sb.video_url);
  480. }
  481. //currentSubject.disciplineFlag 判断是否开打违规
  482. if(sb.discipline_id){
  483. $scope.currentSubject.disciplineFlag = 'Active'
  484. }
  485. $scope.scoreStep = 'scorePanel';
  486. if($scope.getParamValue('NineScore', 'InActive') == 'Active') {
  487. $timeout(function() {
  488. $(".numkeyboard").numkeyboard();
  489. $(".numkeyboard").focus();
  490. }, 500);
  491. }
  492. }
  493. /***************************************************************************
  494. * 选择评分区间
  495. */
  496. $scope.chooseScore = function(score) {
  497. $scope.showScore = true;
  498. var array = new Array();
  499. for (var value = score.score_max; value >= score.score_min; value = value - (score.score_tick)) {
  500. var score_value = value;
  501. if (value < score.score_min)
  502. score_value = score.score_min;
  503. array.push({
  504. score_value : score_value
  505. });
  506. }
  507. $scope.currentScore = score;
  508. $scope.scoreArray = array;
  509. }
  510. /***************************************************************************
  511. * 对某个科目进行评分(未提交)
  512. */
  513. $scope.gradeScore = function(score_value, discipline_id) {
  514. //取消违规
  515. var obj = angular.extend({}, $scope.judge, {
  516. judge_score : score_value,
  517. std_subject_id : $scope.currentSubject.std_subject_id,
  518. discipline_notice: $scope.currentSubject.discipline_notice,
  519. discipline_id: discipline_id
  520. });
  521. //多科目计算总分
  522. if($scope.currentStd.SubjectArray.length > 1) {
  523. $scope.currentStd.totalScore = 0;
  524. for(const subject of $scope.currentStd.SubjectArray) {
  525. if( $scope.currentSubject.subject_id == subject.subject_id) {
  526. $scope.currentStd.totalScore += parseInt(score_value);
  527. } else {
  528. $scope.currentStd.totalScore += parseInt(subject.judge_score === undefined ? 0 : subject.judge_score);
  529. }
  530. }
  531. }
  532. $rootScope.ajaxRequest({
  533. url : '../exam/judge/grade/std/record.htm',
  534. data : obj
  535. }, function(response) {
  536. $scope.currentSubject.judge_score = score_value;
  537. $scope.checkGradeTotol();
  538. if(score_value == 20 && $scope.currentSubject.discipline_id){
  539. return ; //如果是单独选择的违规,那么不跳走,方便后续打分
  540. }
  541. if ($scope.currentStd.SubjectArray.length > 1) {
  542. $scope.scoreStep = 'subjectPanel';
  543. }
  544. })
  545. }
  546. //取消违规
  547. $scope.clearDiscipline = function(){
  548. $scope.currentSubject.discipline_id=undefined;
  549. var obj = angular.extend({}, $scope.judge, {
  550. judge_score : '',
  551. std_subject_id : $scope.currentSubject.std_subject_id,
  552. discipline_id: ''
  553. });
  554. $rootScope.ajaxRequest({
  555. url : '../exam/judge/grade/std/record.htm',
  556. data : obj
  557. }, function(response) {
  558. $scope.checkGradeTotol();
  559. $scope.stdDiscipline();
  560. })
  561. }
  562. /***************************************************************************
  563. * 回避或者取消回避
  564. */
  565. $scope.avoidStd = function() {
  566. var obj = angular.extend({}, $scope.judge, {
  567. judge_avoid : $scope.currentStd.avoid_flag == 'Active' ? 'InActive' : 'Active',
  568. std_subject_id : $scope.currentStd.SubjectArray[0].std_subject_id
  569. });
  570. $rootScope.ajaxRequest({
  571. url : '../exam/judge/grade/std/avoid.htm',
  572. data : obj
  573. }, function(response) {
  574. $scope.currentStd.avoid_flag = ($scope.currentStd.avoid_flag == 'Active' ? undefined : 'Active');
  575. angular.forEach($scope.currentStd.SubjectArray, function(sb) {
  576. sb.judge_score = undefined;
  577. sb.judge_record_score = undefined;
  578. sb.judge_avoid = $scope.currentStd.avoid_flag;
  579. });
  580. $scope.checkGradeTotol();
  581. })
  582. }
  583. /***************************************************************************
  584. * 判断已经评分的数量
  585. */
  586. $scope.checkGradeTotol = function() {
  587. var total = 0;
  588. angular.forEach($scope.StdArray, function(std) {
  589. var flag = true;
  590. angular.forEach(std.SubjectArray, function(sb) {
  591. if (sb.judge_avoid != 'Active' && sb.judge_score == undefined)
  592. flag = false;
  593. });
  594. if (flag) {
  595. std.score_flag = true;
  596. total++;
  597. } else {
  598. std.score_flag = false;
  599. }
  600. });
  601. $scope.scoreStdTotal = total;
  602. }
  603. /***************************************************************************
  604. * 提交前确认
  605. */
  606. $scope.confirmScore = function() {
  607. var flag = new Array();
  608. for (var i = 0; i < $scope.StdArray.length; i++) {
  609. flag.push($scope.StdArray[i].score_flag);
  610. }
  611. var truePosition = flag.lastIndexOf(true);
  612. var falsePosition = flag.indexOf(false);
  613. if (truePosition > falsePosition && falsePosition != -1) {
  614. alert('前面的考生未打分,请打分后在提交分数!');
  615. $scope.clickChooseStd($scope.StdArray[falsePosition]);
  616. return;
  617. }
  618. var array = new Array();
  619. for (var i = 0; i < $scope.StdArray.length; i++) {
  620. if ($scope.StdArray[i].score_flag == true) {
  621. var confirm_score_value = "";
  622. for (var k = 0; k < $scope.StdArray[i].SubjectArray.length; k++) {
  623. var subject = $scope.StdArray[i].SubjectArray[k];
  624. confirm_score_value = confirm_score_value + (k > 0 ? "、" : "") + subject.subject_name + "【" + (subject.judge_avoid == 'Active' ? "回避" : (subject.discipline_id?'违规'+subject.judge_score:subject.judge_score)) + "】";
  625. }
  626. $scope.StdArray[i].confirm_score_value = confirm_score_value;
  627. array.push($scope.StdArray[i]);
  628. } else {
  629. break;
  630. }
  631. }
  632. if (array.length == 0)
  633. return;
  634. $scope.confirmStdArray = array;
  635. if ($scope.getParamValue('ShowJudgeSign', 'InActive') == 'Active') {
  636. $scope.setStdNumber(array);
  637. }
  638. $scope.currStep = 'ConfirmScore';
  639. }
  640. /***************************************************************************
  641. * 查看分数
  642. */
  643. $scope.lookScore = function() {
  644. $rootScope.ajaxRequest({
  645. url : '../exam/judge/grade/judge/lookScore.htm',
  646. data : {
  647. room_id : $scope.room.ly_room_id,
  648. judge_id : $scope.judge.judge_id
  649. }
  650. }, function(response) {
  651. $scope.stdScoreArray = response.array;
  652. });
  653. $scope.currStep = 'LookScore';
  654. }
  655. // 选中上一个考生
  656. $scope.chooseLastStd = function() {
  657. $scope.showScore = false;
  658. $scope.currentScore = undefined;
  659. $scope.disciplineFlag = 'InActive';
  660. // 当前选中考生
  661. var curStd = $scope.currentStd;
  662. if (!curStd)
  663. return;
  664. for (var k = 0; k < $scope.StdArray.length; k++) {
  665. var std = $scope.StdArray[k];
  666. if (std.std_id === curStd.std_id) {
  667. if (k > 0) {
  668. $scope.currentStd = $scope.StdArray[k - 1];
  669. if($scope.getParamValue('JudgeVideoScore', 'InActive') == 'Active' && $scope.currentStd.separate_score == 'Active') {
  670. if ($scope.currentStd.ExVideoList && $scope.currentStd.ExVideoList.length > 0) {
  671. let skips = parseInt($scope.currentStd.ExVideoList[0]["skip_prepare_secs"]);
  672. $scope.changeVideoSource($scope.currentStd.ExVideoList[0].video_file, skips);
  673. }
  674. }
  675. $scope.clickChooseStd($scope.currentStd);
  676. //这里滚动
  677. $("#stuList")[0].scrollTop = $(".stu-info:eq("+(k-1)+")")[0].offsetTop -81
  678. break;
  679. } else {
  680. alert('已经是第一个考生!')
  681. }
  682. }
  683. }
  684. if($scope.getParamValue('NineScore', 'InActive') == 'Active') {
  685. $scope.nineExit();
  686. }
  687. }
  688. // 选中下一个考生
  689. $scope.chooseNextStd = function() {
  690. $scope.showScore = false;
  691. $scope.currentScore = undefined;
  692. $scope.disciplineFlag = 'InActive';
  693. // 当前选中考生
  694. var curStd = $scope.currentStd;
  695. if (!curStd)
  696. return;
  697. for (var k = 0; k < $scope.StdArray.length; k++) {
  698. var std = $scope.StdArray[k];
  699. if (std.std_id === curStd.std_id) {
  700. if ((k + 1) < $scope.StdArray.length) {
  701. $scope.currentStd = $scope.StdArray[k + 1];
  702. if($scope.getParamValue('JudgeVideoScore', 'InActive') == 'Active' && $scope.currentStd.separate_score == 'Active') {
  703. if ($scope.currentStd.ExVideoList && $scope.currentStd.ExVideoList.length > 0) {
  704. let skips = parseInt($scope.currentStd.ExVideoList[0]["skip_prepare_secs"]);
  705. $scope.changeVideoSource($scope.currentStd.ExVideoList[0].video_file, skips);
  706. }
  707. }
  708. $scope.clickChooseStd($scope.currentStd);
  709. $("#stuList")[0].scrollTop = $(".stu-info:eq("+(k+1)+")")[0].offsetTop -81
  710. break;
  711. } else {
  712. // 无下一个考生 提示 TODO
  713. alert('已经是最后一个考生!')
  714. }
  715. }
  716. }
  717. if($scope.getParamValue('NineScore', 'InActive') == 'Active') {
  718. $scope.nineExit();
  719. }
  720. }
  721. // aes加密
  722. $scope.aesValue = function(value) {
  723. var key = CryptoJS.enc.Utf8.parse($scope.judge.des_key);
  724. var str = CryptoJS.enc.Utf8.parse(value);
  725. var base64 = CryptoJS.enc.Base64.stringify(str);
  726. var encrypted = CryptoJS.AES.encrypt(str, key, {
  727. mode : CryptoJS.mode.ECB,
  728. padding : CryptoJS.pad.Pkcs7
  729. });
  730. return encrypted.toString();
  731. }
  732. /***************************************************************************
  733. * 提交分数
  734. */
  735. $scope.submitScore = function() {
  736. // && !$("#signature")[0].contentWindow.flag
  737. if ($scope.getParamValue('ShowJudgeSign', 'InActive') == 'Active' && $("#signature")[0].contentWindow.document.getElementById('saveBtn').disabled) {
  738. alert('提交分数前,请先保存签名!');
  739. return;
  740. }
  741. if ($scope.getParamValue('ShowJudgeSign', 'InActive') == 'Active') {
  742. $("#signature")[0].contentWindow.saveSignature();
  743. }
  744. var std = undefined;
  745. $scope.commitScoreFlag = true;
  746. for (var i = 0; i < $scope.confirmStdArray.length; i++) {
  747. if ($scope.confirmStdArray[i].commit_flag != true) {
  748. std = $scope.confirmStdArray[i];
  749. break;
  750. }
  751. }
  752. if (std == undefined) {
  753. $scope.commitScoreFlag = undefined;
  754. $scope.currentSubject = undefined;
  755. $scope.currentScore = undefined;
  756. $scope.currentStd = undefined;
  757. // 已经完成评分
  758. $scope.confirmStdArray = [];
  759. $scope.currStep = 'Examing';
  760. if ($scope.StdArray.length > 0) {
  761. $scope.chooseStd($scope.StdArray[0]);
  762. }
  763. return;
  764. }
  765. debugger;
  766. if ($scope.requestingStdId == undefined) {
  767. $scope.requestingStdId = std.std_id;
  768. $scope.submitStdScore(std);
  769. }
  770. // 1秒钟等待
  771. $timeout($scope.submitScore, 1000);
  772. }
  773. /***************************************************************************
  774. * 提交分数,单个考生
  775. */
  776. $scope.submitStdScore = function(std) {
  777. debugger;
  778. angular.forEach(std.SubjectArray, function(sb) {
  779. sb.room_id = $scope.room.ly_room_id;
  780. sb.agent_id = $scope.judge.agent_id;
  781. sb.judge_id = $scope.judge.judge_id;
  782. sb.judge_seq = $scope.judge.judge_seq;
  783. sb.real_exam_seq = std.real_exam_seq;
  784. if (sb.judge_avoid == 'Active')
  785. std.judge_avoid = 'Active';
  786. });
  787. var data = angular.extend({}, $scope.judge, {
  788. score_json : $scope.aesValue(angular.toJson(std.SubjectArray)),
  789. std_id : std.std_id,
  790. real_exam_seq : std.real_exam_seq,
  791. judge_avoid : std.judge_avoid,
  792. remark : std.remark,
  793. discipline_id: std.discipline_id
  794. });
  795. $rootScope.ajaxRequest({
  796. url : '../exam/judge/grade/std/score.htm',
  797. data : data,
  798. error : function() {
  799. // $scope.submitStdScore(std);
  800. // 出现评分分差,跳转到打分界面
  801. $scope.confirmStdArray = [];
  802. $scope.requestingStdId = undefined;
  803. }
  804. }, function(response) {
  805. std.commit_flag = true;
  806. $scope.scoreStdTotal = $scope.scoreStdTotal - 1;
  807. // 移除队列
  808. for (var i = 0; i < $scope.StdArray.length; i++) {
  809. if ($scope.StdArray[i].std_id == std.std_id) {
  810. $scope.StdArray.splice(i, 1);
  811. break;
  812. }
  813. }
  814. $scope.requestingStdId = undefined;
  815. })
  816. }
  817. $scope.cancelConfirm = function() {
  818. $scope.currStep = 'Examing';
  819. //是否开启视频评分
  820. if($scope.getParamValue('JudgeVideoScore', 'InActive') == 'Active' && $scope.currentStd.separate_score == 'Active') {
  821. setTimeout(function() {
  822. var v = document.getElementById('video-player');
  823. if (v) {
  824. let skips = parseInt($scope.currentStd.ExVideoList[0]["skip_prepare_secs"]);
  825. $scope.showVideo($scope.currentStd.ExVideoList[0].video_file, skips);
  826. $scope.first_load = false;
  827. }
  828. }, 1000);
  829. }
  830. }
  831. $scope.showJudge = function() {
  832. $scope.modifyJudge = angular.extend({}, $scope.judge, {});
  833. // 显示评分版
  834. $('#judgeModal').modal('show')
  835. }
  836. $scope.changeJudge = function() {
  837. $rootScope.ajaxRequest({
  838. url : '../exam/judge/grade/judge/modify.htm',
  839. data : $scope.modifyJudge
  840. }, function(response) {
  841. $scope.judge = response.entity;
  842. // todo 更优雅的提醒方式
  843. alert('评委信息已修改!');
  844. $('#judgeModal').modal('hide')
  845. })
  846. }
  847. $scope.exitJudge = function() {
  848. $scope.judge = undefined;
  849. $scope.currentSubject = undefined;
  850. $scope.currentScore = undefined;
  851. $scope.currentStd = undefined;
  852. $scope.scoreStdTotal = 0;
  853. $scope.StdArray = [];
  854. $scope.confirmStdArray = undefined;
  855. $scope.requestingStdId == undefined;
  856. if ($scope.groupArray != undefined) {
  857. $scope.chooseRoom($scope.room);
  858. } else {
  859. $scope.currStep = 'LoginName';
  860. }
  861. }
  862. $scope.getBatchName = function(tracks) {
  863. var current_batch = 1;
  864. angular.forEach($scope.currentStd.tracksArray, function(t) {
  865. if (t.tracks_batch > current_batch)
  866. current_batch = t.tracks_batch;
  867. });
  868. if (tracks.tracks_batch == 1) {
  869. return '';
  870. }
  871. if (tracks.tracks_batch == 2)
  872. return '复试:'
  873. return '三试:'
  874. }
  875. $scope.getTracksClass = function(tracks) {
  876. var current_batch = 1;
  877. angular.forEach($scope.currentStd.tracksArray, function(t) {
  878. if (t.tracks_batch > current_batch)
  879. current_batch = t.tracks_batch;
  880. });
  881. if (current_batch == tracks.tracks_batch) {
  882. return 'text-success';
  883. }
  884. return '';
  885. }
  886. $scope.login = function() {
  887. var login_name = document.getElementById('login_name').value;
  888. if (!login_name) {
  889. alert('请输入评委登录账号!');
  890. return;
  891. }
  892. $scope.queryJudge($.trim(login_name));
  893. //$scope.launchFullscreen();
  894. }
  895. $rootScope.ajaxRequest({
  896. url : '../exam/judge/grade/param.htm'
  897. }, function(response) {
  898. var map = {};
  899. for (var i = 0; i < response.array.length; i++) {
  900. map[response.array[i].param_name] = response.array[i];
  901. }
  902. $scope.ParamMap = map;
  903. if ($scope.getParamValue('JudgeLoginType', 'LoginName') == 'ChooseGroup') {
  904. $scope.showGroup();
  905. }
  906. //是否开启生成Pad随机码
  907. if($scope.getParamValue('PadRandomCode', 'Active') == 'Active') {
  908. $scope.generateRandom();
  909. }
  910. });
  911. /***************************************************************************
  912. * 获取客户端的MAC地址
  913. */
  914. $rootScope.ajaxRequest({
  915. url : '../exam/judge/grade/judge/getMac.htm'
  916. }, function(response) {
  917. if (response) {
  918. $scope.clientMac = response.entity;
  919. }
  920. });
  921. /***************************************************************************
  922. * 获取提交考生的起止序号
  923. */
  924. $scope.setStdNumber = function(array) {
  925. $scope.numberBetween = "";
  926. if(array.length >= 1) {
  927. $scope.numberBetween += array[0].real_exam_echo;
  928. $scope.numberBetween += "~" + array[array.length-1].real_exam_echo;
  929. }
  930. }
  931. // 清除签名
  932. $scope.clearCanvas = function() {
  933. $("#signature")[0].contentWindow.clearCanvas();
  934. }
  935. // 保存签名
  936. $scope.saveSignature = function() {
  937. if ($("#signature")[0].contentWindow.document.getElementById('saveBtn').disabled) {
  938. alert('保存签名前,请先签名!');
  939. return;
  940. }
  941. $("#signature")[0].contentWindow.saveSignature();
  942. }
  943. //标记违纪
  944. $scope.stdDiscipline = function(sb) {
  945. if($scope.currentSubject.disciplineFlag == 'Active'){
  946. $scope.currentSubject.disciplineFlag = 'InActive';
  947. //$scope.currentSubject.discipline_id = ''
  948. }else{
  949. $scope.currentSubject.disciplineFlag = 'Active';
  950. }
  951. }
  952. $timeout(function() {
  953. $('#login_name').focus();
  954. // $scope.launchFullscreen();
  955. }, 100);
  956. //***九宫格输分***************************************************************
  957. //保存录入分数
  958. $scope.saveJudgeScore = function() {
  959. var score = $('#score_cur').val();
  960. //录入前判断
  961. if(score == '00' || score == '000') {
  962. score = '0';
  963. }
  964. if(score.length == 2 && score.substring(0,1) == '0') {
  965. score = score.substring(1,2);
  966. }
  967. if(score.length == 3 && score.substring(0,1) == '0') {
  968. score = score.substring(1,3);
  969. }
  970. $scope.gradeScore(score);
  971. }
  972. //返回到科目选择界面
  973. $scope.backPanel = function() {
  974. $scope.scoreStep = 'subjectPanel';
  975. $scope.nineExit();
  976. }
  977. //九宫格控制
  978. $scope.nineExit = function() {
  979. if($(".auth_keybord")) {
  980. $(".auth_keybord").css({
  981. "display" : "none"
  982. });
  983. }
  984. }
  985. //***九宫格输分***************************************************************
  986. /**********************************
  987. * 生成32随机码
  988. */
  989. $scope.randomString = function(len) {
  990. len = len || 32;
  991. var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
  992. var maxPos = $chars.length;
  993. var str = '';
  994. for (i = 0; i < len; i++) {
  995. str += $chars.charAt(Math.floor(Math.random() * maxPos));
  996. }
  997. return str;
  998. }
  999. /**********************************
  1000. * 本地存储随机码
  1001. */
  1002. $scope.generateRandom = function() {
  1003. if(!window.localStorage){
  1004. alert("浏览器不支持localstorage");
  1005. return false;
  1006. }else{
  1007. if(!localStorage.getItem('padMac')) {
  1008. localStorage.setItem('padMac', $scope.randomString());
  1009. }
  1010. }
  1011. }
  1012. /**********************************
  1013. * 查看考题
  1014. */
  1015. $scope.lookTopic = function() {
  1016. $rootScope.ajaxRequest({
  1017. url : '../std/video/topic.htm',
  1018. data: {
  1019. std_id : $scope.currentStd.std_id,
  1020. ly_group_id : $scope.currentSubject.ly_group_id
  1021. }
  1022. }, function(response) {
  1023. $scope.topic = response.array;
  1024. $('#topicModal').modal('show');
  1025. });
  1026. }
  1027. $scope.showPhoto = function() {
  1028. // 显示评分版
  1029. $('#judgeModal2').modal('show');
  1030. }
  1031. } ]);