ClassQuestionModel.php 1.2 KB
<?php
/**
 * Created by PhpStorm.
 * auther: sgj
 * Date: 2020/9/28
 * Time: 17:13
 */

namespace api\common\model;


use think\Model;

class ClassQuestionModel extends Model
{

    protected $name = 'class_question';

    /**
     * 获取班级问题
     * @param $class_id
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getClassQuesion($class_id){
//        $info[]='A.可能第';
//        $info[]='A.可能第';
//        $info[]='A.可能第';
//        $info[]='A.可能第';
        //dump(json_encode($info,true));
        $map['class_id']=$class_id;
        $list=$this->where($map)->select();
        foreach ($list as $k=>$v) {
            $info[$k]['options_array']=json_decode($v['options'],true);
            $info[$k]['title']=$v['title'];
            $info[$k]['answer']=$v['answer'];
            $info[$k]['id']=$v['id'];
        }
        return $info;
    }

    /**
     * 获取成绩
     */
    public function getAnswer($class_id){
        $map['class_id']=$class_id;
        $list=$this->where($map)->field('id,answer')->select()->toArray();
        return $list;
    }

}