thirdview_under_line.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  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:#2977ff;}
  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="必填" 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" source="0">
  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 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 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 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 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 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 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 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 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" readonly class='core datetimepicker8' style="width: 100px;" name="examDate" />
  311. </div>
  312. <div id="examDate"></div>
  313. </div>
  314. </div>
  315. <input name="type" value="" type="hidden"/>
  316. <input name="teacherId" value="0" type="hidden"/>
  317. <input name="markType" value="3" 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. </form>
  322. <div class="mcp-form-list mcp-fl-btns clearfix">
  323. <input type="button" value="确定" class="mcp-sure-btn" id="createThird" active="true">
  324. <input type="button" value="返回" class="mcp-back-btn">
  325. </div>
  326. </div>
  327. <div class="confirmbox-mask" style="display: none" id="classModal">
  328. <div class="class-modal">
  329. <i class="icon icon-close">关闭</i>
  330. <div class="class-modal-head">修改分值</div>
  331. <div class="class-modal-body">
  332. <p><span>总分:</span> <input type="text" name="total_score" /><button class="avg">平均分配</button><span>无法平均分配</span></p>
  333. </div>
  334. <p class="class_btn">
  335. <input type="hidden" name="topic_type_index" value="0">
  336. <button type="button" class="save_score">确定</button>
  337. </p>
  338. </div>
  339. </div>
  340. <div class="confirmbox-mask" style="display: none" id="examModal">
  341. <div class="class-modal">
  342. <i class="icon icon-close">关闭</i>
  343. <div class="class-modal-head">试卷预览</div>
  344. <div class="class-modal-body">
  345. </div>
  346. <p class="class_btn">
  347. <button type="button" class="exam-close">确定</button>
  348. </p>
  349. </div>
  350. </div>
  351. </div>
  352. <script>
  353. $(document).ready(function(){
  354. $('.datetimepicker8').datetimepicker({
  355. onGenerate:function( ct ){
  356. $(this).find('.xdsoft_date').toggleClass('xdsoft_disabled');
  357. $(this).find('.xdsoft_today').removeClass('xdsoft_disabled');
  358. },
  359. format:'Y-m-d',
  360. formatDate:'Y-m-d',
  361. minDate:'-1970/01/2',
  362. maxDate:'+1970/01/2',
  363. //minDate: '-<?php echo date('Y-m-d', strtotime('Yesterday')); ?>',
  364. timepicker:false
  365. });
  366. //选择考试时间
  367. //选择教材题源
  368. var subjects = <?php echo json_encode($teacherSubjectNames); ?>;
  369. var textbooks = <?php echo json_encode($teacherSubjectMaterialNames); ?>;
  370. for(var key in subjects){
  371. $(".choose-grade").append('<option value="'+ key +'">'+ subjects[key] +'</option>');
  372. }
  373. $(".choose-grade").change(function(){
  374. var obj = $(this);
  375. var val = obj.val();
  376. var child = $('.choose-book');
  377. child.html('<option value="0">选择教材</option>');
  378. for (var key in textbooks) {
  379. if (key == val) {
  380. child.html('');
  381. for (var name in textbooks[key]) {
  382. child.append('<option value="'+ [name] +'">'+ textbooks[key][name] +'</option>');
  383. }
  384. }
  385. }
  386. });
  387. //返回
  388. $('.mcp-back-btn').click(function(){
  389. location.href="<?php echo Yii::app()->createUrl('third/index?list_type=1')?>";
  390. });
  391. $('input[name="examName"]').keydown(function(event){
  392. $('#examName-error').html("");
  393. });
  394. //阅卷方式
  395. $('.markType').click(function(){
  396. var markType = $(this).attr('value');
  397. if(markType){
  398. $('#markType-error').html("");
  399. }
  400. $('input[name="markType"]').val(markType);
  401. });
  402. //选择教师
  403. $('.sel-option').click(function(){
  404. var teacher_id = $(this).attr('id');
  405. if(teacher_id){
  406. $('#choose-error').html("");
  407. }
  408. $('input[name="teacherId"]').val(teacher_id);
  409. $.post(
  410. "<?php echo Yii::app()->createUrl('third/ajaxchangeclasses')?>",
  411. {teacher_id:teacher_id},
  412. function(result){
  413. if(result.error){
  414. $('#choose-error').html(result.error);
  415. }else{
  416. $.each(result.class_arr_select,function(k,v){
  417. $('.g'+v.grade).html($('.g'+v.grade).html()+"<span grade='"+v.grade+"' classid='"+v.class_id+"'>"+v.class_name+"</span>");
  418. });
  419. $.each(result.class_arr_noselect,function(k,v){
  420. $('#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>');
  421. });
  422. }
  423. },
  424. 'json'
  425. );
  426. });
  427. var gradeArr=[];
  428. <?php
  429. if(Yii::app()->params['grade_list']){
  430. foreach (Yii::app()->params['grade_list'] as $param){
  431. echo "gradeArr.push('".$param['id']."');";
  432. }
  433. }
  434. ?>
  435. //切换年级
  436. $('.a-years,.a-province,.paper-type > span, .grade-sel ul li').click(function(){
  437. if(!$(this).hasClass('active')){
  438. $(this).addClass('active').siblings().removeClass('active');
  439. var grade=$(this).attr("grade");
  440. for(var i=0;i<=gradeArr.length;i++){
  441. if(gradeArr[i]==grade){
  442. $("#grade"+grade).show();
  443. $('.g'+grade).show();
  444. $('.g'+grade).attr('status',1);
  445. }else{
  446. $("#grade"+gradeArr[i]).hide();
  447. $(".g"+gradeArr[i]).hide();
  448. $(".g"+gradeArr[i]).attr('status',0);
  449. }
  450. }
  451. }
  452. });
  453. //添加班级
  454. $(".bj-sel ul").on("click","li", function(){
  455. $('#classIds-error').html("");
  456. $(this).find('.judge-sel').addClass('active');
  457. $(this).remove();
  458. var grade = $(this).attr('grade');
  459. $('.g'+grade).append('<span grade="'+$(this).attr("grade")+'" classid="'+$(this).attr("classid")+'">'+$(this).text()+'</span>');
  460. });
  461. //移除班级
  462. $('.sel-classes').delegate('span','click',function(){
  463. $(this).remove();
  464. $("#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>');
  465. });
  466. if ($('.sel-classes > span').length > 0){
  467. for (var i = 0;i < $('.sel-classes > span').length; i++){
  468. for (var k = 0;k < $('.bjs-lis').length; k++){
  469. if ($('.bjs-lis').eq(k).text().trim()==$('.sel-classes > span').eq(i).text().trim()) {
  470. $('.bjs-lis').eq(k).find('.judge-sel').addClass('active');
  471. }
  472. }
  473. }
  474. }
  475. $('.mcp-radio-sel').click(function(){
  476. if (!$(this).find('.sel-btn').hasClass('select')) {
  477. $(this).find('.sel-btn').addClass('select');
  478. $(this).siblings().find('.sel-btn').removeClass('select');
  479. var type = $(this).find('.sel-btn').attr('value');
  480. if(type){
  481. $('#type-error').html("");
  482. }
  483. $('input[name="type"]').val(type);
  484. }
  485. });
  486. $('.grade-sel ul li').click(function(){
  487. $(this).addClass('active').siblings().removeClass('active');
  488. });
  489. // $('.judge-sel').on('click',function(){
  490. // alert(1);
  491. // if (!$(this).hasClass('active')) {
  492. // $(this).addClass('active');
  493. // $('.sel-classes').append('<span>'+$(this).closest('.bjs-lis').text()+'</span>');
  494. // } else {
  495. // $(this).removeClass('active');
  496. // for (var i = 0;i < $('.sel-classes > span').length; i++) {
  497. // console.log($('.sel-classes > span').eq(i).text());
  498. // if ($('.sel-classes > span').eq(i).text().trim() == $(this).closest('.bjs-lis').text().trim()){
  499. // $('.sel-classes > span').eq(i).remove();
  500. // }
  501. // }
  502. // }
  503. // });
  504. $('.sel-classes > span').click(function(){
  505. $(this).remove();
  506. for (var i = 0;i < $('.bjs-lis').length; i++) {
  507. if ($('.bjs-lis').eq(i).text().trim()==$(this).text().trim()){
  508. $('.bjs-lis').eq(i).find('.judge-sel').removeClass('active');
  509. }
  510. }
  511. });
  512. // 下拉列表模拟
  513. $('.inp-text').click(function(){
  514. if ($(this).next().is(':hidden')){
  515. $(this).next().show();
  516. } else {
  517. $(this).next().hide();
  518. }
  519. });
  520. // 点下拉列表选项
  521. $('.select-con li').click(function(){
  522. $(this).closest('.select-con').hide();
  523. $(this).closest('.mcp-form-detail').find('.inp-text').text($(this).text());
  524. });
  525. // 点击空白处下拉列表消失
  526. $(document).click(function(e){
  527. var targetNode = $(e.target).closest(".inp-text");
  528. if (targetNode.length>0){
  529. return;
  530. }else{
  531. $(".select-con").hide();
  532. }
  533. });
  534. $("body").delegate("#createThird[active='true']", "click", function(e) {
  535. var classIds='';
  536. $(".sel-classes[status=1]").children("span").each(function(){
  537. classIds += $(this).attr('classid')+",";
  538. });
  539. $('input[name="classIds"]').val(classIds);
  540. var error = new Array();
  541. var classIds = $('input[name="classIds"]').val();
  542. var examName = $('input[name="examName"]').val();
  543. var type = $('input[name="type"]').val();
  544. var teacherId = $('input[name="teacherId"]').val();
  545. var examDate = $("input[name='examDate']").val();
  546. if(examName == "" || examName == null){
  547. $('#examName-error').html('请指定考试名称');
  548. error.push('没有指定考试名称');
  549. }else{
  550. $('#examName-error').html('');
  551. }
  552. //检测试题设置
  553. $select_obj=$('.topic_type_select');
  554. $isFoundErr=false;
  555. $topicData=[];
  556. for (var i=0;i<$select_obj.length;i++){
  557. 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'){
  558. $isFoundErr=true;
  559. break;
  560. }else{
  561. $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()+'"}');
  562. }
  563. }
  564. if($isFoundErr){
  565. error.push('试题类型数量或分数未设置');
  566. $('#topic_error').html('试题数量或分数未设置');
  567. }else{
  568. $('input[name=topic_data]').val('['+$topicData.join(',')+']');
  569. $('#topic_error').html('');
  570. }
  571. if(type == "" || type == null){
  572. $('#type-error').html('请指定考试类型');
  573. error.push('没有指定考试类型');
  574. }else{
  575. $('#type-error').html('');
  576. }
  577. if(teacherId == '0' || teacherId == null){
  578. $('#choose-error').html('请指定阅卷老师');
  579. error.push('没有指定阅卷老师');
  580. }else{
  581. $('#choose-error').html('');
  582. if(classIds == "" || classIds == null){
  583. $('#classIds-error').html('请指定考试班级');
  584. error.push('没有指定考试班级');
  585. }else{
  586. $('#classIds-error').html('');
  587. }
  588. }
  589. if (examDate == '') {
  590. $('#examDate').html('请设置考试日期');
  591. error.push('请设置考试日期');
  592. } else if (examDate < '<?php echo date('Y-m-d'); ?>') {
  593. //$('#examDate').html('考试日期设置错误');
  594. //error.push('考试日期设置错误');
  595. }else{
  596. $('#examDate').html('');
  597. }
  598. if(error.length == 0){
  599. $(this).attr("active","false");
  600. //$(".saveForm").submit();
  601. //改为ajax提交
  602. index=layer.msg('正在保存,请稍候......',{time:9000000});
  603. $.ajax({
  604. url:'<?php echo Yii::app()->createUrl('third/createthirdunderline')?>',
  605. method:'POST',
  606. dataType:'json',
  607. data:$(".saveForm").serialize(),
  608. success:function (res) {
  609. layer.close(index);
  610. if(res.status==1){
  611. window.location="<?php echo Yii::app()->createUrl('third/index?list_type=1')?>";
  612. }else{
  613. layer.msg(res.msg);
  614. }
  615. }
  616. });
  617. }
  618. });
  619. //================题型选择部分操作代码=================================
  620. var selected_type=[]; //已选题型
  621. $('.topic_type_select').eq(0).find('.topic_type').val(1);
  622. $('.topic_type_select').eq(0).find('.topic_type').attr('source',1);
  623. selected_type.push('1');
  624. function create_topic_type_select_obj(){
  625. $obj=$('.topic_type_select').eq(0).clone();
  626. $obj.find('.topic_count').val(0);
  627. $obj.find('.score_list').val('');
  628. $obj.find('.score_sum').val(0);
  629. $obj.find('.score').html('共-分');
  630. var option=$obj.find('.topic_type option');
  631. var is_have_topic_type=false;
  632. for(var i=0;i<option.length;i++){
  633. if(option.eq(i).attr('value')==0 || $.inArray(option.eq(i).attr('value'),selected_type)!=-1){
  634. continue;
  635. }else{
  636. $obj.find('.topic_type').val(option.eq(i).attr('value'));
  637. selected_type.push(option.eq(i).attr('value'));
  638. $obj.find('.topic_type').attr('source',option.eq(i).attr('value'));
  639. is_have_topic_type=true;
  640. break;
  641. }
  642. }
  643. if(is_have_topic_type){
  644. return $obj;
  645. }else{
  646. return false;
  647. }
  648. }
  649. $('.add_topic_type').click(function () {
  650. $obj=create_topic_type_select_obj();
  651. console.log(selected_type);
  652. if(!$obj){
  653. layer.msg('没有可用题型!');
  654. }else{
  655. $(this).before($obj);
  656. }
  657. });
  658. $('.icon-close,.exam-close').click(function(){
  659. $(this).closest('.confirmbox-mask').hide();
  660. });
  661. $('.save_score').click(function(){
  662. var topicScore=[];
  663. for(var i=1;i<=$('.topic_score').length;i++){
  664. if($('input[name=total_score_'+i+']').val()==0 || $('input[name=total_score_'+i+']').val()==''){
  665. layer.msg('请填写题目分数!');
  666. return false;
  667. }
  668. topicScore.push($('input[name=total_score_'+i+']').val());
  669. }
  670. var obj_index=$('input[name=topic_type_index]').val();
  671. $('.topic_type_select').eq(obj_index).find('.score_list').val(topicScore.join(','));
  672. $('.topic_type_select').eq(obj_index).find('.score').html('共'+$('input[name=total_score]').val()+'分');
  673. $('.topic_type_select').eq(obj_index).find('.score_sum').val($('input[name=total_score]').val());
  674. classModal.style.display = 'none';
  675. });
  676. //试卷预览
  677. $('.preview').click(function(){
  678. $obj=$('.topic_type_select');
  679. for(var i=0;i<$obj.length;i++){
  680. if($obj.eq(i).find('.topic_count').val()==0 ){
  681. layer.msg('试题数量或分数未设置!');
  682. return false;
  683. }
  684. }
  685. $('#examModal').show();
  686. var html='';
  687. var digit=['一','二','三','四','五','六','七','八','九','十','十一','十二','十三','十四','十五','十六','十七','十八','十九','二十','二十一'];
  688. var topic_num=1;
  689. for(var i=0;i<$obj.length;i++){
  690. topic_count=parseInt($obj.eq(i).find('.topic_count').val());
  691. score_sum=$obj.eq(i).find('.score_sum').val();
  692. html+='<p>'+ digit[i]+'、'+$obj.eq(i).find('.topic_type').find("option:selected").text()+'(共'+topic_count+'题,'+score_sum+'分)</p>';
  693. html+='<p>';
  694. while (topic_count>0){
  695. html+=topic_num+',';
  696. topic_num++;
  697. topic_count--;
  698. }
  699. html+='</p>';
  700. }
  701. $('#examModal').find('.class-modal-body').html(html);
  702. });
  703. $('input[name=examName]').change(function () {
  704. if($(this).val().length>30){
  705. layer.msg('考试名称不能超过30字');
  706. $(this).val('');
  707. }
  708. });
  709. $('.class-modal-body')
  710. .on('click','.avg',function(){
  711. var total_score=$('input[name=total_score]').val();
  712. var topic_count=$('.topic_score').length;
  713. if(total_score==0 || total_score==''){
  714. layer.msg('请填写题目总分!');
  715. }else{
  716. var avg_score=total_score/topic_count;
  717. if(checkFloat(avg_score)==false){
  718. $('.avg_result').html('无法平均分配');
  719. $('.avg_result').addClass('red');
  720. }else{
  721. $('.avg_result').html('');
  722. for(var i=1;i<=topic_count;i++){
  723. $('.topic_score').val(avg_score);
  724. }
  725. }
  726. }
  727. })
  728. .on('change','.total_score',function(){
  729. $(this).val($(this).val().replace(/[^\d+|\.]/g,""));
  730. if(checkFloat($(this).val())==false){
  731. layer.msg('分数设置不正确!');
  732. $(this).val(0);
  733. }
  734. if( $(this).val()!=''){
  735. $(this).val(parseFloat($(this).val()));
  736. }
  737. $('.topic_score').val(0);
  738. $('#topic_error').html('');
  739. })
  740. .on('change','.topic_score',function(){
  741. $(this).val($(this).val().replace(/[^\d+|\.]/g,""));
  742. if(checkFloat($(this).val())==false){
  743. layer.msg('分数设置不正确!');
  744. $(this).val(0);
  745. }
  746. if( $(this).val()!=''){
  747. $(this).val(parseFloat($(this).val()));
  748. }
  749. var sum=0;
  750. for(var i=0;i<$('.topic_score').length;i++){
  751. if($('.topic_score').eq(i).val()!=''){
  752. sum+=parseFloat($('.topic_score').eq(i).val());
  753. }
  754. }
  755. $('.total_score').val(sum);
  756. $('#topic_error').html('');
  757. });
  758. $('.topic_area')
  759. .on('click','.icon-add',function(){
  760. $obj=create_topic_type_select_obj();
  761. if(!$obj){
  762. layer.msg('没有可用题型!');
  763. }else{
  764. $(this).closest('.topic_type_select').before($obj);
  765. }
  766. })
  767. .on('mouseover','.icon-del',function(){
  768. $(this).css('background','url(/images/u436.png) left center no-repeat');
  769. $(this).css('background-size','18px 18px');
  770. })
  771. .on('mouseout','.icon-del',function(){
  772. $(this).css('background','url(/images/u434.png) left center no-repeat');
  773. $(this).css('background-size','18px 18px');
  774. })
  775. .on('click','.icon-del',function(){
  776. $obj=$(this).closest('.topic_type_select');
  777. if($('.topic_type_select').length>1){
  778. layer.msg('您确定要删除该题型吗?', {
  779. time: 0,
  780. btn: ['确定', '取消'],
  781. yes: function(index){
  782. layer.close(index);
  783. selected_type.splice(selected_type.indexOf($obj.find('.topic_type').val()),1);
  784. $obj.remove();
  785. }
  786. });
  787. }
  788. })
  789. .on('change','input[name=topic_count]',function(){
  790. $(this).val($(this).val().replace(/[^\d+]/g,""));
  791. if( $(this).val()!=''){
  792. $(this).val(parseInt($(this).val()));
  793. }
  794. if($(this).val()>100){
  795. $(this).val(0);
  796. }
  797. $(this).closest('.topic_type_select').find('.score_list').val(''); //修改试题数量,分值清空
  798. $(this).closest('.topic_type_select').find('.score').html('共-分');
  799. $('#topic_error').html('');
  800. })
  801. .on('click','.up_score',function(){
  802. $obj=$(this).closest('.topic_type_select');
  803. $topic_num=parseInt($obj.find('.topic_count').val());
  804. var start_topic_num=0;
  805. for(var i=0;i<$obj.index();i++){
  806. topic_count_befor=parseInt($('.topic_type_select').eq(i).find('.topic_count').val());
  807. start_topic_num+=topic_count_befor;
  808. }
  809. $('input[name=topic_type_index]').val($obj.index());
  810. var ScoreArr=[];
  811. var score_list=$obj.find('.score_list').val();
  812. var total_score=$obj.find('.score_sum').val();
  813. if(score_list!=''){
  814. ScoreArr=score_list.split(',');
  815. }
  816. if($topic_num==0 || $topic_num==''){
  817. layer.msg('请填写题目数量!');
  818. }else{
  819. classModal.style.display = 'block';
  820. $('#classModal').find('.class-modal-body').html('');
  821. $('#classModal').find('.class-modal-body').html('');
  822. if(ScoreArr.length>0){
  823. 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>';
  824. for(var i=0;i<$topic_num;i++){
  825. html+='<p><span>第'+(start_topic_num+i+1)+'题:</span><input type="text" class="topic_score" name="total_score_'+(i+1)+'" value="'+ScoreArr[i]+'" /></p>';
  826. }
  827. }else{
  828. var html='<p><span>总分:</span><input type="text" class="total_score" name="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" value="0" class="topic_score" name="total_score_'+(i+1)+'" /></p>';
  831. }
  832. }
  833. $('#classModal').find('.class-modal-body').html(html);
  834. }
  835. })
  836. .on('change','.topic_type',function () {
  837. var source=$(this).attr('source');
  838. var select_topic_type=$(this).val();
  839. var this_index=$('.topic_type').index(this);
  840. var new_selected_type=[];
  841. for(var i=0;i<$('.topic_type').length;i++){
  842. new_selected_type.push($('.topic_type').eq(i).val());
  843. if(i==this_index){
  844. continue;
  845. }
  846. if(select_topic_type==$('.topic_type').eq(i).val()){
  847. layer.msg('该题型已存在,请重新选择!');
  848. $(this).val(source);
  849. return false;
  850. }
  851. }
  852. selected_type=new_selected_type;
  853. $(this).attr('source',select_topic_type);
  854. console.log(selected_type);
  855. });
  856. function checkFloat(num){
  857. num=String(num);
  858. arr=num.split(".");
  859. //console.log(arr[1]);
  860. if(arr[1]==undefined){
  861. return true;
  862. }else if(arr[1]==5){
  863. return true;
  864. }
  865. return false;
  866. }
  867. });
  868. </script>