作者 何书鹏
1 个管道 的构建 通过 耗费 1 分 29 秒

PC端答题优化

@@ -482,7 +482,7 @@ class Exam extends Api @@ -482,7 +482,7 @@ class Exam extends Api
482 if($correct == $answer){ 482 if($correct == $answer){
483 Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>$study['dan_score']]); 483 Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>$study['dan_score']]);
484 }else{ 484 }else{
485 - Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer]); 485 + Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>0]);
486 } 486 }
487 //算出总得分 487 //算出总得分
488 $score = Db::name('answer_detail') 488 $score = Db::name('answer_detail')
@@ -518,9 +518,9 @@ class Exam extends Api @@ -518,9 +518,9 @@ class Exam extends Api
518 $correct = explode(',',$correct); 518 $correct = explode(',',$correct);
519 } 519 }
520 if(!empty($answer)){ 520 if(!empty($answer)){
521 - $answer = explode(',',$answer); 521 + $answer1 = explode(',',$answer);
522 } 522 }
523 - $result = array_diff($correct,$answer); 523 + $result = count($answer1) > count($correct) ? array_diff($answer1,$correct) : array_diff($correct,$answer1);
524 524
525 //判断用户是否回答正确 525 //判断用户是否回答正确
526 if(empty($result)){ 526 if(empty($result)){
@@ -528,7 +528,7 @@ class Exam extends Api @@ -528,7 +528,7 @@ class Exam extends Api
528 Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>$study['duo_score']]); 528 Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>$study['duo_score']]);
529 }else{ 529 }else{
530 //回答错误 530 //回答错误
531 - Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer]); 531 + Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>0]);
532 } 532 }
533 533
534 //算出总得分 534 //算出总得分
@@ -564,7 +564,7 @@ class Exam extends Api @@ -564,7 +564,7 @@ class Exam extends Api
564 if($correct == $answer){ 564 if($correct == $answer){
565 Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>$study['pan_score']]); 565 Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>$study['pan_score']]);
566 }else{ 566 }else{
567 - Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer]); 567 + Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>0]);
568 } 568 }
569 //算出总得分 569 //算出总得分
570 $score = Db::name('answer_detail') 570 $score = Db::name('answer_detail')