如何随意提问而不重复 [英] How to random a question without repetition

查看:110
本文介绍了如何随意提问而不重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的系统是电脑化考试。但我的问题是,如何在不重复的情况下随机输出所有问题。?

解决方案

假设您在数据库中有名为Question的表格。

让我们现在移动

 create table #RandomQuestion(id uniqueidentifier NOT NULL DEFAULT newid(),QuestionNo int)

insert into #RandomQuestion(QuestionNo)
从问题中选择QuestionNo

从#RandomQuestion中选择前100个问题

按ID排序





现在你可以根据你的要求使用这个100/50 /等问题作为你的随机问题。


提出一系列问题/查询 - 键/索引/等等。对于问题,然后洗牌。

看看我的解决方案:扑克牌游戏(在主要组中制作随机4组数字) [ ^ ]进行改组。

提出问题洗牌后的订单。

一旦出现,请不要重复使用问题。

再次对下一系列问题进行随机播放。


< blockquote>这可能是你想要的

   -   创建样本表 
创建 问题(
quid < span class =code-keyword> int ,
问题 nvarchar 100

- Sampel Insert Query
插入 进入问题 1 ' MY 1st Questions'
插入 进入问题 2 ' MY 2nd Questions'
insert into 问题 values 3 ' MY 3rd Questions'
插入 进入问题 values 4 ' 我的第四个问题'
插入 进入问题 values 5 ' 我的第五个问题'
插入 进入问题 6 ' 我的第6个问题'
插入 进入问题 7 ' 我的第7个问题'
插入 进入 Que stions 8 ' 我的第8个问题'
插入 进入问题 9 ' < span class =code-string> MY 9th Questions')
insert into 问题 10 ' 我的第10个问题'



,解决方案是

   cte  as 
选择 Abs(校验和(newid())%10)作为 ORdid,* 来自问题

选择 top 5 * 来自 cte 订单 ordid



请参阅示例 [ ^ ]


My system is Computerized Examination. But my problem is, how can i random all questions without repetition.?

解决方案

Suppose you have table named "Question" in database.
Lets move now

create table #RandomQuestion  (id uniqueidentifier NOT NULL DEFAULT newid(),QuestionNo int)

insert into #RandomQuestion  (QuestionNo)
select QuestionNo from Question

select top 100 QuestionNo 
from #RandomQuestion 
order by id



Now you can use this 100/ 50/ etc. questions, as per your requirement, as your random ques.


Make an array of the questions/lookup-keys/indices/etc. for the questions and then shuffle the array.
Look at my solution in: playing cards game (make Random 4 groups of Numbers in Main Group)[^] for shuffling.
Present the questions in the shuffled order.
Don't re-use a question, once presented.
Shuffle again for the next sequence of questions.


Well this might be what you want

--Create sample table
create table Questions(
quid int,
questions nvarchar(100)
)
--Sampel Insert Query
insert into Questions values(1,'MY 1st Questions')
insert into Questions values(2,'MY 2nd Questions')
insert into Questions values(3,'MY 3rd Questions')
insert into Questions values(4,'MY 4th Questions')
insert into Questions values(5,'MY 5th Questions')
insert into Questions values(6,'MY 6th Questions')
insert into Questions values(7,'MY 7th Questions')
insert into Questions values(8,'MY 8th Questions')
insert into Questions values(9,'MY 9th Questions')
insert into Questions values(10,'MY 10th Questions')


and the solution is

with cte as(
select Abs(checksum(newid())%10) as ORdid ,* from questions
)
select top 5 * from cte order by ordid


see the Example[^]


这篇关于如何随意提问而不重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆