2db47680
hexiaodong
chore: 初始提交 php 遗...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
<?php
namespace addons\exam\controller;
use addons\exam\model\CorrectionQuestionModel;
use app\admin\model\exam\CorrectionTypeModel;
/**
* 纠错接口
*/
class Correction extends Base
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
protected $user;
/**
* 纠错类型
*/
public function types()
{
$types = CorrectionTypeModel::all();
$this->success('', ['types' => $types]);
}
/**
* 提交纠错
*/
public function submit()
{
$question_id = input('question_id/d');
// $type_ids = input('type_ids/a', []);
$type_names = input('type_names/a', []);
$remark = input('remark/s', '', 'trim,strip_tags,htmlspecialchars,xss_clean');
if (!$question_id) {
$this->error(__('缺少题目ID参数'));
}
// if (!$type_ids) {
// $this->error(__('请选择纠错类型'));
// }
if (!$type_names) {
$this->error(__('请选择纠错类型'));
}
CorrectionQuestionModel::create([
'user_id' => $this->auth->id,
'question_id' => $question_id,
'type_ids' => '',//implode(',', $type_ids),
'type_names' => implode(',', $type_names),
'remark' => $remark,
]);
$this->success('提交成功,感谢您的反馈');
}
/**
* 纠错反馈列表
*/
public function list()
{
$list = CorrectionQuestionModel::with([
'question' => function ($query) {
$query->with([
'cates' => function ($query) {
$query->field('id,name');
},
])->field('id,cate_id,kind,title');
}
])->where('user_id', $this->auth->id)->order('id', 'desc')->paginate(15, true);
$this->success('', $list);
}
}
|