ExamFinishController.class.php
5.27 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
133
<?php
/**
* Created by PhpStorm.
* User: zhonglei
* Date: 17/6/5
* Time: 14:31
*/
namespace Frontend\Controller\Index;
use Common\Common\ArticleHelper;
use Common\Common\Constant;
use Common\Common\StudyMap;
use Common\Common\TaskCenter;
use Common\Common\Train;
use Common\Service\ArticleService;
use Common\Service\ExamService;
use Think\Log;
class ExamFinishController extends AbstractController
{
/**
* 测评完成
* @author tangxingguo
*/
public function Index()
{
Log::record(sprintf('---%s %s ExamFinish Start ---', QY_DOMAIN, APP_DIR), Log::INFO);
Log::record('get: ' . var_export($_GET, true), Log::INFO);
$article_id = I('get.article_id', 0, 'intval');
$article_chapter_id = I('get.article_chapter_id', 0, 'intval');
$source_id = I('get.source_id', 0, 'intval');
$customtask_id = I('get.customtask_id', 0, 'intval');
$plan_id = I('get.plan_id', 0, 'intval');
$ed_id = I('get.ed_id', 0, 'intval');
$map_id = I('get.map_id', 0, 'intval');
$path_id = I('get.path_id', 0, 'intval');
$user = $this->_login->user;
$param = [
'article_id' => $article_id,
'customtask_id' => $customtask_id,
'plan_id' => $plan_id,
'ed_id' => $ed_id,
'map_id' => $map_id,
'path_id' => $path_id,
];
// 课程详情
$articleServ = new ArticleService();
$articleInfo = $articleServ->get($article_id);
// 课程考试通过
$conds = [
'article_id' => $article_id,
'uid' => $user['memUid'],
];
$allExamPass = false;// 系列课程:所有子课程测评完成,且本身不需要测评
if (!empty($source_id) && !empty($article_chapter_id)) {
$conds['article_chapter_id'] = $article_chapter_id;
$conds['source_id'] = $source_id;
if (Constant::ARTICLE_IS_CHECK_FALSE == $articleInfo['is_exam']) {
$articleHelper = &ArticleHelper::instance();
$allExamPass = $articleHelper->getStudyStatus($user['memUid'], $article_id, $customtask_id, $plan_id, $ed_id, $map_id, $path_id);
}
}
$examServ = new ExamService();
$examInfo = $examServ->get_by_conds($conds, ['created' => 'desc']);
// 测评通过,不是子课程 或 子课程全部测评通过(系列课程本身不需要测评)的情况下,触发积分、任务埋点
if (!empty($examInfo) && Constant::ARTICLE_EXAM_IS_PASS == $examInfo['is_pass'] && (empty($source_id) || $allExamPass)) {
switch ($articleInfo['course_type']) {
// 任务类课程,触发任务中心常规任务埋点:完成课程
case Constant::COURSE_TYPE_TASK:
$taskCenterServ = &TaskCenter::instance();
$taskCenterServ->triggerCustomtask([
'uid' => $user['memUid'],
'customtask_id' => $customtask_id,
'app_data_id' => $article_id,
'action_key' => 'course_study',
'description' => '完成课程',
]);
break;
// 线下培训类课程,触发埋点:完成课程
case Constant::COURSE_TYPE_TRAIN:
$trainServ = &Train::instance();
$trainServ->syncTrainStatus($plan_id, $article_id);
break;
// 其他类课程(学习地图),触发埋点:完成课程
case Constant::COURSE_TYPE_OTHER:
$studyMap = new StudyMap($map_id);
// 校验权限
$studyMap->checkRight($path_id, $article_id, $user);
// 触发埋点
$studyMap->studyContent($path_id, $article_id, $user);
break;
// 常规类课程,考试通过,并且不是系列课程的子课程,取激励
default:
$articleHelper = &ArticleHelper::instance();
$awardInfo = $articleHelper->getAwardByUser($user);
if (!empty($awardInfo)) {
$param['award_ids'] = array_column($awardInfo, 'award_id');
}
break;
}
}
// 课程
$param['data_id'] = isset($articleInfo['data_id']) ? $articleInfo['data_id'] : '';
if (isset($articleInfo['article_type']) && Constant::ARTICLE_TYPE_MULTI == $articleInfo['article_type']) {
// 系列课程
if (empty($source_id) || Constant::ARTICLE_EXAM_IS_PASS == $examInfo['is_pass']) {
// 没有素材ID 或 通过测评,跳转至系列课程详情
redirectFront('app/page/course/detail/course-detail', $param);
} else {
// 存在素材ID和帐章节ID,跳转至素材详情页
$param['source_id'] = $source_id;
$param['article_chapter_id'] = $article_chapter_id;
redirectFront('app/page/course/detail/detail', $param);
}
} else {
// 单课程
redirectFront('app/page/course/detail/detail', $param);
}
}
}