123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584 |
- <script>
- $(function(){
- //初始化
- var superUser='<?php if( isset(Yii::app()->session['testFlag'])&&(Yii::app()->session['testFlag']==1)){echo 1;}else{echo 0;}?>';
- var allowChangeAnswer=false;
- // $('.topic-list').eq(0).removeClass('hide').addClass('show');
- $('.topic-send-point').click(function(){
- $('.send-control').toggle();
- $('.topic-edit-cancel').click();
- if($('.topic-edit').attr('disabled')==undefined){
- $('.topic-edit').attr('disabled',true);
- }else{
- $('.topic-edit').attr('disabled',false);
- }
- });
- //点击答案
- $('.answer-list').click(function(){
- if(!allowChangeAnswer) return false;
- issend= $(this).closest('tr').find('.topic-score').attr('issend');
- if(issend==1){
- layer.msg('已经设置送分/0分,不能修改答案');
- return false;
- }
- if(!$(this).hasClass('answer-active')){
- if(!$(this).hasClass('answer-multi')){
- $(this).closest('tr').find('.answer-list').removeClass('answer-active');
- $(this).closest('tr').find('.new-answer').val($(this).html());
- }
- $(this).addClass('answer-active');
- }else{
- if($(this).closest('tr').find('.answer-active').length==1){
- layer.msg('至少选择一项答案');
- }else{
- $(this).removeClass('answer-active');
- }
- }
- var answer='';
- if($(this).hasClass('answer-multi')){
- $(this).closest('tr').find('.answer-active').each(function(i,v){
- if(answer==''){
- answer=$(v).html();
- }else{
- answer=answer+','+$(v).html();
- }
- })
- console.log(answer);
- $(this).closest('tr').find('.new-answer').val(answer);
- }
- });
- //点击规则
- $('.rule-list').click(function(){
- if(!allowChangeAnswer) return false;
- if(!$(this).hasClass('rule-active')){
- $(this).closest('tr').find('.rule-list').removeClass('rule-active');
- $(this).addClass('rule-active');
- }
- });
- $('.topic-edit').click(function(){
- topic_type=$('input[name=select-tab]').val();
- obj=$(this);
- if(topic_type==5 || topic_type==7){
- msg='1、线上阅卷:<br>' +
- '(1)未开始阅卷可修改分值。<br>' +
- '(2)已开始阅卷,已阅学生成绩不会自动更新。若将分值改大,需重新按更新后分值再次批改,否则会导致修改分值后批阅的学生分值比修改前已阅学生分值大;若将分值改小,需老师对已阅学生重新打分,否则会导致无法完成阅卷。\n' +
- '<br>' +
- '2、线下阅卷:\n' +
- '<br>' +
- '(1)答题卡未保存可修改分值。\n' +
- '<br>' +
- '(2)答题卡已保存,修改分值对学生打分不生效。';
- indexmsg=layer.confirm(msg, {
- title:"*修改需知!!!",
- btn: ['我已知晓', '取消'] //按钮
- }, function () {
- layer.close(indexmsg)
- $('.topic-edit-cancel').show();
- $('.topic-edit-save').show();
- obj.hide();
- $('.list-type-'+topic_type).find('.topic-score').each(function(i,v){
- if($(v).attr('issend')==0 || $(v).attr('issend')==undefined){
- $(v).attr('disabled',false);
- }
- });
- allowChangeAnswer=true;
- },function(){
- layer.close(indexmsg)
- return false;
- })
- }else{
- $('.topic-edit-cancel').show();
- $('.topic-edit-save').show();
- $(this).hide();
- $('.list-type-'+topic_type).find('.topic-score').each(function(i,v){
- if($(v).attr('issend')==0 || $(v).attr('issend')==undefined){
- $(v).attr('disabled',false);
- }
- });
- allowChangeAnswer=true;
- }
- });
- $('.topic-edit-cancel').click(function(){
- $(this).hide();
- $('.topic-edit-save').hide();
- $('.topic-edit').show();
- topic_type=$('input[name=select-tab]').val();
- $('.list-type-'+topic_type).find('.topic-score').attr('disabled',true);
- allowChangeAnswer=false;
- });
- $(".topic-score").keyup(function(){
- topic_type=$('input[name=select-tab]').val();
- console.log(topic_type);
- $(this).val($(this).val().replace(/[^0-9|\.]/g,""));
- if(topic_type==17){
- $('.list-type-17').find('.topic-score').val($(this).val());
- }
- });
- $('.topic-menu').click(function(){
- $('.topic-menu').removeClass('menu-active');
- topic_type=$(this).attr('id');
- $('.topic-list').removeClass('show').addClass('hide');
- $('.list-type-'+topic_type).removeClass('hide').addClass('show');
- $(this).addClass('menu-active');
- $('input[name=select-tab]').val(topic_type);
- $('.topic-edit-cancel').click();
- console.log(topic_type)
- if(topic_type==1){
- $('.topic-send-point').show();
- }else{
- $('.topic-send-point').hide();
- }
- });
- $('.topic-menu').eq(0).click();
- //保存
- $('.topic-edit-save').click(function(){
- topic_type=$('input[name=select-tab]').val();
- obj= $('.list-type-'+topic_type).find('.operate-tr');
- saveBtn= $(this);
- var data=[];
- var topicScore={};
- var topicRule=[];
- var multipleScore={};
- var error=false;
- obj.each(function(i,v){
- if(topic_type==1 || topic_type==3){
- topicid=$(v).find('.topic-id').val();
- answer=$(v).find('.new-answer').val();
- score=$(v).find('.topic-score').val();
- oldAnswer=$(v).find('input[name=old-answer]').val();
- oldScore=$(v).find('.topic-score').attr('old-score');
- temp={
- answer:'',
- score:'',
- topic_id:topicid
- };
- if(score==''){
- layer.msg('请填写题目分数!');
- error=true;
- }
- if(score==0){
- layer.msg('分值不能为0!');
- error=true;
- }
- isChange=false;
- if(answer!='' && oldAnswer!=answer){
- temp.answer=answer
- isChange=true;
- }
- if(oldScore!=score){
- temp.score=score
- isChange=true;
- }
- if(parseFloat(score)>49){
- layer.msg('选择题分数上限为49分!');
- error=true;
- }
- if(isChange){
- if(checkFloat(score)==false){
- layer.msg('分数设置不正确!');
- error=true;
- }
- data.push(temp)
- }
- }else if(topic_type==5 || topic_type==7 || topic_type==17){
- topicid=$(v).find('.topic-id').val();
- score=$(v).find('.topic-score').val();
- oldScore=$(v).find('.topic-score').attr('old-score');
- if(score==''){
- layer.msg('请填写题目分数!');
- error=true;
- }
- if(score==0){
- layer.msg('分值不能为0!');
- error=true;
- }
- if(parseFloat(score)>60){
- layer.msg('主观题分数上限为60分!');
- error=true;
- }
- //是否多空题
- // if($(v).find('.multiple')!=undefined){
- //
- // multiTemp=[];
- // multiObj=$(v).find('multiple');
- // console.log(multiObj.length);
- // multiObj.each(function(ii,vv){
- // multiTemp.push($(vv).val())
- // })
- // multipleScore.topicid=multiTemp;
- // }
- //console.log(multipleScore);
- var order=$(v).find('.topic-score').attr('order');
- if(oldScore!=score){
- if(checkFloat(score)==false){
- layer.msg('分数设置不正确!');
- error=true;
- }
- if($(v).find('.multiple').length>0 && multipleScore[topicid]==undefined){
- multiTemp=[];
- scoreSum=0;
- multiObj=$('.multiple-'+topicid);
- multiObj.each(function(ii,vv){
- multiTemp.push($(vv).val())
- scoreSum+=parseFloat($(vv).val());
- })
- multipleScore[topicid]=multiTemp;
- score=scoreSum
- }
- if(topicScore[order]==undefined){
- topicScore[order]=score;
- }
- }
- }else if(topic_type==2){
- //多选
- topicid=$(v).find('.topic-id').val();
- //新值
- score=$(v).find('input[name=topic-score]').val();
- halfscore=$(v).find('input[name=topic-half-score]').val();
- answer=$(v).find('.new-answer').val();
- rule=$(v).find('.rule-active').attr('rule');
- //原值
- oldScore=$(v).find('.topic-score').attr('old-score');
- oldAnswer=$(v).find('.old-answer').val();
- oldhalfScore=$(v).find('.topic-half-score').attr('old-score');
- oldRule=$(v).find('.old-rule').val();
- temp={
- topic_id:topicid,
- score:score,
- half_score:halfscore,
- rule:rule,
- answer:answer
- };
- if(score==''){
- layer.msg('请填写题目分数!');
- error=true;
- }
- if(score==0){
- layer.msg('分值不能为0!');
- error=true;
- }
- if( halfscore==''){
- layer.msg('请填写题目半对分!');
- error=true;
- }
- // if(halfscore==0 ){
- // layer.msg('半对分不能为0!');
- // error=true;
- // }
- if(parseFloat(score)>49){
- layer.msg('客观题分数上限为49分!');
- error=true;
- }
- isChange=false;
- if(score!=oldScore || rule!=oldRule || halfscore!=oldhalfScore || answer!=oldAnswer){
- isChange=true;
- }
- if(isChange){
- if(checkFloat(score)==false){
- layer.msg('分数设置不正确!');
- error=true;
- }
- if(checkFloat(halfscore)==false){
- layer.msg('半对分数设置不正确!');
- error=true;
- }
- topicRule.push(temp);
- }
- }
- })
- if(error){
- return false;
- }
- saveBtn.attr('disabled',true);
- if(topic_type==1 || topic_type==3){
- if(data.length==0 ){
- layer.msg('数据没有变化 ');
- return false;
- }
- layer.msg('正在更新,请稍候......',{time:0});
- $.ajax({
- url:'<?php echo $this->createUrl('allSubject/updateScoreAnswerBatch')?>',
- type:'POST',
- dataType:'json',
- data:{change_data:data,paper_id:$("input[name=paper_id]").val()},
- success:function(res){
- saveBtn.attr('disabled',false);
- layer.closeAll();
- if(res.status==1){
- layer.msg('修改成功',{icon:1,time:2000},function () {
- window.location.reload();
- });
- }else{
- if(res.msg!=undefined){
- layer.msg(res.msg)
- obj.attr('disabled',false);
- }else{
- layer.msg('修改失败',{icon:1,time:2000},function () {
- window.location.reload();
- });
- }
- }
- }
- });
- }else if(topic_type==5 || topic_type==7){
- if($.isEmptyObject(topicScore)==true){
- layer.msg('数据没有变化 ');
- return false;
- }
- layer.msg('正在更新,请稍候......',{time:0});
- $.ajax({
- url:'<?php echo $this->createUrl('allSubject/updateScoreBatch')?>',
- type:'POST',
- dataType:'json',
- data:{scores:topicScore,paper_id:$("input[name=paper_id]").val(),multiple_score:multipleScore},
- success:function(res){
- saveBtn.attr('disabled',false);
- layer.closeAll();
- if(res.status==1){
- layer.msg('修改成功',{icon:1,time:2000},function () {
- window.location.reload();
- });
- }else{
- if(res.msg!=undefined){
- layer.msg(res.msg)
- obj.attr('disabled',false);
- }else{
- layer.msg('修改失败',{icon:1,time:2000},function () {
- window.location.reload();
- });
- }
- }
- }
- });
- }else if(topic_type==2){
- layer.msg('正在更新,请稍候......',{time:0});
- exam_id=$('input[name=exam_id]').val();
- $.ajax({
- url:'<?php echo $this->createUrl('allSubject/changeMultiRuleBatchNew')?>',
- data:{exam_id:exam_id,topic_data:topicRule},
- dataType:'json',
- type:'POST',
- success:function(res){
- layer.closeAll();
- saveBtn.attr('disabled',false);
- if(res.status==1){
- layer.msg('更新成功');
- location.reload();
- }else{
- layer.msg(res.msg);
- }
- }
- });
- }else if(topic_type==17){
- if($.isEmptyObject(topicScore)==true){
- layer.msg('数据没有变化 ');
- return false;
- }
- layer.msg('正在更新,请稍候......',{time:0});
- $.ajax({
- url:'<?php echo $this->createUrl('allSubject/UpdateScoreXuan')?>',
- type:'POST',
- dataType:'json',
- data:{scores:topicScore,paper_id:$("input[name=paper_id]").val()},
- success:function(res){
- saveBtn.attr('disabled',false);
- layer.closeAll();
- if(res.status==1){
- layer.msg('修改成功',{icon:1,time:2000},function () {
- window.location.reload();
- });
- }else{
- if(res.msg!=undefined){
- layer.msg(res.msg)
- obj.attr('disabled',false);
- }else{
- layer.msg('修改失败',{icon:1,time:2000},function () {
- window.location.reload();
- });
- }
- }
- }
- });
- }
- });
- $('.sendPoints').click(function(){
- let topicId=$(this).attr('topic_id');
- let paperId=$(this).attr('paper_id');
- let actionType=$(this).attr('action_type');
- let optionCount=$(this).attr('option_count');
- msg='';
- if(actionType==1){
- $('input[name=paperId]').val(paperId);
- $('input[name=topicId]').val(topicId);
- html='<tr>';
- letterArr=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
- for(i=0;i<optionCount;i++){
- html+='<td class="answer_3">'+letterArr[i]+'</td>';
- }
- html+='</tr>';
- $('#sendPointAnswer').html(html);
- $('#sendScore').show();
- }else{
- if($(this).attr('disabled')=='disabled'){
- return false;
- }
- msg='0分题每题只可设置一次,且不可撤销,请谨慎操作';
- indexmsg=layer.confirm(msg, {
- btn: ['确定', '取消'] //按钮
- }, function () {
- $('.sendPoints').attr('disabled',true);
- layer.close(indexmsg);
- layer.msg('更新中请稍候。。。。。。',{time:0});
- $.ajax({
- url:"<?php echo $this->createUrl('paper/sendPoints')?>",
- data:{actype:actionType,paper_id:paperId,topic_id:topicId},
- dataType:'json',
- type:'POST',
- success:function(res){
- if(res.status==1){
- layer.msg('更新成功');
- location.reload();
- }else{
- if(res.msg!=undefined){
- layer.msg(res.msg);
- }else{
- layer.msg('更新失败');
- }
- }
- }
- });
- })
- }
- });
- $(".answerShow")
- .on('click','.answer_3',function(){
- showLogObj=$(this).closest('table').closest('tr');
- if(!$(this).hasClass('active')){
- $(this).addClass('active');
- }else{
- if(showLogObj.find('.active').length<=1){
- layer.msg('送分题答案不能少于一个');
- return false;
- }
- $(this).removeClass('active');
- }
- var nowAnswer=[];
- $.each(showLogObj.find('.answer_3'),function(i,v){
- if($(v).hasClass('active')){
- nowAnswer.push($(v).html())
- }
- })
- $('input[name=sendScoreAnswer]').val(nowAnswer.join(','));
- })
- $('.saveSendScoreBtn').click(function(){
- answer=$('input[name=sendScoreAnswer]').val();
- if(answer==''){
- layer.msg('请选择送分答案');
- }
- let topicId=$('input[name=topicId]').val();
- let paperId=$('input[name=paperId]').val();
- if($(this).attr('disabled')=='disabled'){
- return false;
- }
- msg='送分题每题只可设置一次,且不可撤销,请谨慎操作';
- indexmsg=layer.confirm(msg, {
- btn: ['确定', '取消'] //按钮
- }, function () {
- $('.saveSendScoreBtn').attr('disabled',true);
- layer.close(indexmsg);
- layer.msg('更新中请稍候。。。。。。',{time:0});
- $.ajax({
- url:"<?php echo $this->createUrl('paper/sendScore')?>",
- data:{answer:answer,paper_id:paperId,topic_id:topicId},
- dataType:'json',
- type:'POST',
- success:function(res){
- if(res.status==1){
- layer.msg('更新成功');
- location.reload();
- }else{
- if(res.msg!=undefined){
- layer.msg(res.msg);
- }else{
- layer.msg('更新失败');
- }
- }
- }
- });
- })
- });
- $('.icon-close').click(function(){
- $('#sendScore').hide();
- });
- function checkFloat(num){
- num=String(num);
- arr=num.split(".");
- //console.log(arr[1]);
- if(arr[1]==undefined){
- return true;
- }else if(arr[1]==5 || arr[1]==0){
- return true;
- }
- return false;
- }
- });
- </script>
|