StudyMapController.class.php
2.37 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
<?php
/**
* Created by PhpStorm.
* User: pw
* Date: 18/5/29
* Time: 16:10
*/
namespace Frontend\Controller\Index;
use Common\Service\AnswerService;
use Common\Service\PaperService;
class StudyMapController extends AbstractController
{
/**
* 考试类型:测评
*/
const EVALUATION = 0;
/**
* 考试类型:模拟
*/
const SIMULATION = 1;
/**
* 从学习地图应用的学习内容跳转至手机端考试详情页
*/
public function Index()
{
$map_id = I('get.map_id', 0, 'intval');
$path_id = I('get.path_id', 0, 'intval');
$app_data_id = I('get.app_data_id', 0, 'intval');
// 跳转至前端详情页,详情页请求详情接口时会报出此错误
$paperServ = new PaperService();
$exam = $paperServ->get($app_data_id);
if (empty($exam)) {
redirectFront('/app/page/exam/exam-start', ['ep_id' => $app_data_id]);
}
// 前端所需参数
$param = [
'map_id' => $map_id,
'path_id' => $path_id,
'ep_id' => $app_data_id
];
// 如果是模拟考试,参加过并且已交卷
if (self::SIMULATION == $exam['paper_type']) {
$answerServ = new AnswerService();
$conds = [
'ep_id' => $app_data_id,
'uid' => !empty($this->_login->user) ? $this->_login->user['memUid'] : ''
];
$test_answer = $answerServ->list_by_conds($conds);
if (!empty($test_answer) && !empty($test_answer[0]['my_end_time'])) {
// 跳转页面
redirectFront('/app/page/exam/exam-test-record', $param);
}
} elseif (self::EVALUATION == $exam['paper_type']) {
$answerServ = new AnswerService();
$conds = [
'ep_id' => $app_data_id,
'uid' => !empty($this->_login->user) ? $this->_login->user['memUid'] : ''
];
$test_answer = $answerServ->list_by_conds($conds);
if (!empty($test_answer) && !empty($test_answer[0]['my_end_time'])) {
// 跳转页面
$param['ea_id'] = $test_answer[0]['ea_id'];
redirectFront('/app/page/exam/exam-result', $param);
}
}
// 跳转页面
redirectFront('/app/page/exam/exam-start', $param);
}
}