$data['e_id'], 'type' => $data['type'], 'questions_id' => $data['questions_id'], 'uid' => $uid])->value('id'); if ($data['is_correct'] != 2) $data['score'] = 0; if ($id) { $dat['user_answer'] = $data['user_answer']; $dat['is_correct'] = $data['is_correct']; $dat['score'] = $data['score']; $res = self::edit($dat, $id); } else { $data['uid'] = $uid; $res = self::set($data); } return $res; } /**检测是否答题 * @param $e_id * @param $uid * @param $qid */ public static function checkWhetherAnswerQuestions($e_id, $type, $uid, $qid) { $test = self::where(['e_id' => $e_id, 'type' => $type, 'questions_id' => $qid, 'uid' => $uid])->find(); if (!$test) return []; else return ['is_correct' => $test['is_correct'], 'user_answer' => $test['user_answer']]; } }