智慧教务系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

108 lines
3.0 KiB

<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址:https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\adminapi\controller\exam_questions;
use core\base\BaseAdminController;
use app\service\admin\exam_questions\ExamQuestionsService;
/**
* 试题控制器
* Class ExamQuestions
* @package app\adminapi\controller\exam_questions
*/
class ExamQuestions extends BaseAdminController
{
/**
* 获取试题列表
* @return \think\Response
*/
public function lists(){
$data = $this->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);
}
}