Dear All
I am making a quiz with a four-option-multiple-choice scenario.
When you enter the quiz, you provide one answer and three wrong answers.
Then the contestant opens the quiz and I trying to present them the four
answers on the page in a randomized way (i.e. you have no idea which one
comes first).
I know the rnd command, but how do you do rnd without replacement?
TIA
- Nicolaas 10 1509
This is math not a computer group.
"WindAndWav es" <ac****@ngaru.c om> wrote in message
news:TH******** ************@ne ws.xtra.co.nz.. . Dear All
I am making a quiz with a four-option-multiple-choice scenario.
When you enter the quiz, you provide one answer and three wrong answers.
Then the contestant opens the quiz and I trying to present them the four answers on the page in a randomized way (i.e. you have no idea which one comes first).
I know the rnd command, but how do you do rnd without replacement?
TIA
- Nicolaas
On Fri, 27 Aug 2004 15:14:52 +1200, "WindAndWav es" <ac****@ngaru.c om>
wrote: Dear All
I am making a quiz with a four-option-multiple-choice scenario.
When you enter the quiz, you provide one answer and three wrong answers.
Then the contestant opens the quiz and I trying to present them the four answers on the page in a randomized way (i.e. you have no idea which one comes first).
I know the rnd command, but how do you do rnd without replacement?
TIA
- Nicolaas
Set up an array of 4 elements.
Randomly choose one.
Remove it from the list.
Randomly choose one of the 3.
And so on.
Dear Michael
I had a go at this and this is what I came up with (slightly different):
Private Sub Form_Current()
'randomises the anwsers
Const ProEro = 12: 'on error GoTo ERR
'---
Dim Ctl As Control
Dim C(3) As Byte
Dim I As Integer
Dim J As Integer
'---assign numbers
For I = 0 To 3
TryAgain:
C(I) = Int(Rnd * 5)
If C(I) = 0 Or C(I) = 5 Then GoTo TryAgain
If I = 0 Then GoTo looper
'--- check if it exists already and try again if this is so
For J = (I - 1) To 0 Step -1
If C(I) = C(J) Then GoTo TryAgain
Next J
looper:
Next I
'---place data
For I = 0 To 3
Set Ctl = Me.Controls("O" & C(I))
Ctl.ControlSour ce = "=[QA" & I & "]"
Ctl.Tag = I
'---reset tickbox
Me.Controls("C" & I + 1) = False
Next I
xit:
Exit Sub
ERR:
Call FerrorLog(ERR.N umber, 0, ProEro + Modero): Resume Next
End Sub
"Michael Gray" <fl****@newsguy .spam.com> wrote in message
news:dh******** *************** *********@4ax.c om... On Fri, 27 Aug 2004 15:14:52 +1200, "WindAndWav es" <ac****@ngaru.c om> wrote:
Dear All
I am making a quiz with a four-option-multiple-choice scenario.
When you enter the quiz, you provide one answer and three wrong answers.
Then the contestant opens the quiz and I trying to present them the four answers on the page in a randomized way (i.e. you have no idea which one comes first).
I know the rnd command, but how do you do rnd without replacement?
TIA
- Nicolaas
Set up an array of 4 elements. Randomly choose one. Remove it from the list. Randomly choose one of the 3. And so on.
On Sat, 28 Aug 2004 00:21:41 +1200, "WindAndWav es" <ac****@ngaru.c om>
wrote: Dear Michael
I had a go at this and this is what I came up with (slightly different):
:
If all you are trying to achieve is to get it to work, by far and away
the most efficient method (but no the most elegant perhaps), is to
pre-populate an array with the 24 possible permutations (of the four
questions), and choose one randomly from this list.
This is much more efficient than any other way.
So you would do something like this the first time the program runs:
Dim Permutation(24) As String
Permutation(0) = "1234"
Permutation(1) = "1243"
Permutation(2) = "1324"
Permutation(3) = "1342"
Permutation(4) = "1432"
Permutation(5) = "1423"
Permutation(6) = "2134"
Permutation(7) = "2143"
Permutation(8) = "2314"
Permutation(9) = "2341"
Permutation(10) = "2431"
Permutation(11) = "2413"
Permutation(12) = "3124"
Permutation(13) = "3142"
Permutation(14) = "3214"
Permutation(15) = "3241"
Permutation(16) = "3412"
Permutation(17) = "3421"
Permutation(18) = "4123"
Permutation(19) = "4132"
Permutation(20) = "4213"
Permutation(21) = "4231"
Permutation(22) = "4312"
Permutation(23) = "4321"
(I have used strings here for ease of demonstration only, and assume
an array base of zero [Option Base 0])
Then your subroutine would select one of these 24 elements at random,
and apply the order chosen.
I will leave it to you work out the mechanics...
That is a nice solution Michael, thank you for that idea.
"Michael Gray" <fl****@newsguy .spam.com> wrote in message
news:d4******** *************** *********@4ax.c om... On Sat, 28 Aug 2004 00:21:41 +1200, "WindAndWav es" <ac****@ngaru.c om> wrote:
Dear Michael
I had a go at this and this is what I came up with (slightly different): :
If all you are trying to achieve is to get it to work, by far and away the most efficient method (but no the most elegant perhaps), is to pre-populate an array with the 24 possible permutations (of the four questions), and choose one randomly from this list. This is much more efficient than any other way.
So you would do something like this the first time the program runs:
Dim Permutation(24) As String Permutation(0) = "1234" Permutation(1) = "1243" Permutation(2) = "1324" Permutation(3) = "1342" Permutation(4) = "1432" Permutation(5) = "1423" Permutation(6) = "2134" Permutation(7) = "2143" Permutation(8) = "2314" Permutation(9) = "2341" Permutation(10) = "2431" Permutation(11) = "2413" Permutation(12) = "3124" Permutation(13) = "3142" Permutation(14) = "3214" Permutation(15) = "3241" Permutation(16) = "3412" Permutation(17) = "3421" Permutation(18) = "4123" Permutation(19) = "4132" Permutation(20) = "4213" Permutation(21) = "4231" Permutation(22) = "4312" Permutation(23) = "4321"
(I have used strings here for ease of demonstration only, and assume an array base of zero [Option Base 0])
Then your subroutine would select one of these 24 elements at random, and apply the order chosen. I will leave it to you work out the mechanics...
On Sun, 29 Aug 2004 08:46:02 +1200, "WindAndWav es" <ac****@ngaru.c om>
wrote: That is a nice solution Michael, thank you for that idea.
Actually it's not my idea.
It dates from ancient times.
Logarithm tables are a good example, as are "Ready Reckoners" which
were essential in the days of Pounds, Shillings & Pence.
Often pre-populated tables are the most effective way to go with a lot
of problems, although it's surprising how many programmers shy away
from them, or don't even think of them.
They are particularly handy in programs that perform intensive
trigonometry. (Even if a F.P. processor is available)
A table of sin(x) covering an 8th of a circle to the required
precision is all that one needs. The rest of the circle can be
synthesised without having to call transcendental functions
repeatedly.
It's used a lot by people who program microprocessors in machine code,
who *do* tend to think this way.
Michael G.
Michael Gray <fl****@newsguy .spam.com> wrote in message news:<d4******* *************** **********@4ax. com>... On Sat, 28 Aug 2004 00:21:41 +1200, "WindAndWav es" <ac****@ngaru.c om> wrote:
Dear Michael
I had a go at this and this is what I came up with (slightly different): :
If all you are trying to achieve is to get it to work, by far and away the most efficient method (but no the most elegant perhaps), is to pre-populate an array with the 24 possible permutations (of the four questions), and choose one randomly from this list. This is much more efficient than any other way.
So you would do something like this the first time the program runs:
Dim Permutation(24) As String Permutation(0) = "1234" Permutation(1) = "1243" Permutation(2) = "1324" Permutation(3) = "1342" Permutation(4) = "1432" Permutation(5) = "1423" Permutation(6) = "2134" Permutation(7) = "2143" Permutation(8) = "2314" Permutation(9) = "2341" Permutation(10) = "2431" Permutation(11) = "2413" Permutation(12) = "3124" Permutation(13) = "3142" Permutation(14) = "3214" Permutation(15) = "3241" Permutation(16) = "3412" Permutation(17) = "3421" Permutation(18) = "4123" Permutation(19) = "4132" Permutation(20) = "4213" Permutation(21) = "4231" Permutation(22) = "4312" Permutation(23) = "4321"
(I have used strings here for ease of demonstration only, and assume an array base of zero [Option Base 0])
Then your subroutine would select one of these 24 elements at random, and apply the order chosen. I will leave it to you work out the mechanics...
or.. more simply and elegantly.. pick a random number from 1 to 24..
then u can sieve through the # to find out which permutation it is..
if it's in the first 6.. 1 is first
second 6 2 is first
etc.
within that group of six..
if it's in the first 2.. etc.
in the 2.. the order of the two will determine the order of the last two...
it's very simple..
On 15 Sep 2004 19:21:56 -0700, dw*****@yahoo.c om (David Bandel) wrote: Michael Gray <fl****@newsguy .spam.com> wrote in message news:<d4******* *************** **********@4ax. com>... On Sat, 28 Aug 2004 00:21:41 +1200, "WindAndWav es" <ac****@ngaru.c om> wrote:
>Dear Michael > >I had a go at this and this is what I came up with (slightly different): > :
If all you are trying to achieve is to get it to work, by far and away the most efficient method (but no the most elegant perhaps), is to pre-populate an array with the 24 possible permutations (of the four questions), and choose one randomly from this list. This is much more efficient than any other way.
So you would do something like this the first time the program runs:
Dim Permutation(24) As String Permutation(0) = "1234" Permutation(1) = "1243" Permutation(2) = "1324" Permutation(3) = "1342" Permutation(4) = "1432" Permutation(5) = "1423" Permutation(6) = "2134" Permutation(7) = "2143" Permutation(8) = "2314" Permutation(9) = "2341" Permutation(10) = "2431" Permutation(11) = "2413" Permutation(12) = "3124" Permutation(13) = "3142" Permutation(14) = "3214" Permutation(15) = "3241" Permutation(16) = "3412" Permutation(17) = "3421" Permutation(18) = "4123" Permutation(19) = "4132" Permutation(20) = "4213" Permutation(21) = "4231" Permutation(22) = "4312" Permutation(23) = "4321"
(I have used strings here for ease of demonstration only, and assume an array base of zero [Option Base 0])
Then your subroutine would select one of these 24 elements at random, and apply the order chosen. I will leave it to you work out the mechanics...
or.. more simply and elegantly.. pick a random number from 1 to 24..
then u can sieve through the # to find out which permutation it is..
if it's in the first 6.. 1 is first second 6 2 is first etc.
within that group of six.. if it's in the first 2.. etc.
in the 2.. the order of the two will determine the order of the last two...
it's very simple..
I agree.
But for time critical routines, there's no substitute for a
pre-populated table.
I don't implement it as above, of course, but as an array of arrays.
One random look-up gives you the order without having to go through
seiving ranges.
They are "Pre-seived" as it were.
But you are right: your way is more elegant,
but I dispute that it is "simpler" to actually implement.
Here's what i came up with:
I assume the table with the questions has the following format:
Id
Question
RightAnswer
WrongAnswer1
WrongAnswer2
WrongAnswer3
Now the following query will give you the answers to question 1 in
random order:
SELECT Answer, Correct
FROM
(SELECT RND() AS Position, RightAnswer AS Answer, True AS Correct FROM
Questions WHERE Id = 1
UNION ALL
SELECT RND() AS Position, WrongAnswer1, False AS Correct FROM
Questions WHERE Id = 1
UNION ALL
SELECT RND() AS Position, WrongAnswer2, False AS Correct FROM
Questions WHERE Id = 1
UNION ALL SELECT RND() AS Position, WrongAnswer3, False AS Correct
FROM Questions WHERE Id = 1)
ORDER BY Position;
I hardcoded question 1 in there to keep it simple, when you open this
in VBA you replace that with the Id of the question you want to ask.
It almost as lengthy as the other alternative, it just looks more
'pure' to me.
Regards,
GJ
Michael Gray <fl****@newsguy .spam.com> wrote in message news:<k8******* *************** **********@4ax. com>... On 15 Sep 2004 19:21:56 -0700, dw*****@yahoo.c om (David Bandel) wrote:
Michael Gray <fl****@newsguy .spam.com> wrote in message news:<d4******* *************** **********@4ax. com>... On Sat, 28 Aug 2004 00:21:41 +1200, "WindAndWav es" <ac****@ngaru.c om> wrote:
>Dear Michael > >I had a go at this and this is what I came up with (slightly different): > :
If all you are trying to achieve is to get it to work, by far and away the most efficient method (but no the most elegant perhaps), is to pre-populate an array with the 24 possible permutations (of the four questions), and choose one randomly from this list. This is much more efficient than any other way.
So you would do something like this the first time the program runs:
Dim Permutation(24) As String Permutation(0) = "1234" Permutation(1) = "1243" Permutation(2) = "1324" Permutation(3) = "1342" Permutation(4) = "1432" Permutation(5) = "1423" Permutation(6) = "2134" Permutation(7) = "2143" Permutation(8) = "2314" Permutation(9) = "2341" Permutation(10) = "2431" Permutation(11) = "2413" Permutation(12) = "3124" Permutation(13) = "3142" Permutation(14) = "3214" Permutation(15) = "3241" Permutation(16) = "3412" Permutation(17) = "3421" Permutation(18) = "4123" Permutation(19) = "4132" Permutation(20) = "4213" Permutation(21) = "4231" Permutation(22) = "4312" Permutation(23) = "4321"
(I have used strings here for ease of demonstration only, and assume an array base of zero [Option Base 0])
Then your subroutine would select one of these 24 elements at random, and apply the order chosen. I will leave it to you work out the mechanics...
or.. more simply and elegantly.. pick a random number from 1 to 24..
then u can sieve through the # to find out which permutation it is..
if it's in the first 6.. 1 is first second 6 2 is first etc.
within that group of six.. if it's in the first 2.. etc.
in the 2.. the order of the two will determine the order of the last two...
it's very simple..
I agree.
But for time critical routines, there's no substitute for a pre-populated table. I don't implement it as above, of course, but as an array of arrays. One random look-up gives you the order without having to go through seiving ranges. They are "Pre-seived" as it were.
But you are right: your way is more elegant, but I dispute that it is "simpler" to actually implement. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sketcher |
last post by:
Hi, I am trying to create a quiz,
Code is as follows:
<html>
<head>
<title>Quiz</title>
</head>
<BODY>
<Center><TABLE cellSpacing=3 cellPadding=0 border=0>
|
by: Vandana Rola |
last post by:
Hello Everyone,
I am a beginner in Javascript.I want to create fun quiz tool using
javascript (no database). The feature of that tool is every question
has five choices. The user needs to select three best choices. If they
do, a message window pops up which says good choices or something and
take them to next question. If they don't choose all of the best
choices they get another message like try again but these are not the
best choices...
|
by: DAL |
last post by:
I want to build my kid a program that cycles through questions (using a
label for the question), and lets him choose one of two radio buttons for
the right answer. How do I get every set of questions and answers to cycle
through until the last question? Also, how can I give him the score after
the last question. Thank you in advance. DAL.
P.S. As a beginner, I figured I couldn't pass up the chance to learn
something new, and to practice...
|
by: philip |
last post by:
hello, i am now developing a quiz application for my school using
ASP.NET and SQL SERVER 2005, here is a senario:
It will have 20 students for taking a quiz in a classroom, they have to
answer randomly generated 100 questions in 90 minutes from database,
each of those questions may have a picture (approximately 200K), and
the picture is stored in the database as image type.
i have 2 methods for retrieving 100 questions for each student.
|
by: kenny |
last post by:
I'm making a quiz to be posted on the internet. but I'm facing difficulties in finding a simple timer for the quiz (unlimited timing) which will keep on running regardless to the change of the page throughout the quiz.
And well how to display the result of the quiz and te grade of the person who has taken the quiz....
| |
by: NoPeasHear |
last post by:
I don't know what I am doing wrong...
I used this tutorial...
http://www.permadi.com/tutorial/flashMXQuiz/index.html
It works with their quiz.xml file, but when I add an option for multiple correct answers, the results page always gives me a response of 0.
What would I change from the tutorial to have multiple correct responses reflect in the results?
<?xml version="1.0"?>
|
by: Raqueeb Hassan |
last post by:
Hello,
I was helping one of my friend's school on setting up a online quiz
system. They have the AMP systems to host php+mysql. The quiz
script/software should have the following features:
a. Excellent results screen (customizable) which can be printed right
away.
b. 3/5 simultaneously run quizes along with a authentication system.
c. Should be able to handle MCQs (multiple choice questions) along with
|
by: nomad |
last post by:
Hello Everyone:
Just want to ask how easy would it be to build a quiz in Java.
I have not use Java for a few months (5).
Quiz would need the following:
1. T or F and mulitiple question, possible write the answer
2. Client must register and sign in to take the test/quiz (db is needed)
3. Quiz gives final results of the test: How many they got right, pass or fail
4. DB holds results of the tests.
5. Must be able to take the quiz on-line ie...
|
by: empiresolutions |
last post by:
I am building a app that creates quizzes. This is how it goes -
- Create Quiz
- Provide up to 10 different types of Quiz Results
- Give up to 50 Questions
- Each Question has up to 10 possible Answers.
- Each Answer is assigned a Weighted value.... for each type of Quiz Result.
- Weighted values are in the range of -6, 0, +6.
- Each Quiz will also apply the same Weight range for if a M/F is taking and what of 6 age groups the taker is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |