thirdview_section.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  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. <style>
  7. #choose-error{color: #FF0000;}
  8. #examName-error{color: #FF0000;}
  9. #classIds-error{color: #FF0000;}
  10. #type-error{color: #FF0000;}
  11. #markType-error{color: #FF0000;}
  12. #subject-error{color: #FF0000;}
  13. #examDate{color: #FF0000;}
  14. </style>
  15. <div class="main-content-inner">
  16. <!-- 导航栏开始-->
  17. <?php include(Yii::app()->basePath.'/views/layouts/view_navigation.php');?>
  18. <!-- 导航栏结束-->
  19. <div class="test-data">
  20. <div class="page-content">
  21. <div class="mcp-title">
  22. <span class="active">第1步、考试基本信息</span>
  23. <span><i class="horizontal-line"></i></span>
  24. <span>第2步、关联在线答题卡</span>
  25. </div>
  26. <form class="saveForm">
  27. <div class="mcp-main-con">
  28. <div class="mcp-form-list clearfix">
  29. <div class="mcp-form-menu fl">试卷名称</div>
  30. <div class="mcp-form-detail fl"><input type="text" placeholder="必填" class="test-paper-name" name="examName"></div>
  31. <div id="examName-error"></div>
  32. </div>
  33. <div class="mcp-form-list clearfix">
  34. <div class="mcp-form-menu fl">选择教材</div>
  35. <div class="mcp-form-detail fl clearfix">
  36. <select name="textbookId" id="textbookId" class="fl choose-subject choose-book">
  37. <option value="0">请选择教材</option>
  38. <?php
  39. if($textbookTree){
  40. foreach ($textbookTree as $item){
  41. echo '<option value="'.$item['textbook_id'].'">'.$item['textbook_name'].'</option>';
  42. }
  43. }
  44. ?>
  45. </select>
  46. </div>
  47. <div id="subject-error"></div>
  48. </div>
  49. <div class="mcp-form-list clearfix">
  50. <div class="mcp-form-menu fl">考试类型</div>
  51. <div class="mcp-form-detail fl clearfix">
  52. <div class="mcp-radio-sel fl">
  53. <span class="sel-btn select examType" value="1"></span>
  54. <span>周考</span>
  55. </div>
  56. <div class="mcp-radio-sel fl">
  57. <span class="sel-btn examType" value="2"></span>
  58. <span>单元考</span>
  59. </div>
  60. <div class="mcp-radio-sel fl">
  61. <span class="sel-btn examType" value="3"></span>
  62. <span>月考</span>
  63. </div>
  64. <div class="mcp-radio-sel fl">
  65. <span class="sel-btn examType" value="4"></span>
  66. <span>联考</span>
  67. </div>
  68. <div class="mcp-radio-sel fl">
  69. <span class="sel-btn examType" value="5"></span>
  70. <span>期中考试</span>
  71. </div>
  72. <div class="mcp-radio-sel fl">
  73. <span class="sel-btn examType" value="6"></span>
  74. <span>期末考试</span>
  75. </div>
  76. <div class="mcp-radio-sel fl">
  77. <span class="sel-btn examType" value="7"></span>
  78. <span>模拟考</span>
  79. </div>
  80. <div class="mcp-radio-sel fl">
  81. <span class="sel-btn examType" value="8"></span>
  82. <span>冲刺考</span>
  83. </div>
  84. <div class="clear"></div>
  85. <div class="mcp-radio-sel fl">
  86. <span class="sel-btn examType" value="9"></span>
  87. <span>测验(适用于非正式考试)</span>
  88. </div>
  89. </div>
  90. <div id="type-error"></div>
  91. </div>
  92. <div class="mcp-form-list clearfix">
  93. <div class="mcp-form-menu fl">主阅卷员</div>
  94. <div class="mcp-form-detail fl">
  95. <div class="inp-text pointer">选择阅卷员</div>
  96. <ul class="select-con tac" style="max-height: 300px;overflow: auto">
  97. <?php foreach($teacher_arr as $t):?>
  98. <li class="sel-option pointer" id="<?php echo $t['teacher_id']?>"><?php echo $t['teacher_name']?></li>
  99. <?php endforeach;?>
  100. </ul>
  101. </div>
  102. <div id="choose-error"></div>
  103. </div>
  104. <div class="mcp-form-list clearfix">
  105. <div class="mcp-form-menu fl">考试班级</div>
  106. <div class="mcp-form-detail fl">
  107. <div class="test-classes-desc">默认已选我执教的班级(<span class="">单击移除</span>)<span id="classIds-error"></span></div>
  108. <?php
  109. if(isset(Yii::app()->params['grade_config'])){
  110. $first=true;
  111. foreach (Yii::app()->params['grade_config'] as $id =>$item){
  112. if($first){
  113. $first=false;
  114. echo '<div class="sel-classes g'.$id.'" status="1"></div>';
  115. }else{
  116. echo '<div class="sel-classes g'.$id.'" style="display: none;" status="0"></div>';
  117. }
  118. }
  119. }
  120. ?>
  121. <div class="clearfix">
  122. <div class="grade-sel fl">
  123. <div class="grade-top">年级</div>
  124. <ul>
  125. <?php
  126. if(isset(Yii::app()->params['grade_config'])){
  127. foreach (Yii::app()->params['grade_config'] as $id =>$item){
  128. echo '<li grade="'.$id.'">'.$item['grade_name'].'</li>';
  129. }
  130. }
  131. ?>
  132. </ul>
  133. </div>
  134. <?php
  135. if(isset(Yii::app()->params['grade_config'])){
  136. $first=true;
  137. foreach (Yii::app()->params['grade_config'] as $id =>$item){
  138. if($first){
  139. $first=false;
  140. echo '<div class="bj-sel fl" id="grade'.$id.'">';
  141. echo '<div class="class-top">班级</div>';
  142. echo '<ul></ul>';
  143. echo '</div>';
  144. }else{
  145. echo '<div class="bj-sel fl" id="grade'.$id.'" style="display: none;">';
  146. echo '<div class="class-top">班级</div>';
  147. echo '<ul></ul>';
  148. echo '</div>';
  149. }
  150. }
  151. }
  152. ?>
  153. </div>
  154. </div>
  155. </div>
  156. <div class="mcp-form-list clearfix">
  157. <div class="mcp-form-menu fl">阅卷方式</div>
  158. <div class="mcp-form-detail fl clearfix" id ="markType">
  159. <div class="mcp-radio-sel fl">
  160. <span class="sel-btn select markType" value="3"></span>
  161. <span class ="markType" value="3">班级混合阅卷</span>
  162. </div>
  163. <div class="mcp-radio-sel fl">
  164. <span class="sel-btn markType" value="4"></span>
  165. <span class="markType" value="4">班级单独阅卷</span>
  166. </div>
  167. <div class="mcp-radio-sel fl">
  168. <span class="sel-btn markType" value="0"></span>
  169. <span class="markType" value="0">线下阅卷(暂只支持在线答题卡)</span>
  170. </div>
  171. <div id="markType-error"></div>
  172. </div>
  173. </div>
  174. <div class="mcp-form-list clearfix">
  175. <div class="mcp-form-menu fl">考试时间</div>
  176. <div class="mcp-form-detail fl clearfix">
  177. <input type="text" class='core datetimepicker8' style="width: 100px;" name="examDate" />
  178. </div>
  179. <div id="examDate"></div>
  180. </div>
  181. </div>
  182. <input name="type" value="1" type="hidden"/>
  183. <input name="teacherId" value="0" type="hidden"/>
  184. <input name="markType" value="3" type="hidden"/>
  185. <input name="classIds" value="0" type="hidden"/>
  186. <input name="subjectId" value="<?php echo Yii::app()->session['session_duoxueke_subject_id'];?>" type="hidden"/>
  187. <input name="tplIndex" value="1050" type="hidden"/>
  188. </form>
  189. <!--<button id="createThird">确定</button>-->
  190. <!-- <div class="mcp-form-list mcp-fl-btns clearfix">
  191. <input type="button" value="保存并返回" class="mcp-sure-btn" id="createThird" active="true">
  192. <input type="button" value="确定" class="mcp-sure-btn" active="true">
  193. <input type="button" value="返回" class="mcp-back-btn" >
  194. </div> -->
  195. <div class="template-flag-box">
  196. <a href="javascript:;" id="createThird" active="true">保存并返回</a>
  197. <!-- <a href="javascript:;" id="goNext" active="true">保存并下一步</a> -->
  198. <a href="javascript:;" id="goNextNew" active="true">保存并下一步</a>
  199. <a href="javascript:;" id="goBack" class="gray" active="true">放弃并返回</a>
  200. <!--<a href="javascript:;" class="template-flag">创建答题卡</a>-->
  201. </div>
  202. </div>
  203. </div>
  204. </div>
  205. <script>
  206. $(document).ready(function(){
  207. var gradeArr=[];
  208. <?php
  209. if(Yii::app()->params['grade_list']){
  210. foreach (Yii::app()->params['grade_list'] as $param){
  211. echo "gradeArr.push('".$param['id']."');";
  212. }
  213. }
  214. ?>
  215. var teacher_name = '';
  216. var islocal = ~location.href.indexOf('xg.com');
  217. var baseUrl = '';
  218. if(islocal){
  219. // baseUrl ='http://192.168.1.51/index.php'
  220. baseUrl ='/index.php'
  221. }else {
  222. baseUrl =''
  223. }
  224. var saveFormData ="";
  225. function isReturn(){
  226. // var isCardReturn = localStorage.getItem('isCardReturn');
  227. // var isCardReturn = ~document.referrer.indexOf('online/third');
  228. var locationUrl = window.location.href;
  229. let isCardReturn = locationUrl.indexOf('isCardReturn')
  230. if(isCardReturn>-1){
  231. $('.test-data').hide();
  232. $('.relation-answer-card').show();
  233. saveFormData = JSON.parse(localStorage.getItem('testFormData'));
  234. }else{
  235. var locationUrl = window.location.href;
  236. localStorage.setItem('referrerUrl',JSON.stringify(locationUrl));
  237. }
  238. }
  239. isReturn();
  240. $('.datetimepicker8').datetimepicker({
  241. onGenerate:function( ct ){
  242. $(this).find('.xdsoft_date').toggleClass('xdsoft_disabled');
  243. $(this).find('.xdsoft_today').removeClass('xdsoft_disabled');
  244. },
  245. format:'Y-m-d',
  246. formatDate:'Y-m-d',
  247. minDate:'-1970/01/2',
  248. maxDate:'+1970/01/2',
  249. // minDate: '-<?php echo date('Y-m-d', strtotime('Yesterday')); ?>',
  250. timepicker:false
  251. });
  252. //返回
  253. $('.mcp-back-btn').click(function(){
  254. location.href="<?php echo Yii::app()->createUrl('third/index')?>";
  255. });
  256. $('input[name="examName"]').keydown(function(event){
  257. $('#examName-error').html("");
  258. });
  259. //阅卷方式
  260. $('.markType').click(function(){
  261. var markType = $(this).attr('value');
  262. if(markType){
  263. $('#markType-error').html("");
  264. }
  265. $('input[name="markType"]').val(markType);
  266. });
  267. //考试类型
  268. $('.examType').click(function(){
  269. var type = $(this).attr('value');
  270. if(type){
  271. $('#type-error').html("");
  272. }
  273. $('input[name="type"]').val(type);
  274. });
  275. //选择教师
  276. $('.sel-option').click(function(){
  277. var teacher_id = $(this).attr('id');
  278. teacher_name = $(this).text();
  279. if(teacher_id){
  280. $('#choose-error').html("");
  281. }
  282. $('input[name="teacherId"]').val(teacher_id);
  283. $.post(
  284. "<?php echo Yii::app()->createUrl('third/ajaxchangeclasses')?>",
  285. {teacher_id:teacher_id},
  286. function(result){
  287. if(result.error){
  288. $('#choose-error').html(result.error);
  289. }else{
  290. $.each(result.class_arr_select,function(k,v){
  291. $('.g'+v.grade).html($('.g'+v.grade).html()+"<span grade='"+v.grade+"' classid='"+v.class_id+"'>"+v.class_name+"</span>");
  292. });
  293. $.each(result.class_arr_noselect,function(k,v){
  294. $('#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>');
  295. });
  296. }
  297. },
  298. 'json'
  299. );
  300. });
  301. //切换年级
  302. $('.a-years,.a-province,.paper-type > span, .grade-sel ul li').click(function(){
  303. if(!$(this).hasClass('active')){
  304. $(this).addClass('active').siblings().removeClass('active');
  305. var grade=$(this).attr("grade");
  306. for(var i=0;i<=gradeArr.length;i++){
  307. if(gradeArr[i]==grade){
  308. $("#grade"+grade).show();
  309. $('.g'+grade).show();
  310. $('.g'+grade).attr('status',1);
  311. }else{
  312. $("#grade"+gradeArr[i]).hide();
  313. $(".g"+gradeArr[i]).hide();
  314. $(".g"+gradeArr[i]).attr('status',0);
  315. }
  316. }
  317. }
  318. });
  319. //添加班级
  320. $(".bj-sel ul").on("click","li", function(){
  321. $('#classIds-error').html("");
  322. $(this).find('.judge-sel').addClass('active');
  323. $(this).remove();
  324. var grade = $(this).attr('grade');
  325. $('.g'+grade).append('<span grade="'+$(this).attr("grade")+'" classid="'+$(this).attr("classid")+'">'+$(this).text()+'</span>');
  326. });
  327. //移除班级
  328. $('.sel-classes').delegate('span','click',function(){
  329. $(this).remove();
  330. $("#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>');
  331. });
  332. if ($('.sel-classes > span').length > 0){
  333. for (var i = 0;i < $('.sel-classes > span').length; i++){
  334. for (var k = 0;k < $('.bjs-lis').length; k++){
  335. if ($('.bjs-lis').eq(k).text().trim()==$('.sel-classes > span').eq(i).text().trim()) {
  336. $('.bjs-lis').eq(k).find('.judge-sel').addClass('active');
  337. }
  338. }
  339. }
  340. }
  341. $('.mcp-radio-sel').click(function(){
  342. if (!$(this).find('.sel-btn').hasClass('select')) {
  343. $(this).find('.sel-btn').addClass('select');
  344. $(this).siblings().find('.sel-btn').removeClass('select');
  345. }
  346. });
  347. $('.grade-sel ul li').click(function(){
  348. $(this).addClass('active').siblings().removeClass('active');
  349. });
  350. // $('.judge-sel').on('click',function(){
  351. // alert(1);
  352. // if (!$(this).hasClass('active')) {
  353. // $(this).addClass('active');
  354. // $('.sel-classes').append('<span>'+$(this).closest('.bjs-lis').text()+'</span>');
  355. // } else {
  356. // $(this).removeClass('active');
  357. // for (var i = 0;i < $('.sel-classes > span').length; i++) {
  358. // console.log($('.sel-classes > span').eq(i).text());
  359. // if ($('.sel-classes > span').eq(i).text().trim() == $(this).closest('.bjs-lis').text().trim()){
  360. // $('.sel-classes > span').eq(i).remove();
  361. // }
  362. // }
  363. // }
  364. // });
  365. $('.sel-classes > span').click(function(){
  366. $(this).remove();
  367. for (var i = 0;i < $('.bjs-lis').length; i++) {
  368. if ($('.bjs-lis').eq(i).text().trim()==$(this).text().trim()){
  369. $('.bjs-lis').eq(i).find('.judge-sel').removeClass('active');
  370. }
  371. }
  372. });
  373. // 下拉列表模拟
  374. $('.inp-text').click(function(){
  375. if ($(this).next().is(':hidden')){
  376. $(this).next().show();
  377. } else {
  378. $(this).next().hide();
  379. }
  380. });
  381. // 点下拉列表选项
  382. $('.select-con li').click(function(){
  383. $(this).closest('.select-con').hide();
  384. $(this).closest('.mcp-form-detail').find('.inp-text').text($(this).text());
  385. });
  386. // 点击空白处下拉列表消失
  387. $(document).click(function(e){
  388. var targetNode = $(e.target).closest(".inp-text");
  389. if (targetNode.length>0){
  390. return;
  391. }else{
  392. $(".select-con").hide();
  393. }
  394. });
  395. function saveThirdForm(e,btnType) {
  396. var classIds='';
  397. $(".sel-classes[status=1]").children("span").each(function(){
  398. classIds += $(this).attr('classid')+",";
  399. });
  400. $('input[name="classIds"]').val(classIds);
  401. var error = new Array();
  402. var classIds = $('input[name="classIds"]').val();
  403. var examName = $('input[name="examName"]').val();
  404. var type = $('input[name="type"]').val();
  405. var teacherId = $('input[name="teacherId"]').val();
  406. var markType = $("#markType").find(".select").attr("value");
  407. var subjectId = $('input[name=subjectId]').val();
  408. var examDate = $("input[name='examDate']").val();
  409. var textbookId = $("#textbookId").val();
  410. if(examName == "" || examName == null){
  411. $('#examName-error').html('请指定考试名称');
  412. error.push('没有指定考试名称');
  413. }else{
  414. $('#examName-error').html('');
  415. }
  416. if(textbookId == 0 || textbookId == null){
  417. $('#subject-error').html('请选择教材版本');
  418. error.push('请选择教材版本');
  419. }else{
  420. $('#examName-error').html('');
  421. }
  422. if(type == "" || type == null){
  423. $('#type-error').html('请指定考试类型');
  424. error.push('没有指定考试类型');
  425. }else{
  426. $('#type-error').html('');
  427. }
  428. if(teacherId == '0' || teacherId == null){
  429. $('#choose-error').html('请指定阅卷老师');
  430. error.push('没有指定阅卷老师');
  431. }else{
  432. $('#choose-error').html('');
  433. if(classIds == "" || classIds == null){
  434. $('#classIds-error').html('请指定考试班级');
  435. error.push('没有指定考试班级');
  436. }else{
  437. $('#classIds-error').html('');
  438. }
  439. }
  440. if(!markType){
  441. $('#markType-error').html('请指定阅卷方式');
  442. error.push('没有指定阅卷方式');
  443. }else{
  444. $('#markType-error').html('');
  445. }
  446. if (examDate == '') {
  447. $('#examDate').html('请设置考试日期');
  448. error.push('请设置考试日期');
  449. } else if (examDate < '<?php echo date('Y-m-d'); ?>') {
  450. // $('#examDate').html('考试日期设置错误');
  451. // error.push('考试日期设置错误');
  452. }else{
  453. $('#examDate').html('');
  454. }
  455. console.log(error);
  456. if(error.length == 0){
  457. // debugger
  458. $(e.target).attr("active","false");
  459. saveFormData = {
  460. examName:examName,
  461. subjectId:subjectId,
  462. textbookId:$('select[name="textbookId"]').val(),
  463. tpl_index:$('input[name="tplIndex"]').val(),
  464. examDate:examDate,
  465. type:type,
  466. teacherId:teacherId,
  467. markType:markType,
  468. classIds:classIds,
  469. };
  470. localStorage.setItem('testFormData',JSON.stringify(saveFormData))
  471. var formData = new FormData();
  472. for(var k in saveFormData){
  473. formData.append(k,saveFormData[k])
  474. }
  475. $.ajax({
  476. url:'<?php echo $this->createUrl('third/createthirdForNext')?>',
  477. method: 'POST',
  478. processData: false,
  479. contentType: false,
  480. dataType: 'json',
  481. data: formData,
  482. success: function (data) {
  483. if(data.status ==1){
  484. saveFormData.examGroupId = data.examGroupId;
  485. saveFormData.teacher_name = teacher_name;
  486. var addGrade = 0;
  487. $('.grade-sel ul li').each(function(){
  488. if($(this).hasClass('active')){
  489. addGrade = $(this).attr('grade')
  490. }
  491. })
  492. saveFormData.grade = addGrade;
  493. localStorage.setItem('testFormData',JSON.stringify(saveFormData));
  494. if(btnType===1){
  495. goBack();
  496. }else if(btnType===2){
  497. $('.test-data').hide();
  498. $('.relation-answer-card').show();
  499. }else if(btnType===3){
  500. // location.href = '/index.php/third/thirdCardSecond'
  501. location.href = '/index.php/online/answersheetList/examGroupId/'+saveFormData.examGroupId+'?isThird=1&examGroupId='+saveFormData.examGroupId
  502. }
  503. }else{
  504. if(data.info){
  505. layer.msg(data.info);
  506. }else{
  507. if(data.msg){
  508. layer.msg(data.msg);
  509. }
  510. //
  511. }
  512. $(e.target).attr("active","true");
  513. }
  514. }
  515. })
  516. }
  517. }
  518. function goBack(){
  519. location.href = '/index.php/third/index'
  520. }
  521. //保存并返回
  522. $("body").delegate("#createThird[active='true']", "click", function(e) {
  523. console.log('111');
  524. saveThirdForm(e,1);
  525. });
  526. //保存并关联答题卡
  527. $("body").delegate("#goNext[active='true']", "click", function(e) {
  528. saveThirdForm(e,2);
  529. });
  530. //保存并关联答题卡
  531. $("body").delegate("#goNextNew[active='true']", "click", function(e) {
  532. saveThirdForm(e,3);
  533. });
  534. //取消并返回
  535. $("body").delegate("#goBack[active='true']", "click", function(e) {
  536. localStorage.setItem('isCardReturn',0)
  537. goBack();
  538. });
  539. });
  540. </script>
  541. <script src="/js/third/submit.js"></script>