AnswerDetailModel.class.php
5.68 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php
/**
* 考试-答卷详情表
* @author: houyingcai
* @email: 594609175@qq.com
* @date : 2017-05-19 18:03:52
* @version $Id$
*/
namespace Common\Model;
class AnswerDetailModel extends AbstractModel
{
// 待批阅
const READ = 1;
// 批阅中
const READING = 2;
// 已批阅
const READ_OVER = 3;
/**
* 构造方法
*/
public function __construct()
{
parent::__construct();
}
/**
* 查询答题记录个数
*
* @author: 蔡建华
* @param int $ep_id
* @param string $uid 用户ID
* @param string $fields 返回字段
*
* @return array
*/
public function answer_detail_record_num($ep_id = 0, $uid = '', $fields = "*")
{
$where = ' status < ? AND domain = ? ';
$params[] = AnswerModel::ST_DELETE;
$params[] = QY_DOMAIN;
$AnswerModel = new AnswerModel();
$table = $AnswerModel->get_tname();
$sql = " AND ea_id in( select distinct ea_id from " . $table . " where status <? AND domain= ? AND ep_id=? AND is_pass in(?) AND uid = ?)";
$params[] = AnswerModel::ST_DELETE;
$params[] = QY_DOMAIN;
$params[] = $ep_id;
$params[] = [self::NO_MY_PASS, self::MY_PASS];
$params[] = $uid;
$sql = "select count( {$fields}) from __TABLE__ where {$where} $sql";
return $this->_m->result($sql, $params);
}
/**
* 计算分数总和
*
* @param array $conds 查询条件
*
* @return array|bool
*/
public function get_score($conds = [])
{
$params = [];
// 条件
$wheres = [];
if (!$this->_parse_where($wheres, $params, $conds)) {
return false;
}
// 企业标记
$wheres[] = "`{$this->prefield}domain`=?";
$params[] = QY_DOMAIN;
// 状态条件
$wheres[] = "`{$this->prefield}status`<?";
$params[] = $this->get_st_delete();
$sql = "select sum(my_score) FROM __TABLE__ where " . implode(' AND ', $wheres);
return $this->_m->result($sql, $params);
}
/**
* 根据条件查询试卷
*
* @author: 蔡建华
* @param $conds array 查询条件
* @param null $page_option 分页参数
* @param array $order_option 排序参数
* @param string $fields 查询的字段
*
* @return array|bool
*/
public function count_answer_detail_list($conds, $page_option = null, $order_option = [], $fields = '*')
{
$params = [];
// 条件
$wheres = [];
if (!$this->_parse_where($wheres, $params, $conds)) {
return false;
}
// 企业标记
$wheres[] = "a.domain=?";
$params[] = QY_DOMAIN;
// 状态条件
$wheres[] = "a.status<?";
$params[] = $this->get_st_delete();
$answer = new AnswerModel();
$table = $answer->get_tname();
// 排序
$orderby = '';
if (!$this->_order_by($orderby, $order_option)) {
return false;
}
// 分页参数
$limit = '';
if (!$this->_limit($limit, $page_option)) {
return false;
}
$sql = "SELECT $fields FROM __TABLE__ a LEFT JOIN $table b on a.ea_id =b.ea_id WHERE " . implode(' AND ',
$wheres) . " {$orderby} {$limit}";
// 读取记录
return $this->_m->fetch_array($sql, $params);
}
/**
* 根据条件查询试卷列表
*
* @author: 蔡建华
* @param $conds array 查询条件
* @param null $page_option 分页参数
* @param array $order_option 排序参数
* @param string $fields 查询的字段
*
* @return array|bool
*/
public function answer_detail_list($conds, $page_option = null, $order_option = [], $fields = '*')
{
$params = [];
// 条件
$wheres = [];
if (!$this->_parse_where($wheres, $params, $conds)) {
return false;
}
// 企业标记
$wheres[] = "domain=?";
$params[] = QY_DOMAIN;
// 状态条件
$wheres[] = "status<?";
$params[] = $this->get_st_delete();
$answer = new AnswerModel();
$table = $answer->get_tname();
$wheres[] = "ea_id in(SElECT ea_id FROM $table where (answer_status=?))";
$params[] = self::READ_OVER;
// 排序
$orderby = '';
if (!$this->_order_by($orderby, $order_option)) {
return false;
}
// 分页参数
$limit = '';
if (!$this->_limit($limit, $page_option)) {
return false;
}
$sql = "SELECT {$fields} FROM __TABLE__ WHERE " . implode(' AND ',
$wheres) . "{$orderby}{$limit}";
// 读取记录
return $this->_m->fetch_array($sql, $params);
}
/**
* 根据条件查询试卷列表
*
* @author: 蔡建华
* @param $conds array 查询条件
*
* @return int
*/
public function answer_detail_count($conds)
{
$params = [];
// 条件
$wheres = [];
if (!$this->_parse_where($wheres, $params, $conds)) {
return false;
}
// 企业标记
$wheres[] = "a.domain=?";
$params[] = QY_DOMAIN;
// 状态条件
$wheres[] = "a.status<?";
$params[] = $this->get_st_delete();
$wheres[] = "b.answer_status=?";
$params[] = self::READ_OVER;
$sql = "SELECT count(*) FROM __TABLE__ a LEFT JOIN `oa_exam_answer` b ON a.ea_id =b.ea_id WHERE " . implode(' AND ',
$wheres);
// 读取记录
$count = $this->_m->result($sql, $params);
return $count;
}
}