$review, ]); } public function answer() { $id = input('id'); if (empty($id)) { return '该题库不存在或已删除'; } $section_list = OfficerReviewSectionModel::where('rid', $id)->column('name','id'); $list = OfficerReviewTitleModel::where('rid', $id)->order('no', 'asc')->select()->toArray(); if (empty($list)) { return '该题库不存在或已删除'; } foreach ($list as &$v) { $v['section'] = $section_list[$v['rsid']]; unset($v); } return view('', [ 'id' => $id, 'list' => json_encode($list), ]); } public function answerPost() { sleep(3); $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(); } }