_operate.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <script>
  2. $(function(){
  3. //初始化
  4. var superUser='<?php if( isset(Yii::app()->session['testFlag'])&&(Yii::app()->session['testFlag']==1)){echo 1;}else{echo 0;}?>';
  5. var allowChangeAnswer=false;
  6. // $('.topic-list').eq(0).removeClass('hide').addClass('show');
  7. $('.topic-send-point').click(function(){
  8. $('.send-control').toggle();
  9. $('.topic-edit-cancel').click();
  10. if($('.topic-edit').attr('disabled')==undefined){
  11. $('.topic-edit').attr('disabled',true);
  12. }else{
  13. $('.topic-edit').attr('disabled',false);
  14. }
  15. });
  16. //点击答案
  17. $('.answer-list').click(function(){
  18. if(!allowChangeAnswer) return false;
  19. issend= $(this).closest('tr').find('.topic-score').attr('issend');
  20. if(issend==1){
  21. layer.msg('已经设置送分/0分,不能修改答案');
  22. return false;
  23. }
  24. if(!$(this).hasClass('answer-active')){
  25. if(!$(this).hasClass('answer-multi')){
  26. $(this).closest('tr').find('.answer-list').removeClass('answer-active');
  27. $(this).closest('tr').find('.new-answer').val($(this).html());
  28. }
  29. $(this).addClass('answer-active');
  30. }else{
  31. if($(this).closest('tr').find('.answer-active').length==1){
  32. layer.msg('至少选择一项答案');
  33. }else{
  34. $(this).removeClass('answer-active');
  35. }
  36. }
  37. var answer='';
  38. if($(this).hasClass('answer-multi')){
  39. $(this).closest('tr').find('.answer-active').each(function(i,v){
  40. if(answer==''){
  41. answer=$(v).html();
  42. }else{
  43. answer=answer+','+$(v).html();
  44. }
  45. })
  46. console.log(answer);
  47. $(this).closest('tr').find('.new-answer').val(answer);
  48. }
  49. });
  50. //点击规则
  51. $('.rule-list').click(function(){
  52. if(!allowChangeAnswer) return false;
  53. if(!$(this).hasClass('rule-active')){
  54. $(this).closest('tr').find('.rule-list').removeClass('rule-active');
  55. $(this).addClass('rule-active');
  56. }
  57. });
  58. $('.topic-edit').click(function(){
  59. topic_type=$('input[name=select-tab]').val();
  60. obj=$(this);
  61. if(topic_type==5 || topic_type==7){
  62. msg='1、线上阅卷:<br>' +
  63. '(1)未开始阅卷可修改分值。<br>' +
  64. '(2)已开始阅卷,已阅学生成绩不会自动更新。若将分值改大,需重新按更新后分值再次批改,否则会导致修改分值后批阅的学生分值比修改前已阅学生分值大;若将分值改小,需老师对已阅学生重新打分,否则会导致无法完成阅卷。\n' +
  65. '<br>' +
  66. '2、线下阅卷:\n' +
  67. '<br>' +
  68. '(1)答题卡未保存可修改分值。\n' +
  69. '<br>' +
  70. '(2)答题卡已保存,修改分值对学生打分不生效。';
  71. indexmsg=layer.confirm(msg, {
  72. title:"*修改需知!!!",
  73. btn: ['我已知晓', '取消'] //按钮
  74. }, function () {
  75. layer.close(indexmsg)
  76. $('.topic-edit-cancel').show();
  77. $('.topic-edit-save').show();
  78. obj.hide();
  79. $('.list-type-'+topic_type).find('.topic-score').each(function(i,v){
  80. if($(v).attr('issend')==0 || $(v).attr('issend')==undefined){
  81. $(v).attr('disabled',false);
  82. }
  83. });
  84. allowChangeAnswer=true;
  85. },function(){
  86. layer.close(indexmsg)
  87. return false;
  88. })
  89. }else{
  90. $('.topic-edit-cancel').show();
  91. $('.topic-edit-save').show();
  92. $(this).hide();
  93. $('.list-type-'+topic_type).find('.topic-score').each(function(i,v){
  94. if($(v).attr('issend')==0 || $(v).attr('issend')==undefined){
  95. $(v).attr('disabled',false);
  96. }
  97. });
  98. allowChangeAnswer=true;
  99. }
  100. });
  101. $('.topic-edit-cancel').click(function(){
  102. $(this).hide();
  103. $('.topic-edit-save').hide();
  104. $('.topic-edit').show();
  105. topic_type=$('input[name=select-tab]').val();
  106. $('.list-type-'+topic_type).find('.topic-score').attr('disabled',true);
  107. allowChangeAnswer=false;
  108. });
  109. $(".topic-score").keyup(function(){
  110. topic_type=$('input[name=select-tab]').val();
  111. console.log(topic_type);
  112. $(this).val($(this).val().replace(/[^0-9|\.]/g,""));
  113. if(topic_type==17){
  114. $('.list-type-17').find('.topic-score').val($(this).val());
  115. }
  116. });
  117. $('.topic-menu').click(function(){
  118. $('.topic-menu').removeClass('menu-active');
  119. topic_type=$(this).attr('id');
  120. $('.topic-list').removeClass('show').addClass('hide');
  121. $('.list-type-'+topic_type).removeClass('hide').addClass('show');
  122. $(this).addClass('menu-active');
  123. $('input[name=select-tab]').val(topic_type);
  124. $('.topic-edit-cancel').click();
  125. console.log(topic_type)
  126. if(topic_type==1){
  127. $('.topic-send-point').show();
  128. }else{
  129. $('.topic-send-point').hide();
  130. }
  131. });
  132. $('.topic-menu').eq(0).click();
  133. //保存
  134. $('.topic-edit-save').click(function(){
  135. topic_type=$('input[name=select-tab]').val();
  136. obj= $('.list-type-'+topic_type).find('.operate-tr');
  137. saveBtn= $(this);
  138. var data=[];
  139. var topicScore={};
  140. var topicRule=[];
  141. var multipleScore={};
  142. var error=false;
  143. obj.each(function(i,v){
  144. if(topic_type==1 || topic_type==3){
  145. topicid=$(v).find('.topic-id').val();
  146. answer=$(v).find('.new-answer').val();
  147. score=$(v).find('.topic-score').val();
  148. oldAnswer=$(v).find('input[name=old-answer]').val();
  149. oldScore=$(v).find('.topic-score').attr('old-score');
  150. temp={
  151. answer:'',
  152. score:'',
  153. topic_id:topicid
  154. };
  155. if(score==''){
  156. layer.msg('请填写题目分数!');
  157. error=true;
  158. }
  159. if(score==0){
  160. layer.msg('分值不能为0!');
  161. error=true;
  162. }
  163. isChange=false;
  164. if(answer!='' && oldAnswer!=answer){
  165. temp.answer=answer
  166. isChange=true;
  167. }
  168. if(oldScore!=score){
  169. temp.score=score
  170. isChange=true;
  171. }
  172. if(parseFloat(score)>49){
  173. layer.msg('选择题分数上限为49分!');
  174. error=true;
  175. }
  176. if(isChange){
  177. if(checkFloat(score)==false){
  178. layer.msg('分数设置不正确!');
  179. error=true;
  180. }
  181. data.push(temp)
  182. }
  183. }else if(topic_type==5 || topic_type==7 || topic_type==17){
  184. topicid=$(v).find('.topic-id').val();
  185. score=$(v).find('.topic-score').val();
  186. oldScore=$(v).find('.topic-score').attr('old-score');
  187. if(score==''){
  188. layer.msg('请填写题目分数!');
  189. error=true;
  190. }
  191. if(score==0){
  192. layer.msg('分值不能为0!');
  193. error=true;
  194. }
  195. if(parseFloat(score)>60){
  196. layer.msg('主观题分数上限为60分!');
  197. error=true;
  198. }
  199. //是否多空题
  200. // if($(v).find('.multiple')!=undefined){
  201. //
  202. // multiTemp=[];
  203. // multiObj=$(v).find('multiple');
  204. // console.log(multiObj.length);
  205. // multiObj.each(function(ii,vv){
  206. // multiTemp.push($(vv).val())
  207. // })
  208. // multipleScore.topicid=multiTemp;
  209. // }
  210. //console.log(multipleScore);
  211. var order=$(v).find('.topic-score').attr('order');
  212. if(oldScore!=score){
  213. if(checkFloat(score)==false){
  214. layer.msg('分数设置不正确!');
  215. error=true;
  216. }
  217. if($(v).find('.multiple').length>0 && multipleScore[topicid]==undefined){
  218. multiTemp=[];
  219. scoreSum=0;
  220. multiObj=$('.multiple-'+topicid);
  221. multiObj.each(function(ii,vv){
  222. multiTemp.push($(vv).val())
  223. scoreSum+=parseFloat($(vv).val());
  224. })
  225. multipleScore[topicid]=multiTemp;
  226. score=scoreSum
  227. }
  228. if(topicScore[order]==undefined){
  229. topicScore[order]=score;
  230. }
  231. }
  232. }else if(topic_type==2){
  233. //多选
  234. topicid=$(v).find('.topic-id').val();
  235. //新值
  236. score=$(v).find('input[name=topic-score]').val();
  237. halfscore=$(v).find('input[name=topic-half-score]').val();
  238. answer=$(v).find('.new-answer').val();
  239. rule=$(v).find('.rule-active').attr('rule');
  240. //原值
  241. oldScore=$(v).find('.topic-score').attr('old-score');
  242. oldAnswer=$(v).find('.old-answer').val();
  243. oldhalfScore=$(v).find('.topic-half-score').attr('old-score');
  244. oldRule=$(v).find('.old-rule').val();
  245. temp={
  246. topic_id:topicid,
  247. score:score,
  248. half_score:halfscore,
  249. rule:rule,
  250. answer:answer
  251. };
  252. if(score==''){
  253. layer.msg('请填写题目分数!');
  254. error=true;
  255. }
  256. if(score==0){
  257. layer.msg('分值不能为0!');
  258. error=true;
  259. }
  260. if( halfscore==''){
  261. layer.msg('请填写题目半对分!');
  262. error=true;
  263. }
  264. // if(halfscore==0 ){
  265. // layer.msg('半对分不能为0!');
  266. // error=true;
  267. // }
  268. if(parseFloat(score)>49){
  269. layer.msg('客观题分数上限为49分!');
  270. error=true;
  271. }
  272. isChange=false;
  273. if(score!=oldScore || rule!=oldRule || halfscore!=oldhalfScore || answer!=oldAnswer){
  274. isChange=true;
  275. }
  276. if(isChange){
  277. if(checkFloat(score)==false){
  278. layer.msg('分数设置不正确!');
  279. error=true;
  280. }
  281. if(checkFloat(halfscore)==false){
  282. layer.msg('半对分数设置不正确!');
  283. error=true;
  284. }
  285. topicRule.push(temp);
  286. }
  287. }
  288. })
  289. if(error){
  290. return false;
  291. }
  292. saveBtn.attr('disabled',true);
  293. if(topic_type==1 || topic_type==3){
  294. if(data.length==0 ){
  295. layer.msg('数据没有变化 ');
  296. return false;
  297. }
  298. layer.msg('正在更新,请稍候......',{time:0});
  299. $.ajax({
  300. url:'<?php echo $this->createUrl('allSubject/updateScoreAnswerBatch')?>',
  301. type:'POST',
  302. dataType:'json',
  303. data:{change_data:data,paper_id:$("input[name=paper_id]").val()},
  304. success:function(res){
  305. saveBtn.attr('disabled',false);
  306. layer.closeAll();
  307. if(res.status==1){
  308. layer.msg('修改成功',{icon:1,time:2000},function () {
  309. window.location.reload();
  310. });
  311. }else{
  312. if(res.msg!=undefined){
  313. layer.msg(res.msg)
  314. obj.attr('disabled',false);
  315. }else{
  316. layer.msg('修改失败',{icon:1,time:2000},function () {
  317. window.location.reload();
  318. });
  319. }
  320. }
  321. }
  322. });
  323. }else if(topic_type==5 || topic_type==7){
  324. if($.isEmptyObject(topicScore)==true){
  325. layer.msg('数据没有变化 ');
  326. return false;
  327. }
  328. layer.msg('正在更新,请稍候......',{time:0});
  329. $.ajax({
  330. url:'<?php echo $this->createUrl('allSubject/updateScoreBatch')?>',
  331. type:'POST',
  332. dataType:'json',
  333. data:{scores:topicScore,paper_id:$("input[name=paper_id]").val(),multiple_score:multipleScore},
  334. success:function(res){
  335. saveBtn.attr('disabled',false);
  336. layer.closeAll();
  337. if(res.status==1){
  338. layer.msg('修改成功',{icon:1,time:2000},function () {
  339. window.location.reload();
  340. });
  341. }else{
  342. if(res.msg!=undefined){
  343. layer.msg(res.msg)
  344. obj.attr('disabled',false);
  345. }else{
  346. layer.msg('修改失败',{icon:1,time:2000},function () {
  347. window.location.reload();
  348. });
  349. }
  350. }
  351. }
  352. });
  353. }else if(topic_type==2){
  354. layer.msg('正在更新,请稍候......',{time:0});
  355. exam_id=$('input[name=exam_id]').val();
  356. $.ajax({
  357. url:'<?php echo $this->createUrl('allSubject/changeMultiRuleBatchNew')?>',
  358. data:{exam_id:exam_id,topic_data:topicRule},
  359. dataType:'json',
  360. type:'POST',
  361. success:function(res){
  362. layer.closeAll();
  363. saveBtn.attr('disabled',false);
  364. if(res.status==1){
  365. layer.msg('更新成功');
  366. location.reload();
  367. }else{
  368. layer.msg(res.msg);
  369. }
  370. }
  371. });
  372. }else if(topic_type==17){
  373. if($.isEmptyObject(topicScore)==true){
  374. layer.msg('数据没有变化 ');
  375. return false;
  376. }
  377. layer.msg('正在更新,请稍候......',{time:0});
  378. $.ajax({
  379. url:'<?php echo $this->createUrl('allSubject/UpdateScoreXuan')?>',
  380. type:'POST',
  381. dataType:'json',
  382. data:{scores:topicScore,paper_id:$("input[name=paper_id]").val()},
  383. success:function(res){
  384. saveBtn.attr('disabled',false);
  385. layer.closeAll();
  386. if(res.status==1){
  387. layer.msg('修改成功',{icon:1,time:2000},function () {
  388. window.location.reload();
  389. });
  390. }else{
  391. if(res.msg!=undefined){
  392. layer.msg(res.msg)
  393. obj.attr('disabled',false);
  394. }else{
  395. layer.msg('修改失败',{icon:1,time:2000},function () {
  396. window.location.reload();
  397. });
  398. }
  399. }
  400. }
  401. });
  402. }
  403. });
  404. $('.sendPoints').click(function(){
  405. let topicId=$(this).attr('topic_id');
  406. let paperId=$(this).attr('paper_id');
  407. let actionType=$(this).attr('action_type');
  408. let optionCount=$(this).attr('option_count');
  409. msg='';
  410. if(actionType==1){
  411. $('input[name=paperId]').val(paperId);
  412. $('input[name=topicId]').val(topicId);
  413. html='<tr>';
  414. letterArr=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
  415. for(i=0;i<optionCount;i++){
  416. html+='<td class="answer_3">'+letterArr[i]+'</td>';
  417. }
  418. html+='</tr>';
  419. $('#sendPointAnswer').html(html);
  420. $('#sendScore').show();
  421. }else{
  422. if($(this).attr('disabled')=='disabled'){
  423. return false;
  424. }
  425. msg='0分题每题只可设置一次,且不可撤销,请谨慎操作';
  426. indexmsg=layer.confirm(msg, {
  427. btn: ['确定', '取消'] //按钮
  428. }, function () {
  429. $('.sendPoints').attr('disabled',true);
  430. layer.close(indexmsg);
  431. layer.msg('更新中请稍候。。。。。。',{time:0});
  432. $.ajax({
  433. url:"<?php echo $this->createUrl('paper/sendPoints')?>",
  434. data:{actype:actionType,paper_id:paperId,topic_id:topicId},
  435. dataType:'json',
  436. type:'POST',
  437. success:function(res){
  438. if(res.status==1){
  439. layer.msg('更新成功');
  440. location.reload();
  441. }else{
  442. if(res.msg!=undefined){
  443. layer.msg(res.msg);
  444. }else{
  445. layer.msg('更新失败');
  446. }
  447. }
  448. }
  449. });
  450. })
  451. }
  452. });
  453. $(".answerShow")
  454. .on('click','.answer_3',function(){
  455. showLogObj=$(this).closest('table').closest('tr');
  456. if(!$(this).hasClass('active')){
  457. $(this).addClass('active');
  458. }else{
  459. if(showLogObj.find('.active').length<=1){
  460. layer.msg('送分题答案不能少于一个');
  461. return false;
  462. }
  463. $(this).removeClass('active');
  464. }
  465. var nowAnswer=[];
  466. $.each(showLogObj.find('.answer_3'),function(i,v){
  467. if($(v).hasClass('active')){
  468. nowAnswer.push($(v).html())
  469. }
  470. })
  471. $('input[name=sendScoreAnswer]').val(nowAnswer.join(','));
  472. })
  473. $('.saveSendScoreBtn').click(function(){
  474. answer=$('input[name=sendScoreAnswer]').val();
  475. if(answer==''){
  476. layer.msg('请选择送分答案');
  477. }
  478. let topicId=$('input[name=topicId]').val();
  479. let paperId=$('input[name=paperId]').val();
  480. if($(this).attr('disabled')=='disabled'){
  481. return false;
  482. }
  483. msg='送分题每题只可设置一次,且不可撤销,请谨慎操作';
  484. indexmsg=layer.confirm(msg, {
  485. btn: ['确定', '取消'] //按钮
  486. }, function () {
  487. $('.saveSendScoreBtn').attr('disabled',true);
  488. layer.close(indexmsg);
  489. layer.msg('更新中请稍候。。。。。。',{time:0});
  490. $.ajax({
  491. url:"<?php echo $this->createUrl('paper/sendScore')?>",
  492. data:{answer:answer,paper_id:paperId,topic_id:topicId},
  493. dataType:'json',
  494. type:'POST',
  495. success:function(res){
  496. if(res.status==1){
  497. layer.msg('更新成功');
  498. location.reload();
  499. }else{
  500. if(res.msg!=undefined){
  501. layer.msg(res.msg);
  502. }else{
  503. layer.msg('更新失败');
  504. }
  505. }
  506. }
  507. });
  508. })
  509. });
  510. $('.icon-close').click(function(){
  511. $('#sendScore').hide();
  512. });
  513. function checkFloat(num){
  514. num=String(num);
  515. arr=num.split(".");
  516. //console.log(arr[1]);
  517. if(arr[1]==undefined){
  518. return true;
  519. }else if(arr[1]==5 || arr[1]==0){
  520. return true;
  521. }
  522. return false;
  523. }
  524. });
  525. </script>