$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() { $answer = input('answer'); $answer['rid'] = input('rid'); $officer_answer = OfficerAnswerModel::create($answer); ajax_return(0, '', $officer_answer['id']); } public function answerDetailPost() { $id = input('id'); $aid = input('aid'); $no = input('no'); $index = input('index'); $option = []; $review_title = OfficerReviewTitleModel::where('rid', $id)->where('no', $no)->find(); foreach ($review_title['option'] as $v) { if ($v['score'] == $index) { $option = $v; break; } } OfficerAnswerDetailModel::create([ 'aid' => $aid, 'no' => $no, 'title' => $review_title['title'], 'score' => $option['score'], 'option_title' => $option['title'], ]); ajax_return(); } public function answerFinish() { $aid = input('aid'); $score = OfficerAnswerDetailModel::where('aid', $aid)->sum('score'); OfficerAnswerModel::update(['score' => $score, 'status' => 2], ['id' => $aid]); ajax_return(); } // 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(); } }