MockRecordController.class.php 1.78 KB
<?php
/**
 * 模拟考试记录列表
 * User: yingcai
 * Date: 2017/10/12
 * Time: 下午7:35
 */

namespace Apicp\Controller\Exam;

use Common\Common\ExamHelper;
use Common\Common\User;

class MockRecordController extends \Apicp\Controller\AbstractController
{
    /**
     * MockRecord
     * @author houyingcai
     * @desc 模拟考试记录列表
     * @param Int ep_id:true 试卷ID
     * @param String uid:true 用户uid
     * @return array
               array(
                    'username' => '任航正', // 姓名
                    'avatar' => "http://p.qlogo.cn/bizmail/nJu877ib3Gd3x5f9tdJHrajYVLtMS20IDcYJyFOnzTLpf1Eozs2xkyw/0", // 头像
                    'high_score' => '20.00', // 最高分
                    'list' => array( // 记录列表
                        array(
                            'ea_id' => 321,  // 答卷ID
                            'my_score' => '20.00',  // 得分
                            'my_begin_time' => 1502541598595, // 考试时间(毫秒级)
                            'my_time' => 37, // 用时(级)
                        ),
                    ),
                )
     */
    public function Index_post()
    {
        $params = I('post.');

        $ep_id = intval($params['ep_id']);
        if (!$ep_id) {

            E('_EMPTY_EP_ID');
        }

        $uid = $params['uid'];
        if (!$uid) {

            E('_EMPTY_UID');
        }

        $exam_helper = &ExamHelper::instance();

        // 模拟记录列表
        $list = $exam_helper->mock_record_list($ep_id, $uid);

        foreach ($list['list'] as &$v) {
            $v['ea_id'] = intval($v['ea_id']);
            $v['my_begin_time'] = (int)$v['my_begin_time'];
            $v['my_time'] = ceil($v['my_time']/1000);
        }

        $this->_result = $list;
    }

}