ExamController.class.php
2.26 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
<?php
/**
* Created by PhpStorm.
* User: zhonglei
* Date: 17/6/5
* Time: 14:31
*/
namespace Frontend\Controller\Index;
use Common\Common\Constant;
use Common\Service\ArticleService;
use Common\Service\ArticleChapterService;
class ExamController extends AbstractController
{
/**
* Index
* @author zhonglei
* @desc 跳转至手机端测评
* @param Int article_id:true 课程ID
* @param Int article_chapter_id 章节ID,对素材测评时必填
* @param Int source_id 素材ID,对素材测评时必填
* @param Int customtask_id 任务ID
* @param int plan_id 培训计划ID
* @param int ed_id 培训ID
* @param int map_id 学习地图ID
* @param int path_id 学习路径ID
*/
public function Index()
{
$params = [
'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'),
];
// 对课程进行测评
if (empty($params['article_chapter_id']) && empty($params['source_id'])) {
$articleServ = new ArticleService();
$data = $articleServ->get($params['article_id']);
} else { // 对章节素材进行测评
$chapterServ = new ArticleChapterService();
$data = $chapterServ->get_by_conds([
'parent_id' => $params['article_chapter_id'],
'source_id' => $params['source_id'],
]);
}
if (!empty($data) && !empty($data['et_ids'])) {
$et_ids = unserialize($data['et_ids']);
// 随机题目
if ($data['rand_num'] > 0) {
$keys = (array)array_rand($et_ids, $data['rand_num']);
$et_ids = array_intersect_key_reserved($et_ids, $keys, true);
}
$params['et_ids'] = implode(',', $et_ids);
}
redirectFront('/app/page/exam/exam-going-promote', $params, 'Exam');
}
}