<?php /** * 【考试中心-后台】获取考试统计详情 * RecordController.class.php * @author: houyingcai * @email: 594609175@qq.com * @date : 2017-05-23 16:33:46 * @version $Id$ */ namespace Apicp\Controller\Answer; use Common\Service\CategoryService; use Common\Service\PaperService; use Common\Service\RightService; use Common\Service\AnswerService; class RecordController extends AbstractController { // 旧数据 const OLD_DATA = 1; // 新数据 const NEW_DATA = 2; /** @var CategoryService */ protected $cate_service; /** @var PaperService */ protected $paper_service; /** @var RightService */ protected $right_service; /** @var AnswerService */ protected $answer_service; public function before_action($action = '') { if (!parent::before_action($action)) { return false; } // 实例化试卷分类service $this->cate_service = new CategoryService(); // 实例化试卷service $this->paper_service = new PaperService(); // 实例化权限service $this->right_service = new RightService(); // 实例化答卷service $this->answer_service = new AnswerService(); return true; } public function Index_post() { $ep_id = I('ep_id', 0, 'intval'); //获取试卷ID if (!$ep_id) { E('_EMPTY_EP_ID'); } // 获取试卷详情 $paper = $this->paper_service->get($ep_id); // 试卷不存在 if (empty($paper)) { E('_ERR_PAPER_NOT_FOUND'); } // 新老数据标识 $is_old = $paper['is_old']; // 试卷类型:1=自主,2=规则,3=随机 $ep_type = $paper['ep_type']; // 是否显示试题分析:默认新数据显示 $show_analysis = self::NEW_DATA; // 随机抽题 if (PaperService::TOPIC_RANDOM == $ep_type) { // 老数据 if (self::OLD_DATA == $is_old) { // 随机老数据不显示 $show_analysis = self::OLD_DATA; } } $conds = [ 'epc_id' => $ep_id, 'er_type' => PaperService::RIGHT_PAPER ]; // 权限范围 $right = []; if ($paper['is_all'] != PaperService::AUTH_ALL) { list($db_right, $right) = $this->right_service->get_right_data($conds); } // 获取分类名称 $category = $this->cate_service->get($paper['ec_id']); // 组装返回数据 $data = array( 'paper_type' => (int)$paper['paper_type'], 'ep_name' => $paper['ep_name'], 'begin_time' => $paper['begin_time'], 'end_time' => $paper['end_time'], 'paper_time' => $paper['paper_time'], 'total_score' => (int)$paper['total_score'], 'pass_score' => (int)$paper['pass_score'], 'ec_name' => $category['ec_name'], 'is_all' => (int)$paper['is_all'], 'right' => $right ? $right : [], 'show_analysis' => $show_analysis ); $this->_result = $data; } }