import.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <style>
  2. .addborder{border:1px solid #ccc}
  3. .addheight{height:30px;border-radius:2px;}
  4. .addheight:focus{border-color: #66afe9;box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(102, 175, 233, 0.6);outline: 0 none;}
  5. .ace{position:relative;top:0px !important;left:0px !important;}
  6. label{font-weight:100 !important;}
  7. .diy_select{height:30px;width:260px;position:relative;font-size:12px;background:#fff;color:#000;float:left;border-radius:4px;}
  8. .diy_select:active{box-shadow:0 0 5px #66afe9;border:1px solid #66afe9}
  9. .diy_select_btn,.diy_select_txt{float:left;height:100%;line-height:30px}
  10. .diy_select,.diy_select_list{border:1px solid #ccc;}
  11. .diy_select_txt{width:200px;}
  12. .diy_select_txt,.diy_select_list li{text-indent:10px;overflow:hidden}
  13. .diy_select_btn{width:98px;background:url(/images/arrBottom.png) no-repeat center}
  14. .diy_select_list{position:absolute;top:27px;left:0px;z-index:88888;border-top:none;width:100%;display:none;_top:29px;background: #fff;max-height:300px;overflow-y:scroll;}
  15. .diy_select_list li{list-style:none;height:30px;line-height:30px;cursor:default;_background:#fff;/**padding-left: 10px;**/}
  16. .diy_select_list li.focus{background:#3399FF;color:#fff}
  17. .diy_select label{position:absolute;left:180px;width:160px;top:4px;font-size:15px;}
  18. </style>
  19. <style>
  20. /*弹出层*/
  21. .confirmbox {
  22. background: #fff;
  23. border: 1px solid #cccccc;
  24. border-radius: 3px;
  25. padding: 40px 40px 30px;
  26. text-align: center;
  27. position: fixed;
  28. left: 50%;
  29. top: 50%;
  30. transform: translate(-50%, -50%);
  31. z-index: 99;
  32. }
  33. .confirmbox-mask {
  34. background: rgba(0, 0, 0, .7);
  35. left: 0;
  36. right: 0;
  37. top: 0;
  38. bottom: 0;
  39. z-index: 99;
  40. position: fixed;
  41. }
  42. .confirmbox-mask button {
  43. border: none;
  44. background: #2977ff;
  45. width: 80px;
  46. height: 26px;
  47. border-radius: 3px;
  48. font-size: 14px;
  49. color: #fff;
  50. outline: none;
  51. cursor: pointer;
  52. }
  53. .confirmbox-mask button.save {
  54. display: block;
  55. margin: 40px auto;
  56. }
  57. .confirmbox .confirmbox-btns {
  58. margin-top: 40px;
  59. }
  60. .class-modal {
  61. width: 700px;
  62. background: #fff;
  63. // border-radius: 5px;
  64. position: absolute;
  65. top: 50%;
  66. left: 50%;
  67. transform: translate(-50%, -50%);
  68. height:420px;
  69. }
  70. .class-modal-head {
  71. font-size: 14px;
  72. background:#2977ff;
  73. color:#fff;
  74. height:25px;
  75. line-height: 25px;
  76. padding: 0 0 0 15px;
  77. }
  78. .class-modal-body {
  79. margin-top: 5px;
  80. overflow: auto;
  81. padding:15px;
  82. min-height: 340px;
  83. }
  84. .class-modal-body .classes {
  85. margin-bottom: 20px;
  86. }
  87. .class-modal-body .classes > div {
  88. display: inline-block;
  89. max-width: 640px;
  90. vertical-align: top;
  91. }
  92. .class-modal-body .classes a {
  93. text-decoration: none;
  94. display: inline-block;
  95. margin: 0 5px 5px;
  96. color: #136bfb;
  97. font-size: 14px;
  98. }
  99. .class-modal-body .classes a.active {
  100. color: #fc091b;
  101. }
  102. .class-modal .icon-close{
  103. position: absolute;
  104. right: 20px;
  105. top: 2px;
  106. color:#fff;
  107. }
  108. .c-red {
  109. color: #CC3300
  110. }
  111. .avg{
  112. margin:0 10px;
  113. }
  114. .class_btn{
  115. text-align: center;
  116. }
  117. .confirmbox-mask p{
  118. word-wrap : break-word ;
  119. }
  120. .icon-close{
  121. cursor: pointer;
  122. }
  123. .model-input{
  124. border:1px solid #ccc;
  125. padding:5px;
  126. margin-top:10px;
  127. }
  128. .model-input label{
  129. margin:0 15px;
  130. }
  131. table{margin-top:5px;}
  132. .table_list{
  133. height:250px;
  134. overflow: auto;
  135. }
  136. .upload-box{
  137. position:relative;
  138. padding-left:106px;
  139. line-height: 28px;
  140. }
  141. .upload-div,.upload-ipt{
  142. position: absolute;
  143. left:0;
  144. top:0;
  145. width:100px!important;
  146. }
  147. .upload-div{
  148. height:28px;
  149. text-align: center;
  150. background: #eee;
  151. color: #333;
  152. border-radius: 3px;
  153. border:1px solid #ccc;
  154. }
  155. .upload-div:hover{
  156. background: #69d9a7;
  157. }
  158. .upload-ipt{
  159. z-index: 2;
  160. opacity: 0;
  161. }
  162. </style>
  163. <script src="/js/jquery.validate.min.js"></script>
  164. <script type="text/javascript">
  165. jQuery(document).ready(function(){
  166. jQuery("#schoolSubmit").click(function(){
  167. var grade = $(".diy_select_txt").text();
  168. var _text = grade;
  169. var msg = '确定导入'+_text+'学生成绩吗?';
  170. obj=$(this);
  171. layer.msg(msg, {
  172. time: 0,
  173. btn: ['确定', '取消'],
  174. yes: function(index){
  175. layer.close(index);
  176. $('#classAdd').attr('action','<?php echo $this->createUrl('record/importstore');?>');
  177. obj.attr("disabled", true);
  178. jQuery("#classAdd").submit();
  179. }
  180. });
  181. });
  182. jQuery("#studentImgSubmit").click(function(){
  183. var grade = $(".diy_select_txt").text();
  184. var _text = grade;
  185. var msg = '确定导入'+_text+'学生答题图片吗?';
  186. obj=$(this);
  187. layer.msg(msg, {
  188. time: 0,
  189. btn: ['确定', '取消'],
  190. yes: function(index){
  191. layer.close(index);
  192. $('#classAdd').attr('action','<?php echo $this->createUrl('record/importStudentExcel');?>');
  193. obj.attr("disabled", true);
  194. jQuery("#classAdd").submit();
  195. }
  196. });
  197. });
  198. });
  199. </script>
  200. <div class="main-content-inner">
  201. <!-- 导航栏开始-->
  202. <?php include(Yii::app()->basePath.'/views/layouts/view_navigation.php');?>
  203. <!-- 导航栏结束-->
  204. <div class="page-content" style="margin-top:15px;">
  205. <div class="row" style="margin:0px;">
  206. <div class="col-xs-12">
  207. <!-- PAGE CONTENT BEGINS -->
  208. <form enctype="multipart/form-data" class="form-horizontal" action="<?php echo $this->createUrl('record/importstore');?>" method="post" id="classAdd">
  209. <div class="form-group">
  210. <label class="control-label col-xs-12 col-sm-3 no-padding-right">选择考试<span class="errorMessage">*</span>:</label>
  211. <div class="col-sm-9">
  212. <input type="text" name="exam_name" class="exam_name" value="<?php if(isset($exam_name)) echo $exam_name;?>" readonly><span class="choose-exam">选择考试</span>
  213. <input type="hidden" name="exam_group_id" value="<?php if(isset($exam_group_id)) echo $exam_group_id;?>" >
  214. <input type="hidden" name="exam_renew" value="<?php if(isset($renew)) {echo $renew;}else{echo 0;}?>">
  215. </div>
  216. </div>
  217. <div class="form-group">
  218. <label class="control-label col-xs-12 col-sm-3 no-padding-right">识别方式<span class="errorMessage">*</span>:</label>
  219. <div class="col-sm-9">
  220. <select name="check_field" class="check_field">
  221. <option value="student_name" <?php if(isset($check_field) && $check_field=='student_name') echo 'selected';?>>学生姓名</option>
  222. <!--<option value="userno">学号</option>-->
  223. <option value="student_card" <?php if(isset($check_field) && $check_field=='student_card') echo 'selected';?>>系统准考证号</option>
  224. <option value="school_student_card" <?php if(isset($check_field) && $check_field=='school_student_card') echo 'selected';?>>学校准考证号</option>
  225. <!-- <option value="zhixue_student_card" <?php if(isset($check_field) && $check_field=='zhixue_student_card') echo 'selected';?>>智学网准考证号</option>-->
  226. <option value="id_number" <?php if(isset($check_field) && $check_field=='id_number') echo 'selected';?>>身份证号</option>
  227. <!--<option value="student_phone">手机号</option>-->
  228. <?php
  229. if(isset($studentExtend) && $studentExtend){
  230. foreach ($studentExtend as $key=>$val){
  231. if($val['is_enable']==1){
  232. if($key==$check_field){
  233. echo '<option value="'.$key.'" selected>'.$val['field_mean'].'</option>';
  234. }else{
  235. echo '<option value="'.$key.'">'.$val['field_mean'].'</option>';
  236. }
  237. }
  238. }
  239. }
  240. ?>
  241. </select>
  242. </div>
  243. </div>
  244. <div class="form-group">
  245. <label class="control-label col-xs-12 col-sm-3 no-padding-right">模板示例<span class="errorMessage">*</span>:</label>
  246. <div class="col-sm-9">
  247. <table id="template" class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable">
  248. <tr>
  249. <th width="1"></th>
  250. <th>A</th>
  251. <th>B</th>
  252. <th>C</th>
  253. <th>D</th>
  254. <th>E</th>
  255. <th>F</th>
  256. <th>G</th>
  257. <th>H</th>
  258. <th class="hide custom_field_no">I</th>
  259. </tr>
  260. <tr>
  261. <th>1</th>
  262. <th>姓名</th>
  263. <th>班级</th>
  264. <th class="hide custom_field"></th>
  265. <th>科目总分</th>
  266. <th>第一题</th>
  267. <th>第二题</th>
  268. <th>第三题</th>
  269. <th>第四题</th>
  270. <th>第五题</th>
  271. </tr>
  272. <tr>
  273. <th>2</th>
  274. <th>苏苏</th>
  275. <th>高二1班</th>
  276. <th class="hide custom_field_value"></th>
  277. <th>90</th>
  278. <th>5</th>
  279. <th>0</th>
  280. <th>5</th>
  281. <th>0</th>
  282. <th>10</th>
  283. </tr>
  284. </table>
  285. <p class="c-red">注:下载模板表格后请根据选择的识别方式,按对应的模板示例匹配标题信息</p>
  286. </div>
  287. </div>
  288. <div class="form-group">
  289. <label class="control-label col-xs-12 col-sm-3 no-padding-right">上传Excel<span class="errorMessage">*</span>:</label>
  290. <div class="col-sm-9 upload-box">
  291. <div class="col-xs-10 upload-div">选择文件</div>
  292. <span class="upload-exname">请选择文件</span>
  293. <input type="file" id="exname" name="exname" class="col-xs-10 upload-ipt" />
  294. </div>
  295. </div>
  296. <script>
  297. $(function(){
  298. $("#exname").change(function(e){
  299. $(".upload-exname").html(e.currentTarget.files[0].name)
  300. })
  301. })
  302. </script>
  303. <div class="form-group">
  304. <label class="control-label col-xs-12 col-sm-3 no-padding-right">&nbsp;</label>
  305. <div class="col-sm-9">
  306. <div style="margin-top:8px" class="col-sm-9"><a href="/assets/data/importScore/import_score_example_name.xls" class="download_template">下载Excel表格示例</a> <span class="c-red">请根据模板示例调整Excel格式</span></div>
  307. </div>
  308. </div>
  309. <div class="clearfix form-actions">
  310. <div class="col-md-offset-3 col-md-9">
  311. <button class="btn btn-success btn-sm" type="button" id="schoolSubmit">
  312. <i class="ace-icon fa fa-check bigger-110"></i>
  313. 导入
  314. </button>
  315. </div>
  316. </div>
  317. <?php if(isset(Yii::app()->session['testFlag']) && Yii::app()->session['testFlag']==1):?>
  318. <div class="form-group">
  319. <label class="control-label col-xs-12 col-sm-3 no-padding-right">上传作答图片成绩<span class="errorMessage">*</span>:</label>
  320. <div class="col-sm-9 upload-box">
  321. <div class="col-xs-10 upload-div">选择文件</div>
  322. <span class="upload-ywy-exname">请选择文件</span>
  323. <input type="file" id="exnameYwy" name="exnameYwy" class="col-xs-10 upload-ipt" />
  324. </div>
  325. </div>
  326. <script>
  327. $(function(){
  328. $("#exnameYwy").change(function(e){
  329. $(".upload-ywy-exname").html(e.currentTarget.files[0].name)
  330. })
  331. })
  332. </script>
  333. <div class="form-group">
  334. <label class="control-label col-xs-12 col-sm-3 no-padding-right">&nbsp;</label>
  335. <div class="col-sm-9">
  336. <div style="margin-top:8px" class="col-sm-9"><a href="/assets/data/import_ywy_score_example.xls" >下载Excel表格示例</a> </div>
  337. </div>
  338. </div>
  339. <div class="clearfix form-actions">
  340. <div class="col-md-offset-3 col-md-9">
  341. <button class="btn btn-success btn-sm" type="button" id="studentImgSubmit">
  342. <i class="ace-icon fa fa-check bigger-110"></i>
  343. 导入
  344. </button>
  345. </div>
  346. </div>
  347. <?php endif;?>
  348. </form>
  349. <!-- PAGE CONTENT ENDS -->
  350. </div>
  351. </div>
  352. </div>
  353. </div>
  354. <!-- 弹窗 -->
  355. <div class="confirmbox-mask" style="display: none" id="fieldModal">
  356. <div class="class-modal">
  357. <i class="icon close_1 icon-close">×</i>
  358. <div class="class-modal-head">选择考试</div>
  359. <form id="examSelect">
  360. <div class="class-modal-body">
  361. <select name="exam_type" class="exam_type">
  362. <option value="1">校本课程平台考试</option>
  363. <option value="2">第三方考试</option>
  364. </select>
  365. <select name="subject" class="subject">
  366. <?php
  367. if(isset(Yii::app()->params['subjectId']) && Yii::app()->params['subjectId']){
  368. foreach (Yii::app()->params['subjectId'] as $key=>$val){
  369. if($key==6 || $key==51) continue;
  370. echo '<option value="'.$key.'">'.$val.'</option>';
  371. }
  372. }
  373. ?>
  374. </select>
  375. <select name="grade" class="grade">
  376. <option value="0">年级</option>
  377. <?php
  378. if(Yii::app()->params['grade_list']){
  379. foreach (Yii::app()->params['grade_list'] as $id=> $val){
  380. echo '<option value="'.$id.'" >'.$val['grade_name'].'</option>';
  381. }
  382. }
  383. ?>
  384. </select>
  385. <select name="class" class="class" style="width: 100px">
  386. <option value="0">班级</option>
  387. </select>
  388. <input type="text" name="keyword" value="" placeholder="">
  389. <button class="search_exam">搜索</button>
  390. <div class="table_list">
  391. <table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable">
  392. </table>
  393. </div>
  394. <span class="notice c-red hide">部分学生已扫描/上传成绩。若需要重新上传,请勾选“覆盖并重新导入成绩”。否则只导入没有成绩的学生</span>
  395. </div>
  396. <p class="class_btn">
  397. <input type="checkbox" value="1" name="renew">覆盖并重新导入成绩
  398. <button type="button" class="setting_sumbit">确定</button>
  399. </p>
  400. </form>
  401. </div>
  402. </div>
  403. <script src="/js/xsgl.js"></script>
  404. <script>
  405. $(function(){
  406. changeField();
  407. $('#classAdd')[0].reset();
  408. $('#examSelect')[0].reset();
  409. $('.choose-exam,.exam_name').click(function(){
  410. $('#fieldModal').fadeIn();
  411. });
  412. $('.close_1').click(function(){
  413. closeModal();
  414. });
  415. $('.check_field').change(function(){
  416. var field_value=$(this).val();
  417. var field_text=$(this).find("option:selected").text();
  418. if(field_value=='student_name'){
  419. $('.custom_field').addClass('hide');
  420. $('.custom_field_value').addClass('hide');
  421. $('.custom_field_no').addClass('hide');
  422. $('.custom_field').html('');
  423. $('.download_template').attr('href','/assets/data/importScore/import_score_example_name.xls');
  424. }else{
  425. $('.custom_field').removeClass('hide');
  426. $('.custom_field_value').removeClass('hide');
  427. $('.custom_field_no').removeClass('hide');
  428. $('.custom_field').html(field_text);
  429. $('.download_template').attr('href','/assets/data/importScore/import_score_example_student_card.xls');
  430. }
  431. });
  432. function changeField(){
  433. var field_value=$('.check_field').val();
  434. var field_text=$('.check_field').find("option:selected").text();
  435. if(field_value=='student_name'){
  436. $('.custom_field').addClass('hide');
  437. $('.custom_field_value').addClass('hide');
  438. $('.custom_field_no').addClass('hide');
  439. $('.custom_field').html('');
  440. }else{
  441. $('.custom_field').removeClass('hide');
  442. $('.custom_field_value').removeClass('hide');
  443. $('.custom_field_no').removeClass('hide');
  444. $('.custom_field').html(field_text);
  445. }
  446. }
  447. $('.search_exam').click(function(){
  448. var exam_type=$('.exam_type').val();
  449. var subject=$('.subject').val();
  450. var grade=$('.grade').val();
  451. var class_id=$('.class').val();
  452. var keyword=$('input[name=keyword]').val();
  453. $.ajax({
  454. url:'<?php echo $this->createUrl('record/ajaxsearchexam')?>',
  455. type:'POST',
  456. dataType:'json',
  457. data:{'exam_type':exam_type,'subject':subject,'grade':grade,'class':class_id,'keyword':keyword},
  458. success:function(res){
  459. if(res.status==1){
  460. var html='';
  461. html+='<tr>';
  462. html+='<th>选择</th>';
  463. html+='<th>考试名称</th>';
  464. html+='<th>年级</th>';
  465. html+='<th>考试日期</th>';
  466. html+='<th>考试班级</th>';
  467. html+='<th>已导入成绩人数</th>';
  468. html+='</tr>';
  469. $.each(res.list,function(i,n){
  470. html+='<tr>';
  471. html+='<td><input type="radio" name="exam" value="'+n.exam_group_id+'"></td>';
  472. html+='<td>'+n.name+'</td>';
  473. html+='<td>'+n.grade+'</td>';
  474. html+='<td>'+n.exam_date+'</td>';
  475. html+='<td>'+n.class_count+'</td>';
  476. html+='<td>'+n.student_score_count+'</td>';
  477. html+='</tr>';
  478. });
  479. $('#dynamic-table').html(html);
  480. }
  481. }
  482. });
  483. return false;
  484. });
  485. $('.grade').change(function(){
  486. var subjectId=$('.subject').val();
  487. $.post("<?php echo $this->createUrl('print/getGradeClass'); ?>", {"grade": $('.grade').val(),"subjectId":subjectId}, function(data) {
  488. var m = JSON.parse(data);
  489. if(m.status==0)
  490. {
  491. var html = '<option value="0">请选择班级</option>';
  492. $(".class").html(html);
  493. }else{
  494. var html = '<option value="0">请选择班级</option>';
  495. $.each(m.message,function(i,n){
  496. html+='<option value="'+ n.class_id+'">'+ n.class_name+'</option>';
  497. });
  498. $(".class").html(html);
  499. }
  500. });
  501. });
  502. $('.setting_sumbit').click(function(){
  503. var exam_group_id=$('input[name=exam]:checked').val();
  504. var exam_name=$('input[name=exam]:checked').parent().next().html();
  505. if(exam_group_id==undefined){
  506. layer.msg('请选择一场考试');
  507. return false;
  508. }
  509. if($('input[name=renew]').is(':checked')){
  510. $('input[name=exam_renew]').val(1);
  511. console.log(111);
  512. }else{
  513. $('input[name=exam_renew]').val(0);
  514. }
  515. $('input[name=exam_name]').val(exam_name);
  516. $('input[name=exam_group_id]').val(exam_group_id);
  517. closeModal();
  518. return false;
  519. });
  520. $('#dynamic-table')
  521. .on('click','input[name=exam]',function(){
  522. var student_count=$(this).closest('tr').find('td:last').html();
  523. console.log(student_count);
  524. if(student_count>0){
  525. $('.notice').removeClass('hide');
  526. }else{
  527. $('.notice').addClass('hide');
  528. }
  529. })
  530. function closeModal(){
  531. $('#fieldModal').fadeOut();
  532. $('.notice').addClass('hide');
  533. }
  534. })
  535. </script>