DetailController.class.php 1.47 KB
<?php
/**
 * 【考试中心-手机端】5-获取考试结果接口
 * DetailController.class.php
 * @author: 蔡建华
 * @date: 2017-05-23
 */

namespace Api\Controller\Answer;

use Common\Service\AnswerService;
use Common\Service\PaperService;

class DetailController extends AbstractController
{

    public function Index_post()
    {
        // 接收post参数
        $params = I('post.');

        // 答卷id
        $ea_id = $params['ea_id'];

        // 答卷ID不能为空
        if (empty($ea_id)) {

            E('_EMPTY_EA_ID');
        }

        // 实例化答卷service
        $answer_s = new AnswerService();

        // 答卷详情
        $answer_info = $answer_s->get_by_conds(['ea_id' => $ea_id, 'uid' => $this->uid]);
        // 答卷详情为空:答卷不存在
        if (empty($answer_info)) {

            E('_ERR_ANSWER_NOT_FOUND');
        }

        // 试卷id
        $ep_id = $answer_info['ep_id'];

        // 实例化试卷service
        $paper_s = new PaperService();
        // 根据试卷id查询试卷信息
        $paper = $paper_s->get($ep_id);

        // 试卷信息不存在,返回提示"试卷信息不存在"
        if (empty($paper)) {

            E('_EMPTY_PAPER_DATA');
        }

        // 查询答卷数据,返回数据包括:试卷信息、答题情况列表数据
        $result = $answer_s->answer_detail_info($params, $this->_login->user,$answer_info,$paper);

        // 返回结果
        $this->_result = $result;
    }
}