Wild and wacky wizards (creating quizzes)

N

Newbie

What steps does it take for Word/VBA to create truly
randomized multiple-choice/true-false quizzes (printable
and form-protected)? Can it be done by
importing/exporting data from an "itembank" textfile or
with userforms as an automated quiz maker or database
designer?

I imagined userforms, each with a question and the answer
choices (radio buttons or checkboxes) and buttons to "Add
New Question" (to itembank, variable or place holder
textfile or something), "Print It Again, Randy" (prints
different sets of randomized quizzed based on data
entered on the userform, which means no two copies of the
quiz print-outs will be the same...), "Remove
Duplicates", "Create/Save/Open Printable
Quiz", "Create/Save/Open Eletronic (online) Quiz"...

Does anyone have examples or experience with this and is
willing to share? Would someone please tell me it's not
Word Gone Wild and Wacky? :)

Newbie
 
M

martinique

The only difficult part of what you describe is the 'truly' in 'truly
random' -- VB/VBA is capable only of pseudo-random, which is almost
certainly sufficient for what you're trying to do; but it's not 'truly
random' in a strict sense.

That bit of pedantry aside, what you describe is the beginnings of a program
specification. As it stands there's nothing overtly difficult about it, but
as with all programming tasks the devil is in the detail. And the challenge
for you in this situation is to decide how to proceed: presumably you
wouldn't be posting the question if you know how to program this yourself.
You might be lucky enough to find someone who's done exactly this and
volunteers to share the code with you, but probably not. Is there any
commercial potential here?
 
N

Newbie

Doug, thank you for sharing. I copied your code, changed
the location of Source1.doc in the lines and created a
dummy Source1.doc in the specified location
c:\Source1.doc.

VB returned an error message: "Run-time error '5941' The
requested member of the collection does not exist." Is
there a link of reference or downloadble VB helpfile that
could help me identify and trouble-shoot "error 5941"?

I am curious about the content of Source1.doc. Is it a
list of open-ended questions (each question represents a
paragraph)? I teach second grade and give standardized
muliple-choice /true-false quizzes more regularly than
open-ended essay tests. Would it work the same way for
multiple-choice quizzes?
 
N

Newbie

Martinique,

Thanks for pointing out the randomization nature of VBA.
Being a newbie teacher working at a public school, I am
constantly seeking pro bono work from programmers for
educators ...LOL...

Anyway, I would like to toy with the idea of Word doing
the unimaginables and hope that I could, with some help,
create a quiz making template based on userforms. There
are freeware/shareware programs to do the similar thing.
However, it sounds more fun and rewarding if I learn how
to do it in Word. What will be my Visual Basic Lesson No.
2?

Cheers,
Newbie
 
D

Doug Robbins - Word MVP

Hi Newbie,

What line of the code was highlighted when you received the error message?

The macro was created for a source document that contained 100 paragraphs.
Maybe yours contained less and that is why you received the error message.

I assume that your multiple choice questions are probably going to consist
of more than one paragraph, If you were to separate each question with a
continuous section break, the following modification of the code should
work. It has also been modified to handle the actual number of questions
whatever that may be.

Dim Message, Title
Dim Source As Document, Target As Document
Dim question As Range
Dim i As Integer, j As Integer, k As Integer, m As Integer

Message = "Enter number of students" ' Set prompt.
Title = "Randomizer" ' Set title.
' Display message, title
students = InputBox(Message, Title)
Set Source = Documents.Open("E:\Worddocs\source1.doc")
m = Source.Sections.Count
Source.Close
For k = 1 To students
Set Source = Documents.Open("E:\Worddocs\source1.doc")
Set Target = Documents.Add
For i = m To 0 Step -1
j = Int((i * Rnd) + 1)
Set question = Source.Sections(j).Range
Target.Range.InsertAfter question
question.Delete
Next i
' Print and Close Document with random list of questions
Target.PrintOut
' Target.SaveAs ("E:\worddocs\student" & k & ".doc")
Target.Close SaveChanges:=wdDoNotSaveChanges
Source.Close SaveChanges:=wdDoNotSaveChanges
Next k

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
W

woody

ok. im not a good vba programmer try this.

prototype document has teh following text:
<QUESTNUM> <QUESTIONTEXT>
<ANSWER1>___
<ANSWER2>___
<ANSWER3>___
<ANSWER4>___

you have a database of questions with related answers.
something like:

Table Questions
questkey text(5)
question text(100)
correct text(1)

Table Answers
questkey text(5)
answerkey text(1)
Answer text(50)


1) ask how many questions are on the test.

2) open the database and get teh number of records in the
database.

3)a littel math tells you what your using interval range
should be.

4)generate a random number between 0 and the using
interval.

5)your program reads in the prototype document, stores it
to the clipboard.

6) using a move (x) statement where x is the random number
generated, so you skip to record x of teh question table

7) paste the clipboad contents into the document
8) use find and replace statement to replace the question
number and the question text with teh information for the
questions table.

9) define a connection and recordset to the answer table
where the questkey field of teh answer table = teh
questkey of the questions table.

10) in a do while not eof loop read in each answer record,
11)do a search and replace with teh information from
answer tabel into the document text

12) if any unused answer spaces blank them out.

13) skip your using interval range of records from the
question table(if you hit an at end condition just execute
a move first and continue)

14) go back to step 7 until you have generated the number
of questions the user wanted.

15) save document

you could also insert statement to generate an answer key
for the test automatically.

but that is teh basic steps.

Woody
 
W

woody

you could also use VB instead of VBA and have it generate
the tests online using the screen control collection
function.

that way student logs into the program, selects the
subject to test on, and answers the questions as they pop
up, at teh end the program displays teh wrong answers and
prints it out also it logs his grade to a database along
with the missed questions so his/her teacher could suggest
what material to better review.

longest part of it woudl be to setup teh question/answer
section of teh databse for each subject, you woudl want
around 1000 questions in each subject if the test will
have 100 questions, that way teh tests are better
randomized
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top