Commit 23f8217a by 刘海龙

Merge branch 'master' of http://132.232.91.252:9999/ice/eduline

parents 80745f18 3816d04b
......@@ -106,7 +106,7 @@ class IndexAction extends Action
if ($_GET['best']) {
$where['best'] = 1;
}
$list = D('ExamsPaper', 'exams')->getPaperPageList($where, 16, $order, true);
$list = D('ExamsPaper', 'exams')->getPaperPageList($where, 16, $order, true, $_GET['api']);
foreach ($list['data'] as &$v) {
$v['paper_options'] = D('ExamsPaperOptions', 'exams')->where(['exams_paper_id'=>$v['exams_paper_id']])->field('questions_count,score')->find();//getPaperOptionsById($v['exams_paper_id']);
//判断是否需要购买 (管理员)
......
......@@ -25,7 +25,7 @@ class ExamsPaperModel extends Model
* @param integer $limit [description]
* @return array [description]
*/
public function getPaperPageList($map = [], $limit = 20, $order = 'default', $from_front = false)
public function getPaperPageList($map = [], $limit = 20, $order = 'default', $from_front = false, $isApi = 0)
{
$map['is_del'] = 0;
if(!is_admin($this->mid) && $from_front){
......@@ -37,6 +37,14 @@ class ExamsPaperModel extends Model
$str = rtrim($str, 'OR ');
$map['_string'] .= $str.')';
}
if ((int)$isApi === 1) {
$map['_string'] .= ' AND EXISTS ( SELECT exams_paper_id from el_exams_paper_options WHERE el_exams_paper_options.exams_paper_id = el_exams_paper.exams_paper_id)';
}
if ((int)$isApi === 2) {
$map['_string'] .= ' AND attachment > 0';
}
$order = isset($this->order_field[$order]) ? $this->order_field[$order] : $order;
$list = $this->where($map)->order($order)->findPage($limit);
if ($list['data']) {
......
......@@ -327,7 +327,7 @@
let that = this
$.ajax({
type: "GET",
url: "{:U('exams/Index/paper')}" + "&api=1&c=" + that.conditionId,
url: "{:U('exams/Index/paper')}" + "&api=2&c=" + that.conditionId,
dataType: "json",
success: function(res) {
if(res.status == 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment