|
@@ -14,16 +14,17 @@ class Index extends Api
|
|
|
|
|
|
/**
|
|
/**
|
|
* 首页
|
|
* 首页
|
|
- *
|
|
|
|
|
|
+ * 热门试卷3个
|
|
|
|
+ * 未开始的 + 进行中的
|
|
*/
|
|
*/
|
|
public function index()
|
|
public function index()
|
|
{
|
|
{
|
|
- //热门试卷列表
|
|
|
|
$now = time();
|
|
$now = time();
|
|
$papers = Db::name('exam_paper')->field('id,image,title,start_time,end_time,total_score,limit_time')
|
|
$papers = Db::name('exam_paper')->field('id,image,title,start_time,end_time,total_score,limit_time')
|
|
->where('status', 'NORMAL')
|
|
->where('status', 'NORMAL')
|
|
->where('deletetime', NULL)
|
|
->where('deletetime', NULL)
|
|
- ->whereRaw("((start_time = 0 and end_time = 0) or (start_time < {$now} and end_time > {$now}))")
|
|
|
|
|
|
+// ->whereRaw("((start_time = 0 and end_time = 0) or (start_time < {$now} and end_time > {$now}))")
|
|
|
|
+ ->whereRaw("((end_time = 0) or (end_time > {$now}))")
|
|
// ->where('find_in_set(:user_ids,user_ids)', ['user_ids' => $this->auth->id])
|
|
// ->where('find_in_set(:user_ids,user_ids)', ['user_ids' => $this->auth->id])
|
|
->limit(3)
|
|
->limit(3)
|
|
->select();
|
|
->select();
|
|
@@ -37,6 +38,60 @@ class Index extends Api
|
|
$this->success('', $papers);
|
|
$this->success('', $papers);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 首页
|
|
|
|
+ * 全部培训3个
|
|
|
|
+ * 未开始的 + 进行中的
|
|
|
|
+ */
|
|
|
|
+ public function index_trainactive(){
|
|
|
|
+ $now = time();
|
|
|
|
+
|
|
|
|
+ $lists = Db::name('train_active')->field('id,title,logo_image,starttime,endtime')
|
|
|
|
+ ->where('status', 1)
|
|
|
|
+ ->where('deletetime', NULL)
|
|
|
|
+ ->whereRaw("((endtime = 0) or (endtime > {$now}))")
|
|
|
|
+ //->where("(userauth_status = 1) or (find_in_set('".$this->auth->id."',user_ids) )")
|
|
|
|
+ ->limit(3)
|
|
|
|
+ ->select();
|
|
|
|
+
|
|
|
|
+ foreach($lists as $key => &$val){
|
|
|
|
+ $val['image'] = localpath_to_netpath($val['logo_image']);
|
|
|
|
+
|
|
|
|
+ if($now < $val['starttime']){
|
|
|
|
+ $val['show_status'] = 1;
|
|
|
|
+ $val['show_status_text'] = '待开始';
|
|
|
|
+ }
|
|
|
|
+ if($val['starttime'] < $now && $now < $val['endtime']){
|
|
|
|
+ $val['show_status'] = 2;
|
|
|
|
+ $val['show_status_text'] = '进行中';
|
|
|
|
+ }
|
|
|
|
+ if($val['endtime'] < $now){
|
|
|
|
+ $val['show_status'] = 3;
|
|
|
|
+ $val['show_status_text'] = '已结束';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $this->success('', $lists);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //考试,更多,所有考试列表
|
|
|
|
+ public function all_paper_list(){
|
|
|
|
+
|
|
|
|
+ $papers = Db::name('exam_paper')->field('id,image,title,start_time,end_time,total_score,limit_time')
|
|
|
|
+ ->where('status', 'NORMAL')
|
|
|
|
+ ->where('deletetime', NULL)
|
|
|
|
+ ->autopage()
|
|
|
|
+ ->select();
|
|
|
|
+
|
|
|
|
+ foreach($papers as $key => &$val){
|
|
|
|
+ $val['image'] = localpath_to_netpath($val['image']);
|
|
|
|
+ $val['limit_time'] = $val['limit_time']/60; //秒转换分种
|
|
|
|
+ $val['is_start'] = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $this->success('', $papers);
|
|
|
|
+ }
|
|
|
|
+
|
|
//在线考试
|
|
//在线考试
|
|
//我的考试
|
|
//我的考试
|
|
//可参加考试
|
|
//可参加考试
|