[原创]一个考试系统中的存储过程用来生成试卷用的

存储过程|原创

CREATE proc paperbuild @papername char(200), @subject char(10), @xzt int,@xztn int,@tkt int,@tktn int,@pdt int,@pdtn int,
@wdt int,@wdtn int as
/*
power by :liujun
address:衡阳师范学院计算机系0102班
选择题生成部分
*/
declare @bxzt int,@ken varchar(8000)
declare @tempsql varchar(8000),@lxzt int,@lsnd int
set @bxzt=@xzt/2
set @ken=(select top 1 kenlist from tempkenlist where papername=@papername)
set @tempsql='insert into paper(question1,q_type,right_answer,option1,difficulty) select top '+str(@bxzt)+' question1,q_type,right_answer,option1,difficulty from question where q_type=''选择题'' and subject='''+@subject+''' and ken in '+@ken+' order by newid()'
execute(@tempsql)

set @tempsql='update paper set papername='''+@papername+''' where papername is null'
execute(@tempsql)

set @lxzt=@xzt-@bxzt
set @lsnd=(select avg(difficulty) from paper where papername=@papername and q_type='选择题')

if @lsnd>@xztn
begin
 set @tempsql='insert into paper(question1,q_type,right_answer,option1,difficulty) select top '+str(@lxzt)+' question1,q_type,right_answer,option1,difficulty from question where q_type=''选择题'' and subject='''+@subject+''' and difficulty<'''+str(@lsnd)+''' and ken in '+@ken+' and question1 not in(select question1 from paper where q_type=''选择题'' and papername='''+@papername+''') order by newid()'
 execute (@tempsql)
end
else
begin
 set @tempsql='insert into paper(question1,q_type,right_answer,option1,difficulty) select top '+str(@lxzt)+' question1,q_type,right_answer,option1,difficulty from question where q_type=''选择题'' and subject='''+@subject+''' and difficulty>'''+str(@lsnd)+''' and ken in '+@ken+' and question1 not in(select question1 from paper where q_type=''选择题'' and papername='''+@papername+''') order by newid()'
 execute (@tempsql)
end
set @tempsql='update paper set papername='''+@papername+''' where papername is null'
execute(@tempsql)
/*
填空题生成部分
*/
declare @btkt int,@ltkt int
set @btkt=@tkt/2

set @tempsql='insert into paper(question1,q_type,right_answer,option1,difficulty) select top '+str(@btkt)+' question1,q_type,right_answer,option1,difficulty from question where q_type=''填空题'' and subject='''+@subject+''' and ken in '+@ken+' order by newid()'
execute(@tempsql)

set @tempsql='update paper set papername='''+@papername+''' where papername is null'
execute(@tempsql)

set @ltkt=@tkt-@btkt
set @lsnd=(select avg(difficulty) from paper where papername=@papername and q_type='填空题')

if @lsnd>@tktn
begin
 set @tempsql='insert into paper(question1,q_type,right_answer,option1,difficulty) select top '+str(@ltkt)+' question1,q_type,right_answer,option1,difficulty from question where q_type=''填空题'' and subject='''+@subject+''' and difficulty<'''+str(@lsnd)+''' and ken in '+@ken+' and question1 not in(select question1 from paper where q_type=''填空题''  and papername='''+@papername+''') order by newid()'
 execute (@tempsql)
end
else
begin
 set @tempsql='insert into paper(question1,q_type,right_answer,option1,difficulty) select top '+str(@ltkt)+' question1,q_type,right_answer,option1,difficulty from question where q_type=''填空题'' and subject='''+@subject+''' and difficulty>'''+str(@lsnd)+''' and ken in '+@ken+' and question1 not in(select question1 from paper where q_type=''填空题'' and papername='''+@papername+''') order by newid()'
 execute (@tempsql)
end
set @tempsql='update paper set papername='''+@papername+''' where papername is null'
execute(@tempsql)

/*
判断题生成部分
*/
declare @bpdt int,@lpdt int
set @bpdt=@pdt/2

set @tempsql='insert into paper(question1,q_type,right_answer,option1,difficulty) select top '+str(@bpdt)+' question1,q_type,right_answer,option1,difficulty from question where q_type=''判断题'' and subject='''+@subject+''' and ken in '+@ken+' order by newid()'
execute(@tempsql)

set @tempsql='update paper set papername='''+@papername+''' where papername is null'
execute(@tempsql)

set @lpdt=@pdt-@bpdt
set @lsnd=(select avg(difficulty) from paper where papername=@papername and q_type='判断题')
if @lsnd>@pdtn
begin
 set @tempsql='insert into paper(question1,q_type,right_answer,option1,difficulty) select top '+str(@lpdt)+' question1,q_type,right_answer,option1,difficulty from question where q_type=''判断题'' and subject='''+@subject+''' and difficulty<'''+str(@lsnd)+''' and ken in '+@ken+' and question1 not in (select question1 from paper where q_type=''判断题'' and papername='''+@papername+''') order by newid()'
 execute (@tempsql)
end
else
begin
 set @tempsql='insert into paper(question1,q_type,right_answer,option1,difficulty) select top '+str(@lpdt)+' question1,q_type,right_answer,option1,difficulty from question where q_type=''判断题'' and subject='''+@subject+''' and difficulty>'''+str(@lsnd)+''' and ken in '+@ken+' and question1 not in (select question1 from paper where q_type=''判断题'' and papername='''+@papername+''') order by newid()'
 execute (@tempsql)
end
set @tempsql='update paper set papername='''+@papername+''' where papername is null'
execute(@tempsql)

/*
问答题生成部分
*/
declare @bwdt int,@lwdt int
set @bwdt=@wdt/2

set @tempsql='insert into paper(question1,q_type,right_answer,option1,difficulty) select top '+str(@bwdt)+' question1,q_type,right_answer,option1,difficulty from question where q_type=''问答题'' and subject='''+@subject+''' and ken in '+@ken+'  order by newid()'
execute(@tempsql)

set @tempsql='update paper set papername='''+@papername+''' where papername is null'
execute(@tempsql)

set @lwdt=@wdt-@bwdt
set @lsnd=(select avg(difficulty) from paper where papername=@papername and q_type='问答题')
select @wdtn
if @lsnd>@wdtn
begin
 set @tempsql='insert into paper(question1,q_type,right_answer,option1,difficulty) select top '+str(@lwdt)+' question1,q_type,right_answer,option1,difficulty from question where q_type=''问答题'' and subject='''+@subject+''' and ken in '+@ken+' and difficulty<'+str(@lsnd)+' and question1 not in (select question1 from paper where q_type=''问答题'' and papername='''+@papername+''') order by newid()'
 execute (@tempsql)
end
else
begin
 set @tempsql='insert into paper(question1,q_type,right_answer,option1,difficulty) select top '+str(@lwdt)+' question1,q_type,right_answer,option1,difficulty from question where q_type=''问答题'' and subject='''+@subject+''' and ken in '+@ken+' and difficulty>'+str(@lsnd)+' and question1 not in (select question1 from paper where q_type=''问答题'' and papername='''+@papername+''') order by newid()'
 execute (@tempsql)
end
set @tempsql='update paper set papername='''+@papername+''' where papername is null'
execute(@tempsql)

时间: 2024-08-17 16:05:53

[原创]一个考试系统中的存储过程用来生成试卷用的的相关文章

如何在考试系统中实现页面时间倒计时显示和屏幕安全控制,比如不能使用右键,不能拷贝等等?

问题描述 如何在考试系统中实现页面时间倒计时显示和屏幕安全控制,比如不能使用右键,不能拷贝等等? 解决方案 解决方案二:关注解决方案三:看来CSDN也不行呀,这么长时间了,也没人给点建议

求助大神,关于ASP.NET在线考试系统中的问题

问题描述 求助大神,为什么在线考试模块不能抓取考试成绩?代码如下:usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls

请教一个国家级系统中用户信息表应该包含字段

问题描述 最近一个国家级的项目,在设计后台的时候,发现用户信息表中有些常用信息不够,不知道那位大侠有过这方面的经验,请赐教!!谢谢 解决方案 解决方案二:不要停下去啊,解决方案三:国家级别....膜拜企业级别的漂过....解决方案四:引用楼主wazheng的回复: 最近一个国家级的项目,在设计后台的时候,发现用户信息表中有些常用信息不够,不知道那位大侠有过这方面的经验,请赐教!!谢谢 不太清楚你这个国家级的是指什么有更具体的么?解决方案五:国家级是神马?>解决方案六:神马是国家级啊,我现在做的是

sql系统中的存储过程,从中可以找到查询各种信息的语句

create procedure sys.sp_help @objname nvarchar(776) = NULL -- object name we're after as -- PRELIMINARY set nocount on declare @dbname sysname ,@no varchar(35), @yes varchar(35), @none varchar(35) select @no = 'no', @yes = 'yes', @none = 'none' -- If

考虑一个新闻系统中的新闻分类无限分类的可行方式

问题描述 请大家能说的清楚些......如果有类似的前台效果的页面发给我看下也行,,,, 解决方案 解决方案二:使用树.解决方案三:up又开新帖了解决方案四:不明白你的意思,建立分类表,ID类名不可以无限添加么解决方案五:http://www.51aspx.com/CV/xiaokongzi/下载下来看看解决方案六:大哥-这个就是用递归来实现无限分类的.解决方案七:无限分类好像不太现实,一般也就几级吧解决方案八:现成的就用tree,或者自己写递归解决方案九:递归关注mark解决方案十:递归~

在 Visual Basic .NET 中使用存储过程(1)

visual|存储过程 在 Visual Basic .NET 中使用存储过程 Billy Hollis 2002年9月14日 从 MSDN Code Center 下载 StoredProcVB.NET.exe 示例文件(英文).(http://msdn.microsoft.com/code/default.asp?url=/code/sample.asp?url=/msdn-files/026/002/872/msdncompositedoc.xml) 摘要:Billy Hollis 解释了

用WPS表格制作考试系统

目前,标准化考试正大行其道.能不能用WPS表格来制作一套标准化考试题呢?很简单,只要用好其中的公式.函数.窗体就行了. 本考试系统功能: ★学生除输入姓名外,其余操作都用鼠标完成,非常方便. ★系统可自动扫描考生姓名.成绩,避免教师手动批阅的辛苦. ★修改试题库即可更新试题内容. 1.制作试题工作表 1.1表头设计 表头,一般位于工作表的左上部,对整个工作表有重要的导航作用,如图1所示. 图1 图1 表头设计 第1步:新建工作薄.新建一个名为"WPSKSXT"的工作薄,为保证它能在EX

有关考试系统开发的问题

问题描述 我在做一个考试系统,想实现这样一个功能.从题库中随机取出十道题,通过动态控件显示在placeholder里,动态控件主要是有三种,第一种是lable,第二种是单选按钮,第三种多选按钮.第一次显示是可以正常显示的.但是当点提交后就出了以下提示:"/"应用程序中的服务器错误.--------------------------------------------------------------------------------startIndex不能大于字符串长度.参数名:

大家都来挑战一下难度!考试系统找出作弊的人!

问题描述 虽说不是项目中..假设有一个考试系统...ABCD型的答案...怎么找到答案相似度高的同学...用来方便查找是否有人作弊..除了一个个用费时的for的话有没有更好的办法..数据表又怎么建? 解决方案 解决方案二:可以比较有几个答案不一样肯定得循环啊,至于用for还是while就看你了解决方案三:选择题判断有没有作弊是不行的利用主观题程序也查不来这事还要人做解决方案四:可以查找一下错误答案相同...连错误的都差不多~~~!肯定的啦..而且是查的相似度..不是100%.只是拿来参考下是不是