thirdview1.php 92 KB

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