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

答题优化

... ... @@ -481,7 +481,7 @@ class Exam extends Api
if($correct == $answer){
Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>$study['dan_score']]);
}else{
Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer]);
Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>0]);
}
//算出总得分
$score = Db::name('answer_detail')
... ... @@ -512,10 +512,11 @@ class Exam extends Api
if(!empty($correct)){
$correct = explode(',',$correct);
}
$answer1 = [];
if(!empty($answer)){
$answer = explode(',',$answer);
$answer1 = explode(',',$answer);
}
$result = array_diff($correct,$answer);
$result = count($answer1) > count($correct) ? array_diff($answer1,$correct) : array_diff($correct,$answer1);
//判断用户是否回答正确
if(empty($result)){
... ... @@ -523,7 +524,7 @@ class Exam extends Api
Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>$study['duo_score']]);
}else{
//回答错误
Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer]);
Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>0]);
}
//算出总得分
... ... @@ -555,7 +556,7 @@ class Exam extends Api
if($correct == $answer){
Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>$study['pan_score']]);
}else{
Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer]);
Db::name('answer_detail')->where('id',$data['id'])->update(['answer'=>$answer,'score'=>0]);
}
//算出总得分
$score = Db::name('answer_detail')
... ...