You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zhishifufei_php/application/wap/model/topic/TestPaper.php

83 lines
2.9 KiB

<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace app\wap\model\topic;
use traits\ModelTrait;
use basic\ModelBasic;
use app\wap\model\topic\TestPaperCategory;
/**
* 试卷列表 Model
* Class TestPaper
*/
class TestPaper extends ModelBasic
{
use ModelTrait;
/**
* 设置专题显示条件
* @param string $alias 别名
* @param null $model model
* @param bool $isAL 是否起别名,默认执行
* @return $this
*/
public static function PreExercisesWhere($alias = '', $model = null, $isAL = false)
{
if (is_null($model)) $model = new self();
if ($alias) {
$isAL || $model = $model->alias($alias);
$alias .= '.';
}
return $model->where(["{$alias}is_del" => 0, "{$alias}is_show" => 1, "{$alias}status" => 1]);
}
/**练习试卷列表
* @param int $page
* @param int $limit
* @param $tid
* @return array
*/
public static function getTestPaperExercisesList($type, $page, $limit, $pid, $tid, $search)
{
$model = self::PreExercisesWhere();
if ($tid) {
$model = $model->where(['tid' => $tid]);
} else if ($pid && !$tid) {
$tids = TestPaperCategory::where('pid', $pid)->column('id');
$model = $model->where('tid', 'in', $tids);
}
if ($search) $model = $model->where('title', 'LIKE', "%$search%");
$list = $model->where('type', $type)->order('sort desc,id desc')->page($page, $limit)->select();
$list = count($list) ? $list->toArray() : [];
foreach($list as &$item){
$item['answer'] = $item['fake_sales'] + $item['answer'];
}
return $list;
}
/**练习试卷列表
* @param int $page
* @param int $limit
* @param $tid
* @return array
*/
public static function getMerTestPaperList($mer_id,$type, $page, $limit,$institution = 0)
{
$list = [];
if (!$mer_id) return $list;
$model = self::PreExercisesWhere();
$list = $model->where(['type'=>$type])->where('mer_id','in',$mer_id)->where('institution_id',$institution)->order('sort desc,id desc')->page($page, $limit)->select();
$list = count($list) ? $list->toArray() : [];
return $list;
}
}