$review, ]); } public function answer() { $id = input('id'); empty($id) && jump('该题库不存在或已删除'); $list = OfficerReviewSectionModel::with(['title_list'])->where('rid', $id)->order('sort', 'desc')->select()->toArray(); empty($list) && jump('该题库不存在或已删除'); return view('', [ 'id' => $id, 'list' => json_encode($list), ]); } public function answerPost() { $id = input('id'); $answer = input('answer'); $answer_detail = input('answer_detail'); $officer_answer = OfficerAnswerModel::create($answer); $review_title = OfficerReviewTitleModel::where('rid', $id)->column('option,title', 'no'); $score_sum = 0; foreach ($answer_detail as $k => $v) { $options = json_decode($review_title[$k]['option'], true); $option = $options[$v]; OfficerAnswerDetailModel::create([ 'aid' => $officer_answer['id'], 'no' => $k, 'title' => $review_title[$k]['title'], 'score' => $option['score'], 'option_title' => $option['title'], ]); $score_sum += $option['score']; } OfficerAnswerModel::update(['score' => $score_sum], ['id' => $officer_answer['id']]); ajax_return(); } public function finish() { return view(); } }