[原创]一个考试系统中的存储过程用来生成试卷用的
2008-04-26 20:47
615 查看
CREATEprocpaperbuild@papernamechar(200),@subjectchar(10),@xztint,@xztnint,@tktint,@tktnint,@pdtint,@pdtnint,
@wdtint,@wdtnintas
/*
powerby:liujun
address:衡阳师范学院计算机系0102班
选择题生成部分
*/
declare@bxztint,@kenvarchar(8000)
declare@tempsqlvarchar(8000),@lxztint,@lsndint
set@bxzt=@xzt/2
set@ken=(selecttop1kenlistfromtempkenlistwherepapername=@papername)
set@tempsql='insertintopaper(question1,q_type,right_answer,option1,difficulty)selecttop'+str(@bxzt)+'question1,q_type,right_answer,option1,difficultyfromquestionwhereq_type=''选择题''andsubject='''+@subject+'''andkenin'+@ken+'orderbynewid()'
execute(@tempsql)
set@tempsql='updatepapersetpapername='''+@papername+'''wherepapernameisnull'
execute(@tempsql)
set@lxzt=@xzt-@bxzt
set@lsnd=(selectavg(difficulty)frompaperwherepapername=@papernameandq_type='选择题')
if@lsnd>@xztn
begin
set@tempsql='insertintopaper(question1,q_type,right_answer,option1,difficulty)selecttop'+str(@lxzt)+'question1,q_type,right_answer,option1,difficultyfromquestionwhereq_type=''选择题''andsubject='''+@subject+'''anddifficulty<'''+str(@lsnd)+'''andkenin'+@ken+'andquestion1notin(selectquestion1frompaperwhereq_type=''选择题''andpapername='''+@papername+''')orderbynewid()'
execute(@tempsql)
end
else
begin
set@tempsql='insertintopaper(question1,q_type,right_answer,option1,difficulty)selecttop'+str(@lxzt)+'question1,q_type,right_answer,option1,difficultyfromquestionwhereq_type=''选择题''andsubject='''+@subject+'''anddifficulty>'''+str(@lsnd)+'''andkenin'+@ken+'andquestion1notin(selectquestion1frompaperwhereq_type=''选择题''andpapername='''+@papername+''')orderbynewid()'
execute(@tempsql)
end
set@tempsql='updatepapersetpapername='''+@papername+'''wherepapernameisnull'
execute(@tempsql)
/*
填空题生成部分
*/
declare@btktint,@ltktint
set@btkt=@tkt/2
set@tempsql='insertintopaper(question1,q_type,right_answer,option1,difficulty)selecttop'+str(@btkt)+'question1,q_type,right_answer,option1,difficultyfromquestionwhereq_type=''填空题''andsubject='''+@subject+'''andkenin'+@ken+'orderbynewid()'
execute(@tempsql)
set@tempsql='updatepapersetpapername='''+@papername+'''wherepapernameisnull'
execute(@tempsql)
set@ltkt=@tkt-@btkt
set@lsnd=(selectavg(difficulty)frompaperwherepapername=@papernameandq_type='填空题')
if@lsnd>@tktn
begin
set@tempsql='insertintopaper(question1,q_type,right_answer,option1,difficulty)selecttop'+str(@ltkt)+'question1,q_type,right_answer,option1,difficultyfromquestionwhereq_type=''填空题''andsubject='''+@subject+'''anddifficulty<'''+str(@lsnd)+'''andkenin'+@ken+'andquestion1notin(selectquestion1frompaperwhereq_type=''填空题'' andpapername='''+@papername+''')orderbynewid()'
execute(@tempsql)
end
else
begin
set@tempsql='insertintopaper(question1,q_type,right_answer,option1,difficulty)selecttop'+str(@ltkt)+'question1,q_type,right_answer,option1,difficultyfromquestionwhereq_type=''填空题''andsubject='''+@subject+'''anddifficulty>'''+str(@lsnd)+'''andkenin'+@ken+'andquestion1notin(selectquestion1frompaperwhereq_type=''填空题''andpapername='''+@papername+''')orderbynewid()'1
@wdtint,@wdtnintas
/*
powerby:liujun
address:衡阳师范学院计算机系0102班
选择题生成部分
*/
declare@bxztint,@kenvarchar(8000)
declare@tempsqlvarchar(8000),@lxztint,@lsndint
set@bxzt=@xzt/2
set@ken=(selecttop1kenlistfromtempkenlistwherepapername=@papername)
set@tempsql='insertintopaper(question1,q_type,right_answer,option1,difficulty)selecttop'+str(@bxzt)+'question1,q_type,right_answer,option1,difficultyfromquestionwhereq_type=''选择题''andsubject='''+@subject+'''andkenin'+@ken+'orderbynewid()'
execute(@tempsql)
set@tempsql='updatepapersetpapername='''+@papername+'''wherepapernameisnull'
execute(@tempsql)
set@lxzt=@xzt-@bxzt
set@lsnd=(selectavg(difficulty)frompaperwherepapername=@papernameandq_type='选择题')
if@lsnd>@xztn
begin
set@tempsql='insertintopaper(question1,q_type,right_answer,option1,difficulty)selecttop'+str(@lxzt)+'question1,q_type,right_answer,option1,difficultyfromquestionwhereq_type=''选择题''andsubject='''+@subject+'''anddifficulty<'''+str(@lsnd)+'''andkenin'+@ken+'andquestion1notin(selectquestion1frompaperwhereq_type=''选择题''andpapername='''+@papername+''')orderbynewid()'
execute(@tempsql)
end
else
begin
set@tempsql='insertintopaper(question1,q_type,right_answer,option1,difficulty)selecttop'+str(@lxzt)+'question1,q_type,right_answer,option1,difficultyfromquestionwhereq_type=''选择题''andsubject='''+@subject+'''anddifficulty>'''+str(@lsnd)+'''andkenin'+@ken+'andquestion1notin(selectquestion1frompaperwhereq_type=''选择题''andpapername='''+@papername+''')orderbynewid()'
execute(@tempsql)
end
set@tempsql='updatepapersetpapername='''+@papername+'''wherepapernameisnull'
execute(@tempsql)
/*
填空题生成部分
*/
declare@btktint,@ltktint
set@btkt=@tkt/2
set@tempsql='insertintopaper(question1,q_type,right_answer,option1,difficulty)selecttop'+str(@btkt)+'question1,q_type,right_answer,option1,difficultyfromquestionwhereq_type=''填空题''andsubject='''+@subject+'''andkenin'+@ken+'orderbynewid()'
execute(@tempsql)
set@tempsql='updatepapersetpapername='''+@papername+'''wherepapernameisnull'
execute(@tempsql)
set@ltkt=@tkt-@btkt
set@lsnd=(selectavg(difficulty)frompaperwherepapername=@papernameandq_type='填空题')
if@lsnd>@tktn
begin
set@tempsql='insertintopaper(question1,q_type,right_answer,option1,difficulty)selecttop'+str(@ltkt)+'question1,q_type,right_answer,option1,difficultyfromquestionwhereq_type=''填空题''andsubject='''+@subject+'''anddifficulty<'''+str(@lsnd)+'''andkenin'+@ken+'andquestion1notin(selectquestion1frompaperwhereq_type=''填空题'' andpapername='''+@papername+''')orderbynewid()'
execute(@tempsql)
end
else
begin
set@tempsql='insertintopaper(question1,q_type,right_answer,option1,difficulty)selecttop'+str(@ltkt)+'question1,q_type,right_answer,option1,difficultyfromquestionwhereq_type=''填空题''andsubject='''+@subject+'''anddifficulty>'''+str(@lsnd)+'''andkenin'+@ken+'andquestion1notin(selectquestion1frompaperwhereq_type=''填空题''andpapername='''+@papername+''')orderbynewid()'1
相关文章推荐
- 一个用来生成流水号的存储过程
- 一个用来生成流水号的存储过程
- 考试试卷自己主动生成系统
- PROCEDURE_监测系统_原始数据报表数据生成存储过程—求每天平均值插入多表视图
- 好久没来了。共享一个自动生成编号的存储过程
- 通用存储过程: 生成某一个表分页的存储过程
- 使用系统表根据存储过程名字生成ADO.NET数据库访问代码
- 考试试卷自动生成系统
- 考试试卷自动生成系统
- 自动生成对一个数据表的插入和更新的存储过程
- 分享一个自动生成单据的存储过程
- 一个存储过程一分钟一键生成所有实体类
- 一个通用的分页存储过程(原创)
- 一个通用的分页存储过程(原创)
- 一个值得研究的系统存储过程 sp_MSforeachtable
- CodeSmith下载与生成存储过程的一个模板
- 考试试卷自动生成系统
- 将mater库中的系统存储过程批量生成*.sql文件--通用且非常实用
- 一个自动生成预制SQL 的存储过程(一)