1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000 |
- <script src="/js/jquery.datetimepicker.js"></script>
- <link rel="stylesheet" href="/fonts/fpdf/iconfont.css" />
- <link rel="stylesheet" href="/css/modelCreatePaper.css" />
- <link rel="stylesheet" href="/css/jquery.datetimepicker.css" />
- <style>
- #choose-error{color: #FF0000;}
- #examName-error{color: #FF0000;}
- #classIds-error{color: #FF0000;}
- #type-error{color: #FF0000;}
- #markType-error{color: #FF0000;}
- #subject-error{color: #FF0000;}
- #examDate{color: #FF0000;}
- .icon-add,.icon-del{
- width:20px;height:25px;display: inline-block;
- margin-bottom:-5px;
- }
- .icon-add{
- background:url("/images/timg.jpg") left center no-repeat ;
- background-size:18px 18px;
- margin-left:20px;
- }
- .icon-del{background: url("/images/u434.png") left center no-repeat;
- background-size:18px 18px;
- position: relative;
- top: 2px;
- }
- .tag {
- display: inline-block;
- padding: 3px 8px;
- border-radius: 3px;
- color: #ffffff;
- font-size: 12px;
- cursor: pointer;
- }
- .bg-green {
- background: #2977ff;
- }
- .topic_type_select{margin-bottom: 5px;}
- .topic_type_select input{height:26px;}
- .topic_type_select select{height:26px;}
- .border-box{
- border:1px solid #ccc;
- display: inline-block;
- margin-right:20px;
- height:34px;
- }
- .score{color:#333;margin-right:20px;}
- .up_score{color:#619aff;}
- .confirmbox {
- background: #fff;
- border: 1px solid #cccccc;
- border-radius: 3px;
- padding: 40px 40px 30px;
- text-align: center;
- position: fixed;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- z-index: 99;
- }
- .confirmbox-mask {
- background: rgba(0, 0, 0, .7);
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- z-index: 99;
- position: fixed;
- }
- button {
- border: none;
- background: #2977ff;
- width: 80px;
- height: 26px;
- border-radius: 3px;
- font-size: 14px;
- color: #fff;
- outline: none;
- cursor: pointer;
- }
- button.save {
- display: block;
- margin: 40px auto;
- }
- .confirmbox .confirmbox-btns {
- margin-top: 40px;
- }
- .class-modal {
- width: 500px;
- min-height: 400px;
- background: #fff;
- // border-radius: 5px;
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- }
- .class-modal-head {
- font-size: 14px;
- background:#2977ff;
- color:#fff;
- height:25px;
- line-height: 25px;
- padding: 0 0 0 15px;
- }
- .class-modal-body {
- margin-top: 20px;
- max-height: 300px;
- overflow: auto;
- margin-left:50px;
- }
- .class-modal-body .classes {
- margin-bottom: 20px;
- }
- .class-modal-body .classes > div {
- display: inline-block;
- max-width: 640px;
- vertical-align: top;
- }
- .class-modal-body .classes a {
- text-decoration: none;
- display: inline-block;
- margin: 0 5px 5px;
- color: #136bfb;
- font-size: 14px;
- }
- .class-modal-body .classes a.active {
- color: #fc091b
- }
- .class-modal .icon-close{
- position: absolute;
- right: 20px;
- top: 2px;
- color:#fff;
- }
- .c-red {
- color: #CC3300
- }
- .avg{
- margin:0 10px;
- }
- .class_btn{
- text-align: center;
- }
- .confirmbox-mask p{
- word-wrap : break-word ;
- }
- .template-flag-box{padding-left:150px;}
- .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}
- .class-modal-body p span{display: inline-block;width:60px;}
- .class_btn{position: fixed;bottom: 2%;text-align: center;width:500px;}
- .topic_type,.topic_count{
- vertical-align:middle;
- }
- </style>
- <div class="main-content-inner">
- <!-- 导航栏开始-->
- <?php include(Yii::app()->basePath.'/views/layouts/view_navigation.php');?>
- <!-- 导航栏结束-->
- <div class="page-content">
- <div class="mcp-title">模板组卷</div>
- <form class="saveForm" action="<?php echo Yii::app()->createUrl('third/createthirdunderline')?>" method="post" enctype="multipart/form-data">
- <div class="mcp-main-con">
- <div class="mcp-form-list clearfix">
- <div class="mcp-form-menu fl">试卷名称</div>
- <div class="mcp-form-detail fl"><input type="text" placeholder="必填" value="<?php echo $paper['paper_name']?>" class="test-paper-name" name="examName"></div>
- <div id="examName-error"></div>
- </div>
- <div class="mcp-form-list clearfix">
- <div class="mcp-form-menu fl">试卷格式</div>
- <div class="mcp-form-detail topic_area fl">
- <div class="topic_type_select">
- <div class="border-box">
- <select class="topic_type">
- <option value="0">请选择题型</option>
- <?php
- if(isset(Yii::app()->params['third_paper_logic'][Yii::app()->session['session_duoxueke_subject_id']])){
- foreach (Yii::app()->params['third_paper_logic'][Yii::app()->session['session_duoxueke_subject_id']] as $logic=>$type){
- echo '<option value="'.$logic.'">'.$type.'</option>';
- }
- }else{
- foreach (Yii::app()->params['third_paper_logic'][3] as $logic=>$type){
- echo '<option value="'.$logic.'">'.$type.'</option>';
- }
- }
- ?>
- </select>
- <input type="text" class="core topic_count" name="topic_count" value="0">小题
- <span class="icon-add"></span>
- <span class="icon-del"></span>
- </div>
- <span class="score">共--分</span>
- <span class="up_score">修改分值</span>
- <input type="hidden" class="score_list" name="score_list" value="">
- <input type="hidden" class="score_sum" name="score_sum" value="0">
- </div>
- <span class="tag bg-green add_topic_type">新增题型</span>
- <span class="tag bg-green preview">试卷预览</span>
- <span id="topic_error" class="c-red"></span>
- </div>
- </div>
- <div class="mcp-form-list clearfix">
- <div class="mcp-form-menu fl">选择考试类型</div>
- <div class="mcp-form-detail fl clearfix">
- <div class="mcp-radio-sel fl">
- <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==1){echo 'select'; }?> examType" value="1"></span>
- <span class="examType" value="1">周考</span>
- </div>
- <div class="mcp-radio-sel fl">
- <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==2){echo 'select'; }?> examType" value="2"></span>
- <span class="examType" value="2">单元考</span>
- </div>
- <div class="mcp-radio-sel fl">
- <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==3){echo 'select'; }?> examType" value="3"></span>
- <span class="examType" value="3">月考</span>
- </div>
- <div class="mcp-radio-sel fl">
- <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==4){echo 'select'; }?> examType" value="4"></span>
- <span class="examType" value="4">联考</span>
- </div>
- <div class="mcp-radio-sel fl">
- <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==5){echo 'select'; }?> examType" value="5"></span>
- <span class="examType" value="5">期中考试</span>
- </div>
- <div class="mcp-radio-sel fl">
- <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==6){echo 'select'; }?> examType" value="6"></span>
- <span class="examType" value="6">期末考试</span>
- </div>
- <div class="mcp-radio-sel fl">
- <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==7){echo 'select'; }?> examType" value="7"></span>
- <span class="examType" value="7">模拟考</span>
- </div>
- <div class="mcp-radio-sel fl">
- <span class="sel-btn <?php if(isset($paper['type']) && $paper['type']==8){echo 'select'; }?> examType" value="8"></span>
- <span class="examType" value="8">冲刺考</span>
- </div>
- </div>
- <div id="type-error"></div>
- </div>
- <div class="mcp-form-list clearfix">
- <div class="mcp-form-menu fl">主考教师</div>
- <div class="mcp-form-detail fl">
- <div class="inp-text pointer">选择主考教师</div>
- <ul class="select-con tac">
- <!--<li class="sel-option pointer" id="1">高三一班</li>-->
- <?php foreach($teacher_arr as $t):?>
- <li class="sel-option pointer" id="<?php echo $t['teacher_id']?>"><?php echo $t['teacher_name']?></li>
- <?php endforeach;?>
- <!--<li class="sel-option pointer" id="2">高三二班</li>-->
- <!--<li class="sel-option pointer" id="3">高三三班</li>-->
- </ul>
- </div>
- <div id="choose-error"></div>
- </div>
- <div class="mcp-form-list clearfix">
- <div class="mcp-form-menu fl">考试班级</div>
- <div class="mcp-form-detail fl">
- <div class="test-classes-desc">默认选中考试班级(<span class="">单击移除</span>)<span id="classIds-error"></span></div>
- <?php
- if(isset(Yii::app()->params['grade_config'])){
- $first=true;
- foreach (Yii::app()->params['grade_config'] as $id =>$item){
- if($first){
- $first=false;
- echo '<div class="sel-classes g'.$id.'" status="1"></div>';
- }else{
- echo '<div class="sel-classes g'.$id.'" style="display: none;" status="0"></div>';
- }
- }
- }
- ?>
- <div class="clearfix">
- <div class="grade-sel fl">
- <div class="grade-top">年级</div>
- <ul>
- <?php
- if(isset(Yii::app()->params['grade_config'])){
- foreach (Yii::app()->params['grade_config'] as $id =>$item){
- echo '<li grade="'.$id.'">'.$item['grade_name'].'</li>';
- }
- }
- ?>
- </ul>
- </div>
- <?php
- if(isset(Yii::app()->params['grade_config'])){
- $first=true;
- foreach (Yii::app()->params['grade_config'] as $id =>$item){
- if($first){
- $first=false;
- echo '<div class="bj-sel fl" id="grade'.$id.'">';
- echo '<div class="class-top">班级</div>';
- echo '<ul></ul>';
- echo '</div>';
- }else{
- echo '<div class="bj-sel fl" id="grade'.$id.'" style="display: none;">';
- echo '<div class="class-top">班级</div>';
- echo '<ul></ul>';
- echo '</div>';
- }
- }
- }
- ?>
- </div>
- </div>
- </div>
- <div class="mcp-form-list clearfix">
- <div class="mcp-form-menu fl">考试时间</div>
- <div class="mcp-form-detail fl clearfix">
- <input type="text" value="<?php if(isset($paper['exam_date'])){echo $paper['exam_date'];} ?>" class='core datetimepicker8' style="width: 100px;" name="examDate" />
- </div>
- <div id="examDate"></div>
- </div>
- </div>
- <input name="type" value="<?php if(isset($paper['type'])){ echo $paper['type'];}else{ echo 1;}?>" type="hidden"/>
- <input name="teacherId" value="<?php if(isset($paper['teacher_id'])){ echo $paper['teacher_id'];}else{ echo 0;}?>" type="hidden"/>
- <input name="markType" value="0" type="hidden"/>
- <input name="classIds" value="0" type="hidden"/>
- <input name="topic_data" value="" type="hidden">
- <input name="subjectId" value="<?php echo Yii::app()->session['session_duoxueke_subject_id']?>" type="hidden">
- <input name="exam_group_id" value="<?php echo $examgroupid;?>" type="hidden">
- </form>
- <div class="mcp-form-list mcp-fl-btns clearfix">
- <input type="button" value="确定" class="mcp-sure-btn" id="createThird" active="true">
- <input type="button" value="返回" class="mcp-back-btn">
- </div>
- </div>
- <div class="confirmbox-mask" style="display: none" id="classModal">
- <div class="class-modal">
- <i class="icon icon-close">关闭</i>
- <div class="class-modal-head">修改分值</div>
- <div class="class-modal-body">
- <p>总分: <input type="text" name="total_score" /><button class="avg">平均分配</button><span>无法平均分配</span></p>
- </div>
- <p class="class_btn">
- <input type="hidden" name="topic_type_index" value="0">
- <button type="button" class="save_score">确定</button>
- </p>
- </div>
- </div>
- <div class="confirmbox-mask" style="display: none" id="examModal">
- <div class="class-modal">
- <i class="icon icon-close">关闭</i>
- <div class="class-modal-head">试卷预览</div>
- <div class="class-modal-body">
- </div>
- <p class="class_btn">
- <button type="button" class="exam-close">确定</button>
- </p>
- </div>
- </div>
- </div>
- <script>
- $(document).ready(function(){
- $('.datetimepicker8').datetimepicker({
- onGenerate:function( ct ){
- $(this).find('.xdsoft_date').toggleClass('xdsoft_disabled');
- $(this).find('.xdsoft_today').removeClass('xdsoft_disabled');
- },
- format:'Y-m-d',
- formatDate:'Y-m-d',
- minDate:'-1970/01/2',
- maxDate:'+1970/01/2',
- // minDate: '-<?php echo date('Y-m-d', strtotime('Yesterday')); ?>',
- timepicker:false
- });
- //选择考试时间
- //选择教材题源
- var subjects = <?php echo json_encode($teacherSubjectNames); ?>;
- var textbooks = <?php echo json_encode($teacherSubjectMaterialNames); ?>;
- for(var key in subjects){
- $(".choose-grade").append('<option value="'+ key +'">'+ subjects[key] +'</option>');
- }
- $(".choose-grade").change(function(){
- var obj = $(this);
- var val = obj.val();
- var child = $('.choose-book');
- child.html('<option value="0">选择教材</option>');
- for (var key in textbooks) {
- if (key == val) {
- child.html('');
- for (var name in textbooks[key]) {
- child.append('<option value="'+ [name] +'">'+ textbooks[key][name] +'</option>');
- }
- }
- }
- });
- //返回
- $('.mcp-back-btn').click(function(){
- location.href="<?php echo Yii::app()->createUrl('third/index?list_type=1')?>";
- });
- $('input[name="examName"]').keydown(function(event){
- $('#examName-error').html("");
- });
- //阅卷方式
- $('.markType').click(function(){
- var markType = $(this).attr('value');
- if(markType){
- $('#markType-error').html("");
- }
- $('input[name="markType"]').val(markType);
- });
- //选择教师
- var firstLoad=true;
- //判断已选班级id
- var selectedClassId=[];
- <?php
- if(isset($paper['class_id']) && $paper['class_id']){
- foreach ($paper['class_id'] as $cid){
- echo 'selectedClassId.push("'.$cid.'");';
- }
- }
- ?>
- $('.sel-option').click(function(){
- var teacher_id = $(this).attr('id');
- if(teacher_id){
- $('#choose-error').html("");
- }
- $('input[name="teacherId"]').val(teacher_id);
- $.post(
- "<?php echo Yii::app()->createUrl('third/ajaxchangeclasses')?>",
- {teacher_id:teacher_id,selectedClassId:selectedClassId},
- function(result){
- if(result.error){
- $('#choose-error').html(result.error);
- }else{
- $.each(result.class_arr_select,function(k,v){
- $('.g'+v.grade).html($('.g'+v.grade).html()+"<span grade='"+v.grade+"' classid='"+v.class_id+"'>"+v.class_name+"</span>");
- });
- $.each(result.class_arr_noselect,function(k,v){
- $('#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>');
- });
- }
- },
- 'json'
- );
- });
- var gradeArr=[];
- <?php
- if(Yii::app()->params['grade_list']){
- foreach (Yii::app()->params['grade_list'] as $param){
- echo "gradeArr.push('".$param['id']."');";
- }
- }
- ?>
- //切换年级
- $('.a-years,.a-province,.paper-type > span, .grade-sel ul li').click(function(){
- if(!$(this).hasClass('active')){
- $(this).addClass('active').siblings().removeClass('active');
- var grade=$(this).attr("grade");
- for(var i=0;i<=gradeArr.length;i++){
- if(gradeArr[i]==grade){
- $("#grade"+grade).show();
- $('.g'+grade).show();
- $('.g'+grade).attr('status',1);
- }else{
- $("#grade"+gradeArr[i]).hide();
- $(".g"+gradeArr[i]).hide();
- $(".g"+gradeArr[i]).attr('status',0);
- }
- }
- }
- });
- //添加班级
- $(".bj-sel ul").on("click","li", function(){
- $('#classIds-error').html("");
- $(this).find('.judge-sel').addClass('active');
- $(this).remove();
- var grade = $(this).attr('grade');
- $('.g'+grade).append('<span grade="'+$(this).attr("grade")+'" classid="'+$(this).attr("classid")+'">'+$(this).text()+'</span>');
- });
- //移除班级
- $('.sel-classes').delegate('span','click',function(){
- $(this).remove();
- $("#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>');
- });
- if ($('.sel-classes > span').length > 0){
- for (var i = 0;i < $('.sel-classes > span').length; i++){
- for (var k = 0;k < $('.bjs-lis').length; k++){
- if ($('.bjs-lis').eq(k).text().trim()==$('.sel-classes > span').eq(i).text().trim()) {
- $('.bjs-lis').eq(k).find('.judge-sel').addClass('active');
- }
- }
- }
- }
- $('.mcp-radio-sel').click(function(){
- if (!$(this).find('.sel-btn').hasClass('select')) {
- $(this).find('.sel-btn').addClass('select');
- $(this).siblings().find('.sel-btn').removeClass('select');
- var type = $(this).find('.sel-btn').attr('value');
- if(type){
- $('#type-error').html("");
- }
- $('input[name="type"]').val(type);
- }
- });
- $('.grade-sel ul li').click(function(){
- $(this).addClass('active').siblings().removeClass('active');
- });
- // $('.judge-sel').on('click',function(){
- // alert(1);
- // if (!$(this).hasClass('active')) {
- // $(this).addClass('active');
- // $('.sel-classes').append('<span>'+$(this).closest('.bjs-lis').text()+'</span>');
- // } else {
- // $(this).removeClass('active');
- // for (var i = 0;i < $('.sel-classes > span').length; i++) {
- // console.log($('.sel-classes > span').eq(i).text());
- // if ($('.sel-classes > span').eq(i).text().trim() == $(this).closest('.bjs-lis').text().trim()){
- // $('.sel-classes > span').eq(i).remove();
- // }
- // }
- // }
- // });
- $('.sel-classes > span').click(function(){
- $(this).remove();
- for (var i = 0;i < $('.bjs-lis').length; i++) {
- if ($('.bjs-lis').eq(i).text().trim()==$(this).text().trim()){
- $('.bjs-lis').eq(i).find('.judge-sel').removeClass('active');
- }
- }
- });
- // 下拉列表模拟
- $('.inp-text').click(function(){
- if ($(this).next().is(':hidden')){
- $(this).next().show();
- } else {
- $(this).next().hide();
- }
- });
- // 点下拉列表选项
- $('.select-con li').click(function(){
- $(this).closest('.select-con').hide();
- $(this).closest('.mcp-form-detail').find('.inp-text').text($(this).text());
- });
- // 点击空白处下拉列表消失
- $(document).click(function(e){
- var targetNode = $(e.target).closest(".inp-text");
- if (targetNode.length>0){
- return;
- }else{
- $(".select-con").hide();
- }
- });
- $("body").delegate("#createThird[active='true']", "click", function(e) {
- var classIds='';
- $(".sel-classes[status=1]").children("span").each(function(){
- classIds += $(this).attr('classid')+",";
- });
- $('input[name="classIds"]').val(classIds);
- var error = new Array();
- var classIds = $('input[name="classIds"]').val();
- var examName = $('input[name="examName"]').val();
- var type = $('input[name="type"]').val();
- var teacherId = $('input[name="teacherId"]').val();
- var examDate = $("input[name='examDate']").val();
- if(examName == "" || examName == null){
- $('#examName-error').html('请指定考试名称');
- error.push('没有指定考试名称');
- }else{
- $('#examName-error').html('');
- }
- //检测试题设置
- $select_obj=$('.topic_type_select');
- $isFoundErr=false;
- $topicData=[];
- for (var i=0;i<$select_obj.length;i++){
- 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'){
- $isFoundErr=true;
- break;
- }else{
- $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()+'"}');
- }
- }
- if($isFoundErr){
- error.push('试题类型数量或分数未设置');
- $('#topic_error').html('试题数量或分数未设置');
- }else{
- $('input[name=topic_data]').val('['+$topicData.join(',')+']');
- $('#topic_error').html('');
- }
- if(type == "" || type == null){
- $('#type-error').html('请指定考试类型');
- error.push('没有指定考试类型');
- }else{
- $('#type-error').html('');
- }
- if(teacherId == '0' || teacherId == null){
- $('#choose-error').html('请指定阅卷老师');
- error.push('没有指定阅卷老师');
- }else{
- $('#choose-error').html('');
- if(classIds == "" || classIds == null){
- $('#classIds-error').html('请指定考试班级');
- error.push('没有指定考试班级');
- }else{
- $('#classIds-error').html('');
- }
- }
- if (examDate == '') {
- $('#examDate').html('请设置考试日期');
- error.push('请设置考试日期');
- }else{
- $('#examDate').html('');
- }
- //console.log(error);
- if(error.length == 0){
- $(this).attr("active","false");
- //$(".saveForm").submit();
- //改为ajax提交
- index=layer.msg('正在保存,请稍候......',{time:9000000});
- $.ajax({
- url:'<?php echo Yii::app()->createUrl('third/createthirdunderline')?>',
- method:'POST',
- dataType:'json',
- data:$(".saveForm").serialize(),
- success:function (res) {
- layer.close(index);
- if(res.status==1){
- window.location="<?php echo Yii::app()->createUrl('third/index?list_type=1')?>";
- }else{
- layer.msg(res.msg);
- }
- }
- });
- }
- });
- //================题型选择部分操作代码=================================
- var selected_type=[]; //已选题型
- $('.topic_type_select').eq(0).find('.topic_type').val(1);
-
- $('input[name=examName]').change(function () {
- if($(this).val().length>30){
- layer.msg('考试名称不能超过30字');
- $(this).val('');
- }
- });
- function create_topic_type_select_obj(){
- $obj=$('.topic_type_select').eq(0).clone();
- $obj.find('.topic_count').val(0);
- $obj.find('.score_list').val('');
- $obj.find('.score_sum').val(0);
- $obj.find('.score').html('共-分');
- var option=$obj.find('.topic_type option');
- var is_have_topic_type=false;
- for(var i=0;i<option.length;i++){
- if(option.eq(i).attr('value')==0 || $.inArray(option.eq(i).attr('value'),selected_type)!=-1){
- continue;
- }else{
- $obj.find('.topic_type').val(option.eq(i).attr('value'));
- selected_type.push(option.eq(i).attr('value'));
- is_have_topic_type=true;
- break;
- }
- }
- if(is_have_topic_type){
- return $obj;
- }else{
- return false;
- }
- }
- $('.add_topic_type').click(function () {
- $obj=create_topic_type_select_obj();
- if(!$obj){
- layer.msg('没有可用题型!');
- }else{
- $(this).before($obj);
- }
- });
- $('.icon-close,.exam-close').click(function(){
- $(this).closest('.confirmbox-mask').hide();
- });
- $('.save_score').click(function(){
- var topicScore=[];
- for(var i=1;i<=$('.topic_score').length;i++){
- if($('input[name=total_score_'+i+']').val()==0 || $('input[name=total_score_'+i+']').val()==''){
- layer.msg('请填写题目分数!');
- return false;
- }
- topicScore.push($('input[name=total_score_'+i+']').val());
- }
- var obj_index=$('input[name=topic_type_index]').val();
- $('.topic_type_select').eq(obj_index).find('.score_list').val(topicScore.join(','));
- $('.topic_type_select').eq(obj_index).find('.score').html('共'+$('input[name=total_score]').val()+'分');
- $('.topic_type_select').eq(obj_index).find('.score_sum').val($('input[name=total_score]').val());
- classModal.style.display = 'none';
- });
- //试卷预览
- $('.preview').click(function(){
- $obj=$('.topic_type_select');
- for(var i=0;i<$obj.length;i++){
- if($obj.eq(i).find('.topic_count').val()==0 ){
- layer.msg('试题数量或分数未设置!');
- return false;
- }
- }
- $('#examModal').show();
- var html='';
- var digit=['一','二','三','四','五','六','七','八','九','十','十一','十二','十三','十四','十五','十六','十七','十八','十九','二十','二十一'];
- var topic_num=1;
- for(var i=0;i<$obj.length;i++){
- topic_count=parseInt($obj.eq(i).find('.topic_count').val());
- score_sum=$obj.eq(i).find('.score_sum').val();
- html+='<p>'+ digit[i]+'、'+$obj.eq(i).find('.topic_type').find("option:selected").text()+'(共'+topic_count+'题,'+score_sum+'分)</p>';
- html+='<p>';
- while (topic_count>0){
- html+=topic_num+',';
- topic_num++;
- topic_count--;
- }
- html+='</p>';
- }
- $('#examModal').find('.class-modal-body').html(html);
- // console.log(html);
- });
- $('.class-modal-body')
- .on('click','.avg',function(){
- var total_score=$('input[name=total_score]').val();
- var topic_count=$('.topic_score').length;
- if(total_score==0 || total_score==''){
- layer.msg('请填写题目总分!');
- }else{
- var avg_score=total_score/topic_count;
- if(checkFloat(avg_score)==false){
- $('.avg_result').html('无法平均分配');
- $('.avg_result').addClass('red');
- }else{
- $('.avg_result').html('');
- for(var i=1;i<=topic_count;i++){
- $('.topic_score').val(avg_score);
- }
- }
- }
- })
- .on('change','.total_score',function(){
- $(this).val($(this).val().replace(/[^\d+|\.]/g,""));
- if(checkFloat($(this).val())==false){
- layer.msg('分数设置不正确!');
- $(this).val(0);
- }
- if( $(this).val()!=''){
- $(this).val(parseInt($(this).val()));
- }
- $('.topic_score').val(0);
- $('#topic_error').html('');
- })
- .on('change','.topic_score',function(){
- $(this).val($(this).val().replace(/[^\d+|\.]/g,""));
- if(checkFloat($(this).val())==false){
- layer.msg('分数设置不正确!');
- $(this).val(0);
- }
- if( $(this).val()!=''){
- $(this).val(parseFloat($(this).val()));
- }
- var sum=0;
- for(var i=0;i<$('.topic_score').length;i++){
- if($('.topic_score').eq(i).val()!=''){
- sum+=parseFloat($('.topic_score').eq(i).val());
- }
- }
- $('.total_score').val(sum);
- });
- $('.topic_area')
- .on('click','.icon-add',function(){
- $obj=create_topic_type_select_obj();
- if(!$obj){
- layer.msg('没有可用题型!');
- }else{
- $(this).closest('.topic_type_select').before($obj);
- }
- })
- .on('mouseover','.icon-del',function(){
- $(this).css('background','url(/images/u436.png) left center no-repeat');
- $(this).css('background-size','18px 18px');
- })
- .on('mouseout','.icon-del',function(){
- $(this).css('background','url(/images/u434.png) left center no-repeat');
- $(this).css('background-size','18px 18px');
- })
- .on('click','.icon-del',function(){
- $obj=$(this).closest('.topic_type_select');
- if($('.topic_type_select').length>1){
- layer.msg('您确定要删除该题型吗?', {
- time: 0,
- btn: ['确定', '取消'],
- yes: function(index){
- layer.close(index);
- selected_type.splice(selected_type.indexOf($obj.find('.topic_type').val()),1);
- $obj.remove();
- }
- });
- }
- })
- .on('change','input[name=topic_count]',function(){
- $(this).val($(this).val().replace(/[^\d+|\.]/g,""));
- if( $(this).val()!=''){
- $(this).val(parseInt($(this).val()));
- }
- if($(this).val()>100){
- $(this).val(0);
- }
- $(this).closest('.topic_type_select').find('.score_list').val(''); //修改试题数量,分值清空
- $(this).closest('.topic_type_select').find('.score').html('共-分');
- $('#topic_error').html('');
- })
- .on('click','.up_score',function(){
- $obj=$(this).closest('.topic_type_select');
- $topic_num=parseInt($obj.find('.topic_count').val());
- $('input[name=topic_type_index]').val($obj.index());
- var start_topic_num=0;
- for(var i=0;i<$obj.index();i++){
- topic_count_befor=parseInt($('.topic_type_select').eq(i).find('.topic_count').val());
- start_topic_num+=topic_count_befor;
- }
- var ScoreArr=[];
- var score_list=$obj.find('.score_list').val();
- var total_score=$obj.find('.score_sum').val();
- if(score_list!=''){
- ScoreArr=score_list.split(',');
- }
- if($topic_num==0 || $topic_num==''){
- layer.msg('请填写题目数量!');
- }else{
- classModal.style.display = 'block';
- $('#classModal').find('.class-modal-body').html('');
- $('#classModal').find('.class-modal-body').html('');
- if(ScoreArr.length>0){
- 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>';
- for(var i=0;i<$topic_num;i++){
- html+='<p><span>第'+(start_topic_num+i+1)+'题:</span><input type="text" class="topic_score" name="total_score_'+(i+1)+'" value="'+ScoreArr[i]+'" /></p>';
- }
- }else{
- var html='<p><span>总分:</span><input type="text" class="total_score" name="total_score" /><button class="avg">平均分配</button><span class="avg_result"></span></p>';
- for(var i=0;i<$topic_num;i++){
- html+='<p><span>第'+(start_topic_num+i+1)+'题:</span><input type="text" value="0" class="topic_score" name="total_score_'+(i+1)+'" /></p>';
- }
- }
- $('#classModal').find('.class-modal-body').html(html);
- }
- })
- .on('change','.topic_type',function () {
- var select_topic_type=$(this).val();
- var this_index=$('.topic_type').index(this);
- for(var i=0;i<$('.topic_type').length;i++){
- if(i==this_index){
- continue;
- }
- if(select_topic_type==$('.topic_type').eq(i).val()){
- layer.msg('该题型已存在,请重新选择!');
- $(this).val(0);
- return false;
- }
- }
- if($.inArray(select_topic_type,selected_type)==-1){
- selected_type.push(select_topic_type);
- }
- //console.log(selected_type);
- });
- function selectTeacher($teacher_id){
- for(var i=0;i<$('.sel-option').length;i++){
- if($('.sel-option').eq(i).attr('id')==$teacher_id){
- $('.sel-option').eq(i).click();
- }
- }
- }
- function createTopicType(data,first){
- if(first==1){
- $obj=$('.topic_type_select').eq(0);
- $obj.find('.topic_count').val(data['count']);
- $obj.find('.score_list').val(data['score_list']);
- $obj.find('.score_sum').val(data['total_score']);
- $obj.find('.score').html('共'+data['total_score']+'分');
- $obj.find('.topic_type').val(data['type']);
- selected_type.push(String(data['type']));
- }else{
- $obj=$('.topic_type_select').eq(0).clone();
- $obj.find('.topic_count').val(data['count']);
- $obj.find('.score_list').val(data['score_list']);
- $obj.find('.score_sum').val(data['total_score']);
- $obj.find('.score').html('共'+data['total_score']+'分');
- $obj.find('.topic_type').val(data['type']);
- selected_type.push(String(data['type']));
- }
- $('.add_topic_type').before($obj);
- }
- //恢复教师选择//恢复题型选择
- var editTopicData=[];
- <?php
- if(isset($paper['teacher_id'])){
- echo 'selectTeacher("'.$paper['teacher_id'].'");';
- }
- if(isset($paper['topic']) && $paper['topic']){
- $num=1;
- foreach($paper['topic'] as $key=>$topic){
- echo "editTopicData['type']=".$key.";";
- echo "editTopicData['count']=".$topic['count'].";";
- echo "editTopicData['total_score']=".$topic['total_score'].";";
- echo "editTopicData['score_list']='".implode(',',$topic['score'])."';";
- echo "createTopicType(editTopicData,".$num.");";
- $num++;
- }
- }
- ?>
- function checkFloat(num){
- num=String(num);
- arr=num.split(".");
- //console.log(arr[1]);
- if(arr[1]==undefined){
- return true;
- }else if(arr[1]==5){
- return true;
- }
- return false;
- }
- });
- </script>
|