MarkingDetailController.class.php
2.51 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* 答卷批阅详情接口
* User: yingcai
* Date: 2018/4/11
* Time: 下午2:46
*/
namespace Api\Controller\Marking;
use Common\Common\User;
use Common\Service\AnswerDetailService;
use Common\Service\AnswerService;
use Common\Service\RightService;
class MarkingDetailController extends AbstractController
{
public function Index_post()
{
// 接收post参数
$params = I('post.');
$ea_id = intval($params['ea_id']);
if (!$ea_id) {
E('_EMPTY_EA_ID');
}
// 获取答卷信息
$answer_serv = new AnswerService();
$answer = $answer_serv->get($ea_id);
// 答卷信息不存在
if (empty($answer)) {
E('_ERR_ANSWER_NOT_FOUND');
}
// 判断用户是否有权操作
$right_serv = new RightService();
$is_marking_right = $right_serv->count_by_conds([
'epc_id' => $answer['ep_id'],
'er_type' => RightService::RIGHT_MARKING,
'uid' => $this->uid
]);
if (!$is_marking_right) {
E('_ERR_MARKING_NO_QUIT');
}
$page = !empty($params['page']) ? intval($params['page']) : self::DEFAULT_PAGE;
$limit = !empty($params['limit']) ? intval($params['limit']) : self::DEFAULT_LIMIT;
// 分页
list($start, $limit) = page_limit($page, $limit);
$conds = [
'et_type' => [
AnswerService::TOPIC_TYPE_QUESTION,
AnswerService::TOPIC_TYPE_VOICE
],
'ea_id' => $ea_id
];
// 实例化答卷详情service
$answer_detail_s = new AnswerDetailService();
$total = $answer_detail_s->count_by_conds($conds);
$list = [];
if ($total) {
// 获取待批阅题目列表
$order_option['order_num'] = 'ASC';
$data = $answer_detail_s->list_by_conds($conds, [$start, $limit], $order_option);
// 格式化题目列表(阅卷解析)
$list = $answer_detail_s->question_list_format(
$data,
AnswerService::MANUAL_MARKING_TYPE,
AnswerService::ANSWER_MARKING_ANALYSIS
);
}
// 获取考生信息
$user_serv = User::instance();
$user = $user_serv->getByUid($answer['uid']);
$this->_result = [
'username' => $user['memUsername'],
'my_end_time' => $answer['my_end_time'],
'list' => $list,
];
return true;
}
}