request->params([ ["title",""], ["question_type",""], ["created_at",["",""]] ]); return success((new ExamQuestionsService())->getPage($data)); } /** * 试题详情 * @param int $id * @return \think\Response */ public function info(int $id){ return success((new ExamQuestionsService())->getInfo($id)); } /** * 添加试题 * @return \think\Response */ public function add(){ $data = $this->request->params([ ["title",""], ["question_type",""], ["question_content_type",""], ["question_content",""], ["option_json",[]], ["correct_answer",""] ]); $this->validate($data, 'app\validate\exam_questions\ExamQuestions.add'); $id = (new ExamQuestionsService())->add($data); return success('ADD_SUCCESS', ['id' => $id]); } /** * 试题编辑 * @param $id 试题id * @return \think\Response */ public function edit(int $id){ $data = $this->request->params([ ["title",""], ["question_type",""], ["question_content_type",""], ["question_content",""], ["option_json",[]], ["correct_answer",""] ]); $this->validate($data, 'app\validate\exam_questions\ExamQuestions.edit'); (new ExamQuestionsService())->edit($id, $data); return success('EDIT_SUCCESS'); } /** * 试题删除 * @param $id 试题id * @return \think\Response */ public function del(int $id){ (new ExamQuestionsService())->del($id); return success('DELETE_SUCCESS'); } public function random_questions_list(){ $data = $this->request->params([ ["single_choice_count",0], ["multiple_choice_count",0], ["true_false_count",0] ]); return (new ExamQuestionsService())->random_questions_list($data); } public function to_lead_into(){ $data = $this->request->post(); return (new ExamQuestionsService())->to_lead_into($data); } }