post(); $pageSize = request()->post('pageSize', 10); $params['user_id'] = $this->userId; $datas = ExamService::make()->getDataList($params, $pageSize); return message(1010, true, $datas); } catch (\Exception $exception) { $error = ['error' => $exception->getMessage(), 'trace' => $exception->getTrace()]; return message(1009, false, $error); } } /** * 答题历史 * @return array */ public function history() { try { $params = request()->post(); $pageSize = request()->post('pageSize', 10); $params['user_id'] = $this->userId; $datas = ExamService::make()->getHistoryList($params, $pageSize); return message(1010, true, $datas); } catch (\Exception $exception) { $error = ['error' => $exception->getMessage(), 'trace' => $exception->getTrace()]; return message(1009, false, $error); } } /** * 每日一练 * @return array */ public function practice() { try { $params = request()->post(); $pageSize = request()->post('pageSize', 10); $datas = ExamService::make()->getPracticeList($this->userId, $params, $pageSize); return message(1010, true, $datas); } catch (\Exception $exception) { $error = ['error' => $exception->getMessage(), 'trace' => $exception->getTrace()]; return message(1009, false, $error); } } /** * 答题 * @return array */ public function answer() { try { $params = request()->all(); if ($result = ExamService::make()->answer($this->userId, $params)) { return showJson(ExamService::make()->getError(), true, $result); } else { return showJson(ExamService::make()->getError(), false); } } catch (\Exception $exception) { $error = ['error' => $exception->getMessage(), 'trace' => $exception->getTrace()]; return message(1003, false, $error); } } /** * 再次答题 * @return array */ public function reset() { try { $id = request()->post('id'); if (ExamService::make()->reset($id, $this->userId)) { return showJson(1002, true); } else { return showJson(ExamService::make()->getError(), false); } } catch (\Exception $exception) { $error = ['error' => $exception->getMessage(), 'trace' => $exception->getTrace()]; return message(1003, false, $error); } } /** * 详情 */ public function info() { try { $params = request()->all(); $rid = isset($params['rid']) ? intval($params['rid']) : 0; if (empty($rid)) { return message(1036, false); } if ($info = ExamService::make()->getInfo($rid)) { return message(1010, true, $info); } else { return message(1009, false); } } catch (\Exception $exception) { $error = ['error' => $exception->getMessage(), 'trace' => $exception->getTrace()]; return message(1009, false, $error); } } /** * 排行榜 */ public function ranks() { try { $params = request()->all(); $type = isset($params['type']) ? intval($params['type']) : 0; if (empty($type)) { return message(1031, false); } $datas = ExamService::make()->getRankByType($type); return message(1010, true, $datas); } catch (\Exception $exception) { $error = ['error' => $exception->getMessage(), 'trace' => $exception->getTrace()]; return message(1009, false, $error); } } /** * 答题卡数据 */ public function cards() { try { $params = request()->all(); $rid = isset($params['rid']) ? intval($params['rid']) : 0; $paperId = isset($params['id']) ? intval($params['id']) : 0; if (empty($paperId)) { return message(1031, false); } $datas = ExamService::make()->getCardList($this->userId, $paperId, $rid); return message(1010, true, $datas); } catch (\Exception $exception) { $error = ['error' => $exception->getMessage(), 'trace' => $exception->getTrace()]; return message(1009, false, $error); } } }