2

I don't know much MS Office VBA. I have tons (literally) of quiz questions in word files.

Task is to create question papers for students. Word file contains 900 quiz questions categorized chapter wise. Here is the structure of a word file:

H1: Chapter Name
H2: Level-1 questions
li: Questsions (numbered list)
H3: Answer key to Level-1 questions
li: Answers to level-1 questions (numbered list)
H2: Level-2 questions
H3: Answer key to level-2 questions
li: Answers to level-2 questions (numbered list)

H1: Another Chapter Name
...
...

I want to generate tests (other word files) randomy from my question bank. Few conditions are:

  1. At least 1 question must be picked from each chapter and each level.
  2. The question that is already picked must not be picked into any other test.

Also the answer key must be generated for that generated test.

Question:

  1. Is it too much to expect from Office VBA? or can it be done?
  2. How to do it? What all things do I need to look into?

I've no clue about what to do or how to proceed.

R3uK
  • 14,417
  • 7
  • 43
  • 77
claws
  • 52,236
  • 58
  • 146
  • 195
  • PART 1 : `Is it too much to expect from Office VBA?` Nope :) `or can it be done?` Yes `How to do it? What all things do I need to look into?` It would have been much easier if this data was in Excel cells. i,e from looping perspective or marking the question as `asked` so that it is not asked again. Also maintaining the Q&A database would have been easier. If you want to still do it in word VBA then you will have to loop through all `H1` headings and inside that loop, again loop `H2` headings. CONTD... – Siddharth Rout Apr 17 '13 at 13:26
  • PART 2: If a question has been asked you can insert a bookmark at the beginning of the question or say change the font color to red. There are many possibilities actually... You will have to experiment with it and then post the code that you tried so that we can take it form there... – Siddharth Rout Apr 17 '13 at 13:26
  • I mostly agree with @SiddharthRout. If you have your doc well organised with Styles, List, Tables (?! would be best to have), etc. it wouldn't be difficult but rather time-consuming task. – Kazimierz Jawor Apr 17 '13 at 14:17
  • @SiddharthRout: Would it help if the questions were in tables in MS Word instead of Excel? Why I'm sticking to MS Word is due to the formatting of the questions. I've shown two sample questions in Word have a look at them. https://docs.google.com/file/d/0B05HI8_2Zj9KNXZBejVfME1ocjg/edit?usp=sharing I didn't choose excel because it lacks formatting capabilities of Word. Try copying the table from my sample document into excel. by the way, dont use google document viewer for viewing the linked document. Download it and view it in MS Word. – claws Apr 18 '13 at 08:35
  • Yes, If it were in tables then that would definitely help. But remember what you seek is not difficult but very time consuming :) – Siddharth Rout Apr 18 '13 at 08:38
  • It might be scary, but potentially a database in excel / acces but having your questions formated in html or latex (source code )might solve your problem. Then the automation would build your source code, which could then be compiled (or browsed) – RowanC Jul 24 '13 at 11:23

1 Answers1

0

To be honest... using VBA for MS Word it would be torture... ;(

There are more efficient tools... You need to have a database for storing questions, answers of users, and correct answers. Then you need to write application which provides pseudo-random lottery system (see second condition: The question that is already picked must not be picked into any other test.)

Sample code:

Of course, you can treat MS Word document as a "database", but the code implementation would be very difficult. I see it in that way:

  1. read paragraphs one by one
  2. detect formatting
  • if formatting is Header 1 then add text to the collection (alternatively array or Dictionary) of chapters
  • if formatting is Header 2 then add text to the collection of questions
  • and so on... for the answers and correct answer
  • loop through the collection of chapters and randomly choose the question
  • save the chapter and question into other file untill the count of questions is not reached
  • return to point no. 3 till the count of quizes/exams is not reached
  • Conclusion: forget about VBA, choose .NET programming language (C#, VB.NET) or use free online solutions (for example: The internet quiz database).

    Maciej Los
    • 8,468
    • 1
    • 20
    • 35