DetailController.class.php
1.87 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
<?php
/**
* 【考试中心-手机端】4-获取测评/模拟考试(未参与)详情接口
* DetailController.class.php
* @author: 蔡建华
* @date: 2017-05-23
*/
namespace Api\Controller\Paper;
use Common\Common\Train;
use Common\Common\TaskCenter;
use Common\Service\PaperService;
use Common\Common\StudyMap;
class DetailController extends AbstractController
{
public function Index_post()
{
// 接收post参数
$ep_id = I('post.ep_id', 0, 'intval');
// 试卷id为空
if (!$ep_id) {
E('_EMPTY_EP_ID');
}
// 实例化试卷service
$paper_s = new PaperService();
// 根据试卷id查询试卷信息
$data = $paper_s->get($ep_id);
// 试卷信息不存在,返回提示"试卷信息不存在"
if (empty($data)) {
E('_EMPTY_PAPER_DATA');
}
// 试卷分类状态为禁用状态,返回提示"试卷分类已经被禁用"
if (PaperService::EC_CLOSE_STATES == $data['cate_status']) {
E('_EMPTY_CATE_DATA');
}
// 任务id
$task_id = I('post.customtask_id', 0, 'intval');
// 判断用户是否有权限访问“任务类”数据
if (PaperService::TASK_TYPE == $data['exam_type']) {
$taskCenter = &TaskCenter::instance();
$taskCenter->checkCustomtaskRight($task_id, $ep_id, $this->_login->user);
}
// 培训计划id
$plan_id = I('post.plan_id', 0, 'intval');
// 判断用户是否有权限访问“线下培训”数据
if ($plan_id) {
$train = &Train::instance();
$train->checkCustomTrainRight($plan_id, $ep_id, $this->_login->user);
}
// 格式化试卷信息
$result = $paper_s->format_paper_detail($data,$this->uid);
// 返回结果
$this->_result = $result;
}
}