_popup.php 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  1. <style>
  2. .answerList td{text-align: center;padding:3px 0;border-bottom: 1px dotted #ccc;}
  3. .answerShow{border-collapse:separate;background: #666;width:190px;}
  4. .answerShow td{text-align: center;background:#fff;cursor: pointer}
  5. .answerShow td.active{background:#2977ff;color:#fff}
  6. .new_half_score{width:50px;}
  7. </style>
  8. <!-- 修改分数弹窗 -->
  9. <div class="modal">
  10. <div class="modal-shadow"></div>
  11. <div class="modal-content">
  12. <div class="modal-title clearfix">
  13. <span id="topic_order"></span><em class="fr close">×</em>
  14. </div>
  15. <span class="red-tig">&nbsp;&nbsp;&nbsp;&nbsp;提示:只修改试题分值,已批阅的学生得分不做修改!</span>
  16. <div class="model-score">
  17. 分数:<input type="text" name="score">分<br>
  18. <div class="question_scores">
  19. </div>
  20. <input type="hidden" name="paper_id" value="<?php echo $paper_id?>">
  21. <input type="hidden" name="topic_id" value="">
  22. <input type="hidden" name="type" value="">
  23. </div>
  24. <div class="modal-btn">
  25. <a href="javascript:;" class="sumbit">确定</a>
  26. <a href="javascript:;" class="close">取消</a>
  27. </div>
  28. </div>
  29. </div>
  30. <!-- 修改分数弹窗 -->
  31. <div class="modal1">
  32. <div class="modal-shadow"></div>
  33. <div class="modal-content">
  34. <div class="modal-title clearfix">
  35. 更改试题答案(<span id="topic_order1"></span>)<em class="fr close1">×</em>
  36. </div>
  37. <div class="model-score1">
  38. 正确答案:<input type="text" name="answer">
  39. <input type="hidden" name="paper_id" value="<?php echo $paper_id?>">
  40. <input type="hidden" name="topic_id" value="">
  41. <input type="hidden" name="type" value="">
  42. <span style="float: left;margin-left: 70px;font-size: 10px;padding-top: 5px;">正确答案 英文半角大写 A.B.C.D</span>
  43. </div>
  44. <div class="modal-btn">
  45. <a href="javascript:;" class="sumbit1">确定</a>
  46. <a href="javascript:;" class="close1">取消</a>
  47. </div>
  48. </div>
  49. </div>
  50. <!-- 修改多选题分数弹窗 -->
  51. <div class="modal1_multi">
  52. <div class="modal-shadow"></div>
  53. <div class="modal-content">
  54. <div class="modal-title clearfix">
  55. <span class="title-txt">更改试题答案</span><span id="update_msg"></span><em class="fr close3">×</em>
  56. </div>
  57. <div class="model-rule">
  58. 评分规则:
  59. <label><input type="radio" name="rule" value="1" >规则A
  60. <br>全选对为全对;错选漏选为0分。
  61. </label>
  62. <label><input type="radio" name="rule" value="2" checked >规则B
  63. <br>全选对为全对;错选为0分;没有全部选对且没有错选为半对。
  64. </label>
  65. <label><input type="radio" name="rule" value="3">规则C
  66. <br>全选对为全对;答案数量不超过正确答案数量情况下,部分选对为半对;
  67. 答案数量超过正确答案数量或全选错为0分。
  68. </label>
  69. <?php if($subject==9): ?>
  70. <label><input type="radio" name="rule" value="4" >规则D
  71. <br>全选对为全对;答对一个1分;答对两个2分;错选0分。
  72. </label>
  73. <label><input type="radio" name="rule" value="5" >规则E
  74. <br>全选对为全对;答对一个1分;答对两个2分;错选不扣分但全选错0分;超出答案个数0分。
  75. </label>
  76. <label class="c-red">注:规则D和规则E适用于语文新题型,请谨慎使用!</label>
  77. <?php endif;?>
  78. </div>
  79. <div class="model-score-m">
  80. <label class="batch"> <span class="score_tag ">正确答案:</span><input class="score_input" type="text" name="answer_m"></label>
  81. <label class="total_score"><span class="score_tag ">满分:</span><input type="text" class="score_input" name="score_m" value="5">分</label>
  82. <label class="half_score"><span class="score_tag">半对分:</span><input type="text" class="score_input" name="score_half_m" value="3">分</label>
  83. <input type="hidden" name="exam_id_m" value="<?php echo $exam_id?>">
  84. <input type="hidden" name="topic_id_m" value="">
  85. <input type="hidden" name="answer_m" value="">
  86. <input type="hidden" name="type_m" value="">
  87. <input type="hidden" name="is_batch" value="0">
  88. <input type="hidden" name="step" value="0">
  89. <input type="hidden" name="score_half_h" value="">
  90. <span class="tig-txt" style="float: left;margin-left: 70px;font-size: 10px;padding-top: 5px;">正确答案 英文半角大写 A.B.C.D</span>
  91. </div>
  92. <div class="modal-btn">
  93. <a href="javascript:;" class="sumbit3">确定</a>
  94. <a href="javascript:;" class="close3">取消</a>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="modal2">
  99. <div class="modal-shadow"></div>
  100. <div class="modal-content">
  101. <div class="modal-title clearfix">
  102. 修改校本题库题的答案<em class="fr close2">×</em>
  103. </div>
  104. <div class="model-score2">
  105. 正确答案(<span id="topic_order2"></span>):<input type="text" name="answer1">
  106. <input type="hidden" name="paper_id" value="<?php echo $paper_id?>">
  107. <input type="hidden" name="topic_id" value="">
  108. <input type="hidden" name="type" value="">
  109. <span style="float: left;margin-left: 70px;font-size: 10px;padding-top: 5px;">正确答案 英文半角大写 A.B.C.D</span>
  110. </div>
  111. <div class="modal-btn">
  112. <a href="javascript:;" class="sumbit2">确定</a>
  113. <a href="javascript:;" class="close2">取消</a>
  114. </div>
  115. </div>
  116. </div>
  117. <div class="modal_student">
  118. <div class="modal-shadow"></div>
  119. <div class="modal-content">
  120. <div class="modal-title clearfix">
  121. 更改学生答案(<span id="topic_order_student"></span>)<em class="fr close_student">×</em>
  122. </div>
  123. <div class="model-score2">
  124. 原答案:<input type="text" name="old_answer_student">
  125. </div>
  126. <div class="model-score2">
  127. 正确答案:<input type="text" name="answer_student">
  128. <input type="hidden" name="exam_id_student" value="<?php echo $exam_id?>">
  129. <input type="hidden" name="topic_id_student" value="">
  130. <input type="hidden" name="type" value="">
  131. <input type="hidden" name="topic_answer" value="">
  132. <span style="float: left;margin-left: 70px;font-size: 10px;padding-top: 5px;">原答案不填写即更新所有记录,答案格式英文半角大写 A.B.C.D</span>
  133. </div>
  134. <div class="modal-btn">
  135. <a href="javascript:;" class="sumbit_student">确定</a>
  136. <a href="javascript:;" class="close_student">取消</a>
  137. </div>
  138. </div>
  139. </div>
  140. <div class="modal_subject">
  141. <div class="modal-shadow"></div>
  142. <div class="modal-content">
  143. <div class="modal-title clearfix">
  144. 更改试题科目<em class="fr close_subject">×</em>
  145. </div>
  146. <div class="model-score2 oldSubjectName">原科目:</div>
  147. <div class="model-score2">
  148. 正确科目(<span id="topic_order_student"></span>):
  149. <select name="subject_id" id="subject_id">
  150. <option value="0">请选择科目</option>
  151. <?php
  152. if(isset($subjects)){
  153. foreach ($subjects as $key =>$val){
  154. echo '<option value="'.$key.'">'.$val.'</option>';
  155. }
  156. }
  157. ?>
  158. </select>
  159. <input type="hidden" name="exam_id_subject" value="<?php echo $exam_id?>">
  160. <input type="hidden" name="topic_id_subject" value="">
  161. <input type="hidden" name="old_subject_id" value="">
  162. <input type="hidden" name="paper_id_subject" value="<?php echo $paper_id?>">
  163. </div>
  164. <div class="modal-btn">
  165. <a href="javascript:;" class="sumbit_subject">确定</a>
  166. <a href="javascript:;" class="close_subject">取消</a>
  167. </div>
  168. </div>
  169. </div>
  170. <!--批量修改单选题分值-->
  171. <div class="confirmbox-mask" style="display: none" id="classModal">
  172. <div class="class-modal">
  173. <i class="icon icon-close">×</i>
  174. <div class="class-modal-head">批量更改分值</div>
  175. <div class="class-modal-body">
  176. <p><span>总分:</span><input type="text" class="total_score" name="total_score" value="<?php echo $choice_question_score_sum?>" /><button class="avg">平均分配</button></p>
  177. <?php
  178. if(isset($type[1])){
  179. foreach ($type[1] as $item){
  180. $topicNo=0;
  181. if(isset($alias[$item['order']])){
  182. $topicNo =$alias[$item['order']] ;
  183. }else{
  184. $topicNo= $item['order'];
  185. }
  186. echo '<p><span>第'.$topicNo.'题:</span><input type="text" class="topic_score" name="'.$item['order'].'" value="'.$item['score'].'" />分</p>';
  187. }
  188. }
  189. ?>
  190. </div>
  191. <div class="class_btn">
  192. <div class="avg_result c-red"></div>
  193. <input type="hidden" name="topic_type_index" value="0">
  194. <button type="button" class="save_score">确定</button>
  195. </div>
  196. </div>
  197. </div>
  198. <!--批量修改多选题分值-->
  199. <div class="confirmbox-mask" style="display: none" id="classModalMulti">
  200. <div class="class-modal">
  201. <i class="icon icon-close">×</i>
  202. <div class="class-modal-head">批量更改分值</div>
  203. <div class="class-modal-body multiSelectScore">
  204. <p><span>总分:</span><input type="text" class="total_score" name="total_score" value="" /><button class="avg">平均分配</button></p>
  205. </div>
  206. <div class="class_btn">
  207. <div class="avg_multi_result c-red"></div>
  208. <input type="hidden" name="topicAnswer" value="">
  209. <input type="hidden" name="topicRule" value="">
  210. <input type="hidden" name="topic_type_index" value="0">
  211. <input type="hidden" name="topicIds" value="0">
  212. <button type="button" class="save_multi_score">确定</button>
  213. </div>
  214. </div>
  215. </div>
  216. <!--批量客观题答案-->
  217. <div class="confirmbox-mask" style="display: none" id="updateAnswerBatch">
  218. <div class="class-modal">
  219. <i class="icon icon-close">×</i>
  220. <div class="class-modal-head">批量更改答案</div>
  221. <div class="class-modal-body">
  222. <table width="100%" border="0" cellspacing="0" cellpadding="0" class="answerList">
  223. <thead>
  224. <tr>
  225. <td>题号</td>
  226. <td>答案</td>
  227. <td>更新标记</td>
  228. </tr>
  229. </thead>
  230. <tbody>
  231. </tbody>
  232. </table>
  233. </div>
  234. <div class="class_btn">
  235. <div class="avg_result c-red"></div>
  236. <input type="hidden" name="topicType" value="">
  237. <input type="hidden" name="topicHalfScore" value="">
  238. <input type="hidden" name="topicAnswerRule" value="">
  239. <button type="button" class="saveAnswerBatch">确定</button>
  240. </div>
  241. </div>
  242. </div>
  243. <!--送分题选择答案弹窗-->
  244. <div class="confirmbox-mask" style="display: none" id="sendScore">
  245. <div class="class-modal">
  246. <i class="icon icon-close">×</i>
  247. <div class="class-modal-head">设置送分题</div>
  248. <div class="class-modal-body">
  249. <table width="100%" border="0" cellspacing="0" cellpadding="0" class="answerList">
  250. <thead>
  251. <tr>
  252. <td >请选择需要送分的选项,学生选择以下任意选项均得分</td>
  253. </tr>
  254. </thead>
  255. <tbody>
  256. <tr>
  257. <td >
  258. <table width="100%" border="0" cellspacing="1" cellpadding="1" class="answerShow" id="sendPointAnswer" align="center">
  259. <tr>
  260. <td class="answer_3">A</td>
  261. <td class="answer_3">B</td>
  262. <td class="answer_3">C</td>
  263. <td class="answer_3">D</td>
  264. <td class="answer_3">E</td>
  265. <td class="answer_3">F</td>
  266. <td class="answer_3">G</td>
  267. </tr>
  268. </table>
  269. </td>
  270. </tr>
  271. <tr>
  272. <td >注意:一旦设置,不可取消,且不能再修改试题分值与答案,请谨慎操作!</td>
  273. </tr>
  274. </tbody>
  275. </table>
  276. </div>
  277. <div class="class_btn">
  278. <button type="button" class="saveSendScoreBtn">确定</button>
  279. <input type="hidden" name="sendScoreAnswer" value="">
  280. <input type="hidden" name="paperId" value="">
  281. <input type="hidden" name="topicId" value="">
  282. </div>
  283. </div>
  284. </div>
  285. <script>
  286. $('.update_answer_batch').click(function(){
  287. let type=parseInt($(this).attr('type'));
  288. html="";
  289. $('input[name=topicType]').val(type);
  290. rule_score_half=[];
  291. rule=[],topicId=[];
  292. if(type==2 || type==11){
  293. var obj=$(this).closest('.choose-topic').find('.topic');
  294. if(obj.length>0){
  295. for(var i=0;i<obj.length;i++){
  296. if(obj.eq(i).find('.rule_score_half').val()!='' && obj.eq(i).find('.rule_score_half').val()!=undefined){
  297. rule_score_half.push(obj.eq(i).find('.rule_score_half').val());
  298. }else{
  299. rule_score_half.push(obj.eq(i).find('.rule_score_half').val());
  300. }
  301. if(obj.eq(i).find('.rule_type').val()!='' && obj.eq(i).find('.rule_type').val()!=undefined){
  302. rule.push(obj.eq(i).find('.rule_type').val());
  303. }else{
  304. rule.push(1);
  305. }
  306. topicId.push(obj.eq(i).attr('id'));
  307. }
  308. }
  309. $('input[name=topicAnswerRule]').val(rule.join('///'));
  310. $('input[name=topicIds]').val(topicId.join('///'));
  311. $('input[name=topicHalfScore]').val(rule_score_half.join('///'));
  312. }
  313. if(type==1){
  314. <?php
  315. if(isset($type[1])){
  316. foreach ($type[1] as $item){
  317. $topicNo=0;
  318. $right='';
  319. if(isset($alias[$item['order']])){
  320. $topicNo =$alias[$item['order']] ;
  321. }else{
  322. $topicNo= $item['order'];
  323. }
  324. $arr = array(0=>'A',1=>'B',2=>'C',3=>'D',4=>'E',5=>'F',6=>'G',7=>'H',8=>'I',9=>'J',10=>'K',11=>'L',12=>'M');
  325. $ruleAnswer='';
  326. $optionCount=4;
  327. if (isset($topic[$item['topic_id']]) && !empty($topic[$item['topic_id']]) && isset($topic[$item['topic_id']]['items'][0]['options'])) {
  328. $optionCount=count($topic[$item['topic_id']]['items'][0]['options']);
  329. }
  330. if(isset($update_answer[$item['order']])){
  331. $ruleAnswer=$update_answer[$item['order']]['update_answer'];
  332. }
  333. if(!$ruleAnswer){
  334. if($subject==8 && isset($topic[$item['topic_id']]['answer'])){
  335. $right=$topic[$item['topic_id']]['answer'];
  336. }else {
  337. if (isset($topic[$item['topic_id']]) && !empty($topic[$item['topic_id']]) && isset($topic[$item['topic_id']]['items'][0]['options'])) {
  338. foreach ($topic[$item['topic_id']]['items'][0]['options'] as $ok => $opt) {
  339. if ($opt['option_correct'] == 1) {
  340. if (!$right) {
  341. //$right = isset($arr[$ok]) ? $arr[$ok] : '';
  342. $right=numToLetter($ok+1);
  343. } else{
  344. // $right = $right . ',' . $arr[$ok];
  345. $right=$right.','.numToLetter($ok+1);
  346. }
  347. }
  348. }
  349. }
  350. }
  351. }else{
  352. $right=$ruleAnswer;
  353. }
  354. echo "html+='<tr>';";
  355. echo "html+='<td>".$topicNo."</td>';";
  356. echo "html+='<td><table align=\"center\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" class=\"answerShow\">';";
  357. echo "html+='<tr>';";
  358. for($i=0;$i<$optionCount;$i++){
  359. if($right==numToLetter($i+1)){
  360. echo "html+='<td class=\"active answer\" >".numToLetter($i+1)."</td>';";
  361. }else{
  362. echo "html+='<td class=\"answer\">".numToLetter($i+1)."</td>';";
  363. }
  364. }
  365. echo "html+='</tr>';";
  366. echo "html+='</table>';";
  367. echo "html+='</td>';";
  368. echo "html+='<td width=\"30%\" class=\"operateLog\" right=\"{$right}\" nowAnswer=\"{$right}\" topic_id=\"{$item['topic_id']}\">无更新</td>';";
  369. echo "html+='</tr>';";
  370. }
  371. }
  372. ?>
  373. $('.answerList tbody').html(html);
  374. }else if(type==2){
  375. <?php
  376. if(isset($type[2])){
  377. foreach ($type[2] as $item){
  378. $topicNo=0;
  379. $right='';
  380. if(isset($alias[$item['order']])){
  381. $topicNo =$alias[$item['order']] ;
  382. }else{
  383. $topicNo= $item['order'];
  384. }
  385. $arr = array(0=>'A',1=>'B',2=>'C',3=>'D',4=>'E',5=>'F',6=>'G',7=>'H',8=>'I',9=>'J',10=>'K',11=>'L',12=>'M');
  386. $ruleAnswer='';
  387. $ruleType=2;
  388. $ruleScoreHalf=0;
  389. if(isset($new_rules[$item['order']])){
  390. $ruleAnswer=$new_rules[$item['order']]['rule_answer'];
  391. $ruleType=$new_rules[$item['order']]['rule_type'];
  392. $ruleScoreHalf=$new_rules[$item['order']]['rule_score_half'];
  393. }
  394. $optionCount=4;
  395. if (isset($topic[$item['topic_id']]) && !empty($topic[$item['topic_id']]) && isset($topic[$item['topic_id']]['items'][0]['options'])) {
  396. $optionCount=count($topic[$item['topic_id']]['items'][0]['options']);
  397. }
  398. if(!$ruleAnswer){
  399. if($subject==8 && isset($topic[$item['topic_id']]['answer'])){
  400. $right=$topic[$item['topic_id']]['answer'];
  401. }else {
  402. if (isset($topic[$item['topic_id']]) && !empty($topic[$item['topic_id']]) && isset($topic[$item['topic_id']]['items'][0]['options'])) {
  403. foreach ($topic[$item['topic_id']]['items'][0]['options'] as $ok => $opt) {
  404. if ($opt['option_correct'] == 1) {
  405. if (!$right) {
  406. $right = numToLetter($ok+1);
  407. } else {
  408. $right = $right . ',' . numToLetter($ok+1);
  409. }
  410. }
  411. }
  412. }
  413. }
  414. }else{
  415. $right=$ruleAnswer;
  416. }
  417. $rightArr=explode(',',$right);
  418. echo "html+='<tr>';";
  419. echo "html+='<td>".$topicNo."</td>';";
  420. echo "html+='<td><table align=\"center\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" class=\"answerShow\">';";
  421. echo "html+='<tr>';";
  422. for($i=0;$i<$optionCount;$i++){
  423. if(in_array(numToLetter($i+1),$rightArr)){
  424. echo "html+='<td class=\"active answer_2\" >".numToLetter($i+1)."</td>';";
  425. }else{
  426. echo "html+='<td class=\"answer_2\">".numToLetter($i+1)."</td>';";
  427. }
  428. }
  429. echo "html+='</tr>';";
  430. echo "html+='</table>';";
  431. echo "html+='</td>';";
  432. echo "html+='<td width=\"30%\" class=\"operateLog\" rule=\"{$ruleType}\" right=\"{$right}\" half_score=\"{$ruleScoreHalf}\" nowAnswer=\"{$right}\" topic_id=\"{$item['topic_id']}\">无更新</td>';";
  433. echo "html+='</tr>';";
  434. }
  435. }
  436. ?>
  437. $('.answerList tbody').html(html);
  438. }else if(type==11){
  439. <?php
  440. if(isset($type[11])){
  441. foreach ($type[11] as $item){
  442. $topicNo=0;
  443. $right='';
  444. if(isset($alias[$item['order']])){
  445. $topicNo =$alias[$item['order']] ;
  446. }else{
  447. $topicNo= $item['order'];
  448. }
  449. $arr = array(0=>'A',1=>'B',2=>'C',3=>'D',4=>'E',5=>'F',6=>'G',7=>'H',8=>'I',9=>'J',10=>'K',11=>'L',12=>'M');
  450. $ruleAnswer='';
  451. $ruleType=2;
  452. $ruleScoreHalf=0;
  453. if(isset($new_rules[$item['order']])){
  454. $ruleAnswer=$new_rules[$item['order']]['rule_answer'];
  455. $ruleType=$new_rules[$item['order']]['rule_type'];
  456. $ruleScoreHalf=$new_rules[$item['order']]['rule_score_half'];
  457. }
  458. $optionCount=4;
  459. if (isset($topic[$item['topic_id']]) && !empty($topic[$item['topic_id']]) && isset($topic[$item['topic_id']]['type']) && $topic[$item['topic_id']]['type']==5) {
  460. $optionCount=7;
  461. }else{
  462. if (isset($topic[$item['topic_id']]) && !empty($topic[$item['topic_id']]) && isset($topic[$item['topic_id']]['items'][0]['options'])) {
  463. $optionCount=count($topic[$item['topic_id']]['items'][0]['options']);
  464. }
  465. }
  466. if(!$ruleAnswer){
  467. if($subject==8 && isset($topic[$item['topic_id']]['answer'])){
  468. $right=$topic[$item['topic_id']]['answer'];
  469. }else {
  470. if (isset($topic[$item['topic_id']]) && !empty($topic[$item['topic_id']]) && isset($topic[$item['topic_id']]['items'][0]['options'])) {
  471. foreach ($topic[$item['topic_id']]['items'][0]['options'] as $ok => $opt) {
  472. if ($opt['option_correct'] == 1) {
  473. if (!$right) {
  474. $right = numToLetter($ok+1);
  475. } else {
  476. $right = $right . ',' . numToLetter($ok+1);
  477. }
  478. }
  479. }
  480. }
  481. }
  482. }else{
  483. $right=$ruleAnswer;
  484. }
  485. $rightArr=explode(',',$right);
  486. echo "html+='<tr>';";
  487. echo "html+='<td>".$topicNo."</td>';";
  488. echo "html+='<td><table align=\"center\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" class=\"answerShow\">';";
  489. echo "html+='<tr>';";
  490. // $optionCount=26;
  491. for($i=0;$i<$optionCount;$i++){
  492. if(in_array(numToLetter($i+1),$rightArr)){
  493. echo "html+='<td class=\"active answer_2\" >".numToLetter($i+1)."</td>';";
  494. }else{
  495. echo "html+='<td class=\"answer_2\">".numToLetter($i+1)."</td>';";
  496. }
  497. }
  498. echo "html+='</tr>';";
  499. echo "html+='</table>';";
  500. echo "html+='</td>';";
  501. echo "html+='<td width=\"30%\" class=\"operateLog\" rule=\"{$ruleType}\" right=\"{$right}\" half_score=\"{$ruleScoreHalf}\" nowAnswer=\"{$right}\" topic_id=\"{$item['topic_id']}\">无更新</td>';";
  502. echo "html+='</tr>';";
  503. }
  504. }
  505. ?>
  506. $('.answerList tbody').html(html);
  507. //读取答案
  508. var scoreHalf=[];
  509. var obj=$(this).closest('.choose-topic').find('.topic');
  510. if(obj.length>0){
  511. for(var i=0;i<obj.length;i++){
  512. if(obj.eq(i).find('.rule_score_half').val()!='' && obj.eq(i).find('.rule_score_half').val()!=undefined){
  513. scoreHalf.push(obj.eq(i).find('.rule_score_half').val());
  514. }else{
  515. scoreHalf.push(0);
  516. }
  517. }
  518. }
  519. $('input[name=topicHalfScore]').val(scoreHalf.join('///'));
  520. }
  521. $('#updateAnswerBatch').show();
  522. });
  523. $('.update_score_batch').click(function(){
  524. let type=parseInt($(this).attr('type'));
  525. let html='',titleHtml='';
  526. //读取答案
  527. var topicAnswer=[];
  528. var topicId=[];
  529. var rule=[];
  530. var obj=$(this).closest('.choose-topic').find('.topic');
  531. if(obj.length>0){
  532. for(var i=0;i<obj.length;i++){
  533. if(obj.eq(i).find('.rule_answer').val()!='' && obj.eq(i).find('.rule_answer').val()!=undefined){
  534. topicAnswer.push(obj.eq(i).find('.rule_answer').val());
  535. }else{
  536. topicAnswer.push(obj.eq(i).find('.right-answer').val());
  537. }
  538. if(obj.eq(i).find('.rule_type').val()!='' && obj.eq(i).find('.rule_type').val()!=undefined){
  539. rule.push(obj.eq(i).find('.rule_type').val());
  540. }else{
  541. rule.push(1);
  542. }
  543. topicId.push(obj.eq(i).attr('id'));
  544. }
  545. }
  546. $('input[name=topicAnswer]').val(topicAnswer.join('///'));
  547. $('input[name=topicRule]').val(rule.join('///'));
  548. $('input[name=topicIds]').val(topicId.join('///'));
  549. if(type==2){
  550. <?php
  551. if(isset($type[2])){
  552. $totalScore=0;
  553. foreach ($type[2] as $item){
  554. $topicNo=0;
  555. $right='';
  556. if(isset($alias[$item['order']])){
  557. $topicNo =$alias[$item['order']] ;
  558. }else{
  559. $topicNo= $item['order'];
  560. }
  561. $ruleAnswer='';
  562. $ruleType=0;
  563. $ruleScoreHalf=0;
  564. if(isset($new_rules[$item['order']])){
  565. $ruleScoreHalf=$new_rules[$item['order']]['rule_score_half'];
  566. if($new_rules[$item['order']]['rule_score']){
  567. $item['score']=$new_rules[$item['order']]['rule_score'];
  568. }
  569. }
  570. $totalScore+=$item['score'];
  571. echo 'html+="<p><span>第'.$topicNo.'题:</span><input type=\"text\" class=\"topic_multi_score\" name=\"topic_multi_score'.$topicNo.'\" value=\"'.intval($item['score']).'\" />分 半对<input type=\"text\" class=\"new_half_score\" name=\"half_score_'.$topicNo.'\" value=\"'.$ruleScoreHalf.'\" />分</p>";';
  572. }
  573. echo 'titleHtml+="<p><span>总分:</span><input type=\"text\" class=\"total_multi_score\" name=\"total_multi_score\" value=\"'.$totalScore.'\" /><button class=\"avg_multi\">平均分配</button></p>";';
  574. }
  575. ?>
  576. html=titleHtml+html;
  577. $('.multiSelectScore').html(html);
  578. }else if(type==11){
  579. <?php
  580. if(isset($type[11])){
  581. $totalScore=0;
  582. foreach ($type[11] as $item){
  583. $topicNo=0;
  584. $right='';
  585. if(isset($alias[$item['order']])){
  586. $topicNo =$alias[$item['order']] ;
  587. }else{
  588. $topicNo= $item['order'];
  589. }
  590. $ruleAnswer='';
  591. $ruleType=0;
  592. $ruleScoreHalf=0;
  593. if(isset($new_rules[$item['order']])){
  594. $ruleScoreHalf=$new_rules[$item['order']]['rule_score_half'];
  595. if($new_rules[$item['order']]['rule_score']){
  596. $item['score']=$new_rules[$item['order']]['rule_score'];
  597. }
  598. }
  599. $totalScore+=$item['score'];
  600. echo 'html+="<p><span>第'.$topicNo.'题:</span><input type=\"text\" class=\"topic_multi_score\" name=\"topic_multi_score'.$topicNo.'\" value=\"'.intval($item['score']).'\" />分 半对<input type=\"text\" class=\"new_half_score\" name=\"half_score_'.$topicNo.'\" value=\"'.$ruleScoreHalf.'\" />分</p>";';
  601. }
  602. echo 'titleHtml+="<p><span>总分:</span><input type=\"text\" class=\"\" name=\"total_multi_score\" value=\"'.$totalScore.'\" /><button class=\"avg_multi\">平均分配</button></p>";';
  603. }
  604. ?>
  605. html=titleHtml+html;
  606. $('.multiSelectScore').html(html);
  607. }
  608. $('#classModalMulti').show();
  609. });
  610. $('.answerList')
  611. .on('click','.answer',function(){
  612. if(!$(this).hasClass('active')){
  613. showLogObj=$(this).closest('table').closest('tr').find('.operateLog');
  614. $(this).closest('table').find('.answer').removeClass('active');
  615. $(this).addClass('active');
  616. $oldAnswer=showLogObj.attr('right');
  617. if($(this).html()==$oldAnswer){
  618. showLogObj.html("无更新");
  619. showLogObj.removeClass('red-tig');
  620. }else{
  621. showLogObj.html(showLogObj.attr('right')+"改为"+$(this).html());
  622. showLogObj.addClass('red-tig');
  623. }
  624. showLogObj.attr('nowAnswer',$(this).html());
  625. }
  626. })
  627. .on('click','.answer_2',function(){
  628. showLogObj=$(this).closest('table').closest('tr');
  629. $oldAnswer=showLogObj.find('.operateLog').attr('right');
  630. if(!$(this).hasClass('active')){
  631. $(this).addClass('active');
  632. }else{
  633. if(showLogObj.find('.active').length<=1){
  634. layer.msg('多选题答案不能少于一个');
  635. return false;
  636. }
  637. $(this).removeClass('active');
  638. }
  639. console.log(showLogObj.find('.active').length);
  640. var nowAnswer=[];
  641. $.each(showLogObj.find('.answer_2'),function(i,v){
  642. if($(v).hasClass('active')){
  643. nowAnswer.push($(v).html())
  644. }
  645. })
  646. if($oldAnswer==nowAnswer.join(',')){
  647. showLogObj.find('.operateLog').html('无更新');
  648. showLogObj.find('.operateLog').removeClass('red-tig');
  649. }else{
  650. showLogObj.find('.operateLog').html($oldAnswer+"改为"+nowAnswer.join(','));
  651. showLogObj.find('.operateLog').addClass('red-tig');
  652. }
  653. showLogObj.find('.operateLog').attr('nowAnswer',nowAnswer.join(','));
  654. })
  655. .on('click','.answer_3',function(){
  656. showLogObj=$(this).closest('table').closest('tr');
  657. $oldAnswer=showLogObj.find('.operateLog').attr('right');
  658. if(!$(this).hasClass('active')){
  659. $(this).addClass('active');
  660. }else{
  661. if(showLogObj.find('.active').length<=1){
  662. layer.msg('送分题答案不能少于一个');
  663. return false;
  664. }
  665. $(this).removeClass('active');
  666. }
  667. var nowAnswer=[];
  668. $.each(showLogObj.find('.answer_3'),function(i,v){
  669. if($(v).hasClass('active')){
  670. nowAnswer.push($(v).html())
  671. }
  672. })
  673. $('input[name=sendScoreAnswer]').val(nowAnswer.join(','));
  674. })
  675. $('.multiSelectScore')
  676. .on('click','.avg_multi',function(){
  677. var total_score=$('input[name=total_multi_score]').val();
  678. var topic_count=$('.topic_multi_score').length;
  679. if(total_score==0 || total_score==''){
  680. layer.msg('请填写题目总分!');
  681. }else{
  682. var avg_score=total_score/topic_count;
  683. if(checkFloat(avg_score)==false){
  684. $('.avg_multi_result').html('无法平均分配');
  685. $('.avg_multi_result').addClass('red');
  686. }else{
  687. $('.avg_multi_result').html('');
  688. for(var i=1;i<=topic_count;i++){
  689. $('.topic_multi_score').val(avg_score);
  690. }
  691. }
  692. }
  693. })
  694. $('.saveAnswerBatch').click(function(){
  695. if($(this).attr('disabled')=='disabled'){
  696. return false;
  697. }
  698. let updateAnswerArr=[];
  699. let topicType=$('input[name=topicType]').val();
  700. let score_half_m=$("input[name=topicHalfScore]").val();
  701. $.each($('.operateLog'),function(i,v){
  702. let oldAnswer=$(v).attr('right'),
  703. newAnswer=$(v).attr('nowAnswer'),
  704. topicRule=$(v).attr('rule'),
  705. topicHalfScore=$(v).attr('half_score'),
  706. topicId=$(v).attr('topic_id');
  707. if(newAnswer==''){
  708. layer.msg('答案不能为空');
  709. return false;
  710. }
  711. if(oldAnswer!=newAnswer){
  712. updateAnswerArr.push({topicId,newAnswer,topicRule,topicHalfScore});
  713. }
  714. })
  715. if(updateAnswerArr.length==0){
  716. layer.msg('答案无更新');
  717. return false;
  718. }
  719. var data={
  720. exam_id:$("input[name=exam_id_m]").val(),
  721. paper_id:$("input[name=paper_id]").val(),
  722. update_answers:updateAnswerArr,
  723. score_half_m:score_half_m,
  724. change_obj:'answer'
  725. };
  726. $(this).attr('disabled',true);
  727. var alertIndex=layer.msg('正在更新,请稍候。。。。。。',{time:0});
  728. if(topicType==1){
  729. postUrl="<?php echo $this->createUrl('paper/updateAnswerBatch')?>";
  730. }else{
  731. postUrl="<?php echo $this->createUrl('paper/updateMultiAnswerBatch')?>";
  732. }
  733. $.ajax({
  734. url:postUrl,
  735. data:data,
  736. dataType:'json',
  737. type:'POST',
  738. success:function(res){
  739. layer.close(alertIndex);
  740. if(res.status==1){
  741. layer.msg('更新成功');
  742. location.reload();
  743. }else{
  744. layer.msg(res.msg);
  745. }
  746. }
  747. });
  748. });
  749. $('.save_multi_score').click(function(){
  750. if($(this).attr('disabled')=='disabled'){
  751. return false;
  752. }
  753. let topicAnswer=$('input[name=topicAnswer]').val();
  754. let topicRule=$('input[name=topicRule]').val();
  755. let topicIds=$('input[name=topicIds]').val();
  756. let topicScore=[],topicHalfScore=[];
  757. for(var i=0;i<$('.topic_multi_score').length;i++){
  758. if($('.topic_multi_score').eq(i).val()==0 || $('.topic_multi_score').eq(i).val()==''){
  759. layer.msg('请填写题目分数!');
  760. return false;
  761. }
  762. if(parseInt($('.topic_multi_score').eq(i).val())>49){
  763. layer.msg('选择题分数上限为49分!');
  764. return false;
  765. }
  766. if(parseInt($('.topic_multi_score').eq(i).val())<1){
  767. layer.msg('选择题分数不能小于1分!');
  768. return false;
  769. }
  770. if( $('.new_half_score').eq(i).val()=='' || parseFloat($('.new_half_score').eq(i).val())<0 || !checkFloat1($('.new_half_score').eq(i).val()) ){
  771. layer.msg('请填写正确的题目半对分数!');
  772. return false;
  773. }
  774. if( parseFloat($('.new_half_score').eq(i).val())>parseInt($('.topic_multi_score').eq(i).val())){
  775. layer.msg('半对分不能大于满分!');
  776. return false;
  777. }
  778. topicScore.push($('.topic_multi_score').eq(i).val());
  779. topicHalfScore.push($('.new_half_score').eq(i).val());
  780. }
  781. topicAnswerArr=topicAnswer.split('///');
  782. topicRuleArr=topicRule.split('///');
  783. topicIdArr=topicIds.split('///');
  784. let update_answers=[];
  785. for(var i=0;i<topicAnswerArr.length;i++){
  786. update_answers.push({topicId:topicIdArr[i],topicAnswer:topicAnswerArr[i],topicRule:topicRuleArr[i],topicScore:topicScore[i],topicHalfScore:topicHalfScore[i]});
  787. }
  788. console.log(update_answers);
  789. data={
  790. update_answers:update_answers,
  791. exam_id:$("input[name=exam_id_m]").val(),
  792. change_obj:'score'
  793. };
  794. $(this).attr('disabled',true);
  795. var alertIndex=layer.msg('正在更新,请稍候。。。。。。',{time:0});
  796. $.ajax({
  797. url:"<?php echo $this->createUrl('paper/updateMultiAnswerBatch')?>",
  798. data:data,
  799. dataType:'json',
  800. type:'POST',
  801. success:function(res){
  802. layer.close(alertIndex);
  803. if(res.status==1){
  804. layer.msg('更新成功');
  805. location.reload();
  806. }else{
  807. layer.msg(res.msg);
  808. }
  809. }
  810. });
  811. });
  812. $('.sendPoints').click(function(){
  813. let topicId=$(this).attr('topic');
  814. let paperId=$(this).attr('paper_id');
  815. let actionType=$(this).attr('action_type');
  816. let optionCount=$(this).attr('option_count');
  817. msg='';
  818. if(actionType==1){
  819. $('input[name=paperId]').val(paperId);
  820. $('input[name=topicId]').val(topicId);
  821. html='<tr>';
  822. var letter=['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'];
  823. for(i=0;i<optionCount;i++){
  824. html+='<td class="answer_3">'+letter[i]+'</td>';
  825. }
  826. html+='</tr>';
  827. $('#sendPointAnswer').html(html);
  828. $('#sendScore').show();
  829. }else{
  830. if($(this).attr('disabled')=='disabled'){
  831. return false;
  832. }
  833. msg='0分题每题只可设置一次,且不可撤销,请谨慎操作';
  834. indexmsg=layer.confirm(msg, {
  835. btn: ['确定', '取消'] //按钮
  836. }, function () {
  837. $('.sendPoints').attr('disabled',true);
  838. layer.close(indexmsg);
  839. layer.msg('更新中请稍候。。。。。。',{time:0});
  840. $.ajax({
  841. url:"<?php echo $this->createUrl('paper/sendPoints')?>",
  842. data:{actype:actionType,paper_id:paperId,topic_id:topicId},
  843. dataType:'json',
  844. type:'POST',
  845. success:function(res){
  846. if(res.status==1){
  847. layer.msg('更新成功');
  848. location.reload();
  849. }else{
  850. if(res.msg!=undefined){
  851. layer.msg(res.msg);
  852. }else{
  853. layer.msg('更新失败');
  854. }
  855. }
  856. }
  857. });
  858. })
  859. }
  860. });
  861. $('.saveSendScoreBtn').click(function(){
  862. answer=$('input[name=sendScoreAnswer]').val();
  863. if(answer==''){
  864. layer.msg('请选择送分答案');
  865. }
  866. let topicId=$('input[name=topicId]').val();
  867. let paperId=$('input[name=paperId]').val();
  868. if($(this).attr('disabled')=='disabled'){
  869. return false;
  870. }
  871. msg='送分题每题只可设置一次,且不可撤销,请谨慎操作';
  872. indexmsg=layer.confirm(msg, {
  873. btn: ['确定', '取消'] //按钮
  874. }, function () {
  875. $('.saveSendScoreBtn').attr('disabled',true);
  876. layer.close(indexmsg);
  877. layer.msg('更新中请稍候。。。。。。',{time:0});
  878. $.ajax({
  879. url:"<?php echo $this->createUrl('paper/sendScore')?>",
  880. data:{answer:answer,paper_id:paperId,topic_id:topicId},
  881. dataType:'json',
  882. type:'POST',
  883. success:function(res){
  884. if(res.status==1){
  885. layer.msg('更新成功');
  886. location.reload();
  887. }else{
  888. if(res.msg!=undefined){
  889. layer.msg(res.msg);
  890. }else{
  891. layer.msg('更新失败');
  892. }
  893. }
  894. }
  895. });
  896. })
  897. });
  898. $(".modal")
  899. .on('keyup','.question_score',function(){
  900. $(this).val($(this).val().replace(/[^0-9|\.]/g,""));
  901. })
  902. .on("change",'.question_score',function(){
  903. var sum=0;
  904. $('.question_score').each(function(i,v){
  905. score=$(v).val();
  906. if(score=='' || score==0){
  907. score=1;
  908. layer.msg('分数不能为空');
  909. $(v).val(1);
  910. }
  911. sum+=parseFloat(score);
  912. })
  913. $('input[name=score]').val(sum);
  914. })
  915. </script>