on et_exam_exampaper_and_editexampaper.id = et_exam_editexampaper.edit_id
where <@p>edit_id</@p>
order by num asc
]]></sql>
<sqlid="getCount"><![CDATA[
select
(select count(type_num) q_count
from et_exam_exampaper_and_editexampaper
inner join et_exam_editexampaper
on et_exam_exampaper_and_editexampaper.id = et_exam_editexampaper.edit_id
where <@p>edit_id</@p> and type_num=1) q_count1,
(select count(type_num) q_count
from et_exam_exampaper_and_editexampaper
inner join et_exam_editexampaper
on et_exam_exampaper_and_editexampaper.id = et_exam_editexampaper.edit_id
where <@p>edit_id</@p> and type_num=2) q_count2,
(select count(type_num) q_count
from et_exam_exampaper_and_editexampaper
inner join et_exam_editexampaper
on et_exam_exampaper_and_editexampaper.id = et_exam_editexampaper.edit_id
where <@p>edit_id</@p> and type_num=3) q_count3,
(select count(type_num) q_count
from et_exam_exampaper_and_editexampaper
inner join et_exam_editexampaper
on et_exam_exampaper_and_editexampaper.id = et_exam_editexampaper.edit_id
where <@p>edit_id</@p> and type_num=4) q_count4,
(select count(type_num) q_count
from et_exam_exampaper_and_editexampaper
inner join et_exam_editexampaper
on et_exam_exampaper_and_editexampaper.id = et_exam_editexampaper.edit_id
where <@p>edit_id</@p> and type_num=5) q_count5
]]></sql>
<sqlid="insertHistoryExam"><![CDATA[
insert into et_exam_editexampaper (id,edit_id,num,subject,type,type_num,ismust,score,optionA,optionB,optionC,optionD,optionE,optionF,isParagraph,answer)
select md5(uuid()) as id,(select id from et_exam_exampaper_and_editexampaper where <@p>id</@p>) as edit_id,num,subject,type,type_num,ismust,score,optionA,optionB,optionC,optionD,optionE,optionF,isParagraph,answer
from et_exam_editexampaper
where <@p>edit_id</@p>
]]></sql>
<sqlid="questionTypeNum"><![CDATA[
select
(select count(*) from et_exam_question where <@p>categoryid</@p> and type = '1') singlenumcheck,
(select count(*) from et_exam_question where <@p>categoryid</@p> and type = '2') multiplenumcheck,
(select count(*) from et_exam_question where <@p>categoryid</@p> and type = '3') judgementnumcheck,
(select count(*) from et_exam_question where <@p>categoryid</@p> and type = '4') blanknumcheck,
(select count(*) from et_exam_question where <@p>categoryid</@p> and type = '5') essaynumcheck
]]></sql>
<sqlid="deleteExam"><![CDATA[
delete from et_exam_editexampaper where <@p>edit_id</@p>
]]></sql>
<sqlid="insertRandExam"><![CDATA[
insert into et_exam_editexampaper (id,edit_id,num,subject,type,type_num,ismust,optionA,optionB,optionC,optionD,optionE,optionF,isParagraph,answer)
(select md5(uuid()) as id,(select id from et_exam_exampaper_and_editexampaper where <@p>id</@p>) as edit_id,subject,question_type,type,1 as ismust,optionA,optionB,optionC,optionD,optionE,optionF,0 as isParagraph,answer
from et_exam_question where <@p>categoryid</@p>
and type = 1
<@p p=" and %s">card</@p>
order by rand() limit <@p p=" ? ">singleNum</@p>)
union
(select md5(uuid()) as id,(select id from et_exam_exampaper_and_editexampaper where <@p>id</@p>) as edit_id,subject,question_type,type,1 as ismust,optionA,optionB,optionC,optionD,optionE,optionF,0 as isParagraph,answer
from et_exam_question where <@p>categoryid</@p>
and type = 2
<@p p=" and %s">card</@p>
order by rand() limit <@p p=" ? ">multipleNum</@p>)
union
(select md5(uuid()) as id,(select id from et_exam_exampaper_and_editexampaper where <@p>id</@p>) as edit_id,subject,question_type,type,1 as ismust,optionA,optionB,optionC,optionD,optionE,optionF,0 as isParagraph,answer
from et_exam_question where <@p>categoryid</@p>
and type = 3
<@p p=" and %s">card</@p>
order by rand() limit <@p p=" ? ">judgementNum</@p>)
union
(select md5(uuid()) as id,(select id from et_exam_exampaper_and_editexampaper where <@p>id</@p>) as edit_id,subject,question_type,type,1 as ismust,optionA,optionB,optionC,optionD,optionE,optionF,0 as isParagraph,answer
from et_exam_question where <@p>categoryid</@p>
and type = 4
<@p p=" and %s">card</@p>
order by rand() limit <@p p=" ? ">blankNum</@p>)
union
(select md5(uuid()) as id,(select id from et_exam_exampaper_and_editexampaper where <@p>id</@p>) as edit_id,subject,question_type,type,1 as ismust,optionA,optionB,optionC,optionD,optionE,optionF,0 as isParagraph,answer
from et_exam_question where <@p>categoryid</@p>
and type = 5
<@p p=" and %s">card</@p>
order by rand() limit <@p p=" ? ">essayNum</@p>)
) a,(select @i:=0) z
]]></sql>
<sqlid="updateRandExamNum"><![CDATA[
update et_exam_editexampaper a,
(select (@i:=@i+1) i,id,type from et_exam_editexampaper where <@p p =" edit_id = ? ">id</@p> order by type_num) j,
(select @i:=0) z
set a.num = j.i
where a.id=j.id and <@p p =" edit_id = ? ">id</@p>
]]></sql>
<sqlid="getExampaperReturn"><![CDATA[
select * from et_exam_exampaper_and_editexampaper
where <@p>id</@p>
]]></sql>
<sqlid="getQuestionNum"><![CDATA[
select count(*) as num from et_exam_editexampaper
where <@p>edit_id</@p>
]]></sql>
<sqlid="getNumber"><![CDATA[
select count(*) as number,
(select count(*) from et_exam_editexampaper where <@p>edit_id</@p>) as sum