TrainController.class.php
3.64 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/**
* 线下培训入口
* User: yingcai
* Date: 2017/9/6
* Time: 下午5:19
*/
namespace Frontend\Controller\Index;
use Common\Common\Cache;
use Common\Service\AnswerService;
use Common\Service\PaperService;
class TrainController extends \Common\Controller\Frontend\AbstractController
{
/**
* 不是必须登录
* @var string $_require_login
*/
protected $_require_login = false;
public function Index()
{
$plan_id = I('plan_id', 0, 'rintval');
$ed_id = I('ed_id', 0, 'rintval');
$app_data_id = I('app_data_id', 0, 'rintval');
// 初始化缓存信息
$paper_info = [];
// 实例化缓存
$cache =& Cache::instance();
try {
// 获取当前试卷缓存信息
$paper_info = $cache->get('Common.Exam_wx_' . $app_data_id);
} catch (\Think\Exception $e) {
\Think\Log::record($e);
} catch (\Exception $e) {
\Think\Log::record($e);
}
// 如果缓存不存在
if (empty($paper_info)) {
// 试卷表初始化
$paper_service = new PaperService();
// 获取试卷详情
$paper_info = $paper_service->get($app_data_id);
// 如果没有缓存新增缓存
$cache->set('Common.Exam_wx_' . $app_data_id, $paper_info, 7200);
}
// 如果已参与跳转已参与详情 未参与跳转未参与详情
$service = new AnswerService();
$conds = array('ep_id' => $app_data_id, 'uid' => $this->uid, 'my_time > ?' => 0, 'obj_id' => $plan_id);
// 详情
$info = $service->get_by_conds($conds);
// 获取试卷状态
$ep_status = AnswerService::STATUS_ING;
// 未作答
if (empty($info)) {
redirectFront('/app/page/exam/exam-start', array(
'_identifier' => APP_IDENTIFIER,
'ep_id' => $app_data_id,
'ed_id' => $ed_id,
'plan_id' => $plan_id,
'ep_status' => $ep_status
));
}
// 测评试卷
if (PaperService::EVALUATION_PAPER_TYPE == $paper_info['paper_type']) {
// 如果是手动阅卷且没有阅卷
if (PaperService::MANUAL_MARKING_TYPE == $paper_info['marking_type']
&&
$info['answer_status'] < PaperService::READ_OVER
) {
// 已作答测评详情
redirectFront('app/page/exam/exam-scoring',
array(
'_identifier' => APP_IDENTIFIER,
'ep_id' => $app_data_id,
'ed_id' => $ed_id,
'plan_id' => $plan_id
));
}
// 已作答测评详情
redirectFront('app/page/exam/exam-result',
array(
'_identifier' => APP_IDENTIFIER,
'ea_id' => $info['ea_id'],
'pageType' => 'going',
'ep_status' => $ep_status,
'ep_id' => $app_data_id,
'ed_id' => $ed_id,
'plan_id' => $plan_id
));
}
// 模拟
if (PaperService::SIMULATION_PAPER_TYPE == $paper_info['paper_type']) {
// 已作答模拟
redirectFront('/app/page/exam/exam-test-record', array(
'_identifier' => APP_IDENTIFIER,
'ep_id' => $app_data_id,
'ep_status' => $ep_status,
'ed_id' => $ed_id,
'plan_id' => $plan_id
));
}
}
}