and a.id not in(select exam_id from tr_exam_answer where account_id=#{accountId} and state in(1,2))
ORDER BY a.create_time desc
limit #{start},#{end}
</if>
<iftest="state == 2">
select a.name as name ,a.start_time as startTime,a.end_time as endTime,a.id as id,
a.training_project_id as trainingProjectId,a.description as description,
(SELECT MAX(score) FROM tr_exam_answer b WHERE a.id=b.exam_id AND b.account_id=#{accountId} AND b.state=2) AS score,
a.qualified_score,
CASE WHEN NOW() > a.end_time THEN 7 ELSE
(SELECT CASE WHEN IFNULL(MAX(score),-1)=-1 THEN 0 ELSE CASE WHEN MAX(score)>=a.qualified_score THEN 6 ELSE 5 END END AS score FROM tr_exam_answer b WHERE a.id=b.exam_id AND b.account_id=#{accountId} AND b.state=2)
select a.name as name ,a.start_time as startTime,a.end_time as endTime,a.id as id,
a.training_project_id as trainingProjectId,a.description as description,
(SELECT MAX(score) FROM tr_exam_answer b WHERE a.id=b.exam_id AND b.account_id=#{accountId} AND b.state=2) AS score,
CASE WHEN NOW() > a.end_time THEN 7 ELSE
(SELECT CASE WHEN IFNULL(MAX(score),-1)=-1 THEN 0 ELSE CASE WHEN MAX(score)>=a.qualified_score THEN 6 ELSE 5 END END AS score FROM tr_exam_answer b WHERE a.id=b.exam_id AND b.account_id=#{accountId} AND b.state=2)
and a.id not in(select exam_id from tr_exam_answer where account_id=#{accountId} and state in(1,2))
and DATE_SUB(NOW(), INTERVAL 4 DAY) <= a.create_time
ORDER BY a.create_time desc
</if>
<iftest="state == 2">
select a.name as name ,a.start_time as startTime,a.end_time as endTime,a.id as id,
a.training_project_id as trainingProjectId,a.description as description,
(SELECT MAX(score) FROM tr_exam_answer b WHERE a.id=b.exam_id AND b.account_id=#{accountId} AND b.state=2) AS score,
a.qualified_score,
CASE WHEN NOW() > a.end_time THEN 7 ELSE
(SELECT CASE WHEN IFNULL(MAX(score),-1)=-1 THEN 0 ELSE CASE WHEN MAX(score)>=a.qualified_score THEN 6 ELSE 5 END END AS score FROM tr_exam_answer b WHERE a.id=b.exam_id AND b.account_id=#{accountId} AND b.state=2)
END AS handle,a.image,a.create_time, a.create_by_id, a.create_by_name
AND a.state = 2 and DATE_SUB(NOW(), INTERVAL 4 DAY) <= a.create_time
ORDER BY a.create_time desc
</if>
<iftest="state == null">
select a.name as name ,a.start_time as startTime,a.end_time as endTime,a.id as id,
a.training_project_id as trainingProjectId,a.description as description,
(SELECT MAX(score) FROM tr_exam_answer b WHERE a.id=b.exam_id AND b.account_id=#{accountId} AND b.state=2) AS score,
CASE WHEN NOW() > a.end_time THEN 7 ELSE
(SELECT CASE WHEN IFNULL(MAX(score),-1)=-1 THEN 0 ELSE CASE WHEN MAX(score)>=a.qualified_score THEN 6 ELSE 5 END END AS score FROM tr_exam_answer b WHERE a.id=b.exam_id AND b.account_id=#{accountId} AND b.state=2)
END AS handle,a.image,a.create_time, a.create_by_id, a.create_by_name