ClassQuestionModel.php
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?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;
}
}