index_edit_underline.php 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  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. <style>
  6. #choose-error{color: #FF0000;}
  7. #examName-error{color: #FF0000;}
  8. #classIds-error{color: #FF0000;}
  9. #type-error{color: #FF0000;}
  10. #markType-error{color: #FF0000;}
  11. #subject-error{color: #FF0000;}
  12. #examDate{color: #FF0000;}
  13. .icon-add,.icon-del{
  14. width:20px;height:25px;display: inline-block;
  15. margin-bottom:-5px;
  16. }
  17. .icon-add{
  18. background:url("/images/timg.jpg") left center no-repeat ;
  19. background-size:18px 18px;
  20. margin-left:20px;
  21. }
  22. .icon-del{background: url("/images/u434.png") left center no-repeat;
  23. background-size:18px 18px;
  24. position: relative;
  25. top: 2px;
  26. }
  27. .tag {
  28. display: inline-block;
  29. padding: 3px 8px;
  30. border-radius: 3px;
  31. color: #ffffff;
  32. font-size: 12px;
  33. cursor: pointer;
  34. }
  35. .bg-green {
  36. background: #2977ff;
  37. }
  38. .topic_type_select{margin-bottom: 5px;}
  39. .topic_type_select input{height:26px;}
  40. .topic_type_select select{height:26px;}
  41. .border-box{
  42. border:1px solid #ccc;
  43. display: inline-block;
  44. margin-right:20px;
  45. height:34px;
  46. }
  47. .score{color:#333;margin-right:20px;}
  48. .up_score{color:#619aff;}
  49. .confirmbox {
  50. background: #fff;
  51. border: 1px solid #cccccc;
  52. border-radius: 3px;
  53. padding: 40px 40px 30px;
  54. text-align: center;
  55. position: fixed;
  56. left: 50%;
  57. top: 50%;
  58. transform: translate(-50%, -50%);
  59. z-index: 99;
  60. }
  61. .confirmbox-mask {
  62. background: rgba(0, 0, 0, .7);
  63. left: 0;
  64. right: 0;
  65. top: 0;
  66. bottom: 0;
  67. z-index: 99;
  68. position: fixed;
  69. }
  70. button {
  71. border: none;
  72. background: #2977ff;
  73. width: 80px;
  74. height: 26px;
  75. border-radius: 3px;
  76. font-size: 14px;
  77. color: #fff;
  78. outline: none;
  79. cursor: pointer;
  80. }
  81. button.save {
  82. display: block;
  83. margin: 40px auto;
  84. }
  85. .confirmbox .confirmbox-btns {
  86. margin-top: 40px;
  87. }
  88. .class-modal {
  89. width: 500px;
  90. min-height: 400px;
  91. background: #fff;
  92. // border-radius: 5px;
  93. position: absolute;
  94. top: 50%;
  95. left: 50%;
  96. transform: translate(-50%, -50%);
  97. }
  98. .class-modal-head {
  99. font-size: 14px;
  100. background:#2977ff;
  101. color:#fff;
  102. height:25px;
  103. line-height: 25px;
  104. padding: 0 0 0 15px;
  105. }
  106. .class-modal-body {
  107. margin-top: 20px;
  108. max-height: 300px;
  109. overflow: auto;
  110. margin-left:50px;
  111. }
  112. .class-modal-body .classes {
  113. margin-bottom: 20px;
  114. }
  115. .class-modal-body .classes > div {
  116. display: inline-block;
  117. max-width: 640px;
  118. vertical-align: top;
  119. }
  120. .class-modal-body .classes a {
  121. text-decoration: none;
  122. display: inline-block;
  123. margin: 0 5px 5px;
  124. color: #136bfb;
  125. font-size: 14px;
  126. }
  127. .class-modal-body .classes a.active {
  128. color: #fc091b
  129. }
  130. .class-modal .icon-close{
  131. position: absolute;
  132. right: 20px;
  133. top: 2px;
  134. color:#fff;
  135. }
  136. .c-red {
  137. color: #CC3300
  138. }
  139. .avg{
  140. margin:0 10px;
  141. }
  142. .class_btn{
  143. text-align: center;
  144. }
  145. .confirmbox-mask p{
  146. word-wrap : break-word ;
  147. }
  148. .template-flag-box{padding-left:150px;}
  149. .template-flag-box a{display:inline-block;color:#fff;text-decoration:none;border-radius:3px;width: 100px;text-align: center;background: #2977ff;height: 30px;margin-right:20px;line-height:30px}
  150. .class-modal-body p span{display: inline-block;width:60px;}
  151. .class_btn{position: fixed;bottom: 2%;text-align: center;width:500px;}
  152. .topic_type,.topic_count{
  153. vertical-align:middle;
  154. }
  155. </style>
  156. <div class="main-content-inner">
  157. <!-- 导航栏开始-->
  158. <?php include(Yii::app()->basePath.'/views/layouts/view_navigation.php');?>
  159. <!-- 导航栏结束-->
  160. <div class="page-content">
  161. <div class="mcp-title">模板组卷</div>
  162. <form class="saveForm" action="<?php echo Yii::app()->createUrl('third/createthirdunderline')?>" method="post" enctype="multipart/form-data">
  163. <div class="mcp-main-con">
  164. <div class="mcp-form-list clearfix">
  165. <div class="mcp-form-menu fl">试卷名称</div>
  166. <div class="mcp-form-detail fl"><input type="text" placeholder="必填" value="<?php echo $paper['paper_name']?>" class="test-paper-name" name="examName"></div>
  167. <div id="examName-error"></div>
  168. </div>
  169. <div class="mcp-form-list clearfix">
  170. <div class="mcp-form-menu fl">试卷格式</div>
  171. <div class="mcp-form-detail topic_area fl">
  172. <div class="topic_type_select">
  173. <div class="border-box">
  174. <select class="topic_type">
  175. <option value="0">请选择题型</option>
  176. <?php
  177. if(isset(Yii::app()->params['third_paper_logic'][Yii::app()->session['session_duoxueke_subject_id']])){
  178. foreach (Yii::app()->params['third_paper_logic'][Yii::app()->session['session_duoxueke_subject_id']] as $logic=>$type){
  179. echo '<option value="'.$logic.'">'.$type.'</option>';
  180. }
  181. }else{
  182. foreach (Yii::app()->params['third_paper_logic'][3] as $logic=>$type){
  183. echo '<option value="'.$logic.'">'.$type.'</option>';
  184. }
  185. }
  186. ?>
  187. </select>
  188. <input type="text" class="core topic_count" name="topic_count" value="0">小题
  189. <span class="icon-add"></span>
  190. <span class="icon-del"></span>
  191. </div>
  192. <span class="score">共--分</span>
  193. <span class="up_score">修改分值</span>
  194. <input type="hidden" class="score_list" name="score_list" value="">
  195. <input type="hidden" class="score_sum" name="score_sum" value="0">
  196. </div>
  197. <span class="tag bg-green add_topic_type">新增题型</span>
  198. <span class="tag bg-green preview">试卷预览</span>
  199. <span id="topic_error" class="c-red"></span>
  200. </div>
  201. </div>
  202. <div class="mcp-form-list clearfix">
  203. <div class="mcp-form-menu fl">选择考试类型</div>
  204. <div class="mcp-form-detail fl clearfix">
  205. <div class="mcp-radio-sel fl">
  206. <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==1){echo 'select'; }?> examType" value="1"></span>
  207. <span class="examType" value="1">周考</span>
  208. </div>
  209. <div class="mcp-radio-sel fl">
  210. <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==2){echo 'select'; }?> examType" value="2"></span>
  211. <span class="examType" value="2">单元考</span>
  212. </div>
  213. <div class="mcp-radio-sel fl">
  214. <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==3){echo 'select'; }?> examType" value="3"></span>
  215. <span class="examType" value="3">月考</span>
  216. </div>
  217. <div class="mcp-radio-sel fl">
  218. <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==4){echo 'select'; }?> examType" value="4"></span>
  219. <span class="examType" value="4">联考</span>
  220. </div>
  221. <div class="mcp-radio-sel fl">
  222. <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==5){echo 'select'; }?> examType" value="5"></span>
  223. <span class="examType" value="5">期中考试</span>
  224. </div>
  225. <div class="mcp-radio-sel fl">
  226. <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==6){echo 'select'; }?> examType" value="6"></span>
  227. <span class="examType" value="6">期末考试</span>
  228. </div>
  229. <div class="mcp-radio-sel fl">
  230. <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==7){echo 'select'; }?> examType" value="7"></span>
  231. <span class="examType" value="7">模拟考</span>
  232. </div>
  233. <div class="mcp-radio-sel fl">
  234. <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==8){echo 'select'; }?> examType" value="8"></span>
  235. <span class="examType" value="8">冲刺考</span>
  236. </div>
  237. </div>
  238. <div id="type-error"></div>
  239. </div>
  240. <div class="mcp-form-list clearfix">
  241. <div class="mcp-form-menu fl">主考教师</div>
  242. <div class="mcp-form-detail fl">
  243. <div class="inp-text pointer">选择主考教师</div>
  244. <ul class="select-con tac">
  245. <!--<li class="sel-option pointer" id="1">高三一班</li>-->
  246. <?php foreach($teacher_arr as $t):?>
  247. <li class="sel-option pointer" id="<?php echo $t['teacher_id']?>"><?php echo $t['teacher_name']?></li>
  248. <?php endforeach;?>
  249. <!--<li class="sel-option pointer" id="2">高三二班</li>-->
  250. <!--<li class="sel-option pointer" id="3">高三三班</li>-->
  251. </ul>
  252. </div>
  253. <div id="choose-error"></div>
  254. </div>
  255. <div class="mcp-form-list clearfix">
  256. <div class="mcp-form-menu fl">考试班级</div>
  257. <div class="mcp-form-detail fl">
  258. <div class="test-classes-desc">默认选中考试班级(<span class="">单击移除</span>)<span id="classIds-error"></span></div>
  259. <?php
  260. if(isset(Yii::app()->params['grade_config'])){
  261. $first=true;
  262. foreach (Yii::app()->params['grade_config'] as $id =>$item){
  263. if($first){
  264. $first=false;
  265. echo '<div class="sel-classes g'.$id.'" status="1"></div>';
  266. }else{
  267. echo '<div class="sel-classes g'.$id.'" style="display: none;" status="0"></div>';
  268. }
  269. }
  270. }
  271. ?>
  272. <div class="clearfix">
  273. <div class="grade-sel fl">
  274. <div class="grade-top">年级</div>
  275. <ul>
  276. <?php
  277. if(isset(Yii::app()->params['grade_config'])){
  278. foreach (Yii::app()->params['grade_config'] as $id =>$item){
  279. echo '<li grade="'.$id.'">'.$item['grade_name'].'</li>';
  280. }
  281. }
  282. ?>
  283. </ul>
  284. </div>
  285. <?php
  286. if(isset(Yii::app()->params['grade_config'])){
  287. $first=true;
  288. foreach (Yii::app()->params['grade_config'] as $id =>$item){
  289. if($first){
  290. $first=false;
  291. echo '<div class="bj-sel fl" id="grade'.$id.'">';
  292. echo '<div class="class-top">班级</div>';
  293. echo '<ul></ul>';
  294. echo '</div>';
  295. }else{
  296. echo '<div class="bj-sel fl" id="grade'.$id.'" style="display: none;">';
  297. echo '<div class="class-top">班级</div>';
  298. echo '<ul></ul>';
  299. echo '</div>';
  300. }
  301. }
  302. }
  303. ?>
  304. </div>
  305. </div>
  306. </div>
  307. <div class="mcp-form-list clearfix">
  308. <div class="mcp-form-menu fl">考试时间</div>
  309. <div class="mcp-form-detail fl clearfix">
  310. <input type="text" value="<?php if(isset($paper['exam_date'])){echo $paper['exam_date'];} ?>" class='core datetimepicker8' style="width: 100px;" name="examDate" />
  311. </div>
  312. <div id="examDate"></div>
  313. </div>
  314. </div>
  315. <input name="type" value="<?php if(isset($paper['type'])){ echo $paper['type'];}else{ echo 1;}?>" type="hidden"/>
  316. <input name="teacherId" value="<?php if(isset($paper['teacher_id'])){ echo $paper['teacher_id'];}else{ echo 0;}?>" type="hidden"/>
  317. <input name="markType" value="0" type="hidden"/>
  318. <input name="classIds" value="0" type="hidden"/>
  319. <input name="topic_data" value="" type="hidden">
  320. <input name="subjectId" value="<?php echo Yii::app()->session['session_duoxueke_subject_id']?>" type="hidden">
  321. <input name="exam_group_id" value="<?php echo $examgroupid;?>" type="hidden">
  322. </form>
  323. <div class="mcp-form-list mcp-fl-btns clearfix">
  324. <input type="button" value="确定" class="mcp-sure-btn" id="createThird" active="true">
  325. <input type="button" value="返回" class="mcp-back-btn">
  326. </div>
  327. </div>
  328. <div class="confirmbox-mask" style="display: none" id="classModal">
  329. <div class="class-modal">
  330. <i class="icon icon-close">关闭</i>
  331. <div class="class-modal-head">修改分值</div>
  332. <div class="class-modal-body">
  333. <p>总分: <input type="text" name="total_score" /><button class="avg">平均分配</button><span>无法平均分配</span></p>
  334. </div>
  335. <p class="class_btn">
  336. <input type="hidden" name="topic_type_index" value="0">
  337. <button type="button" class="save_score">确定</button>
  338. </p>
  339. </div>
  340. </div>
  341. <div class="confirmbox-mask" style="display: none" id="examModal">
  342. <div class="class-modal">
  343. <i class="icon icon-close">关闭</i>
  344. <div class="class-modal-head">试卷预览</div>
  345. <div class="class-modal-body">
  346. </div>
  347. <p class="class_btn">
  348. <button type="button" class="exam-close">确定</button>
  349. </p>
  350. </div>
  351. </div>
  352. </div>
  353. <script>
  354. $(document).ready(function(){
  355. $('.datetimepicker8').datetimepicker({
  356. onGenerate:function( ct ){
  357. $(this).find('.xdsoft_date').toggleClass('xdsoft_disabled');
  358. $(this).find('.xdsoft_today').removeClass('xdsoft_disabled');
  359. },
  360. format:'Y-m-d',
  361. formatDate:'Y-m-d',
  362. minDate:'-1970/01/2',
  363. maxDate:'+1970/01/2',
  364. // minDate: '-<?php echo date('Y-m-d', strtotime('Yesterday')); ?>',
  365. timepicker:false
  366. });
  367. //选择考试时间
  368. //选择教材题源
  369. var subjects = <?php echo json_encode($teacherSubjectNames); ?>;
  370. var textbooks = <?php echo json_encode($teacherSubjectMaterialNames); ?>;
  371. for(var key in subjects){
  372. $(".choose-grade").append('<option value="'+ key +'">'+ subjects[key] +'</option>');
  373. }
  374. $(".choose-grade").change(function(){
  375. var obj = $(this);
  376. var val = obj.val();
  377. var child = $('.choose-book');
  378. child.html('<option value="0">选择教材</option>');
  379. for (var key in textbooks) {
  380. if (key == val) {
  381. child.html('');
  382. for (var name in textbooks[key]) {
  383. child.append('<option value="'+ [name] +'">'+ textbooks[key][name] +'</option>');
  384. }
  385. }
  386. }
  387. });
  388. //返回
  389. $('.mcp-back-btn').click(function(){
  390. location.href="<?php echo Yii::app()->createUrl('third/index?list_type=1')?>";
  391. });
  392. $('input[name="examName"]').keydown(function(event){
  393. $('#examName-error').html("");
  394. });
  395. //阅卷方式
  396. $('.markType').click(function(){
  397. var markType = $(this).attr('value');
  398. if(markType){
  399. $('#markType-error').html("");
  400. }
  401. $('input[name="markType"]').val(markType);
  402. });
  403. //选择教师
  404. var firstLoad=true;
  405. //判断已选班级id
  406. var selectedClassId=[];
  407. <?php
  408. if(isset($paper['class_id']) && $paper['class_id']){
  409. foreach ($paper['class_id'] as $cid){
  410. echo 'selectedClassId.push("'.$cid.'");';
  411. }
  412. }
  413. ?>
  414. $('.sel-option').click(function(){
  415. var teacher_id = $(this).attr('id');
  416. if(teacher_id){
  417. $('#choose-error').html("");
  418. }
  419. $('input[name="teacherId"]').val(teacher_id);
  420. $.post(
  421. "<?php echo Yii::app()->createUrl('third/ajaxchangeclasses')?>",
  422. {teacher_id:teacher_id,selectedClassId:selectedClassId},
  423. function(result){
  424. if(result.error){
  425. $('#choose-error').html(result.error);
  426. }else{
  427. $.each(result.class_arr_select,function(k,v){
  428. $('.g'+v.grade).html($('.g'+v.grade).html()+"<span grade='"+v.grade+"' classid='"+v.class_id+"'>"+v.class_name+"</span>");
  429. });
  430. $.each(result.class_arr_noselect,function(k,v){
  431. $('#grade'+v.grade+' ul').html($('#grade'+v.grade+' ul').html()+'<li class="bjs-lis ellipsis" grade="'+v.grade+'" classid="'+v.class_id+'" ><span class="judge-sel"></span>'+v.class_name+'</li>');
  432. });
  433. }
  434. },
  435. 'json'
  436. );
  437. });
  438. var gradeArr=[];
  439. <?php
  440. if(Yii::app()->params['grade_list']){
  441. foreach (Yii::app()->params['grade_list'] as $param){
  442. echo "gradeArr.push('".$param['id']."');";
  443. }
  444. }
  445. ?>
  446. //切换年级
  447. $('.a-years,.a-province,.paper-type > span, .grade-sel ul li').click(function(){
  448. if(!$(this).hasClass('active')){
  449. $(this).addClass('active').siblings().removeClass('active');
  450. var grade=$(this).attr("grade");
  451. for(var i=0;i<=gradeArr.length;i++){
  452. if(gradeArr[i]==grade){
  453. $("#grade"+grade).show();
  454. $('.g'+grade).show();
  455. $('.g'+grade).attr('status',1);
  456. }else{
  457. $("#grade"+gradeArr[i]).hide();
  458. $(".g"+gradeArr[i]).hide();
  459. $(".g"+gradeArr[i]).attr('status',0);
  460. }
  461. }
  462. }
  463. });
  464. //添加班级
  465. $(".bj-sel ul").on("click","li", function(){
  466. $('#classIds-error').html("");
  467. $(this).find('.judge-sel').addClass('active');
  468. $(this).remove();
  469. var grade = $(this).attr('grade');
  470. $('.g'+grade).append('<span grade="'+$(this).attr("grade")+'" classid="'+$(this).attr("classid")+'">'+$(this).text()+'</span>');
  471. });
  472. //移除班级
  473. $('.sel-classes').delegate('span','click',function(){
  474. $(this).remove();
  475. $("#grade"+$(this).attr("grade")).children("ul").append('<li class="bjs-lis" grade="'+$(this).attr("grade")+'" classid="'+$(this).attr("classid")+'"><span class="judge-sel"></span>'+$(this).html()+'</li>');
  476. });
  477. if ($('.sel-classes > span').length > 0){
  478. for (var i = 0;i < $('.sel-classes > span').length; i++){
  479. for (var k = 0;k < $('.bjs-lis').length; k++){
  480. if ($('.bjs-lis').eq(k).text().trim()==$('.sel-classes > span').eq(i).text().trim()) {
  481. $('.bjs-lis').eq(k).find('.judge-sel').addClass('active');
  482. }
  483. }
  484. }
  485. }
  486. $('.mcp-radio-sel').click(function(){
  487. if (!$(this).find('.sel-btn').hasClass('select')) {
  488. $(this).find('.sel-btn').addClass('select');
  489. $(this).siblings().find('.sel-btn').removeClass('select');
  490. var type = $(this).find('.sel-btn').attr('value');
  491. if(type){
  492. $('#type-error').html("");
  493. }
  494. $('input[name="type"]').val(type);
  495. }
  496. });
  497. $('.grade-sel ul li').click(function(){
  498. $(this).addClass('active').siblings().removeClass('active');
  499. });
  500. // $('.judge-sel').on('click',function(){
  501. // alert(1);
  502. // if (!$(this).hasClass('active')) {
  503. // $(this).addClass('active');
  504. // $('.sel-classes').append('<span>'+$(this).closest('.bjs-lis').text()+'</span>');
  505. // } else {
  506. // $(this).removeClass('active');
  507. // for (var i = 0;i < $('.sel-classes > span').length; i++) {
  508. // console.log($('.sel-classes > span').eq(i).text());
  509. // if ($('.sel-classes > span').eq(i).text().trim() == $(this).closest('.bjs-lis').text().trim()){
  510. // $('.sel-classes > span').eq(i).remove();
  511. // }
  512. // }
  513. // }
  514. // });
  515. $('.sel-classes > span').click(function(){
  516. $(this).remove();
  517. for (var i = 0;i < $('.bjs-lis').length; i++) {
  518. if ($('.bjs-lis').eq(i).text().trim()==$(this).text().trim()){
  519. $('.bjs-lis').eq(i).find('.judge-sel').removeClass('active');
  520. }
  521. }
  522. });
  523. // 下拉列表模拟
  524. $('.inp-text').click(function(){
  525. if ($(this).next().is(':hidden')){
  526. $(this).next().show();
  527. } else {
  528. $(this).next().hide();
  529. }
  530. });
  531. // 点下拉列表选项
  532. $('.select-con li').click(function(){
  533. $(this).closest('.select-con').hide();
  534. $(this).closest('.mcp-form-detail').find('.inp-text').text($(this).text());
  535. });
  536. // 点击空白处下拉列表消失
  537. $(document).click(function(e){
  538. var targetNode = $(e.target).closest(".inp-text");
  539. if (targetNode.length>0){
  540. return;
  541. }else{
  542. $(".select-con").hide();
  543. }
  544. });
  545. $("body").delegate("#createThird[active='true']", "click", function(e) {
  546. var classIds='';
  547. $(".sel-classes[status=1]").children("span").each(function(){
  548. classIds += $(this).attr('classid')+",";
  549. });
  550. $('input[name="classIds"]').val(classIds);
  551. var error = new Array();
  552. var classIds = $('input[name="classIds"]').val();
  553. var examName = $('input[name="examName"]').val();
  554. var type = $('input[name="type"]').val();
  555. var teacherId = $('input[name="teacherId"]').val();
  556. var examDate = $("input[name='examDate']").val();
  557. if(examName == "" || examName == null){
  558. $('#examName-error').html('请指定考试名称');
  559. error.push('没有指定考试名称');
  560. }else{
  561. $('#examName-error').html('');
  562. }
  563. //检测试题设置
  564. $select_obj=$('.topic_type_select');
  565. $isFoundErr=false;
  566. $topicData=[];
  567. for (var i=0;i<$select_obj.length;i++){
  568. if($select_obj.eq(i).find('.topic_count').val()==0 || $select_obj.eq(i).find('.score_list').val()=='' || $select_obj.eq(i).find('topic_type').val()=='0'){
  569. $isFoundErr=true;
  570. break;
  571. }else{
  572. $topicData.push('{"topic_type":'+$select_obj.eq(i).find('.topic_type').val()+',"topic_count":'+$select_obj.eq(i).find('.topic_count').val()+','+'"topic_score":"'+$select_obj.eq(i).find('.score_list').val()+'"}');
  573. }
  574. }
  575. if($isFoundErr){
  576. error.push('试题类型数量或分数未设置');
  577. $('#topic_error').html('试题数量或分数未设置');
  578. }else{
  579. $('input[name=topic_data]').val('['+$topicData.join(',')+']');
  580. $('#topic_error').html('');
  581. }
  582. if(type == "" || type == null){
  583. $('#type-error').html('请指定考试类型');
  584. error.push('没有指定考试类型');
  585. }else{
  586. $('#type-error').html('');
  587. }
  588. if(teacherId == '0' || teacherId == null){
  589. $('#choose-error').html('请指定阅卷老师');
  590. error.push('没有指定阅卷老师');
  591. }else{
  592. $('#choose-error').html('');
  593. if(classIds == "" || classIds == null){
  594. $('#classIds-error').html('请指定考试班级');
  595. error.push('没有指定考试班级');
  596. }else{
  597. $('#classIds-error').html('');
  598. }
  599. }
  600. if (examDate == '') {
  601. $('#examDate').html('请设置考试日期');
  602. error.push('请设置考试日期');
  603. }else{
  604. $('#examDate').html('');
  605. }
  606. //console.log(error);
  607. if(error.length == 0){
  608. $(this).attr("active","false");
  609. //$(".saveForm").submit();
  610. //改为ajax提交
  611. index=layer.msg('正在保存,请稍候......',{time:9000000});
  612. $.ajax({
  613. url:'<?php echo Yii::app()->createUrl('third/createthirdunderline')?>',
  614. method:'POST',
  615. dataType:'json',
  616. data:$(".saveForm").serialize(),
  617. success:function (res) {
  618. layer.close(index);
  619. if(res.status==1){
  620. window.location="<?php echo Yii::app()->createUrl('third/index?list_type=1')?>";
  621. }else{
  622. layer.msg(res.msg);
  623. }
  624. }
  625. });
  626. }
  627. });
  628. //================题型选择部分操作代码=================================
  629. var selected_type=[]; //已选题型
  630. $('.topic_type_select').eq(0).find('.topic_type').val(1);
  631. $('input[name=examName]').change(function () {
  632. if($(this).val().length>30){
  633. layer.msg('考试名称不能超过30字');
  634. $(this).val('');
  635. }
  636. });
  637. function create_topic_type_select_obj(){
  638. $obj=$('.topic_type_select').eq(0).clone();
  639. $obj.find('.topic_count').val(0);
  640. $obj.find('.score_list').val('');
  641. $obj.find('.score_sum').val(0);
  642. $obj.find('.score').html('共-分');
  643. var option=$obj.find('.topic_type option');
  644. var is_have_topic_type=false;
  645. for(var i=0;i<option.length;i++){
  646. if(option.eq(i).attr('value')==0 || $.inArray(option.eq(i).attr('value'),selected_type)!=-1){
  647. continue;
  648. }else{
  649. $obj.find('.topic_type').val(option.eq(i).attr('value'));
  650. selected_type.push(option.eq(i).attr('value'));
  651. is_have_topic_type=true;
  652. break;
  653. }
  654. }
  655. if(is_have_topic_type){
  656. return $obj;
  657. }else{
  658. return false;
  659. }
  660. }
  661. $('.add_topic_type').click(function () {
  662. $obj=create_topic_type_select_obj();
  663. if(!$obj){
  664. layer.msg('没有可用题型!');
  665. }else{
  666. $(this).before($obj);
  667. }
  668. });
  669. $('.icon-close,.exam-close').click(function(){
  670. $(this).closest('.confirmbox-mask').hide();
  671. });
  672. $('.save_score').click(function(){
  673. var topicScore=[];
  674. for(var i=1;i<=$('.topic_score').length;i++){
  675. if($('input[name=total_score_'+i+']').val()==0 || $('input[name=total_score_'+i+']').val()==''){
  676. layer.msg('请填写题目分数!');
  677. return false;
  678. }
  679. topicScore.push($('input[name=total_score_'+i+']').val());
  680. }
  681. var obj_index=$('input[name=topic_type_index]').val();
  682. $('.topic_type_select').eq(obj_index).find('.score_list').val(topicScore.join(','));
  683. $('.topic_type_select').eq(obj_index).find('.score').html('共'+$('input[name=total_score]').val()+'分');
  684. $('.topic_type_select').eq(obj_index).find('.score_sum').val($('input[name=total_score]').val());
  685. classModal.style.display = 'none';
  686. });
  687. //试卷预览
  688. $('.preview').click(function(){
  689. $obj=$('.topic_type_select');
  690. for(var i=0;i<$obj.length;i++){
  691. if($obj.eq(i).find('.topic_count').val()==0 ){
  692. layer.msg('试题数量或分数未设置!');
  693. return false;
  694. }
  695. }
  696. $('#examModal').show();
  697. var html='';
  698. var digit=['一','二','三','四','五','六','七','八','九','十','十一','十二','十三','十四','十五','十六','十七','十八','十九','二十','二十一'];
  699. var topic_num=1;
  700. for(var i=0;i<$obj.length;i++){
  701. topic_count=parseInt($obj.eq(i).find('.topic_count').val());
  702. score_sum=$obj.eq(i).find('.score_sum').val();
  703. html+='<p>'+ digit[i]+'、'+$obj.eq(i).find('.topic_type').find("option:selected").text()+'(共'+topic_count+'题,'+score_sum+'分)</p>';
  704. html+='<p>';
  705. while (topic_count>0){
  706. html+=topic_num+',';
  707. topic_num++;
  708. topic_count--;
  709. }
  710. html+='</p>';
  711. }
  712. $('#examModal').find('.class-modal-body').html(html);
  713. // console.log(html);
  714. });
  715. $('.class-modal-body')
  716. .on('click','.avg',function(){
  717. var total_score=$('input[name=total_score]').val();
  718. var topic_count=$('.topic_score').length;
  719. if(total_score==0 || total_score==''){
  720. layer.msg('请填写题目总分!');
  721. }else{
  722. var avg_score=total_score/topic_count;
  723. if(checkFloat(avg_score)==false){
  724. $('.avg_result').html('无法平均分配');
  725. $('.avg_result').addClass('red');
  726. }else{
  727. $('.avg_result').html('');
  728. for(var i=1;i<=topic_count;i++){
  729. $('.topic_score').val(avg_score);
  730. }
  731. }
  732. }
  733. })
  734. .on('change','.total_score',function(){
  735. $(this).val($(this).val().replace(/[^\d+|\.]/g,""));
  736. if(checkFloat($(this).val())==false){
  737. layer.msg('分数设置不正确!');
  738. $(this).val(0);
  739. }
  740. if( $(this).val()!=''){
  741. $(this).val(parseInt($(this).val()));
  742. }
  743. $('.topic_score').val(0);
  744. $('#topic_error').html('');
  745. })
  746. .on('change','.topic_score',function(){
  747. $(this).val($(this).val().replace(/[^\d+|\.]/g,""));
  748. if(checkFloat($(this).val())==false){
  749. layer.msg('分数设置不正确!');
  750. $(this).val(0);
  751. }
  752. if( $(this).val()!=''){
  753. $(this).val(parseFloat($(this).val()));
  754. }
  755. var sum=0;
  756. for(var i=0;i<$('.topic_score').length;i++){
  757. if($('.topic_score').eq(i).val()!=''){
  758. sum+=parseFloat($('.topic_score').eq(i).val());
  759. }
  760. }
  761. $('.total_score').val(sum);
  762. });
  763. $('.topic_area')
  764. .on('click','.icon-add',function(){
  765. $obj=create_topic_type_select_obj();
  766. if(!$obj){
  767. layer.msg('没有可用题型!');
  768. }else{
  769. $(this).closest('.topic_type_select').before($obj);
  770. }
  771. })
  772. .on('mouseover','.icon-del',function(){
  773. $(this).css('background','url(/images/u436.png) left center no-repeat');
  774. $(this).css('background-size','18px 18px');
  775. })
  776. .on('mouseout','.icon-del',function(){
  777. $(this).css('background','url(/images/u434.png) left center no-repeat');
  778. $(this).css('background-size','18px 18px');
  779. })
  780. .on('click','.icon-del',function(){
  781. $obj=$(this).closest('.topic_type_select');
  782. if($('.topic_type_select').length>1){
  783. layer.msg('您确定要删除该题型吗?', {
  784. time: 0,
  785. btn: ['确定', '取消'],
  786. yes: function(index){
  787. layer.close(index);
  788. selected_type.splice(selected_type.indexOf($obj.find('.topic_type').val()),1);
  789. $obj.remove();
  790. }
  791. });
  792. }
  793. })
  794. .on('change','input[name=topic_count]',function(){
  795. $(this).val($(this).val().replace(/[^\d+|\.]/g,""));
  796. if( $(this).val()!=''){
  797. $(this).val(parseInt($(this).val()));
  798. }
  799. if($(this).val()>100){
  800. $(this).val(0);
  801. }
  802. $(this).closest('.topic_type_select').find('.score_list').val(''); //修改试题数量,分值清空
  803. $(this).closest('.topic_type_select').find('.score').html('共-分');
  804. $('#topic_error').html('');
  805. })
  806. .on('click','.up_score',function(){
  807. $obj=$(this).closest('.topic_type_select');
  808. $topic_num=parseInt($obj.find('.topic_count').val());
  809. $('input[name=topic_type_index]').val($obj.index());
  810. var start_topic_num=0;
  811. for(var i=0;i<$obj.index();i++){
  812. topic_count_befor=parseInt($('.topic_type_select').eq(i).find('.topic_count').val());
  813. start_topic_num+=topic_count_befor;
  814. }
  815. var ScoreArr=[];
  816. var score_list=$obj.find('.score_list').val();
  817. var total_score=$obj.find('.score_sum').val();
  818. if(score_list!=''){
  819. ScoreArr=score_list.split(',');
  820. }
  821. if($topic_num==0 || $topic_num==''){
  822. layer.msg('请填写题目数量!');
  823. }else{
  824. classModal.style.display = 'block';
  825. $('#classModal').find('.class-modal-body').html('');
  826. $('#classModal').find('.class-modal-body').html('');
  827. if(ScoreArr.length>0){
  828. var html='<p><span>总分:</span><input type="text" class="total_score" name="total_score" value="'+total_score+'" /><button class="avg">平均分配</button><span class="avg_result"></span></p>';
  829. for(var i=0;i<$topic_num;i++){
  830. html+='<p><span>第'+(start_topic_num+i+1)+'题:</span><input type="text" class="topic_score" name="total_score_'+(i+1)+'" value="'+ScoreArr[i]+'" /></p>';
  831. }
  832. }else{
  833. var html='<p><span>总分:</span><input type="text" class="total_score" name="total_score" /><button class="avg">平均分配</button><span class="avg_result"></span></p>';
  834. for(var i=0;i<$topic_num;i++){
  835. html+='<p><span>第'+(start_topic_num+i+1)+'题:</span><input type="text" value="0" class="topic_score" name="total_score_'+(i+1)+'" /></p>';
  836. }
  837. }
  838. $('#classModal').find('.class-modal-body').html(html);
  839. }
  840. })
  841. .on('change','.topic_type',function () {
  842. var select_topic_type=$(this).val();
  843. var this_index=$('.topic_type').index(this);
  844. for(var i=0;i<$('.topic_type').length;i++){
  845. if(i==this_index){
  846. continue;
  847. }
  848. if(select_topic_type==$('.topic_type').eq(i).val()){
  849. layer.msg('该题型已存在,请重新选择!');
  850. $(this).val(0);
  851. return false;
  852. }
  853. }
  854. if($.inArray(select_topic_type,selected_type)==-1){
  855. selected_type.push(select_topic_type);
  856. }
  857. //console.log(selected_type);
  858. });
  859. function selectTeacher($teacher_id){
  860. for(var i=0;i<$('.sel-option').length;i++){
  861. if($('.sel-option').eq(i).attr('id')==$teacher_id){
  862. $('.sel-option').eq(i).click();
  863. }
  864. }
  865. }
  866. function createTopicType(data,first){
  867. if(first==1){
  868. $obj=$('.topic_type_select').eq(0);
  869. $obj.find('.topic_count').val(data['count']);
  870. $obj.find('.score_list').val(data['score_list']);
  871. $obj.find('.score_sum').val(data['total_score']);
  872. $obj.find('.score').html('共'+data['total_score']+'分');
  873. $obj.find('.topic_type').val(data['type']);
  874. selected_type.push(String(data['type']));
  875. }else{
  876. $obj=$('.topic_type_select').eq(0).clone();
  877. $obj.find('.topic_count').val(data['count']);
  878. $obj.find('.score_list').val(data['score_list']);
  879. $obj.find('.score_sum').val(data['total_score']);
  880. $obj.find('.score').html('共'+data['total_score']+'分');
  881. $obj.find('.topic_type').val(data['type']);
  882. selected_type.push(String(data['type']));
  883. }
  884. $('.add_topic_type').before($obj);
  885. }
  886. //恢复教师选择//恢复题型选择
  887. var editTopicData=[];
  888. <?php
  889. if(isset($paper['teacher_id'])){
  890. echo 'selectTeacher("'.$paper['teacher_id'].'");';
  891. }
  892. if(isset($paper['topic']) && $paper['topic']){
  893. $num=1;
  894. foreach($paper['topic'] as $key=>$topic){
  895. echo "editTopicData['type']=".$key.";";
  896. echo "editTopicData['count']=".$topic['count'].";";
  897. echo "editTopicData['total_score']=".$topic['total_score'].";";
  898. echo "editTopicData['score_list']='".implode(',',$topic['score'])."';";
  899. echo "createTopicType(editTopicData,".$num.");";
  900. $num++;
  901. }
  902. }
  903. ?>
  904. function checkFloat(num){
  905. num=String(num);
  906. arr=num.split(".");
  907. //console.log(arr[1]);
  908. if(arr[1]==undefined){
  909. return true;
  910. }else if(arr[1]==5){
  911. return true;
  912. }
  913. return false;
  914. }
  915. });
  916. </script>