0

I want to use orgmode for writing a simple exam with a bunch of multiple choice questions. The structure I thought of was something like this:

* Multiple Choice 

1. Who was the founder of rationalism?
   a) Locke 
   b) Copernicus
   c) Descartes
   d) Plato
      - C

2. Locke believed that simple ideas, as opposed to complex ideas, came from?
   a) sensation
   b) memory
   c) reflection
   d) faith
      - A

Where the lowest level (after the dash) is the correct answer. My ideas was that I should be able to fold those up, and export only the visible text to have the test, and then export with the invisible text included to have an exam with a key. However, I have only been able to accomplish this by manually putting the cursor on the d) item and hitting tab. This is no problem for five or ten, but is tedious for hundreds. Is there a procedure to do this?

What I have tried so far is to set the org-cycle-include-plain-lists to integrate, and then use various hide (or show) sublevels, but I never quite get the result I am looking for which would be like this:

* Multiple Choice 

1. Who was the founder of rationalism?
   a) Locke 
   b) Copernicus
   c) Descartes
   d) Plato...

2. Locke believed that simple ideas, as opposed to complex ideas, came from?
   a) sensation
   b) memory
   c) reflection
   d) faith...  

Thanks,

brittAnderson
  • 1,428
  • 11
  • 25
  • 1
    I have no experience with exporting invisible text, but I am familiar somewhat with using overlays to visibly hide text. Org-mode uses a regexp to locate the beginning and ending of the region to be folded. You could create your own system of a beginning and ending regexp for the answer, and have a custom function hide them all or show them all. For example, it might always be two (2) tabs followed by a dash and a space for the beginning regexp -- and the ending regexp might always be two (2) new lines `\n\n`. It is possible to incorporate that into org-cycle, but it is purely custom. – lawlist Mar 11 '15 at 16:52
  • 1
    Here is a link to an example where I completely hide or show the `:PROPERTIES:` drawer and I have incorporated that functionality into org-cycle. Your custom solution could be based on a similar concept: http://stackoverflow.com/a/17492723/2112489 – lawlist Mar 11 '15 at 16:56

2 Answers2

1

I was able to get what you were looking for by using tags. I had to place answers in different headline and tag them by doing C-c-C-q

#+EXCLUDE_TAGS: answer

* Multiple Choice 

** Who was the founder of rationalism?
   a) Locke 
   b) Copernicus
   c) Descartes
   d) Plato
*** C                                    :answer:

** Locke believed that simple ideas, as opposed to complex ideas, came from?
   a) sensation
   b) memory
   c) reflection
   d) faith
*** A                                    :answer:
jimmu
  • 1,025
  • 1
  • 10
  • 15
1

While @MisterSpock 's answer works it removes the numbering of the questions, which is desirable in a test. Therefore, an alternative approach is to use drawers, which can be toggled for export in the options, e.g.

#+Options: d:nil

* Multiple Choice 

1. Who was the founder of rationalism?
   a) Locke 
   b) Copernicus
   c) Descartes
   d) Plato
   :answer:
   - C
   :END:

2. Locke believed that simple ideas, as opposed to complex ideas, came   from?
   a) sensation
   b) memory
   c) reflection
   d) faith
   :answer:
   - A
   :END:
brittAnderson
  • 1,428
  • 11
  • 25