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.
107 lines
2.9 KiB
107 lines
2.9 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\adminapi\controller\exam_papers;
|
|
|
|
use core\base\BaseAdminController;
|
|
use app\service\admin\exam_papers\ExamPapersService;
|
|
|
|
|
|
/**
|
|
* 试卷控制器
|
|
* Class ExamPapers
|
|
* @package app\adminapi\controller\exam_papers
|
|
*/
|
|
class ExamPapers extends BaseAdminController
|
|
{
|
|
/**
|
|
* 获取试卷列表
|
|
* @return \think\Response
|
|
*/
|
|
public function lists(){
|
|
$data = $this->request->params([
|
|
["selection_mode",""],
|
|
["created_at",["",""]]
|
|
]);
|
|
return success((new ExamPapersService())->getPage($data));
|
|
}
|
|
|
|
public function all(){
|
|
return success((new ExamPapersService())->all());
|
|
}
|
|
|
|
|
|
/**
|
|
* 试卷详情
|
|
* @param int $id
|
|
* @return \think\Response
|
|
*/
|
|
public function info(int $id){
|
|
return success((new ExamPapersService())->getInfo($id));
|
|
}
|
|
|
|
/**
|
|
* 添加试卷
|
|
* @return \think\Response
|
|
*/
|
|
public function add(){
|
|
$data = $this->request->params([
|
|
["title",""],
|
|
["selection_mode",""],
|
|
["questions_ids",""],
|
|
["total_score",0.00],
|
|
["passing_score",0.00],
|
|
["single_choice_count",0],
|
|
["multiple_choice_count",0],
|
|
["true_false_count",0],
|
|
["every_score",0]
|
|
|
|
]);
|
|
$this->validate($data, 'app\validate\exam_papers\ExamPapers.add');
|
|
$id = (new ExamPapersService())->add($data);
|
|
return success('ADD_SUCCESS', ['id' => $id]);
|
|
}
|
|
|
|
/**
|
|
* 试卷编辑
|
|
* @param $id 试卷id
|
|
* @return \think\Response
|
|
*/
|
|
public function edit(int $id){
|
|
$data = $this->request->params([
|
|
["title",""],
|
|
["selection_mode",""],
|
|
["questions_ids",""],
|
|
["total_score",0.00],
|
|
["passing_score",0.00],
|
|
["single_choice_count",0],
|
|
["multiple_choice_count",0],
|
|
["true_false_count",0],
|
|
["every_score",0]
|
|
|
|
]);
|
|
$this->validate($data, 'app\validate\exam_papers\ExamPapers.edit');
|
|
(new ExamPapersService())->edit($id, $data);
|
|
return success('EDIT_SUCCESS');
|
|
}
|
|
|
|
/**
|
|
* 试卷删除
|
|
* @param $id 试卷id
|
|
* @return \think\Response
|
|
*/
|
|
public function del(int $id){
|
|
(new ExamPapersService())->del($id);
|
|
return success('DELETE_SUCCESS');
|
|
}
|
|
|
|
|
|
}
|
|
|