MsgController.class.php
3.9 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
<?php
/**
* 微信手机端跳转
* Auth:Xtong
* Date:2017年06月02日
*/
namespace Frontend\Controller\Index;
use Common\Common\Cache;
use Common\Service\AnswerService;
use Common\Service\PaperService;
class MsgController extends \Common\Controller\Frontend\AbstractController
{
/** 不是必须登录 @var string $_require_login */
protected $_require_login = false;
public function Index()
{
$params = I('get.');
// 批阅列表
if (PaperService::MARKING_MSG == $params['marking_type']) {
// 批阅列表
redirectFront('/app/page/exam/exam-approval-list',
array('_identifier' => APP_IDENTIFIER, 'ep_id' => $params['ep_id']));
}
// 待批阅
if (PaperService::MARKING_USER_MSG == $params['marking_type']) {
// 待批阅
redirectFront('/app/page/exam/exam-approval-start',
array('_identifier' => APP_IDENTIFIER, 'ea_id' => $params['ea_id'], 'ep_id' => $params['ep_id'], 'exam_type' => $params['exam_type']));
}
// 初始化缓存信息
$paper_info = [];
// 实例化缓存
$cache =& Cache::instance();
try {
// 获取当前试卷缓存信息
$paper_info = $cache->get('Common.Exam_wx_' . $params['ep_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($params['ep_id']);
// 如果没有缓存新增缓存
$cache->set('Common.Exam_wx_' . $params['ep_id'], $paper_info, 7200);
}
// 如果已参与跳转已参与详情 未参与跳转未参与详情
$service = new AnswerService();
$conds = array('ep_id' => $params['ep_id'], 'uid' => $this->uid, 'my_time > ?' => 0);
// 详情
$list = $service->list_by_conds($conds, [0, 1], ['my_score' => 'DESC']);
// 获取试卷状态
$ep_status = $service->paper_status($paper_info['exam_status'], $paper_info['begin_time'],
$paper_info['end_time']);
// 未作答
if (empty($list)) {
redirectFront('app/page/exam/exam-start',
array('_identifier' => APP_IDENTIFIER, 'ep_id' => $params['ep_id'], 'ep_status' => $ep_status));
}
$info = $list[0];
// 测评试卷
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' => $params['ep_id']
));
}
// 已作答测评详情
redirectFront('app/page/exam/exam-result',
array(
'_identifier' => APP_IDENTIFIER,
'ea_id' => !empty($params['ea_id']) ? $params['ea_id'] : $info['ea_id'],
'pageType' => 'going',
'ep_status' => $ep_status,
'ep_id' => $params['ep_id']
));
}
// 模拟
if (PaperService::SIMULATION_PAPER_TYPE == $paper_info['paper_type']) {
// 已作答模拟
redirectFront('app/page/exam/exam-test-record',
array('_identifier' => APP_IDENTIFIER, 'ep_id' => $params['ep_id'], 'ep_status' => $ep_status));
}
}
}