1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 首页接口
- */
- class Index extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- /**
- * 首页
- *
- */
- public function index()
- {
- //热门试卷列表
- $now = time();
- $papers = Db::name('exam_paper')->field('id,image,title,start_time,end_time,total_score,limit_time')
- ->where('status', 'NORMAL')
- ->where('index_status', 1)
- ->whereRaw("((start_time = 0 and end_time = 0) or (start_time < {$now} and end_time > {$now}))")
- ->limit(3)
- ->select();
- foreach($papers as $key => &$val){
- $val['image'] = localpath_to_netpath($val['image']);
- $val['limit_time'] = $val['limit_time']/60; //秒转换分种
- }
- $this->success('', $papers);
- }
- //在线考试
- //我的考试
- //可参加考试
- //我的试卷
- //进行中考试
- //历史考试
- }
|