angular.login.js 25 KB

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