...
|
...
|
@@ -4,7 +4,6 @@ namespace app\mobile\controller; |
|
|
use think\Validate;
|
|
|
use think\Db;
|
|
|
use app\common\controller\Api;
|
|
|
use app\mobile\model\Simulation as SimulationModel;
|
|
|
use app\mobile\model\Question;
|
|
|
use app\mobile\model\QuestionAnswer;
|
|
|
use app\mobile\model\SimulationResult;
|
...
|
...
|
@@ -21,6 +20,7 @@ class Simulation extends Api |
|
|
public function _initialize()
|
|
|
{
|
|
|
parent::_initialize();
|
|
|
$this->model = model('app\mobile\model\Simulation');
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -46,7 +46,7 @@ class Simulation extends Api |
|
|
{
|
|
|
$banner = Db::name('mobile_config')->where('id',1)->value('simulation_adver');
|
|
|
$banner = !empty($banner) ? cdnurl($banner,true) : '';
|
|
|
$list = SimulationModel::order('createtime desc')->select();
|
|
|
$list = $this->model->order('createtime desc')->select();
|
|
|
foreach ($list as $v) {
|
|
|
$v->visible(['id','title','do_num']);
|
|
|
}
|
...
|
...
|
@@ -80,7 +80,7 @@ class Simulation extends Api |
|
|
{
|
|
|
$simulation_id = $this->request->param('simulation_id');
|
|
|
empty($simulation_id) && $this->error('缺少必要参数');
|
|
|
$info = SimulationModel::get($simulation_id);
|
|
|
$info = $this->model->get($simulation_id);
|
|
|
empty($info) && $this->error('试卷信息不存在');
|
|
|
$info['full_score'] = Question::where('target_id',$simulation_id)->sum('score');
|
|
|
$info = $info->visible(['id','title','year','time','pass_score','goods_degree','description','do_num'])->append(['full_score']);
|
...
|
...
|
@@ -118,7 +118,7 @@ class Simulation extends Api |
|
|
$user_id = $this->auth->id;
|
|
|
$simulation_id = $this->request->param('simulation_id');
|
|
|
empty($simulation_id) && $this->error('缺少必要参数');
|
|
|
$info = SimulationModel::get($simulation_id);
|
|
|
$info = $this->model->get($simulation_id);
|
|
|
empty($info) && $this->error('试卷信息不存在');
|
|
|
$time = $info['time'] * 60;
|
|
|
$list = Question::alias('q')
|
...
|
...
|
@@ -172,7 +172,7 @@ class Simulation extends Api |
|
|
$user_id = $this->auth->id;
|
|
|
$simulation_id = $this->request->param('simulation_id');
|
|
|
empty($simulation_id) && $this->error('缺少必要参数');
|
|
|
$info = SimulationModel::get($simulation_id);
|
|
|
$info = $this->model->get($simulation_id);
|
|
|
empty($info) && $this->error('试卷信息不存在');
|
|
|
$list = Question::alias('q')
|
|
|
->join('mobile_question_answer qa','q.id = qa.question_id and user_id='.$user_id,'left')
|
...
|
...
|
@@ -216,7 +216,7 @@ class Simulation extends Api |
|
|
$user_id = $this->auth->id;
|
|
|
$simulation_id = $this->request->param('simulation_id');
|
|
|
empty($simulation_id) && $this->error('缺少必要参数');
|
|
|
$info = SimulationModel::get($simulation_id);
|
|
|
$info = $this->model->get($simulation_id);
|
|
|
empty($info) && $this->error('试卷信息不存在');
|
|
|
$list = Question::alias('q')
|
|
|
->join('mobile_question_answer qa','q.id = qa.question_id and user_id='.$user_id,'left')
|
...
|
...
|
|