thirdview1.php 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024
  1. <script src="/js/jquery.datetimepicker.js"></script>
  2. <link rel="stylesheet" href="/fonts/fpdf/iconfont.css" />
  3. <link rel="stylesheet" href="/css/modelCreatePaper.css" />
  4. <link rel="stylesheet" href="/css/jquery.datetimepicker.css" />
  5. <link rel="stylesheet" href="/css/third/paperCard.css" />
  6. <link type="text/css" rel="stylesheet" href="/js/select/select2.min.css" />
  7. <link rel="stylesheet" href="/css/alert.css"/>
  8. <script src="/js/select/select2.min.js"></script>
  9. <style>
  10. .class-box{
  11. width: 500px;
  12. }
  13. .class-box>p{
  14. margin-bottom: 10px;
  15. }
  16. .class-box>ul{
  17. width: 500px;
  18. height: 200px;
  19. padding: 10px 20px;
  20. background-color: #FAFAFA;
  21. box-sizing: border-box;
  22. border:1px solid #ddd;
  23. }
  24. .class-box>ul>li{
  25. float: left;
  26. margin-right: 15px;
  27. margin-bottom: 10px;
  28. cursor: pointer;
  29. }
  30. .class-box>ul>li>img{
  31. vertical-align: middle;
  32. margin-left: 3px;
  33. }
  34. .class-modal-body{margin-bottom:15px;}
  35. #gradeTxt{display:inline-block;border-left:2px solid #2977ff;padding-left:10px;}
  36. .class_right{
  37. width:650px;
  38. }
  39. .class_area li{
  40. width:185px;
  41. height:30px;
  42. line-height: 30px;
  43. text-align: center;
  44. border:1px solid #ccc;
  45. margin:5px;
  46. border-radius: 3px;
  47. cursor:pointer
  48. }
  49. .class_area li.active{
  50. color:#fff;
  51. background: #2977ff;
  52. cursor:pointer
  53. }
  54. .selected-box{overflow:auto}
  55. </style>
  56. <div class="main-content-inner">
  57. <!-- 导航栏开始-->
  58. <?php include(Yii::app()->basePath.'/views/layouts/view_navigation.php');?>
  59. <!-- 导航栏结束-->
  60. <div class="test-data">
  61. <div class="page-content">
  62. <div class="mcp-title">
  63. <span class="active">第1步、考试基本信息</span>
  64. <span><i class="horizontal-line"></i></span>
  65. <span>第2步、关联在线答题卡</span>
  66. </div>
  67. <div class="">
  68. <div class="mcp-main-con">
  69. <div class="mcp-form-list clearfix">
  70. <div class="mcp-form-menu fl">试卷名称</div>
  71. <div class="mcp-form-detail fl">
  72. <input type="text" placeholder="必填" class="test-paper-name" name="examName">
  73. </div>
  74. <div id="examName-error"></div>
  75. </div>
  76. <div class="mcp-form-list clearfix">
  77. <div class="mcp-form-menu fl">试卷类型</div>
  78. <div class="mcp-form-detail fl">
  79. <div class="inp-text pointer">选择试卷类型</div>
  80. <ul class="select-con tac">
  81. <?php
  82. if(!in_array(Yii::app()->session['session_duoxueke_subject_id'],array(18,19)) && Yii::app()->params['section']!=3){
  83. $paperType = array('1050'=> '其他','0'=> '全国','1'=> '江苏','2'=> '浙江');
  84. }elseif(Yii::app()->params['section']==3){
  85. $paperType = array('1050'=> '其他');
  86. }else{
  87. $paperType = array('1050'=> '其他');
  88. }
  89. ?>
  90. <?php foreach($paperType as $key => $t):?>
  91. <li class="sel-paper-type pointer" id="<?php echo $key?>"><?php echo $t?></li>
  92. <?php endforeach;?>
  93. </ul>
  94. </div>
  95. <div id="paperType-error"></div>
  96. </div>
  97. <div class="mcp-form-list clearfix" style="width:1000px">
  98. <div class="mcp-form-menu fl">考试类型</div>
  99. <div class="mcp-form-detail fl clearfix">
  100. <div class="mcp-radio-sel fl examType">
  101. <span class="sel-btn select" value="1"></span>
  102. <span>周考</span>
  103. </div>
  104. <div class="mcp-radio-sel fl examType">
  105. <span class="sel-btn" value="2"></span>
  106. <span>单元考</span>
  107. </div>
  108. <div class="mcp-radio-sel fl examType">
  109. <span class="sel-btn" value="3"></span>
  110. <span>月考</span>
  111. </div>
  112. <div class="mcp-radio-sel fl examType">
  113. <span class="sel-btn" value="4"></span>
  114. <span>联考</span>
  115. </div>
  116. <div class="mcp-radio-sel fl examType">
  117. <span class="sel-btn" value="5"></span>
  118. <span>期中考试</span>
  119. </div>
  120. <div class="mcp-radio-sel fl examType">
  121. <span class="sel-btn" value="6"></span>
  122. <span>期末考试</span>
  123. </div>
  124. <div class="mcp-radio-sel fl examType">
  125. <span class="sel-btn" value="7"></span>
  126. <span>模拟考</span>
  127. </div>
  128. <div class="mcp-radio-sel fl examType">
  129. <span class="sel-btn" value="8"></span>
  130. <span>冲刺考</span>
  131. </div>
  132. <div class="clear"></div>
  133. <div class="mcp-radio-sel fl examType">
  134. <span class="sel-btn examType" value="9"></span>
  135. <span>测验(适用于非正式考试)</span>
  136. </div>
  137. </div>
  138. <div id="type-error"></div>
  139. </div>
  140. <div class="mcp-form-list clearfix">
  141. <div class="mcp-form-menu fl">主阅卷员</div>
  142. <div class="mcp-form-detail fl">
  143. <select class="sel-option projSelect" style="width: 150px">
  144. <option value="0">选择阅卷员</option>
  145. <?php foreach($teacher_arr as $t):?>
  146. <option class="pointer" value="<?php echo $t['teacher_id']?>"><?php echo $t['teacher_name']?></option>
  147. <?php endforeach;?>
  148. </select>
  149. </div>
  150. <div id="choose-error"></div>
  151. </div>
  152. <div class="mcp-form-list clearfix">
  153. <div class="mcp-form-menu fl">选择年级</div>
  154. <div class="mcp-form-detail fl">
  155. <select class="select-grade" isthird="1" name="select-grade" style="width: 150px">
  156. <option value="0">请选择</option>
  157. <?php
  158. if(isset(Yii::app()->params['grade_config'])){
  159. foreach (Yii::app()->params['grade_config'] as $id => $item){
  160. echo '<option value="'.$id.'">'.$item['grade_name'].'</option>';
  161. }
  162. }
  163. ?>
  164. </select>
  165. </div>
  166. <div id="choose-error"></div>
  167. </div>
  168. <div class="mcp-form-list clearfix">
  169. <div class="mcp-form-menu fl">选择班级</div>
  170. <div class="mcp-form-detail fl">
  171. <a class="btn btn-success btn-sm select-class">添加班级</a>
  172. <div class="select-class-list">
  173. <div class="class-box fl">
  174. <ul class="selected-box">
  175. </ul>
  176. </div>
  177. </div>
  178. </div>
  179. <div id="choose-error"></div>
  180. </div>
  181. <div class="mcp-form-list clearfix">
  182. <div class="mcp-form-menu fl">阅卷方式</div>
  183. <div class="mcp-form-detail fl clearfix" id ="markType">
  184. <div class="mcp-radio-sel fl">
  185. <span class="sel-btn select markType" value="3"></span>
  186. <span class ="markType" value="3">班级混合阅卷</span>
  187. </div>
  188. <div class="<?php if(!in_array(Yii::app()->session['session_duoxueke_subject_id'],array(18,19))){echo 'mcp-radio-sel';}else{echo 'mcp-radio-sel-no';}?> fl">
  189. <span class="sel-btn markType" value="4" ></span>
  190. <span class="markType" value="4">班级单独阅卷 <?php if(in_array(Yii::app()->session['session_duoxueke_subject_id'],array(18,19))){echo ' (文理综暂不支持)';}?></span>
  191. </div>
  192. <div class="mcp-radio-sel fl">
  193. <span class="sel-btn markType" value="0"></span>
  194. <span class="markType" value="0">线下阅卷(暂只支持在线答题卡)</span>
  195. </div>
  196. <div id="markType-error"></div>
  197. </div>
  198. </div>
  199. <div class="mcp-form-list clearfix">
  200. <div class="mcp-form-menu fl">考试时间</div>
  201. <div class="mcp-form-detail fl clearfix">
  202. <input type="text" class='core datetimepicker8' style="width: 140px;line-height: 27px;padding-left: 5px;" name="examDate" id="trial_begin_time_test" readonly/>
  203. </div>
  204. <div id="examDate"></div>
  205. </div>
  206. </div>
  207. <!-- <div class="template-flag-box"> -->
  208. <!-- <a href="javascript:;" id="createThird" active="true">保存试卷</a> -->
  209. <!--<a href="javascript:;" class="template-flag">创建答题卡</a>-->
  210. <!-- </div> -->
  211. <div class="template-flag-box">
  212. <a href="javascript:;" id="createThird" active="true">保存并返回</a>
  213. <!-- <a href="javascript:;" id="goNext" active="true">保存并下一步</a> -->
  214. <a href="javascript:;" id="goNextNew" active="true">保存并下一步</a>
  215. <a href="javascript:;" id="goBack" class="gray" active="true">放弃并返回</a>
  216. <!--<a href="javascript:;" class="template-flag">创建答题卡</a>-->
  217. </div>
  218. <input type="hidden" name="subjectId" value="<?php echo Yii::app()->session['session_duoxueke_subject_id'];?>">
  219. <input type="hidden" name="textbookId" value="0">
  220. <input type="hidden" name="tpl_index" value="1050">
  221. <input type="hidden" name="paperType" value="1050">
  222. <input name="type" value="1" type="hidden"/>
  223. <input name="teacherId" value="0" type="hidden"/>
  224. <input name="markType" value="3" type="hidden"/>
  225. <input name="classIds" value="0" type="hidden"/>
  226. <input name="topic" value="0" type="hidden"/>
  227. <input name="is_update" value="0" type="hidden"/>
  228. <input name="isQxk" value="<?php echo $is_qxk?>" type="hidden"/>
  229. <!-- <input name="third_tpl_id" value="<?php echo isset($thisTpls[0]['third_tpl_id'])?$thisTpls[0]['third_tpl_id']:0 ?>" type="hidden"/> -->
  230. </div>
  231. </div>
  232. </div>
  233. <div class="relation-answer-card">
  234. <div class="page-content">
  235. <div class="mcp-title">
  236. <span >第1步、考试基本信息</span>
  237. <span><i class="horizontal-line"></i></span>
  238. <span class="active">第2步、关联在线答题卡</span>
  239. </div>
  240. <!-- 新版本右侧答题卡 -->
  241. <div class="hgc_leftContent">
  242. <div class="module">
  243. <h2>
  244. <span>当前答题卡</span>
  245. <span class="theme notice">新版本,无需切割模板,可通过扫描入口直接扫描</span>
  246. </h2>
  247. <div class="contentInfo">
  248. <div class="opratorBnts">
  249. <span class="theme" id="saveMyTpl">保存为我的模版</span>
  250. <span class="theme" id="downLoadPdfBtn">下载答题卡</span>
  251. <span class="theme" id="editMyTpl">修改答题卡>></span>
  252. </div>
  253. <div class="subjectInfo">
  254. <div class="infoItem">
  255. <em>基本信息:</em>
  256. <div class="info">
  257. <p>
  258. <span>板式:A3-横版-三栏</span>
  259. <span>考号:填涂(10位)</span>
  260. <span>装订线:有</span>
  261. <span>总分:150分</span>
  262. <span>题量:50</span>
  263. </p>
  264. </div>
  265. </div>
  266. <div class="infoItem">
  267. <em>题目信息:</em>
  268. <div class="info">
  269. <p>
  270. <span>一、单项填空</span>
  271. <span>单选</span>
  272. <span>20题</span>
  273. <span>共20分</span>
  274. </p>
  275. </div>
  276. </div>
  277. </div>
  278. </div>
  279. <div class="contentNoInfo">
  280. <!-- <img src="" alt=""> -->
  281. <span>未创建答题卡</span>
  282. <div class="hbtn">创建在线答题卡</div>
  283. </div>
  284. </div>
  285. <div class="module">
  286. <h2>
  287. <span>我的模版(<em id="tplLength">0</em>)</span>
  288. </h2>
  289. <div class="tplBox">
  290. <div class="leftBtn btnItem"></div>
  291. <div class="tplCut">
  292. <div class="tplList">
  293. </div>
  294. <p id="tplListMsg" style="text-align: center;">暂未保存模板</p>
  295. </div>
  296. <div class="rightBtn btnItem"></div>
  297. </div>
  298. </div>
  299. </div>
  300. <div class="template-flag-box">
  301. <a href="javascript:;" id="createThirdCard" active="true">保存并返回</a>
  302. <a href="javascript:;" id="goBack" class="gray" active="true">放弃并返回</a>
  303. </div>
  304. </div>
  305. </div>
  306. </div>
  307. <!-- 弹窗 -->
  308. <div class="confirmbox-mask" style="display: none;" id="fieldModal">
  309. <div class="class-modal" style="padding: 0px;">
  310. <div class="class-modal-head" style="background-color: #2977ff;color: white;height: 30px;font-size: 16px;font-weight: initial;"><span style="float: left;padding: 5px;">选择考试班级</span><span class=" add-class-close" style="float: right;padding: 5px;cursor: pointer;">X</span></div>
  311. <form id="examSelect">
  312. <div class="class-modal-body">
  313. <p class="title">
  314. <input type="hidden" id="grade_id" name="grade_id" value="0">
  315. <span style="float: left;" id="gradeTxt">
  316. </span>
  317. <span style="margin-left: 300px;">
  318. <input type="checkbox" id="global_check_all" class="add_class_input">&nbsp;全选 &nbsp;&nbsp;
  319. <input type="checkbox" id="global_check_arts" class="add_class_input">&nbsp;全部文科班 &nbsp;&nbsp;
  320. <input type="checkbox" id="global_check_science" class="add_class_input">&nbsp;全部理科班 &nbsp;&nbsp;
  321. </span>
  322. </p>
  323. <div class="class_area" id="class_area">
  324. <ul class="class_right area_1">
  325. </ul>
  326. </div>
  327. </div>
  328. <p class="class_btn" style="text-align: center;">
  329. <input type="hidden" name="exam_gruop_id" value="0">
  330. <button type="button" class="setting_sumbit" style="margin-right: 10px;">确定</button>
  331. <button type="button" class="cancel-btn">取消</button>
  332. </p>
  333. </form>
  334. </div>
  335. </div>
  336. <script>
  337. function isReturn(){
  338. // var isCardReturn = localStorage.getItem('isCardReturn');
  339. // var isCardReturn = ~document.referrer.indexOf('online/third');
  340. var locationUrl = window.location.href;
  341. let isCardReturn = locationUrl.indexOf('isCardReturn')
  342. if(isCardReturn>-1){
  343. $('.test-data').hide();
  344. $('.relation-answer-card').show();
  345. // saveFormData = JSON.parse(localStorage.getItem('testFormData'));
  346. }else {
  347. var locationUrl = window.location.href;
  348. localStorage.setItem('referrerUrl',JSON.stringify(locationUrl));
  349. }
  350. }
  351. isReturn();
  352. var TopicType=new Array(5);
  353. TopicType[0]=[];
  354. TopicType[1]=[];
  355. TopicType[2]=[];
  356. TopicType[3]=[];
  357. TopicType[4]=[];
  358. $(document).ready(function(){
  359. $('.projSelect').select2();
  360. var showmsg = $("._tpl.active").attr("showmsg");
  361. if(showmsg>0){
  362. $("#btnCover").removeClass('dn');
  363. $(".bnt_width").addClass('c_bnt_width');
  364. }else {
  365. $(".bnt_width").removeClass('c_bnt_width');
  366. $("#btnCover").addClass('dn');
  367. $("input[name=tpl_title]").val('');
  368. }
  369. //选择试卷类型
  370. $('.sel-paper-type').click(function() {
  371. var paper_type = $(this).attr('id');
  372. if (paper_type) {
  373. $('#paperType-error').html("");
  374. }
  375. $('input[name="paperType"]').val(paper_type);
  376. });
  377. $('.datetimepicker8').datetimepicker({
  378. onGenerate:function( ct ){
  379. $(this).find('.xdsoft_date').toggleClass('xdsoft_disabled');
  380. $(this).find('.xdsoft_today').removeClass('xdsoft_disabled');
  381. },
  382. format:'Y-m-d',
  383. formatDate:'Y-m-d',
  384. minDate:'-1970/01/2',
  385. maxDate:'+1970/01/2',
  386. todayBtn : true,
  387. // minDate: '-<?php echo date('Y-m-d', strtotime('Yesterday')); ?>',
  388. timepicker:false
  389. });
  390. //选择考试时间
  391. //选择教材题源
  392. var subjects = <?php echo json_encode($teacherSubjectNames); ?>;
  393. var textbooks = <?php echo json_encode($teacherSubjectMaterialNames); ?>;
  394. for(var key in subjects){
  395. $(".choose-grade").append('<option value="'+ key +'">'+ subjects[key] +'</option>');
  396. }
  397. $(".choose-grade").change(function(){
  398. var obj = $(this);
  399. var val = obj.val();
  400. var child = $('.choose-book');
  401. child.html('<option value="0">选择教材</option>');
  402. for (var key in textbooks) {
  403. if (key == val) {
  404. child.html('');
  405. for (var name in textbooks[key]) {
  406. child.append('<option value="'+ [name] +'">'+ textbooks[key][name] +'</option>');
  407. }
  408. }
  409. }
  410. });
  411. //返回
  412. $('.mcp-back-btn').click(function(){
  413. location.href="<?php echo Yii::app()->createUrl('third/index')?>";
  414. });
  415. $('input[name="examName"]').keydown(function(event){
  416. $('#examName-error').html("");
  417. });
  418. //阅卷方式
  419. $('.markType').click(function(){
  420. var markType = $(this).attr('value');
  421. if(markType){
  422. $('#markType-error').html("");
  423. }
  424. $('input[name="markType"]').val(markType);
  425. });
  426. //考试类型
  427. $('.examType').click(function(){
  428. var type = $(this).find("span:eq(0)").attr('value');
  429. if(type){
  430. $('#type-error').html("");
  431. }
  432. $('input[name="type"]').val(type);
  433. });
  434. //选择教师
  435. $('.sel-option').change(function(){
  436. var teacher_id = $(this).val();
  437. if(teacher_id){
  438. $('#choose-error').html("");
  439. }
  440. $('input[name="teacherId"]').val(teacher_id);
  441. });
  442. if ($('.sel-classes > span').length > 0){
  443. for (var i = 0;i < $('.sel-classes > span').length; i++){
  444. for (var k = 0;k < $('.bjs-lis').length; k++){
  445. if ($('.bjs-lis').eq(k).text().trim()==$('.sel-classes > span').eq(i).text().trim()) {
  446. $('.bjs-lis').eq(k).find('.judge-sel').addClass('active');
  447. }
  448. }
  449. }
  450. }
  451. $('.mcp-radio-sel').click(function(){
  452. if (!$(this).find('.sel-btn').hasClass('select')) {
  453. $(this).find('.sel-btn').addClass('select');
  454. $(this).siblings().find('.sel-btn').removeClass('select');
  455. }
  456. });
  457. $('.grade-sel ul li').click(function(){
  458. $(this).addClass('active').siblings().removeClass('active');
  459. });
  460. // $('.judge-sel').on('click',function(){
  461. // alert(1);
  462. // if (!$(this).hasClass('active')) {
  463. // $(this).addClass('active');
  464. // $('.sel-classes').append('<span>'+$(this).closest('.bjs-lis').text()+'</span>');
  465. // } else {
  466. // $(this).removeClass('active');
  467. // for (var i = 0;i < $('.sel-classes > span').length; i++) {
  468. // console.log($('.sel-classes > span').eq(i).text());
  469. // if ($('.sel-classes > span').eq(i).text().trim() == $(this).closest('.bjs-lis').text().trim()){
  470. // $('.sel-classes > span').eq(i).remove();
  471. // }
  472. // }
  473. // }
  474. // });
  475. $('.sel-classes > span').click(function(){
  476. $(this).remove();
  477. for (var i = 0;i < $('.bjs-lis').length; i++) {
  478. if ($('.bjs-lis').eq(i).text().trim()==$(this).text().trim()){
  479. $('.bjs-lis').eq(i).find('.judge-sel').removeClass('active');
  480. }
  481. }
  482. });
  483. // 下拉列表模拟
  484. $('.inp-text').click(function(){
  485. if ($(this).next().is(':hidden')){
  486. $(this).next().show();
  487. } else {
  488. $(this).next().hide();
  489. }
  490. });
  491. // 点下拉列表选项
  492. $('.select-con li').click(function(){
  493. $(this).closest('.select-con').hide();
  494. $(this).closest('.mcp-form-detail').find('.inp-text').text($(this).text());
  495. });
  496. // 点击空白处下拉列表消失
  497. $(document).click(function(e){
  498. var targetNode = $(e.target).closest(".inp-text");
  499. if (targetNode.length>0){
  500. return;
  501. }else{
  502. $(".select-con").hide();
  503. }
  504. });
  505. function saveThirdForm(e,btnType){
  506. var classIds='';
  507. $(".selected-box").find('li').each(function(index,el){
  508. classIds += $(el).attr('value')+",";
  509. });
  510. $('input[name="classIds"]').val(classIds);
  511. var error = new Array();
  512. var classIds = $('input[name="classIds"]').val();
  513. var examName = $('input[name="examName"]').val();
  514. var is_update = $('input[name="is_update"]').val();
  515. var type = $('input[name="type"]').val();
  516. var teacherId = $('input[name="teacherId"]').val();
  517. // var markType = $('input[name="markType"]').val();
  518. var markType = $("#markType").find(".select").attr("value");
  519. var subjectId = $('input[name=subjectId]').val();
  520. var examDate = $("input[name='examDate']").val();
  521. var paperType = $("input[name='paperType']").val();
  522. if(subjectId == 0 || subjectId == null){
  523. $('#subject-error').html('请指定题源');
  524. error.push('没有指定题源');
  525. }else{
  526. $('#subject-error').html('');
  527. }
  528. if(examName == "" || examName == null){
  529. $('#examName-error').html('请指定考试名称');
  530. error.push('没有指定考试名称');
  531. }else{
  532. $('#examName-error').html('');
  533. }
  534. if(type == "" || type == null){
  535. $('#type-error').html('请指定考试类型');
  536. error.push('没有指定考试类型');
  537. }else{
  538. $('#type-error').html('');
  539. }
  540. if(paperType == 0 || paperType == 1 || paperType == 2 || paperType == 1050){
  541. $('#paperType-error').html('');
  542. }else{
  543. $('#paperType-error').html('请指定正确的试卷类型');
  544. error.push('请指定正确的试卷类型');
  545. }
  546. if(teacherId == '0' || teacherId == null){
  547. $('#choose-error').html('请指定阅卷老师');
  548. error.push('没有指定阅卷老师');
  549. }else{
  550. $('#choose-error').html('');
  551. if(classIds == "" || classIds == null){
  552. $('#classIds-error').html('请指定考试班级');
  553. error.push('没有指定考试班级');
  554. }else{
  555. $('#classIds-error').html('');
  556. }
  557. }
  558. if(!markType){
  559. $('#markType-error').html('请指定阅卷方式');
  560. error.push('没有指定阅卷方式');
  561. }else{
  562. $('#markType-error').html('');
  563. }
  564. if (examDate == '') {
  565. $('#examDate').html('请设置考试日期');
  566. error.push('请设置考试日期');
  567. } else if (examDate < '<?php echo date('Y-m-d'); ?>') {
  568. // $('#examDate').html('考试日期设置错误');
  569. // error.push('考试日期设置错误');
  570. }else{
  571. $('#examDate').html('');
  572. }
  573. if(error.length == 0){
  574. $("#createThird").attr('active','false');
  575. var saveFormData={
  576. examName:examName,
  577. teacherId:teacherId,
  578. type:type,
  579. classIds:classIds,
  580. markType:markType,
  581. paperType:paperType,
  582. subjectId:subjectId,
  583. textbookId:0,
  584. examDate:examDate,
  585. // tpl_index:1050,
  586. tpl_index:paperType,
  587. is_update:is_update,
  588. // topic:JSON.stringify(TopicType),
  589. layout:$("input[name=layout]:checked").val(),
  590. select_card_type:$("input[name=select_card_type]:checked").val(),
  591. third_tpl_id:$("input[name='third_tpl_id']").val(),
  592. tpl_save_type:$("input[name='tpl_save_type']:checked").val(),
  593. isQxk:$('input[name="isQxk"]').val()
  594. };
  595. $.post("<?php echo Yii::app()->createUrl('third/quanCreatethird')?>",saveFormData,function (data) {
  596. var m = JSON.parse(data);
  597. if(m.status==1){
  598. $('input[name="is_update"]').val(m.exam_group_id);
  599. saveFormData.examGroupId = m.exam_group_id;
  600. saveFormData.referrerUrl = window.location.href;
  601. var addGrade = 0;
  602. $('.grade-sel ul li').each(function(){
  603. if($(this).hasClass('active')){
  604. addGrade = $(this).attr('grade')
  605. }
  606. })
  607. saveFormData.grade = addGrade;
  608. // var grade = $("input[name='grade']").val();
  609. // saveFormData.examGroupId = m.exam_group_id;
  610. localStorage.setItem('testFormData',JSON.stringify(saveFormData));
  611. if(btnType===1){
  612. goBack()
  613. }else if(btnType===2){
  614. $('.test-data').hide();
  615. $('.relation-answer-card').show();
  616. }else if(btnType===3){
  617. location.href = '/index.php/online/answersheetList/examGroupId/'+saveFormData.examGroupId+'?isThird=1&examGroupId='+saveFormData.examGroupId
  618. // location.href = '/index.php/third/thirdCardSecond'
  619. }
  620. }else{
  621. layer.msg(m.msg);
  622. $("#createThird").attr('active','true');
  623. return false;
  624. }
  625. // if(m.status==0)
  626. // {
  627. // layer.msg(m.msg);
  628. // $("#createThird").attr('active','true');
  629. // return false;
  630. // }else{
  631. // $('input[name="is_update"]').val(m.exam_group_id);
  632. // if(btnType===1){
  633. // location.href = m.result;
  634. // }
  635. // }
  636. });
  637. }else{
  638. layer.msg(error.join(','));
  639. $("#createThird").attr('active','true');
  640. }
  641. }
  642. function goBack(){
  643. // location.href = '/index.php/third/index'
  644. window.history.back();
  645. }
  646. $("body").delegate("#createThird[active='true']", "click", function(e) {
  647. $('#createThird').attr('active',false);
  648. $('#goNext').attr('active',false);
  649. $('#goNextNew').attr('active',false);
  650. saveThirdForm(e,1)
  651. });
  652. //保存并关联答题卡
  653. $("body").delegate("#goNext[active='true']", "click", function(e) {
  654. $('#createThird').attr('active',false);
  655. $('#goNext').attr('active',false);
  656. $('#goNextNew').attr('active',false);
  657. saveThirdForm(e,2);
  658. });
  659. //保存并关联答题卡新版
  660. $("body").delegate("#goNextNew[active='true']", "click", function(e) {
  661. $('#createThird').attr('active',false);
  662. $('#goNext').attr('active',false);
  663. $('#goNextNew').attr('active',false);
  664. saveThirdForm(e,3);
  665. });
  666. //取消并返回
  667. $("body").delegate("#goBack[active='true']", "click", function(e) {
  668. goBack();
  669. //window.history.back();
  670. });
  671. $("#PrintThird").click(function(){
  672. if (!$(".ques-type-control label input").is(':checked')) {
  673. layer.msg('请选择题型!');return false;
  674. }
  675. if($(".ques-topic-num .ques-topic-item-edit").length > 0){
  676. layer.msg('请先保存题型!');return false;
  677. }
  678. var flag = 0;
  679. for(i = 0 ; i<TopicType.length;i++)
  680. {
  681. if(TopicType[i].length>0){
  682. flag = 1;
  683. if( i==4 &&!TopicType[4][0][0]){
  684. layer.msg('选做题设置有误,题型不能为空!');
  685. return false;
  686. }
  687. for (j = 0;j<TopicType[i].length;j++){
  688. if(TopicType[i][j][1]=='' || TopicType[i][j][1]==0)
  689. {
  690. layer.msg('题号不能为空!');
  691. return false;
  692. }
  693. }
  694. }
  695. }
  696. if(flag == 0){
  697. layer.msg('题号不能为空!');
  698. return false;
  699. }
  700. $('input[name="topic"]').val(JSON.stringify(TopicType)); //题型选择数据赋值
  701. var classIds='';
  702. $(".sel-classes[status=1]").children("span").each(function(){
  703. classIds += $(this).attr('classid')+",";
  704. });
  705. $('input[name="classIds"]').val(classIds);
  706. var examName = $('input[name="examName"]').val();
  707. var classIds = $('input[name="classIds"]').val();
  708. var data = {
  709. examName:examName,
  710. classIds:classIds,
  711. layout:$("input[name=layout]:checked").val(),
  712. select_card_type:$("input[name=select_card_type]:checked").val(),
  713. topic:JSON.stringify(TopicType)
  714. };
  715. $.post("<?php echo Yii::app()->createUrl('third/create_sheet')?>",data,function (rs) {
  716. var m = JSON.parse(rs);
  717. if(m.status==0)
  718. {
  719. layer.msg(m.msg);
  720. return false;
  721. }else{
  722. evaluationClient.CreateDiSanFang(JSON.stringify(m.result));
  723. }
  724. });
  725. });
  726. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  727. $("body").delegate("#btnSubmit[active='true']", "click", function(e) {
  728. var classIds='';
  729. $(".sel-classes[status=1]").children("span").each(function(){
  730. classIds += $(this).attr('classid')+",";
  731. });
  732. $('input[name="classIds"]').val(classIds);
  733. var classIds = $('input[name=classIds]').val();
  734. var teacherId = $('input[name="teacherId"]').val();
  735. var subjectId = $('input[name=subjectId]').val();
  736. var tpl_title = $('input[name=tpl_title]').val();
  737. if(tpl_title == "" || tpl_title == null){
  738. layer.msg('没有指定模板名称!');return false;
  739. }
  740. if(subjectId == 0 || subjectId == null){
  741. layer.msg('没有指定题源!');return false;
  742. }
  743. if(teacherId == '0' || teacherId == null){
  744. $('#choose-error').html('请指定阅卷老师');
  745. layer.msg('没有指定阅卷老师!');return false;
  746. }else{
  747. $('#choose-error').html('');
  748. if(classIds == "" || classIds == null){
  749. $('#classIds-error').html('请指定考试班级');
  750. layer.msg('没有指定考试班级!');return false;
  751. }else{
  752. $('#classIds-error').html('');
  753. }
  754. }
  755. if (!$(".ques-type-control label input").is(':checked')) {
  756. layer.msg('请选择题型!');return false;
  757. }
  758. var flag = 0;
  759. for(i = 0 ; i<TopicType.length;i++)
  760. {
  761. if(TopicType[i].length>0){
  762. flag = 1;
  763. if( i==4 &&!TopicType[4][0][0]){
  764. layer.msg('选做题设置有误,题型不能为空!');
  765. return false;
  766. }
  767. for (j = 0;j<TopicType[i].length;j++){
  768. if(TopicType[i][j][1]=='' || TopicType[i][j][1]==0)
  769. {
  770. layer.msg('题号不能为空!');
  771. return false;
  772. }
  773. }
  774. }
  775. }
  776. if(flag == 0){
  777. layer.msg('题号不能为空!');
  778. return false;
  779. }
  780. var data={
  781. tpl_title:tpl_title,
  782. teacherId:teacherId,
  783. classIds:classIds,
  784. subjectId:subjectId,
  785. textbookId:0,
  786. topic:JSON.stringify(TopicType),
  787. layout:$("input[name=layout]:checked").val(),
  788. select_card_type:$("input[name=select_card_type]:checked").val()
  789. };
  790. $.post("<?php echo Yii::app()->createUrl('third/createThirdTpl')?>",data,function (data) {
  791. var m = JSON.parse(data);
  792. if(m.status==1)
  793. { //$('#btnSubmit').attr('active','false');
  794. // layer.msg(m.msg);
  795. $(".template-box").prepend('<li class="_tpl" showmsg="1" third_tpl_id="'+m.result.third_tpl_id+'"><a href="#"><div class="card-type"><span class="size">'+m.result.layout+'</span><span class="type">'+m.result.select_card_type+'</span><i class="icon-delete"></i></div> <p class="card-name">'+m.result.title+'</p></a></li>');
  796. $("input[name=third_tpl_id]").val(m.result.third_tpl_id);
  797. $("._tpl.active").removeClass('active');
  798. $("._tpl").eq(0).addClass('active');
  799. $("#btnCover").removeClass('dn');
  800. layer.msg('保存成功!',{
  801. icon: 1
  802. });
  803. $(".ttd").hide();
  804. $(".bnt_width").addClass('c_bnt_width');
  805. return false;
  806. }else{
  807. layer.msg('保存失败',{
  808. icon: 5
  809. }, function(){
  810. $(".ttd").fadeOut();
  811. });
  812. return false;
  813. }
  814. });
  815. });
  816. $("body").delegate("#btnCover[active='true']", "click", function(e) {
  817. var classIds='';
  818. $(".sel-classes[status=1]").children("span").each(function(){
  819. classIds += $(this).attr('classid')+",";
  820. });
  821. $('input[name="classIds"]').val(classIds);
  822. // var classIds = $('input[name=classIds]').val();
  823. var teacherId = $('input[name="teacherId"]').val();
  824. var subjectId = $('input[name=subjectId]').val();
  825. var tpl_title = $('input[name=tpl_title]').val();
  826. if(tpl_title == "" || tpl_title == null){
  827. layer.msg('没有指定模板名称!');return false;
  828. }
  829. if(subjectId == 0 || subjectId == null){
  830. layer.msg('没有指定题源!');return false;
  831. }
  832. if(teacherId == '0' || teacherId == null){
  833. $('#choose-error').html('请指定阅卷老师');
  834. layer.msg('没有指定阅卷老师!');return false;
  835. }else{
  836. $('#choose-error').html('');
  837. if(classIds == "" || classIds == null){
  838. $('#classIds-error').html('请指定考试班级');
  839. layer.msg('没有指定考试班级!');return false;
  840. }else{
  841. $('#classIds-error').html('');
  842. }
  843. }
  844. if (!$(".ques-type-control label input").is(':checked')) {
  845. layer.msg('请选择题型!');return false;
  846. }
  847. var flag = 0;
  848. for(i = 0 ; i<TopicType.length;i++)
  849. {
  850. if(TopicType[i].length>0){
  851. flag = 1;
  852. if( i==4 &&!TopicType[4][0][0]){
  853. layer.msg('选做题设置有误,题型不能为空!');
  854. return false;
  855. }
  856. for (j = 0;j<TopicType[i].length;j++){
  857. if(TopicType[i][j][1]=='' || TopicType[i][j][1]==0)
  858. {
  859. layer.msg('题号不能为空!');
  860. return false;
  861. }
  862. }
  863. }
  864. }
  865. if(flag == 0){
  866. layer.msg('题号不能为空!');
  867. return false;
  868. }
  869. var data={
  870. tpl_title:tpl_title,
  871. third_tpl_id:$("._tpl.active").attr('third_tpl_id'),
  872. teacherId:teacherId,
  873. classIds:classIds,
  874. subjectId:subjectId,
  875. textbookId:0,
  876. topic:JSON.stringify(TopicType),
  877. layout:$("input[name=layout]:checked").val(),
  878. select_card_type:$("input[name=select_card_type]:checked").val()
  879. };
  880. $.post("<?php echo Yii::app()->createUrl('third/updateThirdTpl')?>",data,function (data) {
  881. var m = JSON.parse(data);
  882. if(m.status==1)
  883. {
  884. $("._tpl.active").children().find('.size').html(m.result.layout);
  885. $("._tpl.active").children().find('.type').html(m.result.select_card_type);
  886. $("._tpl.active").children().find('.card-name').html(m.result.title);
  887. $("._tpl.active").removeClass('active');
  888. $("._tpl").eq(0).addClass('active');
  889. layer.msg('保存成功!',{
  890. icon: 1
  891. });
  892. $(".ttd").fadeOut();
  893. $("#btnCover").removeClass('dn');
  894. $(".bnt_width").addClass('c_bnt_width');
  895. return false;
  896. }else{
  897. layer.msg('保存失败',{
  898. icon: 5
  899. }, function(){
  900. $(".ttd").fadeOut();
  901. });
  902. return false;
  903. }
  904. });
  905. });
  906. $("#btnClose").click(function(){
  907. $(this).parents(".ttd").fadeOut();
  908. });
  909. $(".shut").click(function(){
  910. $("body").css({height :"100%",overflow:"auto"});
  911. });
  912. });
  913. </script>
  914. <script>
  915. var subjects = [];
  916. $(function(){
  917. //console.log(firstCartTpl);
  918. // if(firstCartTpl!='null'){
  919. // TopicType=firstCartTpl;
  920. // }
  921. // $(".template-flag").click(function(){
  922. // FillCard();
  923. // $(".teamplate-list-box").toggle();
  924. // });
  925. // 点击显示隐藏
  926. $(".ques-type-control label input").click(function(e){
  927. var index=$(this).parent().index();
  928. var tempTopic = $(".ques-topic-num .ques-topic").eq(index);
  929. delTopicType(tempTopic);
  930. if($(this).is(":checked")){
  931. $(this).parent("label").addClass("active");
  932. tempTopic.find(".include-text").val("");
  933. tempTopic.find(".include-count").val("");
  934. tempTopic.show();
  935. if(index==0 || index==1){
  936. TopicType[index].push([4,'',0]); //对应数据初始化对应题型,题号,样式三种数据
  937. }else if(index==2){
  938. TopicType[index].push([1,'',1]); //对应数据初始化对应题型,题号,样式三种数据
  939. }else if(index==3){
  940. TopicType[index].push([1,'',0]); //对应数据初始化对应题型,题号,样式三种数据
  941. }else if(index==4){
  942. TopicType[index].push([0,'',0]); //对应数据初始化对应题型,题号,样式三种数据
  943. }
  944. //console.log(TopicType);
  945. }else{
  946. $(this).parent("label").removeClass("active")
  947. tempTopic.hide();
  948. if(index==0 || index==1){
  949. tempTopic.find(".ques-topic-list").eq(0).find("input").val("");
  950. tempTopic.find(".ques-topic-list").find('.topic-num input').val('');
  951. tempTopic.find(".ques-topic-list").eq(0).find(".ques-topic-item").removeClass("ques-topic-item-edit").find("a").html("选项编辑");
  952. }else if(index==2){
  953. // console.log(tempTopic.find(".ques-topic-list").find('.topic-num').find('input').val());
  954. tempTopic.find(".ques-topic-list").find('.topic-num').find('input').val('');
  955. tempTopic.find(".ques-topic-list").find('.line-control').find('input').val(1);
  956. tempTopic.find(".ques-topic-list").eq(0).find(".ques-topic-item").find('label input').eq(0).click();
  957. tempTopic.find(".line-type label:first input").prop("checked",true);
  958. }else if(index==3){
  959. tempTopic.find(".ques-topic-list").find('.topic-num input').val('');
  960. tempTopic.find(".ques-topic-list").eq(0).find("input").val("");
  961. tempTopic.find(".ques-topic-list").find('.line-control').find('input').val(1);
  962. tempTopic.find(".ques-topic-list").eq(0).find(".ques-topic-item").find('label input').eq(0).click();
  963. tempTopic.find(".line-type label:first input").prop("checked",true);
  964. tempTopic.find(".line-type label").eq(0).find("input").prop("checked",true);
  965. }
  966. tempTopic.find(".ques-topic-list").eq(0).find("em").remove();
  967. for(var i=0;i<4;i++){
  968. tempTopic.find(".ques-topic-list").eq(0).find("s").before("<em>【"+arr[i]+"】<b></b></em>");
  969. }
  970. for(var i=tempTopic.find(".ques-topic-list").length;i>1;i--){
  971. tempTopic.find(".ques-topic-list:last").remove();
  972. }
  973. TopicType[index]=[]; //清空对应数据
  974. // console.log(TopicType);
  975. }
  976. $("input[name=bixuan]").val(1);
  977. totalTopicCount();
  978. });
  979. // 答题卡类型选择
  980. $(".card-style a").click(function(){
  981. $(this).addClass("active").siblings().removeClass("active");
  982. $(".card-select").eq($(this).index()).addClass("cur").siblings().removeClass("cur");
  983. $(".card-select").eq($(this).index()).find("input:eq(0)").prop("checked",true).siblings().prop("checked",false);
  984. })
  985. // 选项编辑
  986. $("body").delegate(".ques-topic-item a","click",function(){
  987. if($(this).closest(".ques-topic-item").hasClass("ques-topic-item-edit")){
  988. $(this).closest(".ques-topic-item").removeClass("ques-topic-item-edit");
  989. $(this).html("选项编辑");
  990. $(this).closest(".ques-topic-item").find("s").hide();
  991. //装入修改后数据
  992. var index=$(this).closest('.ques-topic').index(); //第几个大类型
  993. var topic_index=$(this).closest('.ques-topic-list').index()-1; //该题型下第几个子题型
  994. TopicType[index][topic_index][0]=$(this).parent().find('em').length;
  995. // console.log(TopicType);
  996. }else{
  997. $(this).closest(".ques-topic-item").addClass("ques-topic-item-edit");
  998. $(this).siblings("s").show();
  999. if($(this).closest(".ques-topic").hasClass("ques-topic-one")){
  1000. // console.log($(this).closest(".ques-topic-item").find("em").length)
  1001. if($(this).closest(".ques-topic-item").find("em").length >3){
  1002. $(this).siblings("s").hide();
  1003. }else{
  1004. $(this).siblings("s").show();
  1005. }
  1006. }else{
  1007. // console.log($(this).closest(".ques-topic-item").find("em").length)
  1008. if($(this).closest(".ques-topic-item").find("em").length >6){
  1009. $(this).siblings("s").hide();
  1010. }else{
  1011. $(this).siblings("s").show();
  1012. }
  1013. }
  1014. $(this).html("保存");
  1015. }
  1016. });
  1017. // 删除选项
  1018. $("body").delegate(".ques-topic-item-edit b","click",function(){
  1019. if($(this).closest(".ques-topic-item-edit").find("em").length <= 10){
  1020. $(this).closest(".ques-topic-item-edit").find("s").show();
  1021. }
  1022. var tempParent = $(this).closest(".ques-topic-item-edit");
  1023. $(this).closest("em").remove();
  1024. orderABC(tempParent.find("em"))
  1025. hideDel(tempParent.find("b"))
  1026. });
  1027. function orderABC(obj){
  1028. for(var i=0;i<obj.length;i++){
  1029. obj.eq(i).html("【"+arr[i]+"】<b></b>")
  1030. }
  1031. }
  1032. // 增加选项
  1033. var arr = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N'];
  1034. $("body").delegate(".ques-topic-item-edit s","click",function(){
  1035. if($(this).closest(".ques-topic").hasClass("ques-topic-one")){
  1036. addAbc($(this),4)
  1037. }else{
  1038. addAbc($(this),7)
  1039. }
  1040. });
  1041. function addAbc(obj,count){
  1042. var idx = obj.closest(".ques-topic-item-edit").find("em").length;
  1043. obj.before("<em>【"+arr[idx]+"】<b></b></em>");
  1044. hideDel(obj.closest(".ques-topic-item-edit").find("b"))
  1045. if(obj.closest(".ques-topic-item-edit").find("em").length >= count){
  1046. obj.hide();
  1047. }
  1048. }
  1049. // 增加题型
  1050. $(".add-type a").click(function(){
  1051. var temp = $(this).closest(".add-type").prev().clone(true);
  1052. temp.find(".topic-point-num").html($(this).closest(".add-type").prev().index()+1);
  1053. temp.find(".ques-topic-item").removeClass("ques-topic-item-edit").find("a").html("选项编辑");
  1054. temp.find("em").remove();
  1055. for(var i=0;i<temp.find("input[type='text']").length;i++){
  1056. if(!temp.find("input[type='text']").eq(i).hasClass("choose-count")){
  1057. temp.find("input[type='text']").eq(i).val("")
  1058. }
  1059. }
  1060. for(var i=0;i<4;i++){
  1061. temp.find("s").before("<em>【"+arr[i]+"】<b></b></em>");
  1062. }
  1063. //主观题
  1064. if($(this).hasClass("main-topic")){
  1065. temp.find("input[name^='topicType']").attr("name","topicType_"+($(this).closest(".ques-topic").find(".ques-topic-list").length));
  1066. temp.find(".line-control input").val(1)
  1067. }
  1068. //填空题
  1069. if($(this).hasClass("tian_main-topic")){
  1070. temp.find("input[name^='tianketi_Type']").attr("name","tianketi_Type_"+($(this).closest(".ques-topic").find(".ques-topic-list").length));
  1071. temp.find(".line-control input").val(1)
  1072. }
  1073. //选做题
  1074. if($(this).hasClass("xuan-main-topic")){
  1075. temp.find("input[name^='chooseType']").attr("name","chooseType_"+($(this).closest(".ques-topic").find(".ques-topic-list").length));
  1076. }
  1077. temp.find('input:radio').each(function(i){
  1078. temp.find('input:radio').eq(i).attr('checked',false);
  1079. });
  1080. var index=$(this).closest('.ques-topic').index(); //第几个大类型
  1081. //判断数量
  1082. if(index==4 && $(this).closest(".ques-topic").find(".ques-topic-list").length>2){
  1083. return false;
  1084. }
  1085. $(this).closest(".add-type").before(temp);
  1086. if(index==0 || index==1){
  1087. TopicType[index].push([4,'',0]); //对应数据初始化对应题型,题号,样式三种数据
  1088. }else if(index==2){
  1089. $style=$('.line-type input:radio:checked').parent().index()+1;
  1090. temp.find('.line-control').css("display","inline-block");
  1091. TopicType[index].push([1,'',$style]); //对应数据初始化对应题型,题号,样式三种数据
  1092. }else if(index==3){
  1093. var topicTypeIndex=$(this).closest(".ques-topic").find(".ques-topic-list").length;
  1094. temp.find("input[name='topicType_"+topicTypeIndex+"']").eq(0).click();
  1095. $style=$('input[name=lineType]:checked').val();
  1096. temp.find('.line-control').hide();
  1097. TopicType[index].push([1,'',$style]); //对应数据初始化对应题型,题号,样式三种数据
  1098. }else if(index==4){
  1099. $("input[name=bixuan]").val(1);
  1100. var topicTypeIndex=$(this).closest(".ques-topic").find(".ques-topic-list").length;
  1101. TopicType[index].push([0,'',1]); //对应数据初始化对应题型,题号,样式三种数据
  1102. $(this).closest(".ques-topic").last().find("input[name='chooseType_"+(topicTypeIndex-1)+"']").eq(0).click();
  1103. }
  1104. delTopicType($(this).closest(".add-type").siblings(".ques-topic-list"));
  1105. // console.log(TopicType);
  1106. })
  1107. // 显示隐藏主观题横线行数
  1108. initTopicType($(".ques-topic-item input[type='radio']"))
  1109. function initTopicType(obj){
  1110. if(obj.val() == 2){
  1111. obj.closest("label").siblings(".line-control").css("display","inline-block");
  1112. }else{
  1113. obj.closest("label").siblings(".line-control").hide();
  1114. }
  1115. }
  1116. // 删除题型
  1117. function delTopicType(obj){
  1118. obj.find(".ques-item-del").show();
  1119. obj.eq(0).find(".ques-item-del").hide();
  1120. }
  1121. $("body").delegate(".ques-item-del","click",function(){
  1122. var index=$(this).closest('.ques-topic').index(); //大题型索引
  1123. var topic_index=$(this).closest('.ques-topic-list').index()-1;//子题型索引
  1124. if(topic_index!=0){
  1125. TopicType[index].splice(topic_index,1);
  1126. // console.log(TopicType[index]);
  1127. var pBox = $(this).closest(".ques-topic");
  1128. $(this).closest(".ques-topic-list").remove();
  1129. pBox.find(".item-count").html(topicCount(pBox));
  1130. pBox.find('.topic-point-num').each(function(index,val){
  1131. if(index != 0){
  1132. $(this).html(index+1)
  1133. }
  1134. })
  1135. totalTopicCount();
  1136. }
  1137. })
  1138. // 主观题样式切换
  1139. $("body").delegate(".ques-topic-item input[type='radio']","click",function(){
  1140. initTopicType($(this));
  1141. var index=$(this).closest('.ques-topic').index(); //大题型索引
  1142. var topic_index=$(this).closest('.ques-topic-list').index()-1;//子题型索引
  1143. if($(this).val()==2 && index!=2){
  1144. $(this).closest('.ques-topic-item').find('.line-control').css("display","inline-block");
  1145. TopicType[index][topic_index][0]=$(this).val()+'///'+$(this).closest('.ques-topic-item').find('.line-control input').val();
  1146. }else{
  1147. TopicType[index][topic_index][0]=$(this).val();
  1148. if($(this).val()==2){
  1149. $(this).closest('.ques-topic-item').find('.line-control').css("display","inline-block");
  1150. }else{
  1151. $(this).closest('.ques-topic-item').find('.line-control').hide();
  1152. }
  1153. }
  1154. console.log(TopicType);
  1155. });
  1156. // 主观题样式图片显示隐藏
  1157. $("body").delegate(".ques-topic-item .ques-style","mouseenter",function(){
  1158. $(this).find("img").show();
  1159. });
  1160. $("body").delegate(".ques-topic-item .ques-style","mouseleave",function(){
  1161. $(this).find("img").hide();
  1162. });
  1163. // 主观题横线行数加减
  1164. $("body").delegate(".line-control .add","click",function(){
  1165. $(this).siblings("input").val(Number($(this).siblings("input").val())+1);
  1166. var index=$(this).closest('.ques-topic').index(); //大题型索引
  1167. var topic_index=$(this).closest('.ques-topic-list').index()-1;//子题型索引
  1168. if(TopicType[index][topic_index][0]){
  1169. if(index!=2){
  1170. TopicType[index][topic_index][0]='2///'+$(this).siblings("input").val();
  1171. }else{
  1172. TopicType[index][topic_index][0]=$(this).siblings("input").val();
  1173. }
  1174. }
  1175. });
  1176. $("body").delegate(".line-control .del","click",function(){
  1177. if(Number($(this).siblings("input").val()) > 1){
  1178. $(this).siblings("input").val(Number($(this).siblings("input").val())-1);
  1179. var index=$(this).closest('.ques-topic').index(); //大题型索引
  1180. var topic_index=$(this).closest('.ques-topic-list').index()-1;//子题型索引
  1181. if(index!=2){
  1182. TopicType[index][topic_index][0]='2///'+$(this).siblings("input").val();
  1183. }else{
  1184. TopicType[index][topic_index][0]=$(this).siblings("input").val();
  1185. }
  1186. }
  1187. });
  1188. // 校验文本框输入
  1189. $("body").delegate(".topic-num input,.topic-num-choose input","keyup",function(){
  1190. $(this).val($(this).val().replace(/[^\d-,]+/g,""));
  1191. });
  1192. $("body").delegate(".choose-topic-num input,.include-list input","keyup",function(){
  1193. $(this).val($(this).val().replace(/[^\d]+/g,""));
  1194. })
  1195. // 小题校验
  1196. $("body").delegate(".include-list .include-text","blur",function(){
  1197. var tNo = trimArr($(this).closest(".include-list").siblings(".topic-num").find("input").val());
  1198. var sibIpt = $(this).closest(".ques-topic").find(".include-text");
  1199. var count = 0;
  1200. for(var i=0;i<sibIpt.length;i++){
  1201. if($(this).val() == sibIpt.eq(i).val()){
  1202. count++;
  1203. if(count > 1){
  1204. layer.msg('小题题号不能重复!');
  1205. $(this).val("");
  1206. break;
  1207. }
  1208. }
  1209. }
  1210. if($(this).val()){
  1211. console.log($(this).val())
  1212. console.log(tNo)
  1213. if(tNo.indexOf($(this).val()) == -1){
  1214. layer.msg('请输入有效题号!');
  1215. $(this).val("");
  1216. }
  1217. }
  1218. if($(this).val() != "" && $(this).next().val() != ""){
  1219. var bigTopic = $(this).val();
  1220. var smallTopic = $(this).next().val();
  1221. var index=$(this).closest('.ques-topic').index(); //大题型索引
  1222. var topic_index=$(this).closest('.ques-topic-list').index()-1;//子题型索引
  1223. if(TopicType[index][topic_index][3]){
  1224. var tp3Arr = TopicType[index][topic_index][3].split(",");
  1225. var tp3StrNext = '';
  1226. var isHave = 0;
  1227. for(var i=0;i<tp3Arr.length;i++){
  1228. var tp3ArrNext = tp3Arr[i].split("///");
  1229. console.log(tp3ArrNext);
  1230. if(tp3ArrNext[0] == bigTopic){
  1231. tp3ArrNext[1] == smallTopic;
  1232. isHave = 1;
  1233. }
  1234. if(tp3StrNext == ""){
  1235. tp3StrNext = tp3ArrNext.join("///");
  1236. }else{
  1237. tp3StrNext += ","+tp3ArrNext.join("///");
  1238. }
  1239. }
  1240. if(isHave == 0){
  1241. TopicType[index][topic_index][3] += ','+bigTopic+"///"+smallTopic;
  1242. }else{
  1243. TopicType[index][topic_index][3] = tp3StrNext;
  1244. }
  1245. }else{
  1246. TopicType[index][topic_index][3] = bigTopic+"///"+smallTopic;
  1247. }
  1248. }
  1249. })
  1250. $("body").delegate(".include-list .include-count","blur",function(){
  1251. if($(this).val() != "" && $(this).prev().val() != ""){
  1252. var bigTopic = $(this).prev().val();
  1253. var smallTopic = $(this).val();
  1254. var index=$(this).closest('.ques-topic').index(); //大题型索引
  1255. var topic_index=$(this).closest('.ques-topic-list').index()-1;//子题型索引
  1256. if(TopicType[index][topic_index][3]){
  1257. var tp3Arr = TopicType[index][topic_index][3].split(",");
  1258. var tp3StrNext = '';
  1259. var isHave = 0;
  1260. for(var i=0;i<tp3Arr.length;i++){
  1261. var tp3ArrNext = tp3Arr[i].split("///");
  1262. if(tp3ArrNext[0] == bigTopic){
  1263. tp3ArrNext[1] = smallTopic;
  1264. isHave = 1;
  1265. }
  1266. if(tp3StrNext == ""){
  1267. tp3StrNext = tp3ArrNext.join("///");
  1268. }else{
  1269. tp3StrNext += ","+tp3ArrNext.join("///");
  1270. }
  1271. }
  1272. if(isHave == 0){
  1273. TopicType[index][topic_index][3] += ','+bigTopic+"///"+smallTopic;
  1274. }else{
  1275. TopicType[index][topic_index][3] = tp3StrNext;
  1276. }
  1277. }else{
  1278. TopicType[index][topic_index][3] = bigTopic+"///"+smallTopic;
  1279. }
  1280. console.log(TopicType);
  1281. }
  1282. })
  1283. // 选做题校验
  1284. $("body").delegate(".choose-all-count","blur",function(){
  1285. // if(parseInt($(this).val()) > parseInt($(this).siblings(".choose-all-count").val())){
  1286. // layer.msg('sorry,选题数不能大于总题数!');
  1287. // $(this).val("");
  1288. // }
  1289. $(this).closest(".ques-topic").find(".item-count").html(topicCount($(this).closest(".ques-topic")))
  1290. totalTopicCount();
  1291. })
  1292. // choose-count
  1293. //题号计算,10-20
  1294. function trimArr(str){
  1295. if(!str) return [];
  1296. var arr1 = str.split(",");
  1297. var arrNo = [];
  1298. for(var i=0;i<arr1.length;i++){
  1299. var arr2 = arr1[i].split("-");
  1300. for(var j=0;j<arr2.length;j++){
  1301. if(arr2[j] == "" || typeof(arr2[j]) == "undefined"){
  1302. arr2.splice(j,1);
  1303. j= j-1;
  1304. }
  1305. }
  1306. if(arr2.length > 1){
  1307. for(var j = parseInt(arr2[0]);j<=parseInt(arr2[1]);j++){
  1308. arrNo.push(j+'')
  1309. }
  1310. }else{
  1311. if(arr2[0]){
  1312. arrNo.push(arr2[0]+'')
  1313. }
  1314. }
  1315. }
  1316. // console.log(repArr(arrNo))
  1317. return repArr(arrNo);
  1318. }
  1319. //数组去重
  1320. function repArr(arr) {
  1321. for (var i = 0; i < arr.length; i++) {
  1322. if (arr.indexOf(arr[i]) != i) {
  1323. arr.splice(i,1);//删除数组元素后数组长度减1后面的元素前移
  1324. i--;//数组下标回退
  1325. }
  1326. }
  1327. return arr;
  1328. }
  1329. // 题量计算 item-count
  1330. function topicCount(obj){
  1331. var tType = obj.find(".topic-num input");
  1332. var tCountObj = obj.find(".include-count");
  1333. var tChooseObj = obj.find(".choose-count")
  1334. var tempNoStr = "";
  1335. var count = 0;
  1336. for(var i=0;i<tType.length;i++){
  1337. tempNoStr += (','+tType.eq(i).val());
  1338. }
  1339. count = trimArr(tempNoStr).length;
  1340. for(var i=0;i<tCountObj.length;i++){
  1341. if(tCountObj.eq(i).val()){
  1342. count += (tCountObj.eq(i).val()-1)
  1343. }
  1344. }
  1345. for(var i=0;i<tChooseObj.length;i++){
  1346. if(tChooseObj.eq(i).val()){
  1347. count += parseInt(tChooseObj.eq(i).val())
  1348. }
  1349. }
  1350. return count
  1351. }
  1352. function totalTopicCount(){
  1353. var totalCount = 0;
  1354. // for(var i=0;i<$(".item-count").length;i++){z
  1355. // totalCount += parseInt($('.item-count').eq(i).html())
  1356. // }
  1357. for(var i=0;i<$(".ques-topic").length;i++){
  1358. if($(".ques-topic").eq(i).css("display") == "block"){
  1359. totalCount += topicCount($(".ques-topic").eq(i));
  1360. }
  1361. }
  1362. $(".total-count").html(totalCount)
  1363. }
  1364. $("body").delegate(".include-count","blur",function(){
  1365. if($(this).val() == "") return;
  1366. // console.log("sb")
  1367. if($(this).val() > 1){
  1368. $(this).closest(".ques-topic").find(".item-count").html(topicCount($(this).closest(".ques-topic")))
  1369. }else{
  1370. layer.msg('小题数量最小为2!');
  1371. $(this).val('')
  1372. $(this).closest(".ques-topic").find(".item-count").html(topicCount($(this).closest(".ques-topic"))+1)
  1373. }
  1374. totalTopicCount();
  1375. })
  1376. $("body").delegate(".topic-num input","blur",function(){
  1377. $(this).closest(".ques-topic").find(".item-count").html(topicCount($(this).closest(".ques-topic")));
  1378. totalTopicCount();
  1379. });
  1380. // 试题内包含小题
  1381. $("body").delegate(".include-topic a","click",function(){
  1382. var tNo = trimArr($(this).parent().siblings(".topic-num").find("input").val());
  1383. var ulList = $(this).parent().siblings().find('ul');
  1384. if(tNo.length == 0){
  1385. layer.msg('sorry,空题不能添加小题!');
  1386. return;
  1387. }else if(tNo.length <= ulList.children().length){
  1388. layer.msg('请先添加题号,谢谢!');
  1389. return;
  1390. }
  1391. ulList.append('<li>第 <input type="text" class="include-text"> 题有 <input type="text" class="include-count"> 个小题 <img src="/images/u434.png" class="del-include"></li>');
  1392. })
  1393. // 删除小题
  1394. $("body").delegate(".del-include","click",function(){
  1395. var This = $(this);
  1396. var pBox = $(this).closest(".ques-topic");
  1397. var index=This.closest('.ques-topic').index(); //大题型索引
  1398. var topic_index=This.closest('.ques-topic-list').index()-1;//子题型索引
  1399. var text = '';
  1400. var textArr = [];
  1401. $($(this).parent().parent().find("li")).each(function(k,v){
  1402. if(k < $(this).parent().parent().find("li").length - 1){
  1403. var include_text = $(this).find(".include-text").val();
  1404. var include_count = $(this).find(".include-count").val();
  1405. if(include_text > 0 && include_count > 0){
  1406. var textArrNext = include_text+'///'+include_count;
  1407. textArr.push(textArrNext);
  1408. }
  1409. }
  1410. });
  1411. if(textArr.length>0){
  1412. text = textArr.join(',');
  1413. }
  1414. TopicType[index][topic_index][3] = text;
  1415. This.closest("li").remove();
  1416. pBox.find(".item-count").html(topicCount(pBox))
  1417. totalTopicCount();
  1418. layer.msg('删除成功!');
  1419. })
  1420. //题号变化,修改数据
  1421. $('.ques-topic-num').on('change','.topic-num input',function(){
  1422. var index=$(this).closest('.ques-topic').index(); //大题型索引
  1423. var topic_index=$(this).closest('.ques-topic-list').index()-1;//子题型索引
  1424. var text=0;
  1425. if($(this).val()!='' && $(this).val()!=undefined){
  1426. text=$(this).val();
  1427. }
  1428. TopicType[index][topic_index][1]=text;
  1429. // console.log(TopicType);
  1430. });
  1431. $('.ques-topic-num').on('change','.topic-num-choose input',function(){
  1432. var index=$(this).closest('.ques-topic').index(); //大题型索引
  1433. var topic_index=$(this).closest('.ques-topic-list').index()-1;//子题型索引
  1434. var text=0;
  1435. if($(this).val()!='' && $(this).val()!=undefined){
  1436. text=$(this).val();
  1437. }
  1438. TopicType[index][topic_index][1]=text;
  1439. // console.log(TopicType);
  1440. });
  1441. //主观题样式变化,修改数据
  1442. $('.line-type label').click(function(){
  1443. //alert($(this).index());
  1444. var idx = $(this).closest(".ques-topic").index();
  1445. if(!(idx==2||idx==3)) return;
  1446. for(var i=0;i<TopicType[idx].length;i++){
  1447. TopicType[idx][i][2]=$(this).index()+1;
  1448. }
  1449. // console.log(TopicType);
  1450. });
  1451. //选做题
  1452. //题号
  1453. $('.ques-topic').on('change','.choose-topic-num input',function(){
  1454. //alert($(this).index());
  1455. var text='';
  1456. if($(this).index()==0){
  1457. text=$(this).val()+'///'+$(this).next().val();
  1458. }else{
  1459. text=$(this).prev().val()+'///'+$(this).val();
  1460. }
  1461. var index=$(this).closest('.ques-topic').index(); //大题型索引
  1462. var topic_index=$(this).closest('.ques-topic-list').index()-1;//子题型索引
  1463. TopicType[index][topic_index][0]=text;
  1464. // console.log(TopicType);
  1465. });
  1466. //样式
  1467. $('.ques-topic').on('click','.choose-topic input:radio',function(){
  1468. var index=$(this).closest('.ques-topic').index(); //大题型索引
  1469. var topic_index=$(this).closest('.ques-topic-list').index()-1;//子题型索引
  1470. TopicType[index][topic_index][2]=$(this).val();
  1471. });
  1472. function hideDel(obj){
  1473. if(obj.length > 2){
  1474. obj.closest(".ques-topic-item-edit").find("b").css("display","inline");
  1475. }else{
  1476. obj.closest(".ques-topic-item-edit").find("b").hide()
  1477. }
  1478. }
  1479. $("body").on("click","._tpl",function(){
  1480. var showmsg = $(this).attr("showmsg");
  1481. if(showmsg>0){
  1482. $("#btnCover").removeClass('dn');
  1483. $(".bnt_width").addClass('c_bnt_width');
  1484. $("input[name=tpl_title]").val($(this).find(".card-name").html());
  1485. }else {
  1486. $("input[name=layout]").eq(0).prop("checked",true);
  1487. $("input[name=select_card_type]").eq(0).prop("checked",true);
  1488. $(".bnt_width").removeClass('c_bnt_width');
  1489. $("#btnCover").addClass('dn');
  1490. $("input[name=tpl_title]").val('');
  1491. }
  1492. $("._tpl.active").removeClass('active');
  1493. $(this).addClass("active");
  1494. var data = {
  1495. third_tpl_id:$(this).attr("third_tpl_id")
  1496. };
  1497. if(showmsg>0){
  1498. $.post("<?php echo Yii::app()->createUrl('third/getThirdTpl')?>",data,function (res) {
  1499. /**
  1500. * 处理处理
  1501. * */
  1502. if(res.result.tpl_data){
  1503. TopicType=$.parseJSON(res.result.tpl_data);
  1504. FillCard();
  1505. // $("input[name=layout][value="+res.result.layout+"]").prop("checked",true);
  1506. // $("input[name=select_card_type][value="+res.result.select_card_type+"]").prop("checked",true);
  1507. $('input[name="third_tpl_id"]').val(res.result.third_tpl_id);
  1508. if(res.result.layout == 10 || res.result.layout == 11){
  1509. $(".card-select").eq(1).addClass("cur").siblings().removeClass("cur");
  1510. $(".card-style a").eq(1).addClass("active").siblings().removeClass("active");
  1511. $("input[name=layout][value="+res.result.layout+"]").prop("checked",true);
  1512. }else if(res.result.layout == 21 || res.result.layout == 31){
  1513. $(".card-select").eq(0).addClass("cur").siblings().removeClass("cur");
  1514. $(".card-style a").eq(0).addClass("active").siblings().removeClass("active");
  1515. $("input[name=layout][value="+res.result.layout+"]").prop("checked",true);
  1516. }else if(res.result.layout == 40 || res.result.layout == 41){
  1517. $(".card-select").eq(2).addClass("cur").siblings().removeClass("cur");
  1518. $(".card-style a").eq(2).addClass("active").siblings().removeClass("active");
  1519. $("input[name=layout][value="+res.result.layout+"]").prop("checked",true);
  1520. }else if(res.result.layout == 50 || res.result.layout == 51){
  1521. $(".card-select").eq(3).addClass("cur").siblings().removeClass("cur");
  1522. $(".card-style a").eq(3).addClass("active").siblings().removeClass("active");
  1523. $("input[name=layout][value="+res.result.layout+"]").prop("checked",true);
  1524. }
  1525. // console.log(TopicType[0].length);
  1526. }
  1527. console.log(TopicType);
  1528. },'json');
  1529. }else{
  1530. //创建新的答题卡
  1531. TopicType[0]=[];
  1532. TopicType[1]=[];
  1533. TopicType[2]=[];
  1534. TopicType[3]=[];
  1535. TopicType[4]=[];
  1536. $('input[name="third_tpl_id"]').val(0);
  1537. FillCard();
  1538. console.log(TopicType);
  1539. }
  1540. //获取模板数据
  1541. });
  1542. $("body").delegate(".icon-delete","click",function(){
  1543. var obj = $(this);
  1544. layer.msg("确定要永久删除此模板吗?", {
  1545. time: 0,
  1546. btn: ['确定', '取消'],
  1547. yes: function(index){
  1548. layer.close(index);
  1549. $.ajax({
  1550. url: "<?php echo Yii::app()->createUrl('third/delThirdTpl')?>",
  1551. type: "POST",
  1552. dataType: "json",
  1553. data:{
  1554. third_tpl_id:$("._tpl.active").attr('third_tpl_id')
  1555. },
  1556. success: function (m){
  1557. if(m.status){
  1558. layer.msg('删除成功',{
  1559. icon: 1
  1560. }, function(){
  1561. layer.closeAll();
  1562. $("input[name=layout]").eq(0).prop("checked",true);
  1563. $("input[name=select_card_type]").eq(0).prop("checked",true);
  1564. $(".bnt_width").removeClass('c_bnt_width');
  1565. $("#btnCover").addClass('dn');
  1566. $("input[name=tpl_title]").val('');
  1567. $("._tpl.active").removeClass('active');
  1568. $("._tpl:last").addClass("active");
  1569. obj.closest('._tpl').remove();
  1570. //创建新的答题卡
  1571. TopicType[0]=[];
  1572. TopicType[1]=[];
  1573. TopicType[2]=[];
  1574. TopicType[3]=[];
  1575. TopicType[4]=[];
  1576. $('input[name="third_tpl_id"]').val(0);
  1577. FillCard();
  1578. });
  1579. }
  1580. },
  1581. error: function (data, status, e){ //服务器响应失败处理函数
  1582. layer.msg('返回失败!',{
  1583. icon: 5
  1584. }, function(){
  1585. layer.closeAll();
  1586. });
  1587. }
  1588. });
  1589. }
  1590. });
  1591. });
  1592. //saveCard
  1593. $("#saveCard").click(function(){
  1594. var classIds='';
  1595. $(".sel-classes[status=1]").children("span").each(function(){
  1596. classIds += $(this).attr('classid')+",";
  1597. });
  1598. $('input[name="classIds"]').val(classIds);
  1599. var classIds = $('input[name="classIds"]').val();
  1600. var teacherId = $('input[name="teacherId"]').val();
  1601. var subjectId = $('input[name=subjectId]').val();
  1602. if(subjectId == 0 || subjectId == null){
  1603. layer.msg('没有指定题源!');return false;
  1604. }else{
  1605. $('#subject-error').html('');
  1606. }
  1607. if(teacherId == '0' || teacherId == null){
  1608. $('#choose-error').html('请指定阅卷老师');
  1609. layer.msg('没有指定阅卷老师!');return false;
  1610. }else{
  1611. $('#choose-error').html('');
  1612. if(classIds == "" || classIds == null){
  1613. $('#classIds-error').html('请指定考试班级');
  1614. layer.msg('没有指定考试班级!');return false;
  1615. }else{
  1616. $('#classIds-error').html('');
  1617. }
  1618. }
  1619. if (!$(".ques-type-control label input").is(':checked')) {
  1620. layer.msg('请选择题型!');return false;
  1621. }
  1622. var flag = 0;
  1623. for(i = 0 ; i<TopicType.length;i++)
  1624. {
  1625. if(TopicType[i].length>0){
  1626. flag = 1;
  1627. for (j = 0;j<TopicType[i].length;j++){
  1628. if(i==4 && TopicType[i][j][0]==0){
  1629. layer.msg('选做题设置有误,题型不能为空!');
  1630. return false;
  1631. }
  1632. if(TopicType[i][j][1]=='' || TopicType[i][j][1]==0)
  1633. {
  1634. layer.msg('题号不能为空!');
  1635. return false;
  1636. }
  1637. }
  1638. }
  1639. }
  1640. if(flag == 0){
  1641. layer.msg('题号不能为空!');
  1642. return false;
  1643. }
  1644. $(".ttd").fadeIn();
  1645. });
  1646. //根据数据重置答题卡
  1647. function FillCard(){
  1648. //所有选项卡重置
  1649. var tempBox=$(".ques-topic-num .ques-topic");
  1650. for(var i=0;i<tempBox.length;i++){
  1651. tempBox.eq(i).hide();
  1652. if(tempBox.eq(i).find('.ques-topic-list').length>0){
  1653. for(var j=tempBox.eq(i).find('.ques-topic-list').length;j>1;j--){
  1654. tempBox.eq(i).find('.ques-topic-list:last').remove();
  1655. }
  1656. if(i==0 || i==1){
  1657. tempBox.eq(i).find(".ques-topic-list").eq(0).find("input").val("");
  1658. tempBox.eq(i).find(".ques-topic-list").find('.topic-num input').val('');
  1659. tempBox.eq(i).find(".ques-topic-list").eq(0).find(".ques-topic-item").removeClass("ques-topic-item-edit").find("a").html("选项编辑");
  1660. }else if(i==2){
  1661. tempBox.eq(i).find(".ques-topic-list").find('.topic-num').find('input').val('');
  1662. tempBox.eq(i).find(".ques-topic-list").find('.line-control').find('input').val(1);
  1663. }else if(i==3){
  1664. tempBox.eq(i).find('.ques-topic-list').find(".line-control").hide().find('input').val(1);
  1665. //tempBox.eq(i).find('.ques-topic-list').find(".line-control")
  1666. tempBox.eq(i).find(".ques-topic-list").find('.topic-num input').val('');
  1667. for(var k=0;k<tempBox.eq(i).find(".ques-topic-list").find('input[name="topicType"]').length;k++){
  1668. if(k==0){
  1669. tempBox.eq(i).find(".ques-topic-list").find('input[name="topicType"]').eq(k).prop('checked',true);
  1670. }else{
  1671. tempBox.eq(i).find(".ques-topic-list").find('input[name="topicType"]').eq(k).prop('checked',false);
  1672. }
  1673. }
  1674. }else if(i==4){
  1675. tempBox.eq(i).find('.choose-topic-num input').eq(0).val('');
  1676. tempBox.eq(i).find(".ques-topic-list").find('.topic-num input').val('');
  1677. for(var k=0;k<tempBox.eq(i).find(".ques-topic-list").find('input[name="chooseType"]').length;k++){
  1678. if(k==0){
  1679. tempBox.eq(i).find(".ques-topic-list").find('input[name="chooseType"]').eq(k).prop('checked',true);
  1680. }else{
  1681. tempBox.eq(i).find(".ques-topic-list").find('input[name="chooseType"]').eq(k).prop('checked',false);
  1682. }
  1683. }
  1684. }
  1685. tempBox.eq(i).find(".ques-topic-list").eq(0).find("em").remove();
  1686. for(var k=0;k<4;k++){
  1687. tempBox.eq(i).find(".ques-topic-list").eq(0).find("s").before("<em>【"+arr[k]+"】<b></b></em>");
  1688. }
  1689. }
  1690. }
  1691. $(".ques-type-control label input").prop('checked',false).parent("label").removeClass("active");
  1692. /////////////////////
  1693. for(var l=0;l<TopicType.length;l++){
  1694. initType(l)
  1695. $(".ques-topic").eq(l).find(".item-count").html(topicCount($(".ques-topic").eq(l)));
  1696. totalTopicCount();
  1697. }
  1698. function initType(num){
  1699. if(TopicType[num] && TopicType[num].length>0){
  1700. //0单选题 1不定项选题 2填空题 3主观题 4选做题
  1701. var tempTopic = tempBox.eq(num);
  1702. var input_obj=$(".ques-type-control label input").eq(num);
  1703. input_obj.prop('checked',true).parent("label").addClass("active");
  1704. for(var i=0;i<TopicType[num].length;i++){
  1705. if(i==0){
  1706. tempTopic.show();
  1707. tempTopic.find('.ques-item-del').hide();
  1708. if(num == 0 || num == 1){
  1709. //处理题型
  1710. tempTopic.find('.ques-topic-item').find("em").remove();
  1711. for(var j=0;j<TopicType[num][i][0];j++){
  1712. tempTopic.find('.ques-topic-list').eq(0).find('.ques-topic-item').find("s").before("<em>【"+arr[j]+"】<b></b></em>");
  1713. }
  1714. }else if(num == 2){
  1715. //处理题型
  1716. tempTopic.find('.ques-topic-list').eq(0).find('.line-control').css("display","inline-block");
  1717. tempTopic.find('.ques-topic-list').eq(0).find('.line-control input').val(TopicType[2][i][0]);
  1718. var html = "";
  1719. if(TopicType[2][i][3]){
  1720. var smallTopics = TopicType[2][i][3];
  1721. var smallTopicsArr = smallTopics.split(",");
  1722. for(var a=0;a<smallTopicsArr.length;a++){
  1723. var smallTopicsStr = smallTopicsArr[a];
  1724. var nextArr = smallTopicsStr.split("///");
  1725. var bigNum = nextArr[0];
  1726. var smallNum = nextArr[1];
  1727. html += '<li>第 <input type="text" class="include-text" value="'+bigNum+'"> 题有 <input type="text" class="include-count" value="'+smallNum+'"> 个小题 <img src="/images/u434.png" class="del-include"></li>';
  1728. }
  1729. }
  1730. tempTopic.find('.ques-topic-list').eq(0).find('.include-list ul').html(html);
  1731. //处理样式
  1732. tempTopic.find('.line-type label').eq(TopicType[num][i][2]-1).find('input:radio').attr('checked',true);
  1733. }else if(num == 3){
  1734. //处理题型
  1735. if(String(TopicType[num][i][0]).indexOf('///')>-1){
  1736. var NumberArr=TopicType[num][i][0].split('///');
  1737. tempTopic.find('.ques-topic-list').eq(0).find('input[name="topicType"][value="'+NumberArr[0]+'"]').prop("checked",true);
  1738. tempTopic.find('.ques-topic-list').eq(0).find(".line-control input").val(NumberArr[1]);
  1739. tempTopic.find('.ques-topic-list').eq(0).find(".line-control").css("display","inline-block");
  1740. }else{
  1741. tempTopic.find('.ques-topic-list').eq(0).find('input[name="topicType"]').eq(TopicType[num][i][0]-1).prop("checked",true);
  1742. tempTopic.find('.ques-topic-list').eq(0).find(".line-control").hide();
  1743. }
  1744. var html = "";
  1745. if(TopicType[3][i][3]){
  1746. var smallTopics = TopicType[3][i][3];
  1747. var smallTopicsArr = smallTopics.split(",");
  1748. for(var a=0;a<smallTopicsArr.length;a++){
  1749. var smallTopicsStr = smallTopicsArr[a];
  1750. var nextArr = smallTopicsStr.split("///");
  1751. var bigNum = nextArr[0];
  1752. var smallNum = nextArr[1];
  1753. html += '<li>第 <input type="text" class="include-text" value="'+bigNum+'"> 题有 <input type="text" class="include-count" value="'+smallNum+'"> 个小题 <img src="/images/u434.png" class="del-include"></li>';
  1754. }
  1755. }
  1756. tempTopic.find('.ques-topic-list').eq(0).find('.include-list ul').html(html);
  1757. //处理样式
  1758. if(TopicType[num][i][2]==0){
  1759. tempTopic.find('.line-type label').eq(TopicType[num][i][2]).find('input:radio').prop('checked',true);
  1760. }else{
  1761. tempTopic.find('.line-type label').eq(TopicType[num][i][2]-1).find('input:radio').prop('checked',true);
  1762. }
  1763. }else if(num == 4){
  1764. //处理题型
  1765. if(TopicType[num][i][0]){
  1766. var NumberArr=TopicType[num][i][0].split('///');
  1767. tempTopic.find('.choose-topic-num').find('input').eq(0).val(NumberArr[0]);
  1768. tempTopic.find('.choose-topic-num').find('input').eq(1).val(NumberArr[1]);
  1769. }
  1770. //处理样式
  1771. tempTopic.find('input[name="chooseType"]').eq(TopicType[num][i][2]-1).attr('checked',true);
  1772. }
  1773. //处理题号
  1774. tempTopic.find('.ques-topic-list').eq(0).find('.topic-num input').val(TopicType[num][i][1]);
  1775. }else{
  1776. var temp= tempTopic.find(".add-type").prev().clone(true);
  1777. if(num == 0 || num == 1){
  1778. temp.find('.ques-topic-item').find("em").remove();
  1779. for(var j=0;j<TopicType[num][i][0];j++){
  1780. temp.find('.ques-topic-item').find("s").before("<em>【"+arr[j]+"】<b></b></em>");
  1781. }
  1782. }else if(num == 2){
  1783. temp.find('.line-control input').val(TopicType[num][i][0]);
  1784. var html = "";
  1785. if(TopicType[2][i][3]){
  1786. var smallTopics = TopicType[2][i][3];
  1787. var smallTopicsArr = smallTopics.split(",");
  1788. for(var a=0;a<smallTopicsArr.length;a++){
  1789. var smallTopicsStr = smallTopicsArr[a];
  1790. var nextArr = smallTopicsStr.split("///");
  1791. var bigNum = nextArr[0];
  1792. var smallNum = nextArr[1];
  1793. html += '<li>第 <input type="text" class="include-text" value="'+bigNum+'"> 题有 <input type="text" class="include-count" value="'+smallNum+'"> 个小题 <img src="/images/u434.png" class="del-include"></li>';
  1794. }
  1795. }
  1796. temp.find('.include-list ul').html(html);
  1797. }else if(num == 3){
  1798. temp.find("input[name^='topicType']").prop("checked",'');
  1799. temp.find("input[name^='topicType']").attr("name","topicType_"+i);
  1800. //判断题型是否包括横线
  1801. if(String(TopicType[num][i][0]).indexOf('///')>-1){
  1802. var NumberArr=TopicType[num][i][0].split('///');
  1803. temp.find('input[name="topicType_'+i+'"]').eq(NumberArr[0]-1).prop("checked",true);
  1804. temp.find(".line-control input").val(NumberArr[1]);
  1805. temp.eq(0).find(".line-control").show();
  1806. }else{
  1807. temp.find('input[name="topicType_'+i+'"][value="'+TopicType[num][i][0]+'"]').prop("checked",true);
  1808. temp.find(".line-control").hide();
  1809. }
  1810. // temp.find('.line-control input').val(TopicType[num][i][0]);
  1811. var html = "";
  1812. if(TopicType[3][i][3]){
  1813. var smallTopics = TopicType[3][i][3];
  1814. var smallTopicsArr = smallTopics.split(",");
  1815. for(var a=0;a<smallTopicsArr.length;a++){
  1816. var smallTopicsStr = smallTopicsArr[a];
  1817. var nextArr = smallTopicsStr.split("///");
  1818. var bigNum = nextArr[0];
  1819. var smallNum = nextArr[1];
  1820. html += '<li>第 <input type="text" class="include-text" value="'+bigNum+'"> 题有 <input type="text" class="include-count" value="'+smallNum+'"> 个小题 <img src="/images/u434.png" class="del-include"></li>';
  1821. }
  1822. }
  1823. temp.find('.include-list ul').html(html);
  1824. }else if(num == 4){
  1825. if(i==1){
  1826. temp.find("input[name='chooseType']").attr("name","chooseType_"+i);
  1827. }else{
  1828. temp.find("input[name='chooseType_"+(i-1)+"']").attr("name","chooseType_"+i);
  1829. }
  1830. //处理题型
  1831. if(TopicType[num][i][0]){
  1832. var NumberArr=TopicType[num][i][0].split('///');
  1833. temp.find('.choose-topic-num').find('input').eq(0).val(NumberArr[0]);
  1834. temp.find('.choose-topic-num').find('input').eq(1).val(NumberArr[1]);
  1835. }
  1836. temp.find('input[name="chooseType_'+i+'"]').eq(TopicType[num][i][2]-1).attr('checked',true);
  1837. }
  1838. temp.find('.topic-num input').val(TopicType[num][i][1]);
  1839. temp.find('.ques-item-del').show();
  1840. tempTopic.find(".add-type").before(temp);
  1841. }
  1842. }
  1843. }
  1844. }
  1845. }
  1846. });
  1847. function show_version() {
  1848. layer.msg('你的客户端版本太低,请升最新版本');
  1849. }
  1850. </script>
  1851. <script src="/js/third/submit.js"></script>
  1852. <script src="/js/third/select-class.js"></script>