all(); $limit = $param['limit']; $question_name = $param['question_name']; $question_type = $param['question_type']; $difficulty = $param['difficulty']; $where = []; if (!empty($question_name)) { $where[] = ['question_name', 'like', '%' . $question_name . '%']; } if (!empty($question_type)) { $where[] = ['question_type', '=', $question_type]; } if (!empty($difficulty)) { $where[] = ['difficulty', '=', $difficulty]; } $question = new Question(); $list = $question->getPaginateList($where, ['id','question_name','question_type','difficulty','answer','q_options'], ['id' => 'asc'], [], $limit); return sparkSuccess(dataReturn(0, '查询成功',$list)); } public function getQuestionList() { $config = new Config(); $config_info = $config->find(1); $questionList=[]; $question = new Question(); $proportion = \json_decode($config_info['proportion'],true); foreach($proportion as $val) { $where=[]; $where[]=['question_type','=',$val['question_type']]; $where[]=['status','=',1]; $where[]=['difficulty','=',$config_info['difficulty']]; $question_list = $question->getAllList($where,['id','question_name','question_type','difficulty','answer','q_options']); shuffle($question_list); $question_list = array_slice($question_list,0,$val['question_num']); foreach($question_list as &$item) { $item['score'] = $val['score']; } $questionList = array_merge($questionList,$question_list); } $data = ['question_list'=>$questionList,'exam_time'=>$config_info['exam_time']]; return sparkSuccess(dataReturn(0, '查询成功',$data)); } public function getList() { $model = new Manage(); $list = $model->getAllList([],['id','name']); $lists=[]; foreach($list as $v) { $data=[]; $data['value'] = $v['id']; $data['label'] = $v['name']; $lists[]=$data; } return sparkSuccess(dataReturn(0, '查询成功',$lists)); } # 测评管理列表 public function index(Request $request) { if (request()->isAjax()) { $param = $request->all(); $model = new Managent(); $limit = $param['limit']; $m_id = $param['m_id']; $name = $param['name']; $where = []; if (!empty($m_id)) { $where[] = ['m_id', '=', $m_id]; } if (!empty($name)) { $where[] = ['status', 'like', '%' . $name . '%']; } $list = $model->getPaginateList($where, ['*'], ['id' => 'asc'], [], $limit); return sparkSuccess(dataReturn(0, '查询成功',$list)); } return view('train/examination/managent/index'); } /** * 添加试题 * @param $param */ public function store(Request $request) { $param = $request->all(); $model = new Managent(); $model->insertOne($param); return sparkSuccess(dataReturn(0, '添加成功')); } /** * 编辑试题 * @param $param */ public function update(Request $request) { $param = $request->all(); $id = $param['id']; $model = new Managent(); $model->updateById($param,$id); return sparkSuccess(dataReturn(0, '编辑成功')); } /** * 删除数据 */ public function destroy(Request $request) { $param = $request->all(); $id = $param['id']; $model = new Managent(); $model->where('id','=',$id)->delete(); return sparkSuccess(dataReturn(0, '删除成功')); } }